Commit c249a8de authored by Russ Cox's avatar Russ Cox

rename various magic names.

	sigi and sigt:
	sys·sigi_inter -> sigi·inter
	sys·sigt_int -> sigt·int
	Package·sigt_Type -> sigt·Package.Type

	local type T in file x.go T_x -> T·x
	second one T_x_1 -> T·x·1

	method names M on T  T_M -> T·M

correctly handle local embedded types

init functions are the only place left that use underscores

R=ken
OCL=18377
CL=18377
parent 90e5574f
......@@ -516,6 +516,7 @@ gentramp(Type *t, Sig *b)
int c, d, o;
Prog *p;
Type *f;
Sym *msym;
e = lookup(b->name);
for(d=0; d<nelem(dotlist); d++) {
......@@ -585,14 +586,12 @@ out:
f = dotlist[0].field;
//JMP main·Sub_test2(SB)
snprint(namebuf, sizeof(namebuf), "%s_%s",
f->sym->name, b->name);
if(isptr[f->type->etype])
f = f->type;
p = pc;
gins(AJMP, N, N);
p->to.type = D_EXTERN;
p->to.sym = pkglookup(namebuf, f->type->sym->opackage);
p->to.sym = methodsym(lookup(b->name), f->type);
//print("6. %P\n", p);
}
......@@ -661,9 +660,7 @@ dumpsigt(void)
a->name = s1->name;
a->hash = PRIME8*stringhash(a->name) + PRIME9*typehash(f->type, 0);
a->perm = o;
snprint(namebuf, sizeof(namebuf), "%s_%s",
at.sym->name+5, f->sym->name);
a->sym = lookup(namebuf);
a->sym = methodsym(f->sym, t);
a->offset = f->embedded; // need trampoline
o++;
......@@ -813,9 +810,7 @@ dumpsigi(void)
a->hash = PRIME8*stringhash(a->name) + PRIME9*typehash(f->type, 0);
a->perm = o;
snprint(namebuf, sizeof(namebuf), "%s_%s",
at.sym->name+5, f->sym->name);
a->sym = lookup(namebuf);
a->sym = methodsym(f->sym, t);
a->offset = 0;
o++;
......
......@@ -200,8 +200,8 @@ methcmp(Type *t1, Type *t2)
return 1;
}
Node*
methodname(Node *n, Type *t)
Sym*
methodsym(Sym *nsym, Type *t)
{
Sym *s;
char buf[NSYMB];
......@@ -213,12 +213,24 @@ methodname(Node *n, Type *t)
if(s == S)
goto bad;
snprint(buf, sizeof(buf), "%s_%s", s->name, n->sym->name);
return newname(pkglookup(buf, s->opackage));
snprint(buf, sizeof(buf), "%#hT·%s", t, nsym->name);
//print("methodname %s\n", buf);
return pkglookup(buf, s->opackage);
bad:
yyerror("illegal <this> type: %T", t);
return S;
}
Node*
methodname(Node *n, Type *t)
{
Sym *s;
s = methodsym(n->sym, t);
if(s == S)
return n;
return newname(s);
}
/*
......@@ -449,7 +461,6 @@ stotype(Node *n, Type **t)
{
Type *f;
Iter save;
char buf[100];
String *note;
n = listfirst(&save, &n);
......@@ -740,7 +751,6 @@ addtyp(Type *n, int ctxt)
{
Dcl *r, *d;
Sym *s;
char *p;
static int typgen;
if(n==T || n->sym == S)
......@@ -753,9 +763,7 @@ addtyp(Type *n, int ctxt)
else {
r = autodcl;
pushdcl(s);
p = smprint("%s_%d", s->name, ++typgen);
n->xsym = lookup(p);
free(p);
n->vargen = ++typgen;
}
if(s->tblock == block)
......@@ -1168,8 +1176,19 @@ Node*
embedded(Sym *s)
{
Node *n;
char *name;
// Names sometimes have disambiguation junk
// appended after a center dot. Discard it when
// making the name for the embedded struct field.
enum { CenterDot = 0xB7 };
name = s->name;
if(utfrune(s->name, CenterDot)) {
name = strdup(s->name);
*utfrune(name, CenterDot) = 0;
}
n = newname(lookup(s->name));
n = newname(lookup(name));
n = nod(ODCLFIELD, n, N);
n->embedded = 1;
if(s == S)
......
......@@ -135,7 +135,6 @@ struct Type
Type* method;
Sym* sym;
Sym* xsym; // export sym
int32 vargen; // unique name for OTYPE/ONAME
Node* nname;
......@@ -190,7 +189,6 @@ struct Node
Val val;
Sym* osym; // import
Sym* fsym; // import
Sym* psym; // import
Sym* sym; // various
int32 vargen; // unique name for OTYPE/ONAME
......@@ -665,6 +663,7 @@ void defaultlit(Node*);
int listcount(Node*);
void addmethod(Node*, Type*, int);
Node* methodname(Node*, Type*);
Sym* methodsym(Sym*, Type*);
Type* functype(Node*, Node*, Node*);
char* thistypenam(Node*);
void funcnam(Type*, char*);
......
......@@ -984,12 +984,17 @@ Tpretty(Fmt *fp, Type *t)
if(t == types[t->etype] || t == types[TSTRING])
return fmtprint(fp, "%s", s->name);
if(exporting) {
if(t->xsym != S)
s = t->xsym;
if(fp->flags & FmtShort)
fmtprint(fp, "%hS", s);
else
fmtprint(fp, "%lS", s);
if(strcmp(s->opackage, package) == 0)
if(s->otype != t || !s->export)
return fmtprint(fp, "%lS_%s", s, filename);
return fmtprint(fp, "%lS", s);
if(s->otype != t || !s->export) {
fmtprint(fp, "·%s", filename);
if(t->vargen)
fmtprint(fp, "·%d", t->vargen);
}
return 0;
}
return fmtprint(fp, "%S", s);
}
......@@ -1606,12 +1611,11 @@ globalsig(Type *t)
int et;
Sym *s;
char buf[NSYMB];
char *glob;
char *sigx;
if(t == T)
return S;
glob = "sys";
et = t->etype;
switch(et) {
default:
......@@ -1620,7 +1624,8 @@ globalsig(Type *t)
case TINTER:
case TDDD:
if(isnilinter(t)) {
snprint(buf, sizeof(buf), "%s_%s", "sigi", "inter");
sigx = "sigi";
strcpy(buf, "inter");
goto out;
}
return S;
......@@ -1660,10 +1665,11 @@ globalsig(Type *t)
return S;
if(strcmp(t->sym->name, types[et]->sym->name) != 0)
return S;
snprint(buf, sizeof(buf), "%s_%S", "sigt", t->sym);
sigx = "sigt";
snprint(buf, sizeof(buf), "%#T", t);
out:
s = pkglookup(buf, glob);
s = pkglookup(buf, sigx);
if(s->oname == N) {
s->oname = newname(s);
s->oname->type = types[TUINT8];
......@@ -1709,8 +1715,6 @@ signame(Type *t, int block)
block = s->tblock;
if(block > 1) {
snprint(buf, sizeof(buf), "%s_%d%s", e, block, s->name);
// record internal type for signature generation
x = mal(sizeof(*x));
x->op = OTYPE;
......@@ -1719,10 +1723,9 @@ signame(Type *t, int block)
x->forw = signatlist;
x->block = block;
signatlist = x;
} else
snprint(buf, sizeof(buf), "%s_%s", e, s->name);
ss = pkglookup(buf, s->opackage);
}
snprint(buf, sizeof(buf), "%#T", t);
ss = pkglookup(buf, e);
if(ss->oname == N) {
ss->oname = newname(ss);
ss->oname->type = types[TUINT8];
......@@ -2494,7 +2497,6 @@ adddot(Node *n)
{
Type *t;
Sym *s;
Node *l;
int c, d;
walktype(n->left, Erv);
......
......@@ -47,29 +47,29 @@ static Map* hash[1009];
#define END nil,0,0,nil
Sigi sys·sigi_inter[2] = { (byte*)"interface {}", 0, 0, nil, 0, 0 };
Sigi sigi·inter[2] = { (byte*)"interface {}", 0, 0, nil, 0, 0 };
Sigt sys·sigt_int8[2] = { (byte*)"int8", ASIMP, 1, nil, END };
Sigt sys·sigt_int16[2] = { (byte*)"int16", ASIMP, 2, nil, END };
Sigt sys·sigt_int32[2] = { (byte*)"int32", ASIMP, 4, nil, END };
Sigt sys·sigt_int64[2] = { (byte*)"int64", ASIMP, 8, nil, END };
Sigt sigt·int8[2] = { (byte*)"int8", ASIMP, 1, nil, END };
Sigt sigt·int16[2] = { (byte*)"int16", ASIMP, 2, nil, END };
Sigt sigt·int32[2] = { (byte*)"int32", ASIMP, 4, nil, END };
Sigt sigt·int64[2] = { (byte*)"int64", ASIMP, 8, nil, END };
Sigt sys·sigt_uint8[2] = { (byte*)"uint8", ASIMP, 1, nil, END };
Sigt sys·sigt_uint16[2] = { (byte*)"uint16", ASIMP, 2, nil, END };
Sigt sys·sigt_uint32[2] = { (byte*)"uint32", ASIMP, 4, nil, END };
Sigt sys·sigt_uint64[2] = { (byte*)"uint64", ASIMP, 8, nil, END };
Sigt sigt·uint8[2] = { (byte*)"uint8", ASIMP, 1, nil, END };
Sigt sigt·uint16[2] = { (byte*)"uint16", ASIMP, 2, nil, END };
Sigt sigt·uint32[2] = { (byte*)"uint32", ASIMP, 4, nil, END };
Sigt sigt·uint64[2] = { (byte*)"uint64", ASIMP, 8, nil, END };
Sigt sys·sigt_float32[2] = { (byte*)"float32", ASIMP, 4, nil, END };
Sigt sys·sigt_float64[2] = { (byte*)"float64", ASIMP, 8, nil, END };
//Sigt sys·sigt_float80[2] = { (byte*)"float80", ASIMP, 0, nil, END };
Sigt sigt·float32[2] = { (byte*)"float32", ASIMP, 4, nil, END };
Sigt sigt·float64[2] = { (byte*)"float64", ASIMP, 8, nil, END };
//Sigt sigt·float80[2] = { (byte*)"float80", ASIMP, 0, nil, END };
Sigt sys·sigt_bool[2] = { (byte*)"bool", ASIMP, 1, nil, END };
Sigt sys·sigt_string[2] = { (byte*)"string", ASTRING, 8, nil, END };
Sigt sigt·bool[2] = { (byte*)"bool", ASIMP, 1, nil, END };
Sigt sigt·string[2] = { (byte*)"string", ASTRING, 8, nil, END };
Sigt sys·sigt_int[2] = { (byte*)"int", ASIMP, 4, nil, END };
Sigt sys·sigt_uint[2] = { (byte*)"uint", ASIMP, 4, nil, END };
Sigt sys·sigt_uintptr[2] = { (byte*)"uintptr", ASIMP, 8, nil, END };
Sigt sys·sigt_float[2] = { (byte*)"float", ASIMP, 4, nil, END };
Sigt sigt·int[2] = { (byte*)"int", ASIMP, 4, nil, END };
Sigt sigt·uint[2] = { (byte*)"uint", ASIMP, 4, nil, END };
Sigt sigt·uintptr[2] = { (byte*)"uintptr", ASIMP, 8, nil, END };
Sigt sigt·float[2] = { (byte*)"float", ASIMP, 4, nil, END };
static void
printsigi(Sigi *si)
......
......@@ -22,7 +22,7 @@ errchk: ./convlit.go: unmatched error messages:
hello, world
=========== ./interface2.go
cannot convert type *main.S_interface2 to interface main.I_interface2: missing method Foo
cannot convert type *main.S·interface2 to interface main.I·interface2: missing method Foo
throw: interface conversion
SIGSEGV: segmentation violation
Faulting address: 0x0
......@@ -30,7 +30,7 @@ pc: xxx
=========== ./interface3.go
cannot convert type *main.S_interface3 to interface main.I2_interface3: missing method Name
cannot convert type *main.S·interface3 to interface main.I2·interface3: missing method Name
throw: interface conversion
SIGSEGV: segmentation violation
Faulting address: 0x0
......
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