mirror of
https://github.com/golang/go
synced 2024-11-21 19:54:41 -07:00
gc: emit reflect correct reflect types
Fixes #1169. R=ken2 CC=golang-dev https://golang.org/cl/3595043
This commit is contained in:
parent
c7c16175e0
commit
96db724cfc
@ -598,7 +598,7 @@ dcommontype(Sym *s, int ot, Type *t)
|
|||||||
// alg uint8;
|
// alg uint8;
|
||||||
// align uint8;
|
// align uint8;
|
||||||
// fieldAlign uint8;
|
// fieldAlign uint8;
|
||||||
// kind uint8;
|
// kind uint8;
|
||||||
// string *string;
|
// string *string;
|
||||||
// *nameInfo;
|
// *nameInfo;
|
||||||
// }
|
// }
|
||||||
@ -617,7 +617,7 @@ dcommontype(Sym *s, int ot, Type *t)
|
|||||||
if(t->etype == TARRAY && t->bound < 0)
|
if(t->etype == TARRAY && t->bound < 0)
|
||||||
i = KindSlice;
|
i = KindSlice;
|
||||||
if(isptr[t->etype] && t->type->etype == TANY)
|
if(isptr[t->etype] && t->type->etype == TANY)
|
||||||
i = KindUnsafePointer;
|
i = KindUnsafePointer;
|
||||||
if(!haspointers(t))
|
if(!haspointers(t))
|
||||||
i |= KindNoPointers;
|
i |= KindNoPointers;
|
||||||
ot = duint8(s, ot, i); // kind
|
ot = duint8(s, ot, i); // kind
|
||||||
@ -678,11 +678,10 @@ typename(Type *t)
|
|||||||
static Sym*
|
static Sym*
|
||||||
dtypesym(Type *t)
|
dtypesym(Type *t)
|
||||||
{
|
{
|
||||||
int ot, n, isddd;
|
int ot, n, isddd, dupok;
|
||||||
Sym *s, *s1, *s2;
|
Sym *s, *s1, *s2;
|
||||||
Sig *a, *m;
|
Sig *a, *m;
|
||||||
Type *t1;
|
Type *t1, *tbase;
|
||||||
Sym *tsym;
|
|
||||||
|
|
||||||
if(isideal(t))
|
if(isideal(t))
|
||||||
fatal("dtypesym %T", t);
|
fatal("dtypesym %T", t);
|
||||||
@ -695,30 +694,22 @@ dtypesym(Type *t)
|
|||||||
// special case (look for runtime below):
|
// special case (look for runtime below):
|
||||||
// when compiling package runtime,
|
// when compiling package runtime,
|
||||||
// emit the type structures for int, float, etc.
|
// emit the type structures for int, float, etc.
|
||||||
t1 = T;
|
tbase = t;
|
||||||
if(isptr[t->etype])
|
if(isptr[t->etype] && t->sym == S && t->type->sym != S)
|
||||||
t1 = t->type;
|
tbase = t->type;
|
||||||
tsym = S;
|
dupok = tbase->sym == S;
|
||||||
if(t1)
|
|
||||||
tsym = t1->sym;
|
|
||||||
else
|
|
||||||
tsym = t->sym;
|
|
||||||
|
|
||||||
if(compiling_runtime) {
|
if(compiling_runtime) {
|
||||||
if(t == types[t->etype])
|
if(tbase == types[tbase->etype]) // int, float, etc
|
||||||
goto ok;
|
goto ok;
|
||||||
if(t1 && t1 == types[t1->etype])
|
if(tbase->etype == tptr && tbase->type->etype == TANY) // unsafe.Pointer
|
||||||
goto ok;
|
|
||||||
if(t1 && t1->etype == tptr && t1->type->etype == TANY)
|
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
// named types from other files are defined in those files
|
// named types from other files are defined only by those files
|
||||||
if(t->sym && !t->local)
|
if(tbase->sym && !tbase->local)
|
||||||
return s;
|
return s;
|
||||||
if(!t->sym && t1 && t1->sym && !t1->local)
|
if(isforw[tbase->etype])
|
||||||
return s;
|
|
||||||
if(isforw[t->etype] || (t1 && isforw[t1->etype]))
|
|
||||||
return s;
|
return s;
|
||||||
|
|
||||||
ok:
|
ok:
|
||||||
@ -813,7 +804,7 @@ ok:
|
|||||||
case TPTR32:
|
case TPTR32:
|
||||||
case TPTR64:
|
case TPTR64:
|
||||||
if(t->type->etype == TANY) {
|
if(t->type->etype == TANY) {
|
||||||
// ../../pkg/runtime/type.go:/UnsafePointerType
|
// ../../pkg/runtime/type.go:/UnsafePointerType
|
||||||
ot = dcommontype(s, ot, t);
|
ot = dcommontype(s, ot, t);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -854,7 +845,7 @@ ok:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ggloblsym(s, ot, tsym == nil);
|
ggloblsym(s, ot, dupok);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -882,7 +873,7 @@ dumptypestructs(void)
|
|||||||
continue;
|
continue;
|
||||||
t = n->type;
|
t = n->type;
|
||||||
dtypesym(t);
|
dtypesym(t);
|
||||||
if(t->sym && !isptr[t->etype])
|
if(t->sym)
|
||||||
dtypesym(ptrto(t));
|
dtypesym(ptrto(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user