Commit 49a835fc authored by Luuk van Dijk's avatar Luuk van Dijk

gc: keep track of real actual type of identifiers.

R=rsc
CC=golang-dev
https://golang.org/cl/2519042
parent 9c204852
...@@ -41,7 +41,7 @@ enum ...@@ -41,7 +41,7 @@ enum
AMEMWORD, AMEMWORD,
BADWIDTH = -1000000000, BADWIDTH = -1000000000,
MAXWIDTH = 1<<30 MAXWIDTH = 1<<30
}; };
/* /*
...@@ -218,6 +218,7 @@ struct Node ...@@ -218,6 +218,7 @@ struct Node
Node* left; Node* left;
Node* right; Node* right;
Type* type; Type* type;
Type* realtype; // as determined by typecheck
NodeList* list; NodeList* list;
NodeList* rlist; NodeList* rlist;
...@@ -636,9 +637,9 @@ EXTERN Label* labellist; ...@@ -636,9 +637,9 @@ EXTERN Label* labellist;
* *
* typedef struct * typedef struct
* { // must not move anything * { // must not move anything
* uchar array[8]; // pointer to data * uchar array[8]; // pointer to data
* uchar nel[4]; // number of elements * uchar nel[4]; // number of elements
* uchar cap[4]; // allocated number of elements * uchar cap[4]; // allocated number of elements
* } Array; * } Array;
*/ */
EXTERN int Array_array; // runtime offsetof(Array,array) - same for String EXTERN int Array_array; // runtime offsetof(Array,array) - same for String
...@@ -653,8 +654,8 @@ EXTERN int sizeof_Array; // runtime sizeof(Array) ...@@ -653,8 +654,8 @@ EXTERN int sizeof_Array; // runtime sizeof(Array)
* *
* typedef struct * typedef struct
* { // must not move anything * { // must not move anything
* uchar array[8]; // pointer to data * uchar array[8]; // pointer to data
* uchar nel[4]; // number of elements * uchar nel[4]; // number of elements
* } String; * } String;
*/ */
EXTERN int sizeof_String; // runtime sizeof(String) EXTERN int sizeof_String; // runtime sizeof(String)
......
...@@ -1273,7 +1273,7 @@ Tpretty(Fmt *fp, Type *t) ...@@ -1273,7 +1273,7 @@ Tpretty(Fmt *fp, Type *t)
fmtprint(fp, "...%T", t->type->type); fmtprint(fp, "...%T", t->type->type);
else else
fmtprint(fp, "%T", t->type); fmtprint(fp, "%T", t->type);
if(t->note) { if(t->note) {
fmtprint(fp, " "); fmtprint(fp, " ");
if(exporting) if(exporting)
fmtprint(fp, ":"); fmtprint(fp, ":");
...@@ -3607,10 +3607,11 @@ umagic(Magic *m) ...@@ -3607,10 +3607,11 @@ umagic(Magic *m)
Sym* Sym*
ngotype(Node *n) ngotype(Node *n)
{ {
if(n->sym != S && strncmp(n->sym->name, "autotmp_", 8) != 0) if(n->sym != S && n->realtype != T)
if(n->type->etype != TFUNC || n->type->thistuple == 0) if(strncmp(n->sym->name, "autotmp_", 8) != 0)
if(n->type->etype != TSTRUCT || n->type->funarg == 0) if(strncmp(n->sym->name, "statictmp_", 8) != 0)
return typename(n->type)->left->sym; return typename(n->realtype)->left->sym;
return S; return S;
} }
...@@ -3684,4 +3685,3 @@ strlit(char *s) ...@@ -3684,4 +3685,3 @@ strlit(char *s)
t->len = strlen(s); t->len = strlen(s);
return t; return t;
} }
...@@ -80,7 +80,7 @@ typecheck(Node **np, int top) ...@@ -80,7 +80,7 @@ typecheck(Node **np, int top)
n = *np; n = *np;
if(n == N) if(n == N)
return N; return N;
// Resolve definition of name and value of iota lazily. // Resolve definition of name and value of iota lazily.
n = resolve(n); n = resolve(n);
*np = n; *np = n;
...@@ -112,6 +112,7 @@ typecheck(Node **np, int top) ...@@ -112,6 +112,7 @@ typecheck(Node **np, int top)
goto error; goto error;
} }
walkdef(n); walkdef(n);
n->realtype = n->type;
if(n->op == ONONAME) if(n->op == ONONAME)
goto error; goto error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment