Package org.teavm.model.instructions

Examples of org.teavm.model.instructions.InvokeInstruction


            Variable var = program.createVariable();
            ConstructInstruction construct = new ConstructInstruction();
            construct.setReceiver(var);
            construct.setType("com.sun.tools.javac.api.JavacTool");
            block.getInstructions().add(construct);
            InvokeInstruction init = new InvokeInstruction();
            init.setInstance(var);
            init.setType(InvocationType.SPECIAL);
            init.setMethod(new MethodReference("com.sun.tools.javac.api.JavacTool", "<init>", ValueType.VOID));
            block.getInstructions().add(init);
            ExitInstruction exit = new ExitInstruction();
            exit.setValueToReturn(var);
            block.getInstructions().add(exit);
            method.setProgram(program);
View Full Code Here


            BasicBlock block = program.basicBlockAt(i);
            for (Instruction insn : block.getInstructions()) {
                if (!(insn instanceof InvokeInstruction)) {
                    continue;
                }
                InvokeInstruction invoke = (InvokeInstruction)insn;
                if (invoke.getType() != InvocationType.VIRTUAL) {
                    continue;
                }
                ValueDependencyInfo var = methodDep.getVariable(invoke.getInstance().getIndex());
                Set<MethodReference> implementations = getImplementations(var.getTypes(),
                        invoke.getMethod());
                if (implementations.size() == 1) {
                    invoke.setType(InvocationType.SPECIAL);
                    invoke.setMethod(implementations.iterator().next());
                }
            }
        }
    }
View Full Code Here

        Program program = method.getProgram();
        for (int i = 0; i < program.basicBlockCount(); ++i) {
            BasicBlock block = program.basicBlockAt(i);
            for (Instruction insn : block.getInstructions()) {
                if (insn instanceof InvokeInstruction) {
                    InvokeInstruction invoke = (InvokeInstruction)insn;
                    MethodDependencyInfo linkedMethod = dependency.getMethod(invoke.getMethod());
                    if (linkedMethod != null) {
                        invoke.setMethod(linkedMethod.getReference());
                    }
                } else if (insn instanceof GetFieldInstruction) {
                    GetFieldInstruction getField = (GetFieldInstruction)insn;
                    FieldDependencyInfo linkedField = dependency.getField(getField.getField());
                    if (linkedField != null) {
View Full Code Here

    private void transformBlock(BasicBlock block) {
        for (int i = 0; i < block.getInstructions().size(); ++i) {
            Instruction insn = block.getInstructions().get(i);
            if (insn instanceof InvokeInstruction) {
                InvokeInstruction invoke = (InvokeInstruction)insn;
                if (invoke.getType() != InvocationType.VIRTUAL) {
                    continue;
                }
                NullCheckInstruction nullCheck = new NullCheckInstruction();
                nullCheck.setValue(invoke.getInstance());
                Variable var = block.getProgram().createVariable();
                nullCheck.setReceiver(var);
                invoke.setInstance(var);
                block.getInstructions().add(i++, nullCheck);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.teavm.model.instructions.InvokeInstruction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.