Package org.teavm.model

Examples of org.teavm.model.ClassReader


public class JavaScriptResourceInterceptor extends AbstractRendererListener {
    @Override
    public void begin(RenderingContext context, BuildTarget buildTarget) throws IOException {
        boolean hasOneResource = false;
        for (String className : context.getClassSource().getClassNames()) {
            ClassReader cls = context.getClassSource().get(className);
            AnnotationReader annot = cls.getAnnotations().get(JavaScriptResource.class.getName());
            if (annot == null) {
                continue;
            }
            String path = annot.getValue("value").getString();
            String packageName = className.substring(0, className.lastIndexOf('.'));
View Full Code Here


        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

    private void achieveFunctorMethods(DependencyAgent agent, String type, MethodDependency caller) {
        if (caller.isMissing()) {
            return;
        }
        ClassReader cls = agent.getClassSource().get(type);
        if (cls != null) {
            for (MethodReader method : cls.getMethods()) {
                agent.linkMethod(method.getReference(), caller.getStack()).use();
            }
        }
    }
View Full Code Here

        allEnums = agent.createNode();
    }

    @Override
    public void classAchieved(DependencyAgent agent, String className) {
        ClassReader cls = agent.getClassSource().get(className);
        if (cls == null || cls.getParent() == null || !cls.getParent().equals("java.lang.Enum")) {
            return;
        }
        allEnums.propagate(agent.getType(className));
        if (enumConstantsStack != null) {
            MethodReader method = cls.getMethod(new MethodDescriptor("values",
                    ValueType.arrayOf(ValueType.object(cls.getName()))));
            if (method != null) {
                agent.linkMethod(method.getReference(), enumConstantsStack).use();
            }
        }
    }
View Full Code Here

    private boolean isException(ClassReaderSource classSource, String className) {
        while (className != null) {
            if (className.equals("java.lang.Throwable")) {
                return true;
            }
            ClassReader cls = classSource.get(className);
            if (cls == null) {
                return false;
            }
            className = cls.getParent();
        }
        return false;
    }
View Full Code Here

        }
        return cls;
    }

    private ClassHolder findClass(String name) {
        ClassReader cls = innerSource.get(name);
        if (cls != null) {
            return ModelUtils.copyClass(cls);
        }
        return generatedClasses.get(name);
    }
View Full Code Here

    }

    public void addClasses(ListableClassReaderSource classReader) {
        ProgramSourceAggregator sourceAggregator = new ProgramSourceAggregator(sourceFiles);
        for (String className : classReader.getClassNames()) {
            ClassReader cls = classReader.get(className);
            for (MethodReader method : cls.getMethods()) {
                if (method.getProgram() == null) {
                    continue;
                }
                sourceAggregator.addLocationsOfProgram(method.getProgram());
            }
View Full Code Here

        MethodReader method = cls.getMethod(desc);
        if (method != null) {
            return method;
        }
        if (cls.getParent() != null) {
            ClassReader parent = classSource.get(cls.getParent());
            if (parent != null) {
                method = findMethod(parent, desc);
                if (method != null) {
                    return method;
                }
            }
        }
        for (String ifaceName : cls.getInterfaces()) {
            ClassReader iface = classSource.get(ifaceName);
            if (iface != null) {
                method = findMethod(iface, desc);
                if (method != null) {
                    return method;
                }
View Full Code Here

    private boolean isException(ClassReaderSource classSource, String className) {
        while (className != null) {
            if (className.equals("java.lang.Throwable")) {
                return true;
            }
            ClassReader cls = classSource.get(className);
            if (cls == null) {
                return false;
            }
            className = cls.getParent();
        }
        return false;
    }
View Full Code Here

        }
        return known;
    }

    private boolean figureOutIfJavaScriptClass(String className) {
        ClassReader cls = classSource.get(className);
        if (cls == null || !cls.hasModifier(ElementModifier.INTERFACE)) {
            return false;
        }
        for (String iface : cls.getInterfaces()) {
            if (isJavaScriptClass(iface)) {
                return true;
            }
        }
        return false;
View Full Code Here

TOP

Related Classes of org.teavm.model.ClassReader

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.