@Override public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments, Optional<Variable> outputBlockVariable) { Preconditions.checkArgument(arguments.size() == 1); RowExpression argument = arguments.get(0); if (argument.getType().equals(UNKNOWN)) { return loadBoolean(true); } BytecodeNode value = generatorContext.generate(argument, Optional.empty()); // evaluate the expression, pop the produced value, and load the null flag Variable wasNull = generatorContext.wasNull(); BytecodeBlock block = new BytecodeBlock() .comment("is null") .append(value) .pop(argument.getType().getJavaType()) .append(wasNull); // clear the null flag block.append(wasNull.set(constantFalse())); outputBlockVariable.ifPresent(output -> block.append(generateWrite(generatorContext, returnType, output))); return block; } }
block.append(loadBoolean((Boolean) value));
public BytecodeBlock push(boolean value) { nodes.add(loadBoolean(value)); return this; }
public BytecodeBlock putVariable(Variable variable, boolean value) { nodes.add(loadBoolean(value)); putVariable(variable); return this; }
public static BytecodeExpression constantFalse() { return new ConstantBytecodeExpression(boolean.class, loadBoolean(false)); }
public static BytecodeExpression constantTrue() { return new ConstantBytecodeExpression(boolean.class, loadBoolean(true)); }
public static BytecodeExpression constantBoolean(boolean value) { return new ConstantBytecodeExpression(boolean.class, loadBoolean(value)); }
@Override public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments) { Preconditions.checkArgument(arguments.size() == 1); RowExpression argument = arguments.get(0); if (argument.getType().equals(UNKNOWN)) { return loadBoolean(true); } BytecodeNode value = generatorContext.generate(argument); // evaluate the expression, pop the produced value, and load the null flag Variable wasNull = generatorContext.wasNull(); BytecodeBlock block = new BytecodeBlock() .comment("is null") .append(value) .pop(argument.getType().getJavaType()) .append(wasNull); // clear the null flag block.append(wasNull.set(constantFalse())); return block; } }
@Override public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments) { Preconditions.checkArgument(arguments.size() == 1); RowExpression argument = arguments.get(0); if (argument.getType().equals(UNKNOWN)) { return loadBoolean(true); } BytecodeNode value = generatorContext.generate(argument); // evaluate the expression, pop the produced value, and load the null flag Variable wasNull = generatorContext.wasNull(); BytecodeBlock block = new BytecodeBlock() .comment("is null") .append(value) .pop(argument.getType().getJavaType()) .append(wasNull); // clear the null flag block.append(wasNull.set(constantFalse())); return block; } }
return block.append(loadBoolean((Boolean) value));
return block.append(loadBoolean((Boolean) value));