@Override public void visit(BinaryExpression binaryExpression) { sb.append("("); binaryExpression.getLeftExpression().accept(this); sb.append(" "+binaryExpression.getOperator().getRepresentation()+" "); binaryExpression.getRightExpression().accept(this); sb.append(")"); }
public VEB handleExpression(Expression e) { return factory.newValueExpressionBuilder(expressionHandler, new BinaryExpression(expression, GETARRAYATINDEX, e)); } });
@Override public String toString() { return "["+leftExpression + " " + getOperator().getRepresentation() + " " + rightExpression+"]"; } }
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(); }
public T handleExpression(Expression e) { return expressionHandler.handleExpression(new BinaryExpression(expression, operator, e)); } });
@Override public void visit(BinaryExpression binaryExpression) { methodByteCodeContext.incIndent(binaryExpression.getOperator().getRepresentation()); switch (binaryExpression.getOperator()) { case PLUS: methodByteCodeContext.incIndent("left +"); binaryExpression.getLeftExpression().accept(this); methodByteCodeContext.decIndent(); methodByteCodeContext.incIndent("+ right"); binaryExpression.getRightExpression().accept(this); methodByteCodeContext.decIndent(); lastExpressionType = ExistingType.INT; case AND: methodByteCodeContext.incIndent("left &&"); binaryExpression.getLeftExpression().accept(this); methodByteCodeContext.decIndent(); new LiteralExpression(false).accept(this); 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); case GETARRAYATINDEX: methodByteCodeContext.incIndent("array"); binaryExpression.getLeftExpression().accept(this); Type arrayType = lastExpressionType;