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; }
.dup() .ifZeroGoto(equal) .retInt()
.append(generatorContext.generate(first, Optional.empty())) .append(ifWasNullPopAndGoto(scope, notMatch, void.class)) .dup(first.getType().getJavaType()) .putVariable(firstValue);
.dup() .ifZeroGoto(equal) .retInt()
@Override public BytecodeNode getBytecode(MethodGenerationContext generationContext) { BytecodeBlock block = new BytecodeBlock() .newObject(getType()) .dup(); for (BytecodeExpression parameter : parameters) { block.append(parameter); } return block.invokeConstructor(getType(), parameterTypes); }
@Override public BytecodeNode getBytecode(MethodGenerationContext generationContext) { BytecodeBlock bytecodeBlock; if (elementType.isPrimitive()) { bytecodeBlock = new BytecodeBlock() .append(length) .append(TypeInstruction.newPrimitiveArray(elementType)); } else { bytecodeBlock = new BytecodeBlock() .append(length) .append(TypeInstruction.newObjectArray(elementType)); } if (elements != null) { for (int i = 0; i < elements.size(); i++) { BytecodeExpression element = elements.get(i); bytecodeBlock .dup() .append(constantInt(i)) .append(element) .append(getArrayOpCode(elementType).getStore()); } } return bytecodeBlock; }
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; }
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; }
.dup() .ifZeroGoto(equal) .retInt()
.dup() .ifZeroGoto(equal) .retInt()
.append(generatorContext.generate(first)) .append(ifWasNullPopAndGoto(scope, notMatch, void.class)) .dup(first.getType().getJavaType()) .putVariable(firstValue);
.append(generatorContext.generate(first)) .append(ifWasNullPopAndGoto(scope, notMatch, void.class)) .dup(first.getType().getJavaType()) .putVariable(firstValue);
.getVariable(typeVariable) .newObject(BlockBuilderStatus.class) .dup() .invokeConstructor(BlockBuilderStatus.class) .push(1)
.dup() .ifZeroGoto(equal) .retInt()
.dup() .ifZeroGoto(equal) .retInt()