Package org.teavm.model

Examples of org.teavm.model.MethodReference


        context.writeExpr(context.getArgument(0));
        writer.append(".constructor)");
    }

    private void achieveGetClass(DependencyAgent agent, MethodDependency method) {
        MethodReference initMethod = new MethodReference(Class.class, "createNew", Class.class);
        agent.linkMethod(initMethod, method.getStack()).use();
        method.getResult().propagate(agent.getType("java.lang.Class"));
    }
View Full Code Here


    private void generateGetLength(GeneratorContext context, SourceWriter writer) throws IOException {
        String array = context.getParameterName(1);
        writer.append("if (" + array + " === null || " + array + ".constructor.$meta.item === undefined) {")
                .softNewLine().indent();
        String clsName = "java.lang.IllegalArgumentException";
        MethodReference cons = new MethodReference(clsName, new MethodDescriptor("<init>", ValueType.VOID));
        writer.append("$rt_throw(").appendClass(clsName).append(".").appendMethod(cons).append("());").softNewLine();
        writer.outdent().append("}").softNewLine();
        writer.append("return " + array + ".data.length;").softNewLine();
    }
View Full Code Here

    private void achieveGetLength(final DependencyAgent agent, final MethodDependency method) {
        method.getVariable(1).addConsumer(new DependencyConsumer() {
            @Override public void consume(DependencyAgentType type) {
                if (!type.getName().startsWith("[")) {
                    MethodReference cons = new MethodReference(IllegalArgumentException.class, "<init>", void.class);
                    agent.linkMethod(cons, method.getStack()).use();
                }
            }
        });
    }
View Full Code Here

        String array = context.getParameterName(1);
        writer.append("var item = " + array + ".data[" + context.getParameterName(2) + "];").softNewLine();
        writer.append("var type = " + array + ".constructor.$meta.item;").softNewLine();
        for (int i = 0; i < primitives.length; ++i) {
            String wrapper = "java.lang." + primitiveWrappers[i];
            MethodReference methodRef = new MethodReference(wrapper, "valueOf",
                    primitiveTypes[i], ValueType.object(wrapper));
            ClassReader cls = context.getClassSource().get(methodRef.getClassName());
            if (cls == null || cls.getMethod(methodRef.getDescriptor()) == null) {
                continue;
            }
            writer.append("if (type === $rt_" + primitives[i].toLowerCase() + "cls()) {").indent().softNewLine();
            writer.append("return ").appendMethodBody(methodRef).append("(item);").softNewLine();
            writer.outdent().append("} else ");
View Full Code Here

                if (type.getName().startsWith("[")) {
                    String typeName = type.getName().substring(1);
                    for (int i = 0; i < primitiveTypes.length; ++i) {
                        if (primitiveTypes[i].toString().equals(typeName)) {
                            String wrapper = "java.lang." + primitiveWrappers[i];
                            MethodReference methodRef = new MethodReference(wrapper, "valueOf",
                                    primitiveTypes[i], ValueType.object(wrapper));
                            agent.linkMethod(methodRef, method.getStack()).use();
                            method.getResult().propagate(agent.getType("java.lang." + primitiveWrappers[i]));
                        }
                    }
View Full Code Here

        return append(naming.getNameFor(method));
    }

    public SourceWriter appendMethod(String className, String name, ValueType... params)
            throws NamingException, IOException {
        return append(naming.getNameFor(new MethodReference(className, new MethodDescriptor(name, params))));
    }
View Full Code Here

        return append(naming.getFullNameFor(method));
    }

    public SourceWriter appendMethodBody(String className, String name, ValueType... params)
            throws NamingException, IOException {
        return append(naming.getFullNameFor(new MethodReference(className, new MethodDescriptor(name, params))));
    }
View Full Code Here

    public MethodReference getExactMethod(int index) {
        long item = exactMethods[index];
        int classIndex = (int)(item >>> 32);
        int methodIndex = (int)item;
        return new MethodReference(classNames[classIndex], MethodDescriptor.parse(methods[methodIndex]));
    }
View Full Code Here

        }
        String method = componentByKey(methodMapping, methods, generatedLocation);
        if (method == null) {
            return null;
        }
        return new MethodReference(className, MethodDescriptor.parse(method));
    }
View Full Code Here

        RecordArrayBuilder builder = new RecordArrayBuilder(0, 1);
        for (int i = 0; i < exactMethods.length; ++i) {
            builder.add();
        }
        GeneratedLocation prevLocation = new GeneratedLocation(0, 0);
        MethodReference prevMethod = null;
        int prevMethodId = -1;
        for (ExactMethodIterator iter = iterateOverExactMethods(); !iter.isEndReached(); iter.next()) {
            int id = iter.getExactMethodId();
            if (prevMethod != null) {
                int lineIndex = Math.max(0, indexByKey(lineMapping, prevLocation));
View Full Code Here

TOP

Related Classes of org.teavm.model.MethodReference

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.