private static BytecodeExpression generateCheckedAdd(BytecodeExpression x, BytecodeExpression y) { return invokeStatic(ConcatFunction.class, "checkedAdd", int.class, x, y); }
private static BytecodeExpression generateRequireNotNull(Variable variable) { return invokeStatic(Objects.class, "requireNonNull", Object.class, variable.cast(Object.class), constantString(variable.getName() + " is null")) .cast(variable.getType()); }
"map", methodDefinition.getBody(), invokeStatic(Maps.class, "newHashMapWithExpectedSize", HashMap.class, constantInt(javaTypes.size()))); for (int i = 0; i < javaTypes.size(); i++) { body.append(map.invoke("put", Object.class, constantString(names.get(i)).cast(Object.class), parameterList.get(i).cast(Object.class)));
invokeStatic(ColumnarRow.class, "toColumnarRow", ColumnarRow.class, scope.getVariable("block"))));
body.append(result.set(invokeStatic(Slices.class, "allocate", Slice.class, length)));
.comment("lookupSwitch(<stackValue>))") .append(new IfStatement() .condition(invokeStatic(InCodeGenerator.class, "isInteger", boolean.class, value)) .ifFalse(new BytecodeBlock() .gotoLabel(defaultLabel)))
.body(selectedPositions.setElement(position, thisVariable.invoke("filter", boolean.class, session, page, position)))); body.append(invokeStatic( PageFilter.class, "positionsArrayToSelectedPositions",
.getBody() .comment("int leftBlockIndex = decodeSliceIndex(leftPageAddress)") .append(leftBlockIndex.set(invokeStatic(SyntheticAddress.class, "decodeSliceIndex", int.class, leftPageAddress))); .getBody() .comment("int leftBlockPosition = decodePosition(leftPageAddress)") .append(leftBlockPosition.set(invokeStatic(SyntheticAddress.class, "decodePosition", int.class, leftPageAddress))); .getBody() .comment("int rightBlockIndex = decodeSliceIndex(rightPageAddress)") .append(rightBlockIndex.set(invokeStatic(SyntheticAddress.class, "decodeSliceIndex", int.class, rightPageAddress))); .getBody() .comment("int rightBlockPosition = decodePosition(rightPageAddress)") .append(rightBlockPosition.set(invokeStatic(SyntheticAddress.class, "decodePosition", int.class, rightPageAddress)));
PrestoException.class, getStatic(INVALID_FUNCTION_ARGUMENT.getDeclaringClass(), "INVALID_FUNCTION_ARGUMENT").cast(ErrorCodeSupplier.class), invokeStatic( String.class, "format",
private static BytecodeExpression generateCheckedAdd(BytecodeExpression x, BytecodeExpression y) { return invokeStatic(ConcatFunction.class, "checkedAdd", int.class, x, y); }
private static BytecodeExpression generateCheckedAdd(BytecodeExpression x, BytecodeExpression y) { return invokeStatic(ConcatFunction.class, "checkedAdd", int.class, x, y); }
public static BytecodeExpression invokeStatic(Method method, BytecodeExpression... parameters) { return invokeStatic(method, ImmutableList.copyOf(requireNonNull(parameters, "parameters is null"))); }
public static BytecodeExpression invokeStatic( Class<?> methodTargetType, String methodName, Class<?> returnType, Iterable<? extends BytecodeExpression> parameters) { return invokeStatic(type(methodTargetType), methodName, type(returnType), parameters); }
public static BytecodeExpression invokeStatic( ParameterizedType methodTargetType, String methodName, ParameterizedType returnType, Iterable<ParameterizedType> parameterTypes, Iterable<? extends BytecodeExpression> parameters) { return new InvokeBytecodeExpression( null, methodTargetType, methodName, returnType, parameterTypes, parameters); }
public static BytecodeExpression invokeStatic(Method method, Iterable<? extends BytecodeExpression> parameters) { return invokeStatic( type(method.getDeclaringClass()), method.getName(), type(method.getReturnType()), stream(method.getParameterTypes()) .map(ParameterizedType::type) .collect(toImmutableList()), parameters); }
@Test public void testGetField() throws Exception { intCount = 0; assertBytecodeExpression(invokeStatic(getClass(), "incrementAndGetIntCount", int.class).pop(), null, getClass().getSimpleName() + ".incrementAndGetIntCount();"); assertEquals(intCount, 1); longCount = 0; assertBytecodeExpression(invokeStatic(getClass(), "incrementAndGetLongCount", long.class).pop(), null, getClass().getSimpleName() + ".incrementAndGetLongCount();"); assertEquals(longCount, 1); }
public static BytecodeExpression invokeStatic(MethodDefinition method, BytecodeExpression... parameters) { return invokeStatic( method.getDeclaringClass().getType(), method.getName(), method.getReturnType(), method.getParameterTypes(), ImmutableList.copyOf(parameters)); }
private static BytecodeExpression generateRequireNotNull(Variable variable) { return invokeStatic(Objects.class, "requireNonNull", Object.class, variable.cast(Object.class), constantString(variable.getName() + " is null")) .cast(variable.getType()); }
private static BytecodeExpression generateRequireNotNull(Variable variable) { return invokeStatic(Objects.class, "requireNonNull", Object.class, variable.cast(Object.class), constantString(variable.getName() + " is null")) .cast(variable.getType()); }
@Test public void testInvokeStaticMethod() throws Exception { assertBytecodeExpression(invokeStatic(System.class, "lineSeparator", String.class), System.lineSeparator(), "System.lineSeparator()"); assertBytecodeExpression(invokeStatic(Math.class, "cos", double.class, constantDouble(33.3)), Math.cos(33.3), "Math.cos(33.3)"); assertBytecodeExpression( invokeStatic(Math.class, "cos", double.class, ImmutableList.of(double.class), constantDouble(33.3)), Math.cos(33.3), "Math.cos(33.3)"); assertBytecodeExpression( invokeStatic(type(Math.class), "cos", type(double.class), ImmutableList.of(type(double.class)), ImmutableList.of(constantDouble(33.3))), Math.cos(33.3), "Math.cos(33.3)"); } }