com.sun.tools.javac.tree.JCTree.JCClassDecl Java Examples

The following examples show how to use com.sun.tools.javac.tree.JCTree.JCClassDecl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: lua-for-android   Author: qtiuto   File: TypeEnter.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
protected void doCompleteEnvs(List<Env<AttrContext>> envs) {
    for (Env<AttrContext> env : envs) {
        JCClassDecl tree = (JCClassDecl)env.tree;

        queue.add(env);

        JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
        DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
        try {
            dependencies.push(env.enclClass.sym, phaseName);
            runPhase(env);
        } catch (CompletionFailure ex) {
            chk.completionError(tree.pos(), ex);
        } finally {
            dependencies.pop();
            deferredLintHandler.setPos(prevLintPos);
            log.useSource(prev);
        }
    }
}
 
Example #2
public void visitClassDef(JCClassDecl node) {
    super.visitClassDef(node);
    // remove generated constructor that may have been added during attribution:
    List<JCTree> beforeConstructor = List.nil();
    List<JCTree> defs = node.defs;
    while (defs.nonEmpty() && !defs.head.hasTag(Tag.METHODDEF)) {
        beforeConstructor = beforeConstructor.prepend(defs.head);
        defs = defs.tail;
    }
    if (defs.nonEmpty() &&
        (((JCMethodDecl) defs.head).mods.flags & Flags.GENERATEDCONSTR) != 0) {
        defs = defs.tail;
        while (beforeConstructor.nonEmpty()) {
            defs = defs.prepend(beforeConstructor.head);
            beforeConstructor = beforeConstructor.tail;
        }
        node.defs = defs;
    }
    if (node.sym != null) {
        node.sym.completer = new ImplicitCompleter(topLevel);
    }
    node.sym = null;
}
 
Example #3
Source Project: lua-for-android   Author: qtiuto   File: JavaCompiler.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Emit plain Java source for a class.
 *  @param env    The attribution environment of the outermost class
 *                containing this class.
 *  @param cdef   The class definition to be printed.
 */
JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
    JavaFileObject outFile
       = fileManager.getJavaFileForOutput(CLASS_OUTPUT,
                                           cdef.sym.flatname.toString(),
                                           JavaFileObject.Kind.SOURCE,
                                           null);
    if (inputFiles.contains(outFile)) {
        log.error(cdef.pos(), Errors.SourceCantOverwriteInputFile(outFile));
        return null;
    } else {
        try (BufferedWriter out = new BufferedWriter(outFile.openWriter())) {
            new Pretty(out, true).printUnit(env.toplevel, cdef);
            if (verbose)
                log.printVerbose("wrote.file", outFile);
        }
        return outFile;
    }
}
 
Example #4
Source Project: lua-for-android   Author: qtiuto   File: JavacTaskImpl.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void handleFlowResults(Queue<Env<AttrContext>> queue, ListBuffer<Element> elems) {
    for (Env<AttrContext> env: queue) {
        switch (env.tree.getTag()) {
            case CLASSDEF:
                JCClassDecl cdef = (JCClassDecl) env.tree;
                if (cdef.sym != null)
                    elems.append(cdef.sym);
                break;
            case MODULEDEF:
                JCModuleDecl mod = (JCModuleDecl) env.tree;
                if (mod.sym != null)
                    elems.append(mod.sym);
                break;
            case PACKAGEDEF:
                JCCompilationUnit unit = env.toplevel;
                if (unit.packge != null)
                    elems.append(unit.packge);
                break;
        }
    }
    genList.addAll(queue);
}
 
Example #5
Source Project: lua-for-android   Author: qtiuto   File: Check.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Check for cycles in the graph of annotation elements.
 */
void checkNonCyclicElements(JCClassDecl tree) {
    if ((tree.sym.flags_field & ANNOTATION) == 0) return;
    Assert.check((tree.sym.flags_field & LOCKED) == 0);
    try {
        tree.sym.flags_field |= LOCKED;
        for (JCTree def : tree.defs) {
            if (!def.hasTag(METHODDEF)) continue;
            JCMethodDecl meth = (JCMethodDecl)def;
            checkAnnotationResType(meth.pos(), meth.restype.type);
        }
    } finally {
        tree.sym.flags_field &= ~LOCKED;
        tree.sym.flags_field |= ACYCLIC_ANN;
    }
}
 
Example #6
Source Project: lua-for-android   Author: qtiuto   File: Check.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Check for cycles in the graph of constructors calling other
 *  constructors.
 */
void checkCyclicConstructors(JCClassDecl tree) {
    Map<Symbol,Symbol> callMap = new HashMap<>();

    // enter each constructor this-call into the map
    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
        JCMethodInvocation app = TreeInfo.firstConstructorCall(l.head);
        if (app == null) continue;
        JCMethodDecl meth = (JCMethodDecl) l.head;
        if (TreeInfo.name(app.meth) == names._this) {
            callMap.put(meth.sym, TreeInfo.symbol(app.meth));
        } else {
            meth.sym.flags_field |= ACYCLIC;
        }
    }

    // Check for cycles in the map
    Symbol[] ctors = new Symbol[0];
    ctors = callMap.keySet().toArray(ctors);
    for (Symbol caller : ctors) {
        checkCyclicConstructor(tree, caller, callMap);
    }
}
 
Example #7
Source Project: lua-for-android   Author: qtiuto   File: Check.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void checkFunctionalInterface(JCClassDecl tree, ClassSymbol cs) {
    Compound functionalType = cs.attribute(syms.functionalInterfaceType.tsym);

    if (functionalType != null) {
        try {
            types.findDescriptorSymbol((TypeSymbol)cs);
        } catch (Types.FunctionDescriptorLookupError ex) {
            DiagnosticPosition pos = tree.pos();
            for (JCAnnotation a : tree.getModifiers().annotations) {
                if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) {
                    pos = a.pos();
                    break;
                }
            }
            log.error(pos, Errors.BadFunctionalIntfAnno1(ex.getDiagnostic()));
        }
    }
}
 
Example #8
Source Project: lua-for-android   Author: qtiuto   File: Lower.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Map a class symbol to its definition.
 *  @param c    The class symbol of which we want to determine the definition.
 */
JCClassDecl classDef(ClassSymbol c) {
    // First lookup the class in the classdefs table.
    JCClassDecl def = classdefs.get(c);
    if (def == null && outermostMemberDef != null) {
        // If this fails, traverse outermost member definition, entering all
        // local classes into classdefs, and try again.
        classMap.scan(outermostMemberDef);
        def = classdefs.get(c);
    }
    if (def == null) {
        // If this fails, traverse outermost class definition, entering all
        // local classes into classdefs, and try again.
        classMap.scan(outermostClassDef);
        def = classdefs.get(c);
    }
    return def;
}
 
Example #9
Source Project: lua-for-android   Author: qtiuto   File: Lower.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Add all required access methods for a private symbol to enclosing class.
 *  @param sym       The symbol.
 */
void makeAccessible(Symbol sym) {
    JCClassDecl cdef = classDef(sym.owner.enclClass());
    if (cdef == null) Assert.error("class def not found: " + sym + " in " + sym.owner);
    if (sym.name == names.init) {
        cdef.defs = cdef.defs.prepend(
            accessConstructorDef(cdef.pos, sym, accessConstrs.get(sym)));
    } else {
        MethodSymbol[] accessors = accessSyms.get(sym);
        for (int i = 0; i < AccessCode.numberOfAccessCodes; i++) {
            if (accessors[i] != null)
                cdef.defs = cdef.defs.prepend(
                    accessDef(cdef.pos, sym, accessors[i], i));
        }
    }
}
 
Example #10
Source Project: TencentKona-8   Author: Tencent   File: GenStubs.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * methods: remove method bodies, make methods native
 */
@Override
public void visitClassDef(JCClassDecl tree) {
    long prevClassMods = currClassMods;
    currClassMods = tree.mods.flags;
    try {
        super.visitClassDef(tree);;
    } finally {
        currClassMods = prevClassMods;
    }
}
 
Example #11
Source Project: TencentKona-8   Author: Tencent   File: RootDocImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize classes information. Those classes are input from
 * command line.
 *
 * @param env the compilation environment
 * @param classes a list of ClassDeclaration
 */
private void setClasses(DocEnv env, List<JCClassDecl> classes) {
    ListBuffer<ClassDocImpl> result = new ListBuffer<ClassDocImpl>();
    for (JCClassDecl def : classes) {
        //### Do we want modifier check here?
        if (env.shouldDocument(def.sym)) {
            ClassDocImpl cd = env.getClassDoc(def.sym);
            if (cd != null) {
                cd.isIncluded = true;
                result.append(cd);
            } //else System.out.println(" (classdoc is null)");//DEBUG
        } //else System.out.println(" (env.shouldDocument() returned false)");//DEBUG
    }
    cmdLineClasses = result.toList();
}
 
Example #12
Source Project: TencentKona-8   Author: Tencent   File: JavadocTool.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * From a list of top level trees, return the list of contained class definitions
 */
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
    ListBuffer<JCClassDecl> result = new ListBuffer<JCClassDecl>();
    for (JCCompilationUnit t : trees) {
        for (JCTree def : t.defs) {
            if (def.hasTag(JCTree.Tag.CLASSDEF))
                result.append((JCClassDecl)def);
        }
    }
    return result.toList();
}
 
Example #13
Source Project: TencentKona-8   Author: Tencent   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Separate type annotations from declaration annotations and
 * determine the correct positions for type annotations.
 * This version only visits types in signatures and should be
 * called from MemberEnter.
 * The method takes the Annotate object as parameter and
 * adds an Annotate.Worker to the correct Annotate queue for
 * later processing.
 */
public void organizeTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
    annotate.afterRepeated( new Worker() {
        @Override
        public void run() {
            JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);

            try {
                new TypeAnnotationPositions(true).scan(tree);
            } finally {
                log.useSource(oldSource);
            }
        }
    } );
}
 
Example #14
Source Project: TencentKona-8   Author: Tencent   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void validateTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
    annotate.validate(new Worker() { //validate annotations
        @Override
        public void run() {
            JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);

            try {
                attr.validateTypeAnnotations(tree, true);
            } finally {
                log.useSource(oldSource);
            }
        }
    } );
}
 
Example #15
Source Project: TencentKona-8   Author: Tencent   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitClassDef(JCClassDecl tree) {
    if (isInClass)
        return;
    isInClass = true;

    if (sigOnly) {
        scan(tree.mods);
        scan(tree.typarams);
        scan(tree.extending);
        scan(tree.implementing);
    }
    scan(tree.defs);
}
 
Example #16
Source Project: TencentKona-8   Author: Tencent   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitNewClass(JCNewClass tree) {
    if (tree.def != null &&
            !tree.def.mods.annotations.isEmpty()) {
        JCClassDecl classdecl = tree.def;
        TypeAnnotationPosition pos = new TypeAnnotationPosition();
        pos.type = TargetType.CLASS_EXTENDS;
        pos.pos = tree.pos;
        if (classdecl.extending == tree.clazz) {
            pos.type_index = -1;
        } else if (classdecl.implementing.contains(tree.clazz)) {
            pos.type_index = classdecl.implementing.indexOf(tree.clazz);
        } else {
            // In contrast to CLASS elsewhere, typarams cannot occur here.
            Assert.error("Could not determine position of tree " + tree);
        }
        Type before = classdecl.sym.type;
        separateAnnotationsKinds(classdecl, tree.clazz.type, classdecl.sym, pos);
        copyNewClassAnnotationsToOwner(tree);
        // classdecl.sym.type now contains an annotated type, which
        // is not what we want there.
        // TODO: should we put this type somewhere in the superclass/interface?
        classdecl.sym.type = before;
    }

    scan(tree.encl);
    scan(tree.typeargs);
    scan(tree.clazz);
    scan(tree.args);

    // The class body will already be scanned.
    // scan(tree.def);
}
 
Example #17
Source Project: jdk8u60   Author: chenghanpeng   File: GenStubs.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * methods: remove method bodies, make methods native
 */
@Override
public void visitClassDef(JCClassDecl tree) {
    long prevClassMods = currClassMods;
    currClassMods = tree.mods.flags;
    try {
        super.visitClassDef(tree);;
    } finally {
        currClassMods = prevClassMods;
    }
}
 
Example #18
Source Project: lua-for-android   Author: qtiuto   File: LambdaToMethod.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Visit a class.
 * Maintain the translatedMethodList across nested classes.
 * Append the translatedMethodList to the class after it is translated.
 * @param tree
 */
@Override
public void visitClassDef(JCClassDecl tree) {
    if (tree.sym.owner.kind == PCK) {
        //analyze class
        tree = analyzer.analyzeAndPreprocessClass(tree);
    }
    KlassInfo prevKlassInfo = kInfo;
    try {
        kInfo = new KlassInfo(tree);
        super.visitClassDef(tree);
        if (!kInfo.deserializeCases.isEmpty()) {
            int prevPos = make.pos;
            try {
                make.at(tree);
                kInfo.addMethod(makeDeserializeMethod(tree.sym));
            } finally {
                make.at(prevPos);
            }
        }
        //add all translated instance methods here
        List<JCTree> newMethods = kInfo.appendedMethodList.toList();
        tree.defs = tree.defs.appendList(newMethods);
        for (JCTree lambda : newMethods) {
            tree.sym.members().enter(((JCMethodDecl)lambda).sym);
        }
        result = tree;
    } finally {
        kInfo = prevKlassInfo;
    }
}
 
Example #19
Source Project: jdk8u60   Author: chenghanpeng   File: RootDocImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize classes information. Those classes are input from
 * command line.
 *
 * @param env the compilation environment
 * @param classes a list of ClassDeclaration
 */
private void setClasses(DocEnv env, List<JCClassDecl> classes) {
    ListBuffer<ClassDocImpl> result = new ListBuffer<ClassDocImpl>();
    for (JCClassDecl def : classes) {
        //### Do we want modifier check here?
        if (env.shouldDocument(def.sym)) {
            ClassDocImpl cd = env.getClassDoc(def.sym);
            if (cd != null) {
                cd.isIncluded = true;
                result.append(cd);
            } //else System.out.println(" (classdoc is null)");//DEBUG
        } //else System.out.println(" (env.shouldDocument() returned false)");//DEBUG
    }
    cmdLineClasses = result.toList();
}
 
Example #20
Source Project: jdk8u60   Author: chenghanpeng   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Separate type annotations from declaration annotations and
 * determine the correct positions for type annotations.
 * This version only visits types in signatures and should be
 * called from MemberEnter.
 * The method takes the Annotate object as parameter and
 * adds an Annotate.Worker to the correct Annotate queue for
 * later processing.
 */
public void organizeTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
    annotate.afterRepeated( new Worker() {
        @Override
        public void run() {
            JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);

            try {
                new TypeAnnotationPositions(true).scan(tree);
            } finally {
                log.useSource(oldSource);
            }
        }
    } );
}
 
Example #21
Source Project: jdk8u60   Author: chenghanpeng   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void validateTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
    annotate.validate(new Worker() { //validate annotations
        @Override
        public void run() {
            JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);

            try {
                attr.validateTypeAnnotations(tree, true);
            } finally {
                log.useSource(oldSource);
            }
        }
    } );
}
 
Example #22
Source Project: lua-for-android   Author: qtiuto   File: LambdaToMethod.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("fallthrough")
private Symbol owner(boolean skipLambda) {
    List<Frame> frameStack2 = frameStack;
    while (frameStack2.nonEmpty()) {
        switch (frameStack2.head.tree.getTag()) {
            case VARDEF:
                if (((JCVariableDecl)frameStack2.head.tree).sym.isLocal()) {
                    frameStack2 = frameStack2.tail;
                    break;
                }
                JCClassDecl cdecl = (JCClassDecl)frameStack2.tail.head.tree;
                return initSym(cdecl.sym,
                        ((JCVariableDecl)frameStack2.head.tree).sym.flags() & STATIC);
            case BLOCK:
                JCClassDecl cdecl2 = (JCClassDecl)frameStack2.tail.head.tree;
                return initSym(cdecl2.sym,
                        ((JCBlock)frameStack2.head.tree).flags & STATIC);
            case CLASSDEF:
                return ((JCClassDecl)frameStack2.head.tree).sym;
            case METHODDEF:
                return ((JCMethodDecl)frameStack2.head.tree).sym;
            case LAMBDA:
                if (!skipLambda)
                    return ((LambdaTranslationContext)contextMap
                            .get(frameStack2.head.tree)).translatedSym;
            default:
                frameStack2 = frameStack2.tail;
        }
    }
    Assert.error();
    return null;
}
 
Example #23
Source Project: jdk8u60   Author: chenghanpeng   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void visitNewClass(JCNewClass tree) {
    if (tree.def != null &&
            !tree.def.mods.annotations.isEmpty()) {
        JCClassDecl classdecl = tree.def;
        TypeAnnotationPosition pos = new TypeAnnotationPosition();
        pos.type = TargetType.CLASS_EXTENDS;
        pos.pos = tree.pos;
        if (classdecl.extending == tree.clazz) {
            pos.type_index = -1;
        } else if (classdecl.implementing.contains(tree.clazz)) {
            pos.type_index = classdecl.implementing.indexOf(tree.clazz);
        } else {
            // In contrast to CLASS elsewhere, typarams cannot occur here.
            Assert.error("Could not determine position of tree " + tree);
        }
        Type before = classdecl.sym.type;
        separateAnnotationsKinds(classdecl, tree.clazz.type, classdecl.sym, pos);
        copyNewClassAnnotationsToOwner(tree);
        // classdecl.sym.type now contains an annotated type, which
        // is not what we want there.
        // TODO: should we put this type somewhere in the superclass/interface?
        classdecl.sym.type = before;
    }

    scan(tree.encl);
    scan(tree.typeargs);
    scan(tree.clazz);
    scan(tree.args);

    // The class body will already be scanned.
    // scan(tree.def);
}
 
Example #24
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: GenStubs.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * methods: remove method bodies, make methods native
 */
@Override
public void visitClassDef(JCClassDecl tree) {
    long prevClassMods = currClassMods;
    currClassMods = tree.mods.flags;
    try {
        super.visitClassDef(tree);;
    } finally {
        currClassMods = prevClassMods;
    }
}
 
Example #25
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: RootDocImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize classes information. Those classes are input from
 * command line.
 *
 * @param env the compilation environment
 * @param classes a list of ClassDeclaration
 */
private void setClasses(DocEnv env, List<JCClassDecl> classes) {
    ListBuffer<ClassDocImpl> result = new ListBuffer<ClassDocImpl>();
    for (JCClassDecl def : classes) {
        //### Do we want modifier check here?
        if (env.shouldDocument(def.sym)) {
            ClassDocImpl cd = env.getClassDoc(def.sym);
            if (cd != null) {
                cd.isIncluded = true;
                result.append(cd);
            } //else System.out.println(" (classdoc is null)");//DEBUG
        } //else System.out.println(" (env.shouldDocument() returned false)");//DEBUG
    }
    cmdLineClasses = result.toList();
}
 
Example #26
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: JavadocTool.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * From a list of top level trees, return the list of contained class definitions
 */
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
    ListBuffer<JCClassDecl> result = new ListBuffer<JCClassDecl>();
    for (JCCompilationUnit t : trees) {
        for (JCTree def : t.defs) {
            if (def.hasTag(JCTree.Tag.CLASSDEF))
                result.append((JCClassDecl)def);
        }
    }
    return result.toList();
}
 
Example #27
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: TypeAnnotations.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Separate type annotations from declaration annotations and
 * determine the correct positions for type annotations.
 * This version only visits types in signatures and should be
 * called from MemberEnter.
 * The method takes the Annotate object as parameter and
 * adds an Annotate.Worker to the correct Annotate queue for
 * later processing.
 */
public void organizeTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
    annotate.afterRepeated( new Worker() {
        @Override
        public void run() {
            JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);

            try {
                new TypeAnnotationPositions(true).scan(tree);
            } finally {
                log.useSource(oldSource);
            }
        }
    } );
}
 
Example #28
Source Project: lua-for-android   Author: qtiuto   File: LambdaToMethod.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
boolean currentlyInClass(Symbol csym) {
    for (Frame frame : frameStack) {
        if (frame.tree.hasTag(JCTree.Tag.CLASSDEF)) {
            JCClassDecl cdef = (JCClassDecl) frame.tree;
            if (cdef.sym == csym) {
                return true;
            }
        }
    }
    return false;
}
 
Example #29
private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
    List<ClassSymbol> classes = List.nil();
    for (JCCompilationUnit unit : units) {
        for (JCTree node : unit.defs) {
            if (node.hasTag(JCTree.Tag.CLASSDEF)) {
                ClassSymbol sym = ((JCClassDecl) node).sym;
                Assert.checkNonNull(sym);
                classes = classes.prepend(sym);
            }
        }
    }
    return classes.reverse();
}
 
Example #30
Source Project: lua-for-android   Author: qtiuto   File: JavaCompiler.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Prepare attributed parse trees, in conjunction with their attribution contexts,
 * for source or code generation.
 * If any errors occur, an empty list will be returned.
 * @return a list containing the classes to be generated
 */
public Queue<Pair<Env<AttrContext>, JCClassDecl>> desugar(Queue<Env<AttrContext>> envs) {
    ListBuffer<Pair<Env<AttrContext>, JCClassDecl>> results = new ListBuffer<>();
    for (Env<AttrContext> env: envs)
        desugar(env, results);
    return stopIfError(CompileState.FLOW, results);
}