]> Cypherpunks repositories - gostls13.git/commitdiff
6g tweaks
authorRuss Cox <rsc@golang.org>
Tue, 5 May 2009 23:53:46 +0000 (16:53 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 5 May 2009 23:53:46 +0000 (16:53 -0700)
* byteastring is no longer used
* do not generate ODCL, OAS for globals
  (wasn't generating any code but might
  save one or two init functions)
* do not call self from Init function

R=ken
OCL=28309
CL=28309

src/cmd/gc/builtin.c.boot
src/cmd/gc/dcl.c
src/cmd/gc/go.y
src/cmd/gc/sys.go
src/runtime/string.c

index 81ec84c370fc064e6443e66f69db989400023fdc..d935fc564fd633247e7e526ec02371dcdf990794 100644 (file)
@@ -18,7 +18,6 @@ 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.byteastring (? *uint8, ? int) (? string)\n"
        "func sys.arraystring (? []uint8) (? string)\n"
        "func sys.stringiter (? string, ? int) (? int)\n"
        "func sys.stringiter2 (? string, ? int) (retk int, retv int)\n"
index d39b893a35dc96cd561b9717d500422cc597a266..2426fcac02b9c533900fc14ba4f161097e1e2716 100644 (file)
@@ -38,7 +38,8 @@ dodclvar(Node *n, Type *t)
 
        addvar(n, t, dclcontext);
        autoexport(n->sym);
-       addtop = list(addtop, nod(ODCL, n, N));
+       if(funcdepth > 0)
+               addtop = list(addtop, nod(ODCL, n, N));
 }
 
 void
@@ -1299,7 +1300,7 @@ fninit(Node *n)
        Node *done;
        Node *a, *fn, *r;
        uint32 h;
-       Sym *s;
+       Sym *s, *initsym;
 
        if(strcmp(package, "PACKAGE") == 0) {
                // sys.go or unsafe.go during compiler build
@@ -1329,7 +1330,8 @@ fninit(Node *n)
                snprint(namebuf, sizeof(namebuf), "init");
 
        fn = nod(ODCLFUNC, N, N);
-       fn->nname = newname(lookup(namebuf));
+       initsym = lookup(namebuf);
+       fn->nname = newname(initsym);
        fn->type = functype(N, N, N);
        funchdr(fn);
 
@@ -1350,6 +1352,8 @@ fninit(Node *n)
                        continue;
                if(s->oname == N)
                        continue;
+               if(s == initsym)
+                       continue;
 
                // could check that it is fn of no args/returns
                a = nod(OCALL, s->oname, N);
index 4c326f1e72d1fcf2d142dccb8a0cf411ca47d3ac..e5b808460a4d7331a88f2661a32ab7ee6b9f7e30 100644 (file)
@@ -299,8 +299,12 @@ Avardcl:
                $$ = rev($1);
                dodclvar($$, $2);
 
-               $$ = nod(OAS, $$, N);
-               addtotop($$);
+               if(funcdepth == 0) {
+                       $$ = N;
+               } else {
+                       $$ = nod(OAS, $$, N);
+                       addtotop($$);
+               }
        }
 
 Bvardcl:
@@ -309,8 +313,12 @@ Bvardcl:
                $$ = rev($1);
                dodclvar($$, $2);
 
-               $$ = nod(OAS, $$, N);
-               addtotop($$);
+               if(funcdepth == 0) {
+                       $$ = N;
+               } else {
+                       $$ = nod(OAS, $$, N);
+                       addtotop($$);
+               }
        }
 |      new_name_list_r type '=' expr_list
        {
index 6a0a6b3495b1c02359719e1d7c30f30f1f6c81e3..9c2bc4d04fcf8fbebf78265cd96f0c77b10f1e34 100644 (file)
@@ -27,7 +27,6 @@ func  cmpstring(string, string) int;
 func   slicestring(string, int, int) string;
 func   indexstring(string, int) byte;
 func   intstring(int64) string;
-func   byteastring(*byte, int) string;
 func   arraystring([]byte) string;
 func   stringiter(string, int) int;
 func   stringiter2(string, int) (retk int, retv int);
index c62731ea31aa3126848c997b6d196e9e661dd899..667828d66e3153f2b000724dff40a1a72befe7ea 100644 (file)
@@ -173,14 +173,6 @@ sys·intstring(int64 v, String s)
        FLUSH(&s);
 }
 
-void
-sys·byteastring(byte *a, int32 l, String s)
-{
-       s = gostringsize(l);
-       mcpy(s.str, a, l);
-       FLUSH(&s);
-}
-
 void
 sys·arraystring(Array b, String s)
 {