1
0
mirror of https://github.com/golang/go synced 2024-11-24 10:10:07 -07:00

gc: keep track of real actual type of identifiers.

R=rsc
CC=golang-dev
https://golang.org/cl/2519042
This commit is contained in:
Luuk van Dijk 2010-10-15 21:25:34 +02:00
parent 9c20485268
commit 49a835fc97
3 changed files with 15 additions and 13 deletions

View 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)

View 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;
}

View 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;
}