]> Cypherpunks repositories - gostls13.git/commitdiff
parameter declartions in func literals
authorKen Thompson <ken@golang.org>
Thu, 17 Jul 2008 00:22:54 +0000 (17:22 -0700)
committerKen Thompson <ken@golang.org>
Thu, 17 Jul 2008 00:22:54 +0000 (17:22 -0700)
SVN=127678

src/cmd/6g/gen.c
src/cmd/gc/dcl.c
src/cmd/gc/go.h
src/cmd/gc/go.y

index bc682fa44916a82c04471dd75c439e2ad296fe52..3a6735cd62ca4fc7088584a5e834567779c3e6fd 100644 (file)
@@ -102,11 +102,12 @@ allocparams(void)
         * parameters, is the offset in the
         * parameter list.
         */
-       d = autodcl;
+       d = paramdcl->forw;;
        t = funcfirst(&list, curfn->type);
        while(t != T) {
                if(d == D)
                        fatal("allocparams: this & in nil");
+
                if(d->op != ONAME) {
                        d = d->forw;
                        continue;
@@ -114,7 +115,7 @@ allocparams(void)
 
                n = d->dnode;
                if(n->class != PPARAM)
-                       fatal("allocparams: this & in class");
+                       fatal("allocparams: this & in class %N %d", n, n->class);
 
                n->xoffset = t->width;
                d = d->forw;
@@ -133,7 +134,7 @@ allocparams(void)
 
                        n = d->dnode;
                        if(n->class != PPARAM)
-                               fatal("allocparams: out class");
+                               fatal("allocparams: out class %N %d", n, n->class);
 
                        n->xoffset = t->width;
                        d = d->forw;
index 54a3fadb049b490041306185c76ce90c816ffd58..e37e95379684af7f42a37605d0b357c186b7f8d2 100644 (file)
@@ -370,6 +370,8 @@ funcargs(Type *t)
        Iter save;
        int all;
 
+       paramdcl = autodcl->back;       // base of arguments - see allocparams in gen.c
+
        // declare the this/in arguments
        n1 = funcfirst(&save, t);
        while(n1 != T) {
@@ -601,6 +603,30 @@ markdclstack(void)
        }
 }
 
+void
+dumpdcl(char *st)
+{
+       Sym *s, *d;
+       int i;
+
+       print("\ndumpdcl: %s %p\n", st, b0stack);
+
+       i = 0;
+       for(d=dclstack; d!=S; d=d->link) {
+               i++;
+               print("    %.2d %p", i, d);
+               if(d == b0stack)
+                       print(" (b0)");
+               if(d->name == nil) {
+                       print("\n");
+                       continue;
+               }
+               print(" '%s'", d->name);
+               s = pkglookup(d->name, d->package);
+               print(" %lS\n", s);
+       }
+}
+
 void
 testdclstack(void)
 {
index d51e0d08f5aea5c7c2bceb73a5256d6fb334edf1..ed1f903e58ec155125bdb538e15b40fbe1b38cc8 100644 (file)
@@ -385,6 +385,7 @@ EXTERN      vlong   minintval[NTYPE];
 EXTERN vlong   maxintval[NTYPE];
 
 EXTERN Dcl*    autodcl;
+EXTERN Dcl*    paramdcl;
 EXTERN Dcl*    externdcl;
 EXTERN Dcl*    exportlist;
 EXTERN int     dclcontext;     // PEXTERN/PAUTO
@@ -529,6 +530,7 @@ Type*       sortinter(Type*);
 void   markdcl(void);
 void   popdcl(void);
 void   poptodcl(void);
+void   dumpdcl(char*);
 void   markdclstack(void);
 void   testdclstack(void);
 Sym*   pushdcl(Sym*);
index d5ef370c46210f78f64e9d68afdbb35cad0c15ee..0b0e425c5f781b2d69414d3bd4a0acf067e7906b 100644 (file)
@@ -1024,7 +1024,6 @@ fnliteral:
 
                $$ = newname(lookup(namebuf));
                addvar($$, $1, PEXTERN);
-dump("lit1", $$);
 
                {
                        Node *n;
@@ -1035,13 +1034,10 @@ dump("lit1", $$);
                        n->nbody = $3;
                        if(n->nbody == N)
                                n->nbody = nod(ORETURN, N, N);
-dump("comp1", n);
                        compile(n);
-dump("comp2", n);
                }
 
                $$ = nod(OADDR, $$, N);
-dump("lit2", $$);
        }
 
 fnbody: