public void outABinopExpr(ABinopExpr node) { Value right = (Value) mProductions.removeLast(); BinopExpr expr = (BinopExpr) mProductions.removeLast(); Value left = (Value) mProductions.removeLast(); expr.setOp1(left); expr.setOp2(right); mProductions.addLast(expr); }
be.setOp1(uc.defineType(t)); } else if (op1 instanceof UntypedConstant && op2 instanceof UntypedConstant) { if (op1 instanceof UntypedIntOrFloatConstant && op2 instanceof UntypedIntOrFloatConstant) { UntypedIntOrFloatConstant uc1 = (UntypedIntOrFloatConstant) op1; UntypedIntOrFloatConstant uc2 = (UntypedIntOrFloatConstant) op2; be.setOp1(uc1.toIntConstant()); // to int or float, it does not matter be.setOp2(uc2.toIntConstant()); } else if (op1 instanceof UntypedLongOrDoubleConstant && op2 instanceof UntypedLongOrDoubleConstant) { UntypedLongOrDoubleConstant uc1 = (UntypedLongOrDoubleConstant) op1; UntypedLongOrDoubleConstant uc2 = (UntypedLongOrDoubleConstant) op2; be.setOp1(uc1.toLongConstant()); // to long or double, it does not matter be.setOp2(uc2.toLongConstant()); } else { if (op1 instanceof UntypedConstant) { UntypedConstant uc = (UntypedConstant) op1; be.setOp1(uc.defineType(op2.getType())); } else if (op2 instanceof UntypedConstant) { UntypedConstant uc = (UntypedConstant) op2;
private void handleBinopExpr(BinopExpr be, Stmt stmt, Type tlhs) { Value opl = be.getOp1(), opr = be.getOp2(); Type tl = AugEvalFunction.eval_(this.tg, opl, stmt, this.jb), tr = AugEvalFunction.eval_(this.tg, opr, stmt, this.jb); if (be instanceof AddExpr || be instanceof SubExpr || be instanceof MulExpr || be instanceof DivExpr || be instanceof RemExpr || be instanceof GeExpr || be instanceof GtExpr || be instanceof LeExpr || be instanceof LtExpr || be instanceof ShlExpr || be instanceof ShrExpr || be instanceof UshrExpr) { if (tlhs instanceof IntegerType) { be.setOp1(this.uv.visit(opl, IntType.v(), stmt)); be.setOp2(this.uv.visit(opr, IntType.v(), stmt)); } } else if (be instanceof CmpExpr || be instanceof CmpgExpr || be instanceof CmplExpr) { // No checks in the original assigner } else if (be instanceof AndExpr || be instanceof OrExpr || be instanceof XorExpr) { be.setOp1(this.uv.visit(opl, tlhs, stmt)); be.setOp2(this.uv.visit(opr, tlhs, stmt)); } else if (be instanceof EqExpr || be instanceof NeExpr) { if (tl instanceof BooleanType && tr instanceof BooleanType) { } else if (tl instanceof Integer1Type || tr instanceof Integer1Type) { } else if (tl instanceof IntegerType) { be.setOp1(this.uv.visit(opl, IntType.v(), stmt)); be.setOp2(this.uv.visit(opr, IntType.v(), stmt)); } } }
if (fix) { if (!lop.hasAncestor_1(ClassHierarchy.v().INT)) { expr.setOp1(insertCast(expr.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt));
if (!lop.hasAncestor_1(ClassHierarchy.v().INT)) { if (fix) { be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), IntType.v(), stmt)); } else { error("Type Error(7)"); if (fix) { if (!lop.hasAncestor_1(ClassHierarchy.v().INT)) { be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt)); lca = rop; if (!lop.hasAncestor_1(ClassHierarchy.v().INT)) { if (fix) { be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), IntType.v(), stmt)); } else { error("Type Error(9)"); if (!lop.hasAncestor_1(ClassHierarchy.v().INT)) { if (fix) { be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), ByteType.v(), stmt)); lop = ClassHierarchy.v().BYTE; } else { if (fix) { if (!lop.hasAncestor_1(ClassHierarchy.v().INT)) { be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt));
expr.setOp1(insertCast(expr.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt));
expr.setOp1(insertCast(expr.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt));
be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), IntType.v(), stmt)); be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt)); lca = rop; be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), IntType.v(), stmt)); be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), ByteType.v(), stmt)); lop = ClassHierarchy.v().BYTE; be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt));
be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), IntType.v(), stmt)); be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt)); lca = rop; be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), IntType.v(), stmt)); be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), ByteType.v(), stmt)); lop = ClassHierarchy.v().BYTE; be.setOp1(insertCast(be.getOp1(), getTypeForCast(lop), getTypeForCast(rop), stmt));