Commit 39a4b142 authored by Ken Thompson's avatar Ken Thompson

bug103 - but the fix caused other

things to break. hopefully all fixed
now.

R=r
OCL=15597
CL=15597
parent 934a19fa
...@@ -478,7 +478,7 @@ dumpsignatures(void) ...@@ -478,7 +478,7 @@ dumpsignatures(void)
continue; continue;
et = t->etype; et = t->etype;
if(et != TSTRUCT && et != TINTER) if(t->method == T && et != TINTER)
continue; continue;
s = d->dsym; s = d->dsym;
...@@ -549,7 +549,7 @@ dumpsignatures(void) ...@@ -549,7 +549,7 @@ dumpsignatures(void)
t = d->dtype; t = d->dtype;
et = t->etype; et = t->etype;
if(et != TSTRUCT && et != TINTER) if(t->method == T && et != TINTER)
continue; continue;
s = d->dsym; s = d->dsym;
......
...@@ -563,6 +563,7 @@ int isptrto(Type*, int); ...@@ -563,6 +563,7 @@ int isptrto(Type*, int);
int isptrarray(Type*); int isptrarray(Type*);
int isptrdarray(Type*); int isptrdarray(Type*);
int isinter(Type*); int isinter(Type*);
int ismethod(Type*);
int bytearraysz(Type*); int bytearraysz(Type*);
int eqtype(Type*, Type*, int); int eqtype(Type*, Type*, int);
void argtype(Node*, Type*); void argtype(Node*, Type*);
......
...@@ -1224,6 +1224,20 @@ isinter(Type *t) ...@@ -1224,6 +1224,20 @@ isinter(Type *t)
return 0; return 0;
} }
int
ismethod(Type *t)
{
// OLD WAY
if(isptrto(t, TSTRUCT))
return 1;
return 0;
// NEW WAY - but doesnt work yet
if(t != T && t->method != T)
return 1;
return 0;
}
int int
bytearraysz(Type *t) bytearraysz(Type *t)
{ {
......
...@@ -330,8 +330,18 @@ loop: ...@@ -330,8 +330,18 @@ loop:
} }
n->type = *getoutarg(t); n->type = *getoutarg(t);
if(t->outtuple == 1) switch(t->outtuple) {
case 0:
if(top == Erv) {
yyerror("function requires a return type");
n->type = types[TINT32];
}
break;
case 1:
n->type = n->type->type->type; n->type = n->type->type->type;
break;
}
walktype(n->right, Erv); walktype(n->right, Erv);
...@@ -1381,7 +1391,7 @@ lookdot(Node *n, Type *f) ...@@ -1381,7 +1391,7 @@ lookdot(Node *n, Type *f)
if(f->sym != s) if(f->sym != s)
continue; continue;
if(r != T) { if(r != T) {
yyerror("ambiguous DOT reference %s", s->name); yyerror("ambiguous DOT reference %S", s);
break; break;
} }
r = f; r = f;
...@@ -1432,7 +1442,7 @@ walkdot(Node *n) ...@@ -1432,7 +1442,7 @@ walkdot(Node *n)
f = lookdot(n->right, t->method); f = lookdot(n->right, t->method);
if(f == T) { if(f == T) {
yyerror("undefined DOT %s", n->right->sym->name); yyerror("undefined DOT %S", n->right->sym);
return; return;
} }
...@@ -1579,11 +1589,11 @@ ascompat(Type *t1, Type *t2) ...@@ -1579,11 +1589,11 @@ ascompat(Type *t1, Type *t2)
// return 1; // return 1;
if(isinter(t1)) if(isinter(t1))
if(isptrto(t2, TSTRUCT) || isinter(t2)) if(ismethod(t2) || isinter(t2))
return 1; return 1;
if(isinter(t2)) if(isinter(t2))
if(isptrto(t1, TSTRUCT)) if(ismethod(t1))
return 1; return 1;
if(isptrdarray(t1)) if(isptrdarray(t1))
...@@ -1608,7 +1618,7 @@ prcompat(Node *n) ...@@ -1608,7 +1618,7 @@ prcompat(Node *n)
loop: loop:
if(l == N) { if(l == N) {
walktype(r, Erv); walktype(r, Etop);
return r; return r;
} }
...@@ -1673,7 +1683,7 @@ nodpanic(int32 lineno) ...@@ -1673,7 +1683,7 @@ nodpanic(int32 lineno)
on = syslook("panicl", 0); on = syslook("panicl", 0);
n = nodintconst(lineno); n = nodintconst(lineno);
n = nod(OCALL, on, n); n = nod(OCALL, on, n);
walktype(n, Erv); walktype(n, Etop);
return n; return n;
} }
...@@ -2027,7 +2037,7 @@ mapop(Node *n, int top) ...@@ -2027,7 +2037,7 @@ mapop(Node *n, int top)
argtype(on, t->type); // any-4 argtype(on, t->type); // any-4
r = nod(OCALL, on, r); r = nod(OCALL, on, r);
walktype(r, Erv); walktype(r, Etop);
break; break;
assign2: assign2:
...@@ -2056,7 +2066,7 @@ mapop(Node *n, int top) ...@@ -2056,7 +2066,7 @@ mapop(Node *n, int top)
argtype(on, t->type); // any-4 argtype(on, t->type); // any-4
r = nod(OCALL, on, r); r = nod(OCALL, on, r);
walktype(r, Erv); walktype(r, Etop);
break; break;
access2: access2:
...@@ -2446,7 +2456,7 @@ diagnamed(Type *t) ...@@ -2446,7 +2456,7 @@ diagnamed(Type *t)
if(isinter(t)) if(isinter(t))
if(t->sym == S) if(t->sym == S)
yyerror("interface type must be named"); yyerror("interface type must be named");
if(isptrto(t, TSTRUCT)) if(ismethod(t))
if(t->type == T || t->type->sym == S) if(t->type == T || t->type->sym == S)
yyerror("structure type must be named"); yyerror("structure type must be named");
} }
...@@ -2460,7 +2470,7 @@ isandss(Type *lt, Node *r) ...@@ -2460,7 +2470,7 @@ isandss(Type *lt, Node *r)
rt = r->type; rt = r->type;
if(isinter(lt)) { if(isinter(lt)) {
if(isptrto(rt, TSTRUCT)) { if(ismethod(rt)) {
o = OS2I; o = OS2I;
goto ret; goto ret;
} }
...@@ -2470,7 +2480,7 @@ isandss(Type *lt, Node *r) ...@@ -2470,7 +2480,7 @@ isandss(Type *lt, Node *r)
} }
} }
if(isptrto(lt, TSTRUCT)) { if(ismethod(lt)) {
if(isinter(rt)) { if(isinter(rt)) {
o = OI2S; o = OI2S;
goto ret; goto ret;
......
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