]> Cypherpunks repositories - gostls13.git/commitdiff
gc: keep track of real actual type of identifiers.
authorLuuk van Dijk <lvd@golang.org>
Fri, 15 Oct 2010 19:25:34 +0000 (21:25 +0200)
committerLuuk van Dijk <lvd@golang.org>
Fri, 15 Oct 2010 19:25:34 +0000 (21:25 +0200)
R=rsc
CC=golang-dev
https://golang.org/cl/2519042

src/cmd/gc/go.h
src/cmd/gc/subr.c
src/cmd/gc/typecheck.c

index ec1ada74ed94da8988fae3c2bfc2c92783cee1d9..78472d22eb7dd9b70ac24e6d6de93355adb087a5 100644 (file)
@@ -41,7 +41,7 @@ enum
        AMEMWORD,
 
        BADWIDTH        = -1000000000,
-       MAXWIDTH        = 1<<30
+       MAXWIDTH        = 1<<30
 };
 
 /*
@@ -218,6 +218,7 @@ struct      Node
        Node*   left;
        Node*   right;
        Type*   type;
+       Type*   realtype;       // as determined by typecheck
        NodeList*       list;
        NodeList*       rlist;
 
@@ -636,9 +637,9 @@ EXTERN      Label*  labellist;
  *
  * typedef     struct
  * {                           // must not move anything
- *     uchar   array[8];       // pointer to data
- *     uchar   nel[4];         // number of elements
- *     uchar   cap[4];         // allocated number of elements
+ *     uchar   array[8];       // pointer to data
+ *     uchar   nel[4];         // number of elements
+ *     uchar   cap[4];         // allocated number of elements
  * } Array;
  */
 EXTERN int     Array_array;    // runtime offsetof(Array,array) - same for String
@@ -653,8 +654,8 @@ EXTERN      int     sizeof_Array;   // runtime sizeof(Array)
  *
  * typedef     struct
  * {                           // must not move anything
- *     uchar   array[8];       // pointer to data
- *     uchar   nel[4];         // number of elements
+ *     uchar   array[8];       // pointer to data
+ *     uchar   nel[4];         // number of elements
  * } String;
  */
 EXTERN int     sizeof_String;  // runtime sizeof(String)
index a0cb9b4f134187a0d66197fe4e2d868d779bf5ba..ea41a1b7c4d7cba1bc95614f50b9201d11642bcc 100644 (file)
@@ -1273,7 +1273,7 @@ Tpretty(Fmt *fp, Type *t)
                        fmtprint(fp, "...%T", t->type->type);
                else
                        fmtprint(fp, "%T", t->type);
-               if(t->note) {   
+               if(t->note) {
                        fmtprint(fp, " ");
                        if(exporting)
                                fmtprint(fp, ":");
@@ -3607,10 +3607,11 @@ umagic(Magic *m)
 Sym*
 ngotype(Node *n)
 {
-       if(n->sym != S && strncmp(n->sym->name, "autotmp_", 8) != 0)
-       if(n->type->etype != TFUNC || n->type->thistuple == 0)
-       if(n->type->etype != TSTRUCT || n->type->funarg == 0)
-               return typename(n->type)->left->sym;
+       if(n->sym != S && n->realtype != T)
+       if(strncmp(n->sym->name, "autotmp_", 8) != 0)
+       if(strncmp(n->sym->name, "statictmp_", 8) != 0)
+               return typename(n->realtype)->left->sym;
+
        return S;
 }
 
@@ -3684,4 +3685,3 @@ strlit(char *s)
        t->len = strlen(s);
        return t;
 }
-
index 28382f1fd219adf264749d50345f9f9cbe81f22a..9466c39c1446a7c0ec5ea4b3cdc85c908f1477bf 100644 (file)
@@ -80,7 +80,7 @@ typecheck(Node **np, int top)
        n = *np;
        if(n == N)
                return N;
-       
+
        // Resolve definition of name and value of iota lazily.
        n = resolve(n);
        *np = n;
@@ -112,6 +112,7 @@ typecheck(Node **np, int top)
                        goto error;
                }
                walkdef(n);
+               n->realtype = n->type;
                if(n->op == ONONAME)
                        goto error;
        }