public static InvocationExpr constructObject(MethodReference method, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.CONSTRUCTOR); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
public static InvocationExpr invokeStatic(MethodReference method, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.STATIC); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
public static InvocationExpr invoke(MethodReference method, Expr target, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.DYNAMIC); expr.getArguments().add(target); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
public static InvocationExpr invokeSpecial(MethodReference method, Expr target, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.SPECIAL); expr.getArguments().add(target); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
private InvocationExpr parseInvocationExpr(InvocationType invocationType, DataInput input) throws IOException { InvocationExpr expr = new InvocationExpr(); expr.setType(invocationType); String className = symbolTable.at(input.readInt()); MethodDescriptor method = methodDescriptorCache.computeIfAbsent(symbolTable.at(input.readInt()), MethodDescriptor::parse); MethodReference methodRef = methodReferenceCache .computeIfAbsent(className, k -> new HashMap<>()) .computeIfAbsent(method, k -> new MethodReference(className, k)); expr.setMethod(methodRef); int argCount = input.readShort(); for (int i = 0; i < argCount; ++i) { expr.getArguments().add(readExpr(input)); } return expr; }
private void generateAllocStack(Expr sizeExpr) { if (stackVariable != null) { throw new IllegalStateException("Call to ShadowStack.allocStack must be done only once"); } stackVariable = getTemporary(WasmType.INT32); stackVariable.setName("__stack__"); InvocationExpr expr = new InvocationExpr(); expr.setType(InvocationType.SPECIAL); expr.setMethod(new MethodReference(WasmRuntime.class, "allocStack", int.class, Address.class)); expr.getArguments().add(sizeExpr); expr.acceptVisitor(this); result = new WasmSetLocal(stackVariable, result); }
@Override public WasmExpression apply(InvocationExpr invocation, WasmIntrinsicManager manager) { InvocationExpr expr = new InvocationExpr(); MethodReference method = new MethodReference(WasmRuntime.class.getName(), invocation.getMethod().getDescriptor()); expr.setMethod(method); expr.setType(InvocationType.SPECIAL); expr.getArguments().addAll(invocation.getArguments()); return manager.generate(expr); } }
public static InvocationExpr constructObject(MethodReference method, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.CONSTRUCTOR); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
public static InvocationExpr invokeStatic(MethodReference method, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.STATIC); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
public static InvocationExpr invokeSpecial(MethodReference method, Expr target, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.SPECIAL); expr.getArguments().add(target); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
public static InvocationExpr invoke(MethodReference method, Expr target, Expr[] arguments) { InvocationExpr expr = new InvocationExpr(); expr.setMethod(method); expr.setType(InvocationType.DYNAMIC); expr.getArguments().add(target); expr.getArguments().addAll(Arrays.asList(arguments)); return expr; }
private InvocationExpr parseInvocationExpr(InvocationType invocationType, DataInput input) throws IOException { InvocationExpr expr = new InvocationExpr(); expr.setType(invocationType); String className = symbolTable.at(input.readInt()); MethodDescriptor method = MethodDescriptor.parse(symbolTable.at(input.readInt())); expr.setMethod(new MethodReference(className, method)); int argCount = input.readShort(); for (int i = 0; i < argCount; ++i) { expr.getArguments().add(readExpr(input)); } return expr; }
private void generateAllocStack(Expr sizeExpr) { if (stackVariable != null) { throw new IllegalStateException("Call to ShadowStack.allocStack must be done only once"); } stackVariable = getTemporary(WasmType.INT32); stackVariable.setName("__stack__"); InvocationExpr expr = new InvocationExpr(); expr.setType(InvocationType.SPECIAL); expr.setMethod(new MethodReference(WasmRuntime.class, "allocStack", int.class, Address.class)); expr.getArguments().add(sizeExpr); expr.acceptVisitor(this); result = new WasmSetLocal(stackVariable, result); }
@Override public WasmExpression apply(InvocationExpr invocation, WasmIntrinsicManager manager) { InvocationExpr expr = new InvocationExpr(); MethodReference method = new MethodReference(WasmRuntime.class.getName(), invocation.getMethod().getDescriptor()); expr.setMethod(method); expr.setType(InvocationType.SPECIAL); expr.getArguments().addAll(invocation.getArguments()); return manager.generate(expr); } }