elseValue = new BytecodeBlock().visitLabel(nullValue).append(elseValue);
public static BytecodeBlock unboxPrimitiveIfNecessary(Scope scope, Class<?> boxedType) { BytecodeBlock block = new BytecodeBlock(); LabelNode end = new LabelNode("end"); Class<?> unboxedType = Primitives.unwrap(boxedType); Variable wasNull = scope.getVariable("wasNull"); if (unboxedType.isPrimitive()) { LabelNode notNull = new LabelNode("notNull"); block.dup(boxedType) .ifNotNullGoto(notNull) .append(wasNull.set(constantTrue())) .comment("swap boxed null with unboxed default") .pop(boxedType) .pushJavaDefault(unboxedType) .gotoLabel(end) .visitLabel(notNull) .append(unboxPrimitive(unboxedType)); } else { block.dup(boxedType) .ifNotNullGoto(end) .append(wasNull.set(constantTrue())); } block.visitLabel(end); return block; }
block.visitLabel(end);
.gotoLabel(end) .comment("left was true; push left null flag on the stack (false)") .visitLabel(leftIsTrue) .push(false); .gotoLabel(end) .comment("right was true; store left null flag (on stack) in wasNull variable, and push true") .visitLabel(rightIsTrue) .putVariable(wasNull) .push(true); .visitLabel(end);
.gotoLabel(end) .comment("left was false; push left null flag on the stack (false)") .visitLabel(leftIsFalse) .push(false)); .gotoLabel(end) .comment("right was false; store left null flag (on stack) in wasNull variable, and push false") .visitLabel(rightIsTrue) .putVariable(wasNull) .push(false); .visitLabel(end);
.ifZeroGoto(equal) .retInt() .visitLabel(equal) .pop(int.class);
.putVariable(value) .append(switchBlock) .visitLabel(defaultLabel) .append(defaultCaseBlock); .visitLabel(match) .append(generatorContext.wasNull().set(constantFalse())) .push(true) .visitLabel(noMatch) .push(false) .gotoLabel(end); block.append(noMatchBlock); block.visitLabel(end);
.push(false) .retBoolean() .visitLabel(checkNextField);
.push(false) .retBoolean() .visitLabel(checkNextField);
.push(false) .retBoolean() .visitLabel(checkNextField);
.visitLabel(elseLabel); .visitLabel(testLabel) .append(equalsCall);
.pop(boolean.class) .push(false) .visitLabel(end) .retBoolean();
body.visitLabel(end) .retBoolean();
.ifZeroGoto(equal) .retInt() .visitLabel(equal) .pop(int.class);
.visitLabel(done) .append(newInstance(CursorProcessorOutput.class, completedPositionsVariable, finishedVariable) .ret());
@Override public void accept(MethodVisitor visitor, MethodGenerationContext generationContext) { checkState(!condition.isEmpty(), "WhileLoop does not have a condition set"); BytecodeBlock block = new BytecodeBlock() .visitLabel(continueLabel) .append(condition) .ifZeroGoto(endLabel) .append(body) .gotoLabel(continueLabel) .visitLabel(endLabel); block.accept(visitor, generationContext); }
@Override public BytecodeNode getBytecode(MethodGenerationContext generationContext) { LabelNode trueLabel = new LabelNode("true"); LabelNode endLabel = new LabelNode("end"); return new BytecodeBlock() .append(value) .ifTrueGoto(trueLabel) .push(true) .gotoLabel(endLabel) .visitLabel(trueLabel) .push(false) .visitLabel(endLabel); }
@Override public BytecodeNode getBytecode(MethodGenerationContext generationContext) { LabelNode falseLabel = new LabelNode("false"); LabelNode endLabel = new LabelNode("end"); return new BytecodeBlock() .append(condition) .ifFalseGoto(falseLabel) .append(ifTrue) .gotoLabel(endLabel) .visitLabel(falseLabel) .append(ifFalse) .visitLabel(endLabel); }
@Override public BytecodeNode getBytecode(MethodGenerationContext generationContext) { LabelNode trueLabel = new LabelNode("true"); LabelNode endLabel = new LabelNode("end"); return new BytecodeBlock() .append(left) .ifTrueGoto(trueLabel) .append(right) .ifTrueGoto(trueLabel) .push(false) .gotoLabel(endLabel) .visitLabel(trueLabel) .push(true) .visitLabel(endLabel); }