summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-08-25 15:54:25 -0700
committerRob Pike <r@golang.org>2009-08-25 15:54:25 -0700
commita399c977c938c97082e61a01725cfe6d9db34867 (patch)
treef3913b178bfbc73429efbd39df31e880769d1c3d
parent5475005371c17da4fb7ef23ccd8ee050aa91807b (diff)
downloadgolang-a399c977c938c97082e61a01725cfe6d9db34867.tar.gz
rename runtime internals to have modern names (array->slice etc)
R=rsc DELTA=444 (179 added, 177 deleted, 88 changed) OCL=33847 CL=33849
-rw-r--r--src/cmd/gc/align.c4
-rw-r--r--src/cmd/gc/builtin.c.boot18
-rw-r--r--src/cmd/gc/sinit.c12
-rw-r--r--src/cmd/gc/sys.go18
-rw-r--r--src/cmd/gc/walk.c30
-rw-r--r--src/pkg/runtime/Makefile2
-rw-r--r--src/pkg/runtime/cgo2c.c6
-rw-r--r--src/pkg/runtime/chan.c8
-rw-r--r--src/pkg/runtime/hashmap.c12
-rw-r--r--src/pkg/runtime/iface.c8
-rw-r--r--src/pkg/runtime/reflect.cgo2
-rw-r--r--src/pkg/runtime/runtime.c10
-rw-r--r--src/pkg/runtime/runtime.h12
-rw-r--r--src/pkg/runtime/slice.c (renamed from src/pkg/runtime/array.c)54
-rw-r--r--src/pkg/runtime/string.cgo10
-rw-r--r--src/pkg/runtime/symtab.c22
-rw-r--r--src/pkg/runtime/type.h4
17 files changed, 117 insertions, 115 deletions
diff --git a/src/cmd/gc/align.c b/src/cmd/gc/align.c
index bd8b69047..9a013ca6e 100644
--- a/src/cmd/gc/align.c
+++ b/src/cmd/gc/align.c
@@ -186,7 +186,9 @@ dowidth(Type *t)
case TFORW: // should have been filled in
case TANY:
// dummy type; should be replaced before use.
- fatal("dowidth any");
+ if(!debug['A'])
+ fatal("dowidth any");
+ w = 1; // anything will do
break;
case TSTRING:
if(sizeof_String == 0)
diff --git a/src/cmd/gc/builtin.c.boot b/src/cmd/gc/builtin.c.boot
index 3cbb87e1e..e24d9d881 100644
--- a/src/cmd/gc/builtin.c.boot
+++ b/src/cmd/gc/builtin.c.boot
@@ -13,7 +13,7 @@ char *sysimport =
"func sys.printpointer (? any)\n"
"func sys.printiface (? any)\n"
"func sys.printeface (? any)\n"
- "func sys.printarray (? any)\n"
+ "func sys.printslice (? any)\n"
"func sys.printnl ()\n"
"func sys.printsp ()\n"
"func sys.catstring (? string, ? string) (? string)\n"
@@ -21,8 +21,8 @@ char *sysimport =
"func sys.slicestring (? string, ? int, ? int) (? string)\n"
"func sys.indexstring (? string, ? int) (? uint8)\n"
"func sys.intstring (? int64) (? string)\n"
- "func sys.arraystring (? []uint8) (? string)\n"
- "func sys.arraystringi (? []int) (? string)\n"
+ "func sys.slicebytetostring (? []uint8) (? string)\n"
+ "func sys.sliceinttostring (? []int) (? string)\n"
"func sys.stringiter (? string, ? int) (? int)\n"
"func sys.stringiter2 (? string, ? int) (retk int, retv int)\n"
"func sys.ifaceI2E (iface any) (ret any)\n"
@@ -41,7 +41,7 @@ char *sysimport =
"func sys.efaceeq (i1 any, i2 any) (ret bool)\n"
"func sys.ifacethash (i1 any) (ret uint32)\n"
"func sys.efacethash (i1 any) (ret uint32)\n"
- "func sys.newmap (keysize int, valsize int, keyalg int, valalg int, hint int) (hmap map[any] any)\n"
+ "func sys.makemap (keysize int, valsize int, keyalg int, valalg int, hint int) (hmap map[any] any)\n"
"func sys.mapaccess1 (hmap map[any] any, key any) (val any)\n"
"func sys.mapaccess2 (hmap map[any] any, key any) (val any, pres bool)\n"
"func sys.mapassign1 (hmap map[any] any, key any, val any)\n"
@@ -50,7 +50,7 @@ char *sysimport =
"func sys.mapiternext (hiter *any)\n"
"func sys.mapiter1 (hiter *any) (key any)\n"
"func sys.mapiter2 (hiter *any) (key any, val any)\n"
- "func sys.newchan (elemsize int, elemalg int, hint int) (hchan chan any)\n"
+ "func sys.makechan (elemsize int, elemalg int, hint int) (hchan chan any)\n"
"func sys.chanrecv1 (hchan <-chan any) (elem any)\n"
"func sys.chanrecv2 (hchan <-chan any) (elem any, pres bool)\n"
"func sys.chansend1 (hchan chan<- any, elem any)\n"
@@ -62,10 +62,10 @@ char *sysimport =
"func sys.selectrecv (sel *uint8, hchan <-chan any, elem *any) (selected bool)\n"
"func sys.selectdefault (sel *uint8) (selected bool)\n"
"func sys.selectgo (sel *uint8)\n"
- "func sys.newarray (nel int, cap int, width int) (ary []any)\n"
- "func sys.arraysliced (old []any, lb int, hb int, width int) (ary []any)\n"
- "func sys.arrayslices (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
- "func sys.arrays2d (old *any, nel int) (ary []any)\n"
+ "func sys.makeslice (nel int, cap int, width int) (ary []any)\n"
+ "func sys.sliceslice (old []any, lb int, hb int, width int) (ary []any)\n"
+ "func sys.slicearray (old *any, nel int, lb int, hb int, width int) (ary []any)\n"
+ "func sys.arraytoslice (old *any, nel int) (ary []any)\n"
"func sys.closure ()\n"
"func sys.int64div (? int64, ? int64) (? int64)\n"
"func sys.uint64div (? uint64, ? uint64) (? uint64)\n"
diff --git a/src/cmd/gc/sinit.c b/src/cmd/gc/sinit.c
index 4b46f7c7c..84e844c27 100644
--- a/src/cmd/gc/sinit.c
+++ b/src/cmd/gc/sinit.c
@@ -146,8 +146,8 @@ slicerewrite(Node *n)
while(n->op == OCONVNOP)
n = n->left;
- // call to newarray - find nel argument
- nel = findarg(n, "nel", "newarray");
+ // call to makeslice - find nel argument
+ nel = findarg(n, "nel", "makeslice");
if(nel == N || !isslice(n->type))
goto no;
@@ -177,8 +177,8 @@ maprewrite(Node *n)
Type *ta, *tb;
Node *a;
- // call to newarray - find nel argument
- nel = findarg(n, "hint", "newmap");
+ // call to makemap - find len argument
+ nel = findarg(n, "hint", "makemap");
if(nel == N)
goto no;
ta = n->type;
@@ -371,7 +371,7 @@ sli:
if(r->op != OAS && r->op != OEMPTY)
continue;
- // first usage "nam = (newarray CALL args)"
+ // first usage "nam = (makeslice CALL args)"
if(r->right != N && sametmp(r->left, nam)) {
w = slicerewrite(r->right);
if(w == N)
@@ -427,7 +427,7 @@ return;
if(r->op != OAS && r->op != OEMPTY)
continue;
- // first usage "nam = (newmap CALL args)"
+ // first usage "nam = (makemap CALL args)"
if(r->right != N && sametmp(r->left, nam)) {
w = maprewrite(r->right);
if(w == N)
diff --git a/src/cmd/gc/sys.go b/src/cmd/gc/sys.go
index 2144e7c32..3f2492cdf 100644
--- a/src/cmd/gc/sys.go
+++ b/src/cmd/gc/sys.go
@@ -20,7 +20,7 @@ func printstring(string);
func printpointer(any);
func printiface(any);
func printeface(any);
-func printarray(any);
+func printslice(any);
func printnl();
func printsp();
@@ -29,8 +29,8 @@ func cmpstring(string, string) int;
func slicestring(string, int, int) string;
func indexstring(string, int) byte;
func intstring(int64) string;
-func arraystring([]byte) string;
-func arraystringi([]int) string;
+func slicebytetostring([]byte) string;
+func sliceinttostring([]int) string;
func stringiter(string, int) int;
func stringiter2(string, int) (retk int, retv int);
@@ -51,7 +51,7 @@ func efaceeq(i1 any, i2 any) (ret bool);
func ifacethash(i1 any) (ret uint32);
func efacethash(i1 any) (ret uint32);
-func newmap(keysize int, valsize int,
+func makemap(keysize int, valsize int,
keyalg int, valalg int,
hint int) (hmap map[any]any);
func mapaccess1(hmap map[any]any, key any) (val any);
@@ -63,7 +63,7 @@ func mapiternext(hiter *any);
func mapiter1(hiter *any) (key any);
func mapiter2(hiter *any) (key any, val any);
-func newchan(elemsize int, elemalg int, hint int) (hchan chan any);
+func makechan(elemsize int, elemalg int, hint int) (hchan chan any);
func chanrecv1(hchan <-chan any) (elem any);
func chanrecv2(hchan <-chan any) (elem any, pres bool);
func chansend1(hchan chan<- any, elem any);
@@ -77,10 +77,10 @@ func selectrecv(sel *byte, hchan <-chan any, elem *any) (selected bool);
func selectdefault(sel *byte) (selected bool);
func selectgo(sel *byte);
-func newarray(nel int, cap int, width int) (ary []any);
-func arraysliced(old []any, lb int, hb int, width int) (ary []any);
-func arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any);
-func arrays2d(old *any, nel int) (ary []any);
+func makeslice(nel int, cap int, width int) (ary []any);
+func sliceslice(old []any, lb int, hb int, width int) (ary []any);
+func slicearray(old *any, nel int, lb int, hb int, width int) (ary []any);
+func arraytoslice(old *any, nel int) (ary []any);
func closure(); // has args, but compiler fills in
diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c
index b7d6d8e5e..ec136df60 100644
--- a/src/cmd/gc/walk.c
+++ b/src/cmd/gc/walk.c
@@ -773,9 +773,9 @@ walkexpr(Node **np, NodeList **init)
walkexpr(&n->right->left, init);
walkexpr(&n->right->right, init);
// dynamic slice
- // arraysliced(old []any, lb int, hb int, width int) (ary []any)
+ // sliceslice(old []any, lb int, hb int, width int) (ary []any)
t = n->type;
- fn = syslook("arraysliced", 1);
+ fn = syslook("sliceslice", 1);
argtype(fn, t->type); // any-1
argtype(fn, t->type); // any-2
n = mkcall1(fn, t, init,
@@ -790,9 +790,9 @@ walkexpr(Node **np, NodeList **init)
walkexpr(&n->right->left, init);
walkexpr(&n->right->right, init);
// static slice
- // arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any)
+ // slicearray(old *any, nel int, lb int, hb int, width int) (ary []any)
t = n->type;
- fn = syslook("arrayslices", 1);
+ fn = syslook("slicearray", 1);
argtype(fn, n->left->type); // any-1
argtype(fn, t->type); // any-2
n = mkcall1(fn, t, init,
@@ -897,7 +897,7 @@ walkexpr(Node **np, NodeList **init)
goto ret;
case OMAKECHAN:
- n = mkcall1(chanfn("newchan", 1, n->type), n->type, init,
+ n = mkcall1(chanfn("makechan", 1, n->type), n->type, init,
nodintconst(n->type->type->width),
nodintconst(algtype(n->type->type)),
conv(n->left, types[TINT]));
@@ -906,7 +906,7 @@ walkexpr(Node **np, NodeList **init)
case OMAKEMAP:
t = n->type;
- fn = syslook("newmap", 1);
+ fn = syslook("makemap", 1);
argtype(fn, t->down); // any-1
argtype(fn, t->type); // any-2
@@ -919,9 +919,9 @@ walkexpr(Node **np, NodeList **init)
goto ret;
case OMAKESLICE:
- // newarray(nel int, max int, width int) (ary []any)
+ // makeslice(nel int, max int, width int) (ary []any)
t = n->type;
- fn = syslook("newarray", 1);
+ fn = syslook("makeslice", 1);
argtype(fn, t->type); // any-1
n = mkcall1(fn, n->type, nil,
conv(n->left, types[TINT]),
@@ -935,13 +935,13 @@ walkexpr(Node **np, NodeList **init)
goto ret;
case OARRAYBYTESTR:
- // arraystring([]byte) string;
- n = mkcall("arraystring", n->type, init, n->left);
+ // slicebytetostring([]byte) string;
+ n = mkcall("slicebytetostring", n->type, init, n->left);
goto ret;
case OARRAYRUNESTR:
- // arraystring([]byte) string;
- n = mkcall("arraystringi", n->type, init, n->left);
+ // sliceinttostring([]byte) string;
+ n = mkcall("sliceinttostring", n->type, init, n->left);
goto ret;
case OCMPIFACE:
@@ -988,8 +988,8 @@ walkexpr(Node **np, NodeList **init)
goto ret;
case OCONVSLICE:
- // arrays2d(old *any, nel int) (ary []any)
- fn = syslook("arrays2d", 1);
+ // arraytoslice(old *any, nel int) (ary []any)
+ fn = syslook("arraytoslice", 1);
argtype(fn, n->left->type->type); // any-1
argtype(fn, n->type->type); // any-2
n = mkcall1(fn, n->type, init, n->left, nodintconst(n->left->type->type->bound));
@@ -1490,7 +1490,7 @@ walkprint(Node *nn, NodeList **init)
on = syslook("printpointer", 1);
argtype(on, n->type); // any-1
} else if(isslice(n->type)) {
- on = syslook("printarray", 1);
+ on = syslook("printslice", 1);
argtype(on, n->type); // any-1
} else if(isint[et]) {
if(et == TUINT64)
diff --git a/src/pkg/runtime/Makefile b/src/pkg/runtime/Makefile
index 7356bd765..efd3f37de 100644
--- a/src/pkg/runtime/Makefile
+++ b/src/pkg/runtime/Makefile
@@ -35,7 +35,6 @@ OFILES_arm=\
vlrt.$O\
OFILES=\
- array.$O\
asm.$O\
cgocall.$O\
chan.$O\
@@ -60,6 +59,7 @@ OFILES=\
rt0.$O\
sema.$O\
signal.$O\
+ slice.$O\
string.$O\
symtab.$O\
sys.$O\
diff --git a/src/pkg/runtime/cgo2c.c b/src/pkg/runtime/cgo2c.c
index e6c7634ff..3b452b78b 100644
--- a/src/pkg/runtime/cgo2c.c
+++ b/src/pkg/runtime/cgo2c.c
@@ -45,7 +45,7 @@ enum {
Uint,
Uintptr,
String,
- Array,
+ Slice,
};
static struct {
@@ -61,7 +61,7 @@ static struct {
"uint", 4,
"uintptr", 4,
"String", 8,
- "Array", 12,
+ "Slice", 12,
/* fixed size */
"float32", 4,
@@ -710,7 +710,7 @@ main(int argc, char **argv)
if(goarch != NULL && strcmp(goarch, "amd64") == 0) {
type_table[Uintptr].size = 8;
type_table[String].size = 16;
- type_table[Array].size = 8+4+4;
+ type_table[Slice].size = 8+4+4;
structround = 8;
}
}
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c
index c72ea1dff..ceebebf8b 100644
--- a/src/pkg/runtime/chan.c
+++ b/src/pkg/runtime/chan.c
@@ -95,7 +95,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
if(elemalg >= nelem(algarray)) {
printf("chan(alg=%d)\n", elemalg);
- throw("sys·newchan: unsupported elem type");
+ throw("sys·makechan: unsupported elem type");
}
c = mal(sizeof(*c));
@@ -124,7 +124,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
}
if(debug) {
- prints("newchan: chan=");
+ prints("makechan: chan=");
sys·printpointer(c);
prints("; elemsize=");
sys·printint(elemsize);
@@ -138,9 +138,9 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
return c;
}
-// newchan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any);
+// makechan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any);
void
-sys·newchan(uint32 elemsize, uint32 elemalg, uint32 hint, Hchan *ret)
+sys·makechan(uint32 elemsize, uint32 elemalg, uint32 hint, Hchan *ret)
{
ret = makechan(elemsize, elemalg, hint);
FLUSH(&ret);
diff --git a/src/pkg/runtime/hashmap.c b/src/pkg/runtime/hashmap.c
index 91be38443..8c642d9d4 100644
--- a/src/pkg/runtime/hashmap.c
+++ b/src/pkg/runtime/hashmap.c
@@ -664,7 +664,7 @@ donothing(uint32 s, void *a, void *b)
static int32 debug = 0;
-// newmap(keysize uint32, valsize uint32,
+// makemap(keysize uint32, valsize uint32,
// keyalg uint32, valalg uint32,
// hint uint32) (hmap *map[any]any);
Hmap*
@@ -675,12 +675,12 @@ makemap(uint32 keysize, uint32 valsize,
if(keyalg >= nelem(algarray) || algarray[keyalg].hash == nohash) {
printf("map(keyalg=%d)\n", keyalg);
- throw("sys·newmap: unsupported map key type");
+ throw("sys·makemap: unsupported map key type");
}
if(valalg >= nelem(algarray)) {
printf("map(valalg=%d)\n", valalg);
- throw("sys·newmap: unsupported map value type");
+ throw("sys·makemap: unsupported map value type");
}
h = mal(sizeof(*h));
@@ -720,18 +720,18 @@ makemap(uint32 keysize, uint32 valsize,
h->po2 = rnd(h->vo2+valsize, 1);
if(debug) {
- printf("newmap: map=%p; keysize=%d; valsize=%d; keyalg=%d; valalg=%d; offsets=%d,%d; %d,%d,%d; %d,%d,%d\n",
+ printf("makemap: map=%p; keysize=%d; valsize=%d; keyalg=%d; valalg=%d; offsets=%d,%d; %d,%d,%d; %d,%d,%d\n",
h, keysize, valsize, keyalg, valalg, h->ko0, h->vo0, h->ko1, h->vo1, h->po1, h->ko2, h->vo2, h->po2);
}
return h;
}
-// newmap(keysize uint32, valsize uint32,
+// makemap(keysize uint32, valsize uint32,
// keyalg uint32, valalg uint32,
// hint uint32) (hmap *map[any]any);
void
-sys·newmap(uint32 keysize, uint32 valsize,
+sys·makemap(uint32 keysize, uint32 valsize,
uint32 keyalg, uint32 valalg, uint32 hint,
Hmap *ret)
{
diff --git a/src/pkg/runtime/iface.c b/src/pkg/runtime/iface.c
index 63093ad88..6bd2f93ff 100644
--- a/src/pkg/runtime/iface.c
+++ b/src/pkg/runtime/iface.c
@@ -45,7 +45,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail)
Itab *m;
UncommonType *x;
- if(inter->mhdr.nel == 0)
+ if(inter->mhdr.len == 0)
throw("internal error - misuse of itab");
// easy case
@@ -90,7 +90,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail)
}
}
- ni = inter->mhdr.nel;
+ ni = inter->mhdr.len;
m = malloc(sizeof(*m) + ni*sizeof m->fun[0]);
m->inter = inter;
m->type = type;
@@ -100,9 +100,9 @@ search:
// so can iterate over both in lock step;
// the loop is O(ni+nt) not O(ni*nt).
i = inter->m;
- ei = i + inter->mhdr.nel;
+ ei = i + inter->mhdr.len;
t = x->m;
- et = t + x->mhdr.nel;
+ et = t + x->mhdr.len;
for(; i < ei; i++) {
ihash = i->hash;
iname = i->name;
diff --git a/src/pkg/runtime/reflect.cgo b/src/pkg/runtime/reflect.cgo
index af74662db..016b9e9ec 100644
--- a/src/pkg/runtime/reflect.cgo
+++ b/src/pkg/runtime/reflect.cgo
@@ -87,7 +87,7 @@ func setiface(typ *byte, x *byte, ret *byte) {
InterfaceType *t;
t = (InterfaceType*)gettype(typ);
- if(t->mhdr.nel == 0) {
+ if(t->mhdr.len == 0) {
// already an empty interface
*(Eface*)ret = *(Eface*)x;
return;
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c
index c5ba3e6a5..50a94ec92 100644
--- a/src/pkg/runtime/runtime.c
+++ b/src/pkg/runtime/runtime.c
@@ -142,8 +142,8 @@ rnd(uint32 n, uint32 m)
static int32 argc;
static uint8** argv;
-Array os·Args;
-Array os·Envs;
+Slice os·Args;
+Slice os·Envs;
void
args(int32 c, uint8 **v)
@@ -168,13 +168,13 @@ goargs(void)
for(i=0; i<argc; i++)
gargv[i] = gostring(argv[i]);
os·Args.array = (byte*)gargv;
- os·Args.nel = argc;
+ os·Args.len = argc;
os·Args.cap = argc;
for(i=0; i<envc; i++)
genvv[i] = gostring(argv[argc+1+i]);
os·Envs.array = (byte*)genvv;
- os·Envs.nel = envc;
+ os·Envs.len = envc;
os·Envs.cap = envc;
}
@@ -189,7 +189,7 @@ getenv(int8 *s)
bs = (byte*)s;
len = findnull(bs);
envv = (String*)os·Envs.array;
- envc = os·Envs.nel;
+ envc = os·Envs.len;
for(i=0; i<envc; i++){
if(envv[i].len <= len)
continue;
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h
index 48c98f218..c346c692f 100644
--- a/src/pkg/runtime/runtime.h
+++ b/src/pkg/runtime/runtime.h
@@ -42,7 +42,6 @@ typedef uint32 uintptr;
typedef uint8 bool;
typedef uint8 byte;
typedef struct Alg Alg;
-typedef struct Array Array;
typedef struct Func Func;
typedef struct G G;
typedef struct Gobuf Gobuf;
@@ -50,6 +49,7 @@ typedef struct Lock Lock;
typedef struct M M;
typedef struct Mem Mem;
typedef union Note Note;
+typedef struct Slice Slice;
typedef struct Stktop Stktop;
typedef struct String String;
typedef struct Usema Usema;
@@ -140,10 +140,10 @@ struct Eface
void* data;
};
-struct Array
+struct Slice
{ // must not move anything
byte* array; // actual data
- uint32 nel; // number of elements
+ uint32 len; // number of elements
uint32 cap; // allocated number of elements
};
struct Gobuf
@@ -252,7 +252,7 @@ struct Func
String src; // src file name
uint64 entry; // entry pc
int64 frame; // stack frame size
- Array pcln; // pc/ln tab for this func
+ Slice pcln; // pc/ln tab for this func
int64 pc0; // starting pc, ln for table
int32 ln0;
int32 args; // number of 32-bit in/out args
@@ -426,7 +426,7 @@ void notewakeup(Note*);
#define sys_memclr sys·memclr
#define sys_getcallerpc sys·getcallerpc
#define sys_mmap sys·mmap
-#define sys_printarray sys·printarray
+#define sys_printslice sys·printslice
#define sys_printbool sys·printbool
#define sys_printfloat sys·printfloat
#define sys_printhex sys·printhex
@@ -461,7 +461,7 @@ void sys_printpc(void*);
void sys_printpointer(void*);
void sys_printuint(uint64);
void sys_printhex(uint64);
-void sys_printarray(Array);
+void sys_printslice(Slice);
/*
* wrapped for go users
diff --git a/src/pkg/runtime/array.c b/src/pkg/runtime/slice.c
index bbd57b03e..d7a5a062f 100644
--- a/src/pkg/runtime/array.c
+++ b/src/pkg/runtime/slice.c
@@ -6,9 +6,9 @@
static int32 debug = 0;
-// newarray(nel int, cap int, width int) (ary []any);
+// makeslice(nel int, cap int, width int) (ary []any);
void
-sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret)
+sys·makeslice(uint32 nel, uint32 cap, uint32 width, Slice ret)
{
uint64 size;
@@ -16,21 +16,21 @@ sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret)
cap = nel;
size = cap*width;
- ret.nel = nel;
+ ret.len = nel;
ret.cap = cap;
ret.array = mal(size);
FLUSH(&ret);
if(debug) {
- prints("newarray: nel=");
+ prints("makeslice: nel=");
sys·printint(nel);
prints("; cap=");
sys·printint(cap);
prints("; width=");
sys·printint(width);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
@@ -48,15 +48,15 @@ throwslice(uint32 lb, uint32 hb, uint32 n)
throw("array slice");
}
-// arraysliced(old []any, lb int, hb int, width int) (ary []any);
+// sliceslice(old []any, lb int, hb int, width int) (ary []any);
void
-sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
+sys·sliceslice(Slice old, uint32 lb, uint32 hb, uint32 width, Slice ret)
{
if(hb > old.cap || lb > hb) {
if(debug) {
- prints("sys·arraysliced: old=");
- sys·printarray(old);
+ prints("sys·sliceslice: old=");
+ sys·printslice(old);
prints("; lb=");
sys·printint(lb);
prints("; hb=");
@@ -66,7 +66,7 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
prints("\n");
prints("oldarray: nel=");
- sys·printint(old.nel);
+ sys·printint(old.len);
prints("; cap=");
sys·printint(old.cap);
prints("\n");
@@ -75,15 +75,15 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
}
// new array is inside old array
- ret.nel = hb-lb;
+ ret.len = hb-lb;
ret.cap = old.cap - lb;
ret.array = old.array + lb*width;
FLUSH(&ret);
if(debug) {
- prints("sys·arraysliced: old=");
- sys·printarray(old);
+ prints("sys·sliceslice: old=");
+ sys·printslice(old);
prints("; lb=");
sys·printint(lb);
prints("; hb=");
@@ -91,19 +91,19 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
prints("; width=");
sys·printint(width);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
-// arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any);
+// slicearray(old *any, nel int, lb int, hb int, width int) (ary []any);
void
-sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Array ret)
+sys·slicearray(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Slice ret)
{
if(hb > nel || lb > hb) {
if(debug) {
- prints("sys·arrayslices: old=");
+ prints("sys·slicearray: old=");
sys·printpointer(old);
prints("; nel=");
sys·printint(nel);
@@ -119,14 +119,14 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra
}
// new array is inside old array
- ret.nel = hb-lb;
+ ret.len = hb-lb;
ret.cap = nel-lb;
ret.array = old + lb*width;
FLUSH(&ret);
if(debug) {
- prints("sys·arrayslices: old=");
+ prints("sys·slicearray: old=");
sys·printpointer(old);
prints("; nel=");
sys·printint(nel);
@@ -137,37 +137,37 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra
prints("; width=");
sys·printint(width);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
-// arrays2d(old *any, nel int) (ary []any)
+// arraytoslice(old *any, nel int) (ary []any)
void
-sys·arrays2d(byte* old, uint32 nel, Array ret)
+sys·arraytoslice(byte* old, uint32 nel, Slice ret)
{
// new dope to old array
- ret.nel = nel;
+ ret.len = nel;
ret.cap = nel;
ret.array = old;
FLUSH(&ret);
if(debug) {
- prints("sys·arrays2d: old=");
+ prints("sys·slicearrayp: old=");
sys·printpointer(old);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
void
-sys·printarray(Array a)
+sys·printslice(Slice a)
{
prints("[");
- sys·printint(a.nel);
+ sys·printint(a.len);
prints("/");
sys·printint(a.cap);
prints("]");
diff --git a/src/pkg/runtime/string.cgo b/src/pkg/runtime/string.cgo
index c91a7507e..3134cbbfe 100644
--- a/src/pkg/runtime/string.cgo
+++ b/src/pkg/runtime/string.cgo
@@ -157,26 +157,26 @@ func intstring(v int64) (s String) {
s.len = runetochar(s.str, v);
}
-func arraystring(b Array) (s String) {
- s = gostringsize(b.nel);
+func slicebytetostring(b Slice) (s String) {
+ s = gostringsize(b.len);
mcpy(s.str, b.array, s.len);
}
-func arraystringi(b Array) (s String) {
+func sliceinttostring(b Slice) (s String) {
int32 siz1, siz2, i;
int32 *a;
byte dum[8];
a = (int32*)b.array;
siz1 = 0;
- for(i=0; i<b.nel; i++) {
+ for(i=0; i<b.len; i++) {
siz1 += runetochar(dum, a[i]);
}
s = gostringsize(siz1+4);
siz2 = 0;
- for(i=0; i<b.nel; i++) {
+ for(i=0; i<b.len; i++) {
// check for race
if(siz2 >= siz1)
break;
diff --git a/src/pkg/runtime/symtab.c b/src/pkg/runtime/symtab.c
index a03c165af..97501623d 100644
--- a/src/pkg/runtime/symtab.c
+++ b/src/pkg/runtime/symtab.c
@@ -27,23 +27,23 @@
// Return a pointer to a byte array containing the symbol table segment.
void
-sys·symdat(Array *symtab, Array *pclntab)
+sys·symdat(Slice *symtab, Slice *pclntab)
{
- Array *a;
+ Slice *a;
int32 *v;
v = SYMCOUNTS;
a = mal(sizeof *a);
- a->nel = v[0];
- a->cap = a->nel;
+ a->len = v[0];
+ a->cap = a->len;
a->array = SYMDATA;
symtab = a;
FLUSH(&symtab);
a = mal(sizeof *a);
- a->nel = v[1];
- a->cap = a->nel;
+ a->len = v[1];
+ a->cap = a->len;
a->array = SYMDATA + v[0];
pclntab = a;
FLUSH(&pclntab);
@@ -274,8 +274,8 @@ splitpcln(void)
line = 0;
for(; p < ep; p++) {
if(f < ef && pc > (f+1)->entry) {
- f->pcln.nel = p - f->pcln.array;
- f->pcln.cap = f->pcln.nel;
+ f->pcln.len = p - f->pcln.array;
+ f->pcln.cap = f->pcln.len;
f++;
f->pcln.array = p;
f->pc0 = pc;
@@ -295,8 +295,8 @@ splitpcln(void)
pc += PcQuant;
}
if(f < ef) {
- f->pcln.nel = p - f->pcln.array;
- f->pcln.cap = f->pcln.nel;
+ f->pcln.len = p - f->pcln.array;
+ f->pcln.cap = f->pcln.len;
}
}
@@ -311,7 +311,7 @@ funcline(Func *f, uint64 targetpc)
int32 line;
p = f->pcln.array;
- ep = p + f->pcln.nel;
+ ep = p + f->pcln.len;
pc = f->pc0;
line = f->ln0;
for(; p < ep && pc <= targetpc; p++) {
diff --git a/src/pkg/runtime/type.h b/src/pkg/runtime/type.h
index 10d0068ea..86e31ba2a 100644
--- a/src/pkg/runtime/type.h
+++ b/src/pkg/runtime/type.h
@@ -39,7 +39,7 @@ struct UncommonType
{
String *name;
String *pkgPath;
- Array mhdr;
+ Slice mhdr;
Method m[];
};
@@ -62,7 +62,7 @@ struct IMethod
struct InterfaceType
{
Type;
- Array mhdr;
+ Slice mhdr;
IMethod m[];
};