goto abop;
case OCONV:
- if(eqtype(n->type, nl->type, 0)) {
+ if(eqtype(n->type, nl->type)) {
cgen(nl, res);
break;
}
break;
case OCONV:
- if(!eqtype(n->type, nl->type, 0))
+ if(!eqtype(n->type, nl->type))
fatal("agen: non-trivial OCONV");
agen(nl, res);
return;
}
// avoided repeated calculations, errors
- if(eqtype(n->type, t, 0)) {
+ if(eqtype(n->type, t)) {
n->type = t;
return;
}
if(t1->etype != TSTRUCT || t2->etype != TSTRUCT)
return 0;
- if(!eqtype(t1->type, t2->type, 0))
+ if(!eqtype(t1->type, t2->type))
return 0;
t1 = t1->down;
d = f;
continue;
}
- if(!eqtype(t, f->type, 0)) {
+ if(!eqtype(t, f->type)) {
yyerror("method redeclared: %T.%S", pa, sf);
print("\t%T\n\t%T\n", f->type, t);
}
// check for same types
if(on != N) {
- if(eqtype(n->type, on->type, 0)) {
+ if(eqtype(n->type, on->type)) {
if(!eqargs(n->type, on->type)) {
yyerror("function arg names changed: %S", s);
print("\t%T\n\t%T\n", on->type, n->type);
s = importsym(ss, LNAME);
if(s->oname != N) {
- if(eqtype(t, s->oname->type, 0))
+ if(eqtype(t, s->oname->type))
return;
warn("redeclare import var %S from %T to %T",
s, s->oname->type, t);
s = importsym(ss, LATYPE);
if(s->otype != T) {
- if(eqtype(t, s->otype, 0))
+ if(eqtype(t, s->otype))
return;
if(s->otype->etype != TFORW) {
warn("redeclare import type %S from %T to %T",
Type* maptype(Type*, Type*);
Type* methtype(Type*);
Sym* signame(Type*);
-int eqtype(Type*, Type*, int);
+int eqtype(Type*, Type*);
int eqtypenoname(Type*, Type*);
void argtype(Node*, Type*);
int eqargs(Type*, Type*);
labelname:
name
+| LATYPE
+ {
+ $$ = oldname($1);
+ }
| keyword
{
$$ = oldname($1);
* to check whether the rest of the grammar is free of
* reduce/reduce conflicts, comment this section out by
* removing the slash on the next line.
+ *
+ * there should be exactly 1 reduce/reduce conflict
+ * when this block is commented out.
*/
lpack:
LATYPE
if(!a->sym->siggen) {
a->sym->siggen = 1;
- if(!eqtype(this, ifacet, 0)) {
+ if(!eqtype(this, ifacet)) {
if(oldlist == nil)
oldlist = pc;
}
int
-eqtype(Type *t1, Type *t2, int d)
+eqtype1(Type *t1, Type *t2, int d)
{
if(d >= 10)
return 1;
t1 = t1->type;
t2 = t2->type;
for(;;) {
- if(!eqtype(t1, t2, d+1))
+ if(!eqtype1(t1, t2, d+1))
return 0;
if(t1 == T)
return 1;
return 0;
if(ta->etype != TFIELD || tb->etype != TFIELD)
return 0;
- if(!eqtype(ta->type, tb->type, d+1))
+ if(!eqtype1(ta->type, tb->type, d+1))
return 0;
ta = ta->down;
tb = tb->down;
break;
return 0;
}
- return eqtype(t1->type, t2->type, d+1);
+ return eqtype1(t1->type, t2->type, d+1);
+}
+
+int
+eqtype(Type *t1, Type *t2)
+{
+ return eqtype1(t1, t2, 0);
}
int
eqtypenoname(Type *t1, Type *t2)
{
if(t1 == T || t2 == T || t1->etype != TSTRUCT || t2->etype != TSTRUCT)
- return eqtype(t1, t2, 0);
+ return eqtype(t1, t2);
t1 = t1->type;
t2 = t2->type;
for(;;) {
- if(!eqtype(t1, t2, 1))
+ if(!eqtype(t1, t2))
return 0;
if(t1 == T)
return 1;
for(;;) {
if(t1 == t2)
break;
- if(!eqtype(t1, t2, 0))
+ if(!eqtype(t1, t2))
return 0;
t1 = t1->down;
t2 = t2->down;
}
if(tl->etype != TFUNC || tr->etype != TFUNC)
break;
-// if(eqtype(t1, t2, 0))
+// if(eqtype(t1, t2))
}
yyerror("illegal types for operand: %O", o);
defaultlit2(n->left, n->right);
if(n->left->type == T || n->right->type == T)
goto ret;
- if(!eqtype(n->left->type, n->right->type, 0))
+ if(!eqtype(n->left->type, n->right->type))
goto badt;
switch(n->op) {
defaultlit(n->right, t->down);
if(n->right->type == T)
break;
- if(!eqtype(n->right->type, t->down, 0))
+ if(!eqtype(n->right->type, t->down))
goto badt;
n->type = t->type;
if(top == Erv)
defaultlit(n, T);
addtotop(n);
if(n != N && n->type != T)
- if(!eqtype(n->type, types[TBOOL], 0))
+ if(!eqtype(n->type, types[TBOOL]))
yyerror("IF and FOR require a boolean type");
}
return;
// nil conversion
- if(eqtype(t, l->type, 0)) {
+ if(eqtype(t, l->type)) {
if(l->op != ONAME) {
indir(n, l);
n->type = t;
// convert static array to dynamic array
if(isslice(t) && isptr[l->type->etype] && isfixedarray(l->type->type)) {
- if(eqtype(t->type->type, l->type->type->type->type, 0)) {
+ if(eqtype(t->type->type, l->type->type->type->type)) {
indir(n, arrayop(n, Erv));
return;
}
if(f2 != T) {
tt = n->left->type;
rcvr = getthisx(f2->type)->type->type;
- if(!eqtype(rcvr, tt, 0)) {
- if(rcvr->etype == tptr && eqtype(rcvr->type, tt, 0)) {
+ if(!eqtype(rcvr, tt)) {
+ if(rcvr->etype == tptr && eqtype(rcvr->type, tt)) {
walktype(n->left, Elv);
addrescapes(n->left);
n->left = nod(OADDR, n->left, N);
n->left->type = ptrto(tt);
- } else if(tt->etype == tptr && eqtype(tt->type, rcvr, 0)) {
+ } else if(tt->etype == tptr && eqtype(tt->type, rcvr)) {
n->left = nod(OIND, n->left, N);
n->left->type = tt->type;
} else {
int
ascompat(Type *dst, Type *src)
{
- if(eqtype(dst, src, 0))
+ if(eqtype(dst, src))
return 1;
if(dst == T || src == T)
if(isslice(dst)
&& isptr[src->etype]
&& isfixedarray(src->type)
- && eqtype(dst->type, src->type->type, 0))
+ && eqtype(dst->type, src->type->type))
return 1;
if(isnilinter(dst) || isnilinter(src))
if(t != nil)
t = t->type;
- if(!eqtype(t, l->type, 0)) {
+ if(!eqtype(t, l->type)) {
l = nod(OCONV, l, N);
l->type = t;
}
convlit(n->right, t->down);
- if(!eqtype(n->right->type, t->down, 0)) {
+ if(!eqtype(n->right->type, t->down)) {
badtype(n->op, n->right->type, t->down);
break;
}
if(isinter(dst)) {
if(isinter(src)) {
- if(eqtype(dst, src, 0))
+ if(eqtype(dst, src))
return I2Isame;
if(!isnilinter(dst))
ifacecheck(dst, src, lineno, explicit);
goto out;
}
- if(eqtype(lt, rt, 0))
+ if(eqtype(lt, rt))
goto out;
et = ifaceas(lt, rt, 0);
}
if(isslice(lt) && isptr[rt->etype] && isfixedarray(rt->type)) {
- if(!eqtype(lt->type->type, rt->type->type->type, 0))
+ if(!eqtype(lt->type->type, rt->type->type->type))
goto bad;
indir(n, arrayop(n, Etop));
goto out;
if(!colasname(l))
goto allnew;
if(l->sym->block == block) {
- if(!eqtype(l->type, t, 0))
+ if(!eqtype(l->type, t))
goto allnew;
nred++;
}