public Type typeCheck(SymbolTable stable) throws TypeCheckError { final Type tleft = _left.typeCheck(stable); final MethodType ptype = lookupPrimop(stable, "u-", new MethodType(Type.Void, tleft)); if (ptype != null) { final Type arg1 = (Type) ptype.argsType().elementAt(0); if (!arg1.identicalTo(tleft)) { _left = new CastExpr(_left, arg1); } return _type = ptype.resultType(); } throw new TypeCheckError(this); }
final MethodType ptype = (MethodType) primop.elementAt(i); if (ptype.argsCount() != ctype.argsCount()) { continue; final int distance = ctype.distanceTo(ptype); if (distance < minDistance) { minDistance = distance;
public String toSignature() { return toSignature(""); }
public boolean identicalTo(Type other) { boolean result = false; if (other instanceof MethodType) { final MethodType temp = (MethodType) other; if (_resultType.identicalTo(temp._resultType)) { final int len = argsCount(); result = len == temp.argsCount(); for (int i = 0; i < len && result; i++) { final Type arg1 = (Type)_argsType.elementAt(i); final Type arg2 = (Type)temp._argsType.elementAt(i); result = arg1.identicalTo(arg2); } } } return result; }
/** * Compile the function call and treat as an expression * Update true/false-lists. */ public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { Type type = Type.Boolean; if (_chosenMethodType != null) type = _chosenMethodType.resultType(); final InstructionList il = methodGen.getInstructionList(); translate(classGen, methodGen); if ((type instanceof BooleanType) || (type instanceof IntType)) { _falseList.add(il.append(new IFEQ(null))); } }
MethodType I_V = new MethodType(Type.Int, Type.Void); MethodType I_R = new MethodType(Type.Int, Type.Real); MethodType I_S = new MethodType(Type.Int, Type.String); MethodType I_D = new MethodType(Type.Int, Type.NodeSet); MethodType R_I = new MethodType(Type.Real, Type.Int); MethodType R_V = new MethodType(Type.Real, Type.Void); MethodType R_R = new MethodType(Type.Real, Type.Real); MethodType R_D = new MethodType(Type.Real, Type.NodeSet); MethodType R_O = new MethodType(Type.Real, Type.Reference); MethodType I_I = new MethodType(Type.Int, Type.Int); MethodType D_O = new MethodType(Type.NodeSet, Type.Reference); MethodType D_V = new MethodType(Type.NodeSet, Type.Void); MethodType D_S = new MethodType(Type.NodeSet, Type.String); MethodType D_D = new MethodType(Type.NodeSet, Type.NodeSet); MethodType A_V = new MethodType(Type.Node, Type.Void); MethodType S_V = new MethodType(Type.String, Type.Void); MethodType S_S = new MethodType(Type.String, Type.String); MethodType S_A = new MethodType(Type.String, Type.Node); MethodType S_D = new MethodType(Type.String, Type.NodeSet); MethodType S_O = new MethodType(Type.String, Type.Reference); MethodType B_O = new MethodType(Type.Boolean, Type.Reference); MethodType B_V = new MethodType(Type.Boolean, Type.Void); MethodType B_B = new MethodType(Type.Boolean, Type.Boolean); MethodType B_S = new MethodType(Type.Boolean, Type.String); MethodType D_X = new MethodType(Type.NodeSet, Type.Object); MethodType R_RR = new MethodType(Type.Real, Type.Real, Type.Real); MethodType I_II = new MethodType(Type.Int, Type.Int, Type.Int); MethodType B_RR = new MethodType(Type.Boolean, Type.Real, Type.Real); MethodType B_II = new MethodType(Type.Boolean, Type.Int, Type.Int);
public boolean identicalTo(Type other) { boolean result = false; if (other instanceof MethodType) { final MethodType temp = (MethodType) other; if (_resultType.identicalTo(temp._resultType)) { final int len = argsCount(); result = len == temp.argsCount(); for (int i = 0; i < len && result; i++) { final Type arg1 = (Type)_argsType.elementAt(i); final Type arg2 = (Type)temp._argsType.elementAt(i); result = arg1.identicalTo(arg2); } } } return result; }
/** * Compile the function call and treat as an expression * Update true/false-lists. */ public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { Type type = Type.Boolean; if (_chosenMethodType != null) type = _chosenMethodType.resultType(); final InstructionList il = methodGen.getInstructionList(); translate(classGen, methodGen); if ((type instanceof BooleanType) || (type instanceof IntType)) { _falseList.add(il.append(new IFEQ(null))); } }
MethodType I_V = new MethodType(Type.Int, Type.Void); MethodType I_R = new MethodType(Type.Int, Type.Real); MethodType I_S = new MethodType(Type.Int, Type.String); MethodType I_D = new MethodType(Type.Int, Type.NodeSet); MethodType R_I = new MethodType(Type.Real, Type.Int); MethodType R_V = new MethodType(Type.Real, Type.Void); MethodType R_R = new MethodType(Type.Real, Type.Real); MethodType R_D = new MethodType(Type.Real, Type.NodeSet); MethodType R_O = new MethodType(Type.Real, Type.Reference); MethodType I_I = new MethodType(Type.Int, Type.Int); MethodType D_O = new MethodType(Type.NodeSet, Type.Reference); MethodType D_V = new MethodType(Type.NodeSet, Type.Void); MethodType D_S = new MethodType(Type.NodeSet, Type.String); MethodType D_D = new MethodType(Type.NodeSet, Type.NodeSet); MethodType A_V = new MethodType(Type.Node, Type.Void); MethodType S_V = new MethodType(Type.String, Type.Void); MethodType S_S = new MethodType(Type.String, Type.String); MethodType S_A = new MethodType(Type.String, Type.Node); MethodType S_D = new MethodType(Type.String, Type.NodeSet); MethodType S_O = new MethodType(Type.String, Type.Reference); MethodType B_O = new MethodType(Type.Boolean, Type.Reference); MethodType B_V = new MethodType(Type.Boolean, Type.Void); MethodType B_B = new MethodType(Type.Boolean, Type.Boolean); MethodType B_S = new MethodType(Type.Boolean, Type.String); MethodType D_X = new MethodType(Type.NodeSet, Type.Object); MethodType R_RR = new MethodType(Type.Real, Type.Real, Type.Real); MethodType I_II = new MethodType(Type.Int, Type.Int, Type.Int); MethodType B_RR = new MethodType(Type.Boolean, Type.Real, Type.Real); MethodType B_II = new MethodType(Type.Boolean, Type.Int, Type.Int);
public Type typeCheck(SymbolTable stable) throws TypeCheckError { final Type tleft = _left.typeCheck(stable); final Type tright = _right.typeCheck(stable); final MethodType ptype = lookupPrimop(stable, Ops[_op], new MethodType(Type.Void, tleft, tright)); if (ptype != null) { final Type arg1 = (Type) ptype.argsType().elementAt(0); if (!arg1.identicalTo(tleft)) { _left = new CastExpr(_left, arg1); } final Type arg2 = (Type) ptype.argsType().elementAt(1); if (!arg2.identicalTo(tright)) { _right = new CastExpr(_right, arg1); } return _type = ptype.resultType(); } throw new TypeCheckError(this); }
final MethodType ptype = (MethodType) primop.elementAt(i); if (ptype.argsCount() != ctype.argsCount()) { continue; final int distance = ctype.distanceTo(ptype); if (distance < minDistance) { minDistance = distance;
if (_chosenMethodType.toSignature(args). equals("()Ljava/lang/String;")) { args = "I"+DOM_INTF_SIG; _chosenMethodType.toSignature(args)); il.append(new INVOKESTATIC(index));
public boolean identicalTo(Type other) { boolean result = false; if (other instanceof MethodType) { final MethodType temp = (MethodType) other; if (_resultType.identicalTo(temp._resultType)) { final int len = argsCount(); result = len == temp.argsCount(); for (int i = 0; i < len && result; i++) { final Type arg1 = (Type)_argsType.elementAt(i); final Type arg2 = (Type)temp._argsType.elementAt(i); result = arg1.identicalTo(arg2); } } } return result; }
/** * Compile the function call and treat as an expression * Update true/false-lists. */ public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { Type type = Type.Boolean; if (_chosenMethodType != null) type = _chosenMethodType.resultType(); final InstructionList il = methodGen.getInstructionList(); translate(classGen, methodGen); if ((type instanceof BooleanType) || (type instanceof IntType)) { _falseList.add(il.append(new IFEQ(null))); } }
MethodType I_V = new MethodType(Type.Int, Type.Void); MethodType I_R = new MethodType(Type.Int, Type.Real); MethodType I_S = new MethodType(Type.Int, Type.String); MethodType I_D = new MethodType(Type.Int, Type.NodeSet); MethodType R_I = new MethodType(Type.Real, Type.Int); MethodType R_V = new MethodType(Type.Real, Type.Void); MethodType R_R = new MethodType(Type.Real, Type.Real); MethodType R_D = new MethodType(Type.Real, Type.NodeSet); MethodType R_O = new MethodType(Type.Real, Type.Reference); MethodType I_I = new MethodType(Type.Int, Type.Int); MethodType D_O = new MethodType(Type.NodeSet, Type.Reference); MethodType D_V = new MethodType(Type.NodeSet, Type.Void); MethodType D_S = new MethodType(Type.NodeSet, Type.String); MethodType D_D = new MethodType(Type.NodeSet, Type.NodeSet); MethodType A_V = new MethodType(Type.Node, Type.Void); MethodType S_V = new MethodType(Type.String, Type.Void); MethodType S_S = new MethodType(Type.String, Type.String); MethodType S_A = new MethodType(Type.String, Type.Node); MethodType S_D = new MethodType(Type.String, Type.NodeSet); MethodType S_O = new MethodType(Type.String, Type.Reference); MethodType B_O = new MethodType(Type.Boolean, Type.Reference); MethodType B_V = new MethodType(Type.Boolean, Type.Void); MethodType B_B = new MethodType(Type.Boolean, Type.Boolean); MethodType B_S = new MethodType(Type.Boolean, Type.String); MethodType D_X = new MethodType(Type.NodeSet, Type.Object); MethodType R_RR = new MethodType(Type.Real, Type.Real, Type.Real); MethodType I_II = new MethodType(Type.Int, Type.Int, Type.Int); MethodType B_RR = new MethodType(Type.Boolean, Type.Real, Type.Real); MethodType B_II = new MethodType(Type.Boolean, Type.Int, Type.Int);
/** * Type-check this expression, and possibly child expressions. */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Get the left and right operand types Type tleft = _left.typeCheck(stable); Type tright = _right.typeCheck(stable); // Check if the operator supports the two operand types MethodType wantType = new MethodType(Type.Void, tleft, tright); MethodType haveType = lookupPrimop(stable, Ops[_op], wantType); // Yes, the operation is supported if (haveType != null) { // Check if left-hand side operand must be type casted Type arg1 = (Type)haveType.argsType().elementAt(0); if (!arg1.identicalTo(tleft)) _left = new CastExpr(_left, arg1); // Check if right-hand side operand must be type casted Type arg2 = (Type) haveType.argsType().elementAt(1); if (!arg2.identicalTo(tright)) _right = new CastExpr(_right, arg1); // Return the result type for the operator we will use return _type = haveType.resultType(); } throw new TypeCheckError(this); }
final MethodType ptype = (MethodType) primop.elementAt(i); if (ptype.argsCount() != ctype.argsCount()) { continue; final int distance = ctype.distanceTo(ptype); if (distance < minDistance) { minDistance = distance;
public String toSignature() { return toSignature(""); }
public boolean identicalTo(Type other) { boolean result = false; if (other instanceof MethodType) { final MethodType temp = (MethodType) other; if (_resultType.identicalTo(temp._resultType)) { final int len = argsCount(); result = len == temp.argsCount(); for (int i = 0; i < len && result; i++) { final Type arg1 = (Type)_argsType.elementAt(i); final Type arg2 = (Type)temp._argsType.elementAt(i); result = arg1.identicalTo(arg2); } } } return result; }
/** * Compile the function call and treat as an expression * Update true/false-lists. */ public void translateDesynthesized(ClassGenerator classGen, MethodGenerator methodGen) { Type type = Type.Boolean; if (_chosenMethodType != null) type = _chosenMethodType.resultType(); final InstructionList il = methodGen.getInstructionList(); translate(classGen, methodGen); if ((type instanceof BooleanType) || (type instanceof IntType)) { _falseList.add(il.append(new IFEQ(null))); } }