@Override public void visit(BinaryExpression binaryExpression) { sb.append("("); binaryExpression.getLeftExpression().accept(this); sb.append(" "+binaryExpression.getOperator().getRepresentation()+" "); binaryExpression.getRightExpression().accept(this); sb.append(")"); }
public void visit(BinaryExpression binaryExpression) { methodByteCodeContext.incIndent("if left"); ASMMethodGenerator.this.visit(binaryExpression.getLeftExpression()); methodByteCodeContext.decIndent(); methodByteCodeContext.incIndent("if right"); ASMMethodGenerator.this.visit(binaryExpression.getRightExpression()); methodByteCodeContext.decIndent(); methodByteCodeContext.incIndent(binaryExpression.getOperator().getRepresentation()); // TODO: combine expression ! and = etc switch (binaryExpression.getOperator()) { case EQUALS: // TODO handle types generateThenElse(IF_ICMPNE, ifStatement.getElseStatements(), ifStatement.getThenStatements()); break; case GREATER_THAN: generateThenElse(IF_ICMPGT, ifStatement.getThenStatements(), ifStatement.getElseStatements()); break; default: throw new UnsupportedOperationException("op: "+binaryExpression.getOperator()); } methodByteCodeContext.decIndent(); }
methodByteCodeContext.decIndent(); methodByteCodeContext.incIndent("+ right"); binaryExpression.getRightExpression().accept(this); methodByteCodeContext.decIndent(); lastExpressionType = ExistingType.INT; methodByteCodeContext.addInstruction(new JumpInsnNode(IF_ICMPEQ, falseLabel), "AND: IF left is false => false"); methodByteCodeContext.incIndent("&& right"); binaryExpression.getRightExpression().accept(this); methodByteCodeContext.decIndent(); new LiteralExpression(false).accept(this); methodByteCodeContext.decIndent(); methodByteCodeContext.incIndent("["); binaryExpression.getRightExpression().accept(this); methodByteCodeContext.decIndent(); lastExpressionType = arrayType.unNestArray();