public TypeSpec Verify() { var lhsType = Left.Verify(); var rhsType = Right.Verify(); if (lhsType != rhsType) { throw new ArgumentException(lhsType.ToString()); } if ((Relop.Contains("<") || Relop.Contains(">")) && lhsType.ArrayCount != 0) { throw new ArgumentException(); } Next?.Verify(); return(new TypeSpec { ArrayCount = 0, Base = new Primitive { Type = "bool" } }); }
public Type visit(Relop n) { // based on op type, perform corresponding checks Type t1 = n.e1.accept(this); Type t2 = n.e2.accept(this); if ((n.op == Relop.LT) || (n.op == Relop.LE) ||(n.op == Relop.GT) ||(n.op == Relop.GE)) { if (compatible(t1, intType) && compatible(t2, intType)) { return boolType; } } else if ((n.op == Relop.EQ) || (n.op == Relop.NE)) { if (compatible(t1, t2, false)) { return boolType; } } throw new TypeException(" Incorrect operand types in Relop: "+ t1.toString()+ n.opName(n.op).trim() + t2.toString()); }