Commit f25843e6 authored by Ken Thompson's avatar Ken Thompson

bug 026

R=r
OCL=16494
CL=16494
parent c8b9970e
...@@ -358,123 +358,6 @@ ret: ...@@ -358,123 +358,6 @@ ret:
lineno = lno; lineno = lno;
} }
void
agen_inter(Node *n, Node *res)
{
Node nodo, nodr, nodt;
Node *var;
Sym *s;
char *e;
int32 o,lno;
lno = setlineno(n);
// stack offset
memset(&nodo, 0, sizeof(nodo));
nodo.op = OINDREG;
nodo.val.u.reg = D_SP;
nodo.addable = 1;
nodo.type = types[tptr];
// pointer register
regalloc(&nodr, types[tptr], res);
switch(n->op) {
default:
fatal("agen_inter %O\n", n->op);
// case OS2I:
// ifaces2i(*sigi, *sigs, i.map, i.s)
// i.s is input
// (i.map, i.s) is output
cgen(n->left, &nodr);
nodo.xoffset = 3*widthptr;
cgen_as(&nodo, &nodr, 0);
nodtypesig(&nodt, n->type);
agen(&nodt, &nodr);
nodo.xoffset = 0*widthptr;
cgen_as(&nodo, &nodr, 0);
nodtypesig(&nodt, n->left->type);
agen(&nodt, &nodr);
nodo.xoffset = 1*widthptr;
cgen_as(&nodo, &nodr, 0);
e = "ifaces2i";
if(maxarg < 4*widthptr)
maxarg = 4*widthptr;
o = 2*widthptr;
break;
// case OI2I:
// ifacei2i(*sigi, i.map, i.s)
// (i.map, i.s) is input
// (i.map, i.s) is output
nodo.xoffset = 1*widthptr;
if(!n->left->addable) {
var = nod(OXXX, N, N);
tempname(var, n->left->type);
cgen(n->left, var);
cgen(var, &nodo);
} else {
cgen(n->left, &nodo);
}
nodtypesig(&nodt, n->type);
agen(&nodt, &nodr);
nodo.xoffset = 0*widthptr;
cgen_as(&nodo, &nodr, 0);
e = "ifacei2i";
if(maxarg < 3*widthptr)
maxarg = 3*widthptr;
o = 1*widthptr;
break;
// case OI2S:
// ifacei2s(*sigs, i.map, i.s)
// (i.map, i.s) is input
// i.s is output
nodo.xoffset = 1*widthptr;
if(!n->left->addable) {
var = nod(OXXX, N, N);
tempname(var, n->left->type);
cgen(n->left, var);
cgen(var, &nodo);
} else {
cgen(n->left, &nodo);
}
nodtypesig(&nodt, n->type);
agen(&nodt, &nodr);
nodo.xoffset = 0*widthptr;
cgen_as(&nodo, &nodr, 0);
e = "ifacei2s";
if(maxarg < 3*widthptr)
maxarg = 3*widthptr;
o = 2*widthptr;
break;
}
s = pkglookup(e, "sys");
if(s->oname == N) {
s->oname = newname(s);
s->oname->class = PEXTERN;
}
gins(ACALL, N, s->oname);
nodo.xoffset = o;
gins(ALEAQ, &nodo, res);
regfree(&nodr);
lineno = lno;
}
void void
swgen(Node *n) swgen(Node *n)
{ {
......
...@@ -129,7 +129,6 @@ void swgen(Node*); ...@@ -129,7 +129,6 @@ void swgen(Node*);
void selgen(Node*); void selgen(Node*);
Node* lookdot(Node*, Node*, int); Node* lookdot(Node*, Node*, int);
void inarggen(void); void inarggen(void);
void agen_inter(Node*, Node*);
void cgen_as(Node*, Node*, int); void cgen_as(Node*, Node*, int);
void cgen_asop(Node*); void cgen_asop(Node*);
void cgen_ret(Node*); void cgen_ret(Node*);
...@@ -192,8 +191,6 @@ Node* nodarg(Type*, int); ...@@ -192,8 +191,6 @@ Node* nodarg(Type*, int);
void nodreg(Node*, Type*, int); void nodreg(Node*, Type*, int);
void nodindreg(Node*, Type*, int); void nodindreg(Node*, Type*, int);
void nodconst(Node*, Type*, vlong); void nodconst(Node*, Type*, vlong);
Sym* signame(Type*);
void nodtypesig(Node*, Type*);
void gconreg(int, vlong, int); void gconreg(int, vlong, int);
void buildtxt(void); void buildtxt(void);
void stringpool(Node*); void stringpool(Node*);
......
...@@ -294,20 +294,6 @@ nodconst(Node *n, Type *t, vlong v) ...@@ -294,20 +294,6 @@ nodconst(Node *n, Type *t, vlong v)
} }
} }
void
nodtypesig(Node *n, Type *t)
{
memset(n, 0, sizeof(*n));
n->op = ONAME;
n->type = types[TUINT8];
n->etype = TUINT8;
n->xoffset = 0;
n->sym = signame(t);
n->class = PEXTERN;
n->addable = 1;
n->ullman = 0;
}
void void
gconreg(int as, vlong c, int reg) gconreg(int as, vlong c, int reg)
{ {
......
...@@ -476,7 +476,7 @@ dumpsignatures(void) ...@@ -476,7 +476,7 @@ dumpsignatures(void)
if(t == T) if(t == T)
continue; continue;
s = signame(t); s = signame(t, 0);
if(s == S) if(s == S)
continue; continue;
...@@ -485,6 +485,7 @@ dumpsignatures(void) ...@@ -485,6 +485,7 @@ dumpsignatures(void)
x->dsym = d->dsym; x->dsym = d->dsym;
x->dtype = d->dtype; x->dtype = d->dtype;
x->forw = signatlist; x->forw = signatlist;
x->block = 0;
signatlist = x; signatlist = x;
//print("SIG = %lS %lS %lT\n", d->dsym, s, t); //print("SIG = %lS %lS %lT\n", d->dsym, s, t);
} }
...@@ -531,11 +532,14 @@ dumpsignatures(void) ...@@ -531,11 +532,14 @@ dumpsignatures(void)
continue; continue;
t = d->dtype; t = d->dtype;
at.sym = signame(t); at.sym = signame(t, d->block);
if(at.sym == S) if(at.sym == S)
continue; continue;
if(!at.sym->local)
// make unique
if(at.sym->local != 1)
continue; continue;
at.sym->local = 2;
//print("SIGNAME = %lS\n", at.sym); //print("SIGNAME = %lS\n", at.sym);
...@@ -551,7 +555,6 @@ dumpsignatures(void) ...@@ -551,7 +555,6 @@ dumpsignatures(void)
if(strcmp(s->opackage, package) != 0) if(strcmp(s->opackage, package) != 0)
continue; continue;
a = nil; a = nil;
o = 0; o = 0;
......
...@@ -200,8 +200,8 @@ struct Node ...@@ -200,8 +200,8 @@ struct Node
struct Sym struct Sym
{ {
ushort tblock; ushort tblock; // blocknumber for type
ushort vblock; ushort vblock; // blocknumber for variable
uchar undef; // a diagnostic has been generated uchar undef; // a diagnostic has been generated
uchar export; // marked as export uchar export; // marked as export
...@@ -227,10 +227,12 @@ typedef struct Dcl Dcl; ...@@ -227,10 +227,12 @@ typedef struct Dcl Dcl;
struct Dcl struct Dcl
{ {
uchar op; uchar op;
ushort block;
int32 lineno;
Sym* dsym; // for printing only Sym* dsym; // for printing only
Node* dnode; // oname Node* dnode; // oname
Type* dtype; // otype Type* dtype; // otype
int32 lineno;
Dcl* forw; Dcl* forw;
Dcl* back; // sentinel has pointer to last Dcl* back; // sentinel has pointer to last
...@@ -575,7 +577,7 @@ int isptrarray(Type*); ...@@ -575,7 +577,7 @@ int isptrarray(Type*);
int isptrdarray(Type*); int isptrdarray(Type*);
int isinter(Type*); int isinter(Type*);
Type* ismethod(Type*); Type* ismethod(Type*);
Sym* signame(Type*); Sym* signame(Type*, int);
int bytearraysz(Type*); int bytearraysz(Type*);
int eqtype(Type*, Type*, int); int eqtype(Type*, Type*, int);
void argtype(Node*, Type*); void argtype(Node*, Type*);
......
...@@ -1453,10 +1453,11 @@ out: ...@@ -1453,10 +1453,11 @@ out:
} }
Sym* Sym*
signame(Type *t) signame(Type *t, int block)
{ {
Sym *s, *ss; Sym *s, *ss;
char *e; char *e;
Dcl *x;
char buf[NSYMB]; char buf[NSYMB];
if(t == T) if(t == T)
...@@ -1478,7 +1479,22 @@ signame(Type *t) ...@@ -1478,7 +1479,22 @@ signame(Type *t)
if(t->etype == TINTER) if(t->etype == TINTER)
e = "sigi"; e = "sigi";
snprint(buf, sizeof(buf), "%s_%s", e, s->name); if(block == 0)
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;
x->dsym = s;
x->dtype = s->otype;
x->forw = signatlist;
x->block = block;
signatlist = x;
} else
snprint(buf, sizeof(buf), "%s_%s", e, s->name);
ss = pkglookup(buf, s->opackage); ss = pkglookup(buf, s->opackage);
if(ss->oname == N) { if(ss->oname == N) {
ss->oname = newname(ss); ss->oname = newname(ss);
......
...@@ -2491,7 +2491,7 @@ ifaceop(Type *tl, Node *n, int op) ...@@ -2491,7 +2491,7 @@ ifaceop(Type *tl, Node *n, int op)
a = n; // interface a = n; // interface
r = a; r = a;
s = signame(tl); // sigi s = signame(tl, 0); // sigi
if(s == S) if(s == S)
fatal("ifaceop: signame I2T"); fatal("ifaceop: signame I2T");
a = s->oname; a = s->oname;
...@@ -2510,14 +2510,14 @@ ifaceop(Type *tl, Node *n, int op) ...@@ -2510,14 +2510,14 @@ ifaceop(Type *tl, Node *n, int op)
a = n; // elem a = n; // elem
r = a; r = a;
s = signame(tr); // sigt s = signame(tr, 0); // sigt
if(s == S) if(s == S)
fatal("ifaceop: signame-1 T2I: %lT", tr); fatal("ifaceop: signame-1 T2I: %lT", tr);
a = s->oname; a = s->oname;
a = nod(OADDR, a, N); a = nod(OADDR, a, N);
r = list(a, r); r = list(a, r);
s = signame(tl); // sigi s = signame(tl, 0); // sigi
if(s == S) { if(s == S) {
fatal("ifaceop: signame-2 T2I: %lT", tl); fatal("ifaceop: signame-2 T2I: %lT", tl);
} }
...@@ -2537,7 +2537,7 @@ ifaceop(Type *tl, Node *n, int op) ...@@ -2537,7 +2537,7 @@ ifaceop(Type *tl, Node *n, int op)
a = n; // interface a = n; // interface
r = a; r = a;
s = signame(tl); // sigi s = signame(tl, 0); // sigi
if(s == S) if(s == S)
fatal("ifaceop: signame I2I"); fatal("ifaceop: signame I2I");
a = s->oname; a = s->oname;
......
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