summaryrefslogtreecommitdiff
path: root/src/cmd/gc/reflect.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-04-20 15:44:41 +0200
committerOndřej Surý <ondrej@sury.org>2011-04-20 15:44:41 +0200
commit50104cc32a498f7517a51c8dc93106c51c7a54b4 (patch)
tree47af80be259cc7c45d0eaec7d42e61fa38c8e4fb /src/cmd/gc/reflect.c
parentc072558b90f1bbedc2022b0f30c8b1ac4712538e (diff)
downloadgolang-upstream/2011.03.07.1.tar.gz
Imported Upstream version 2011.03.07.1upstream/2011.03.07.1
Diffstat (limited to 'src/cmd/gc/reflect.c')
-rw-r--r--src/cmd/gc/reflect.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/cmd/gc/reflect.c b/src/cmd/gc/reflect.c
index 36c245d47..8129bf1ce 100644
--- a/src/cmd/gc/reflect.c
+++ b/src/cmd/gc/reflect.c
@@ -10,6 +10,7 @@
static NodeList* signatlist;
static Sym* dtypesym(Type*);
+static Sym* weaktypesym(Type*);
static int
sigcmp(Sig *a, Sig *b)
@@ -570,9 +571,17 @@ dcommontype(Sym *s, int ot, Type *t)
{
int i;
Sym *s1;
+ Sym *sptr;
char *p;
dowidth(t);
+
+ sptr = nil;
+ if(t->sym != nil && !isptr[t->etype])
+ sptr = dtypesym(ptrto(t));
+ else
+ sptr = weaktypesym(ptrto(t));
+
s1 = dextratype(t);
// empty interface pointing at this type.
@@ -592,7 +601,8 @@ dcommontype(Sym *s, int ot, Type *t)
// fieldAlign uint8;
// kind uint8;
// string *string;
- // *nameInfo;
+ // *extraType;
+ // ptrToThis *Type
// }
ot = duintptr(s, ot, t->width);
ot = duint32(s, ot, typehash(t));
@@ -616,7 +626,7 @@ dcommontype(Sym *s, int ot, Type *t)
ot = dsymptr(s, ot, s1, 0); // extraType
else
ot = duintptr(s, ot, 0);
-
+ ot = dsymptr(s, ot, sptr, 0); // ptr to type
return ot;
}
@@ -662,6 +672,25 @@ typename(Type *t)
}
static Sym*
+weaktypesym(Type *t)
+{
+ char *p;
+ Sym *s;
+ static Pkg *weak;
+
+ if(weak == nil) {
+ weak = mkpkg(strlit("weak.type"));
+ weak->name = "weak.type";
+ weak->prefix = "weak.type"; // not weak%2etype
+ }
+
+ p = smprint("%#-T", t);
+ s = pkglookup(p, weak);
+ free(p);
+ return s;
+}
+
+static Sym*
dtypesym(Type *t)
{
int ot, n, isddd, dupok;