use of org.neo4j.codegen.Expression in project neo4j by neo4j.
the class MethodSourceWriter method newArray.
@Override
public void newArray(TypeReference type, Expression... constants) {
append("new ").append(type.fullName()).append("[]{");
String sep = "";
for (Expression constant : constants) {
append(sep);
constant.accept(this);
sep = ", ";
}
append("}");
}
use of org.neo4j.codegen.Expression in project neo4j by neo4j.
the class MethodSourceWriter method boolOp.
private void boolOp(Expression[] expressions, String op) {
String sep = "";
for (Expression expression : expressions) {
append(sep);
expression.accept(this);
sep = op;
}
}
use of org.neo4j.codegen.Expression in project neo4j by neo4j.
the class ByteCodeExpressionVisitor method and.
@Override
public void and(Expression... expressions) {
assert expressions.length == 2 : "only supports and(lhs, rhs)";
Expression lhs = expressions[0], rhs = expressions[1];
/*
* something like:
*
* LOAD lhs
* IF FALSE GOTO 0
* LOAD rhs
* IF FALSE GOTO 0
* LOAD TRUE
* GOTO 1
* 0:
* LOAD FALSE
* 1:
* ...continue doing stuff
*/
lhs.accept(this);
Label l0 = new Label();
methodVisitor.visitJumpInsn(IFEQ, l0);
rhs.accept(this);
methodVisitor.visitJumpInsn(IFEQ, l0);
methodVisitor.visitInsn(ICONST_1);
Label l1 = new Label();
methodVisitor.visitJumpInsn(GOTO, l1);
methodVisitor.visitLabel(l0);
methodVisitor.visitInsn(ICONST_0);
methodVisitor.visitLabel(l1);
}
use of org.neo4j.codegen.Expression in project neo4j by neo4j.
the class ByteCodeExpressionVisitor method or.
@Override
public void or(Expression... expressions) {
assert expressions.length == 2 : "only supports or(lhs, rhs)";
Expression lhs = expressions[0], rhs = expressions[1];
/*
* something like:
*
* LOAD lhs
* IF TRUE GOTO 0
* LOAD rhs
* IF FALSE GOTO 1
*
* 0:
* LOAD TRUE
* GOTO 2
* 1:
* LOAD FALSE
* 2:
* ...continue doing stuff
*/
lhs.accept(this);
Label l0 = new Label();
methodVisitor.visitJumpInsn(IFNE, l0);
rhs.accept(this);
Label l1 = new Label();
methodVisitor.visitJumpInsn(IFEQ, l1);
methodVisitor.visitLabel(l0);
methodVisitor.visitInsn(ICONST_1);
Label l2 = new Label();
methodVisitor.visitJumpInsn(GOTO, l2);
methodVisitor.visitLabel(l1);
methodVisitor.visitInsn(ICONST_0);
methodVisitor.visitLabel(l2);
}
use of org.neo4j.codegen.Expression in project neo4j by neo4j.
the class ClassByteCodeWriter method done.
@Override
public void done() {
if (!staticFields.isEmpty()) {
MethodVisitor methodVisitor = classVisitor.visitMethod(ACC_STATIC, "<clinit>", "()V", null, null);
ByteCodeExpressionVisitor expressionVisitor = new ByteCodeExpressionVisitor(methodVisitor);
methodVisitor.visitCode();
for (Map.Entry<FieldReference, Expression> entry : staticFields.entrySet()) {
FieldReference field = entry.getKey();
Expression value = entry.getValue();
value.accept(expressionVisitor);
methodVisitor.visitFieldInsn(PUTSTATIC, byteCodeName(field.owner()), field.name(), typeName(field.type()));
}
methodVisitor.visitInsn(RETURN);
methodVisitor.visitMaxs(0, 0);
methodVisitor.visitEnd();
}
classVisitor.visitEnd();
}
Aggregations