]> Cypherpunks repositories - gostls13.git/commitdiff
parameter in fn literals
authorKen Thompson <ken@golang.org>
Thu, 17 Jul 2008 01:31:01 +0000 (18:31 -0700)
committerKen Thompson <ken@golang.org>
Thu, 17 Jul 2008 01:31:01 +0000 (18:31 -0700)
SVN=127695

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

index 3a6735cd62ca4fc7088584a5e834567779c3e6fd..764f35ee3d4c6fe8a92b851d9a03519baae6a680 100644 (file)
@@ -102,7 +102,7 @@ allocparams(void)
         * parameters, is the offset in the
         * parameter list.
         */
-       d = paramdcl->forw;;
+       d = curfn->type->param->forw;
        t = funcfirst(&list, curfn->type);
        while(t != T) {
                if(d == D)
@@ -117,6 +117,7 @@ allocparams(void)
                if(n->class != PPARAM)
                        fatal("allocparams: this & in class %N %d", n, n->class);
 
+//print("assign %S %ld\n", n->sym, t->width);
                n->xoffset = t->width;
                d = d->forw;
                t = funcnext(&list);
@@ -127,6 +128,7 @@ allocparams(void)
                if(t->nname != N && t->nname->sym->name[0] != '_') {
                        if(d == D)
                                fatal("allocparams: out nil");
+
                        if(d->op != ONAME) {
                                d = d->forw;
                                continue;
index e37e95379684af7f42a37605d0b357c186b7f8d2..b3c74d7dd8d2d30561955f37833ad4580d7bb844 100644 (file)
@@ -364,39 +364,39 @@ funchdr(Node *n)
 }
 
 void
-funcargs(Type *t)
+funcargs(Type *ft)
 {
-       Type *n1;
+       Type *t;
        Iter save;
        int all;
 
-       paramdcl = autodcl->back;       // base of arguments - see allocparams in gen.c
+       ft->param = autodcl->back;      // base of arguments - see allocparams in gen.c
 
        // declare the this/in arguments
-       n1 = funcfirst(&save, t);
-       while(n1 != T) {
-               if(n1->nname != N)
-                       addvar(n1->nname, n1->type, PPARAM);
-               n1 = funcnext(&save);
+       t = funcfirst(&save, ft);
+       while(t != T) {
+               if(t->nname != N)
+                       addvar(t->nname, t->type, PPARAM);
+               t = funcnext(&save);
        }
 
        // declare the outgoing arguments
        all = 0;
-       n1 = structfirst(&save, getoutarg(t));
-       while(n1 != T) {
-               if(n1->nname != N && n1->nname->sym->name[0] != '_') {
-                       addvar(n1->nname, n1->type, PPARAM);
+       t = structfirst(&save, getoutarg(ft));
+       while(t != T) {
+               if(t->nname != N && t->nname->sym->name[0] != '_') {
+                       addvar(t->nname, t->type, PPARAM);
                        all |= 1;
                } else
                        all |= 2;
-               n1 = structnext(&save);
+               t = structnext(&save);
        }
        if(all == 3)
                yyerror("output parameters are all named or not named");
 
-       t->outnamed = 0;
+       ft->outnamed = 0;
        if(all == 1)
-               t->outnamed = 1;
+               ft->outnamed = 1;
 }
 
 /*
index ed1f903e58ec155125bdb538e15b40fbe1b38cc8..bf347271598b1f82eb9338a74e20ac74723304b7 100644 (file)
@@ -68,6 +68,7 @@ struct        Val
 typedef        struct  Sym     Sym;
 typedef        struct  Node    Node;
 typedef        struct  Type    Type;
+typedef        struct  Dcl     Dcl;
 
 struct Type
 {
@@ -84,6 +85,7 @@ struct        Type
 
        Sym*    sym;
        long    vargen;         // unique name for OTYPE/ONAME
+       Dcl*    param;
 
        // most nodes
        Type*   type;
@@ -173,7 +175,6 @@ struct      Sym
 };
 #define        S       ((Sym*)0)
 
-typedef        struct  Dcl     Dcl;
 struct Dcl
 {
        uchar   op;
index ff217fbc9b97c73d488049d32dc32c7989bdce42..28774a5a28190b42394df92af7ae228d40fb6879 100644 (file)
@@ -1179,8 +1179,6 @@ prcompat(Node *n)
 
 loop:
        if(l == N) {
-               if(r == N)
-                       return nod(OBAD, N, N);
                walktype(r, Etop);
                return r;
        }