summaryrefslogtreecommitdiff
path: root/src/cmd/gc/subr.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2008-12-19 03:05:54 -0800
committerRuss Cox <rsc@golang.org>2008-12-19 03:05:54 -0800
commit889007b4edb6af1b1464a5efd43bc0f1d662206e (patch)
tree8fa94ae610b0442953d43d35d193a251b6f149d0 /src/cmd/gc/subr.c
parent65e4c6bf1819903c1b751a3b305a6d2ec07cc283 (diff)
downloadgolang-889007b4edb6af1b1464a5efd43bc0f1d662206e.tar.gz
compiler changes for *chan -> chan; *map -> map; new(T) -> new(*T)
mainly a syntactic change: the compiler representations don't change (chan and map are now hidden pointers like string). R=ken OCL=21578 CL=21582
Diffstat (limited to 'src/cmd/gc/subr.c')
-rw-r--r--src/cmd/gc/subr.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index a561b761a..e180258bb 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -1004,9 +1004,26 @@ Tpretty(Fmt *fp, Type *t)
switch(t->etype) {
case TPTR32:
case TPTR64:
- if(t->type && t->type->etype == TSTRING)
- return fmtprint(fp, "string");
- return fmtprint(fp, "*%T", t->type);
+ t1 = t->type;
+ if(t1 != T) {
+ switch(t1->etype) {
+ case TSTRING:
+ return fmtprint(fp, "string");
+ case TMAP:
+ return fmtprint(fp, "map[%T] %T", t1->down, t1->type);
+ case TCHAN:
+ return fmtprint(fp, "chan %T", t1->type);
+ }
+ }
+ return fmtprint(fp, "*%T", t1);
+
+ // Should not see these: should see ptr instead, handled above.
+ case TSTRING:
+ return fmtprint(fp, "STRING", t->type);
+ case TCHAN:
+ return fmtprint(fp, "CHAN %T", t->type);
+ case TMAP:
+ return fmtprint(fp, "MAP[%T] %T", t->down, t->type);
case TFUNC:
// t->type is method struct
@@ -1056,12 +1073,6 @@ Tpretty(Fmt *fp, Type *t)
return fmtprint(fp, "[%d]%T", (int)t->bound, t->type);
return fmtprint(fp, "[]%T", t->type);
- case TCHAN:
- return fmtprint(fp, "chan %T", t->type);
-
- case TMAP:
- return fmtprint(fp, "map[%T] %T", t->down, t->type);
-
case TINTER:
fmtprint(fp, "interface {");
for(t1=t->type; t1!=T; t1=t1->down) {
@@ -1615,11 +1626,12 @@ iscomposite(Type *t)
if(t == T)
return 0;
switch(t->etype) {
- case TMAP:
case TARRAY:
case TSTRUCT:
return 1;
}
+ if(isptr[t->etype] && t->type != T && t->type->etype == TMAP)
+ return 1;
return 0;
}
@@ -1639,6 +1651,10 @@ signame(Type *t)
if(t->etype == TINTER)
e = "sigi";
+ // don't allow arrays in interfaces
+ if(t->etype == TARRAY)
+ goto bad;
+
// name is exported name, like *[]byte or *Struct or Interface
// (special symbols don't bother the linker).
snprint(buf, sizeof(buf), "%#T", t);