Search in sources :

Example 1 with ComprehensionQualifier

use of com.github.anba.es6draft.ast.ComprehensionQualifier in project es6draft by anba.

the class ComprehensionGenerator method visit.

/**
     * Runtime Semantics: ComprehensionEvaluation
     */
@Override
public Void visit(Comprehension node, CodeVisitor mv) {
    ArrayList<Node> list = new ArrayList<>(node.getList().size() + 1);
    list.addAll(node.getList());
    list.add(node.getExpression());
    elements = list.iterator();
    // Create variables early so they'll appear next to each other in the local variable map.
    ArrayList<Variable<ScriptIterator<?>>> iters = new ArrayList<>();
    for (ComprehensionQualifier e : node.getList()) {
        if (e instanceof ComprehensionFor || e instanceof LegacyComprehensionFor) {
            Variable<ScriptIterator<?>> iter = mv.newVariable("iter", ScriptIterator.class).uncheckedCast();
            iters.add(iter);
        }
    }
    iterators = iters.iterator();
    // Start generating code.
    elements.next().accept(this, mv);
    return null;
}
Also used : LegacyComprehensionFor(com.github.anba.es6draft.ast.LegacyComprehensionFor) ComprehensionFor(com.github.anba.es6draft.ast.ComprehensionFor) Variable(com.github.anba.es6draft.compiler.assembler.Variable) Node(com.github.anba.es6draft.ast.Node) ComprehensionQualifier(com.github.anba.es6draft.ast.ComprehensionQualifier) ArrayList(java.util.ArrayList) LegacyComprehensionFor(com.github.anba.es6draft.ast.LegacyComprehensionFor) ScriptIterator(com.github.anba.es6draft.runtime.internal.ScriptIterator)

Aggregations

ComprehensionFor (com.github.anba.es6draft.ast.ComprehensionFor)1 ComprehensionQualifier (com.github.anba.es6draft.ast.ComprehensionQualifier)1 LegacyComprehensionFor (com.github.anba.es6draft.ast.LegacyComprehensionFor)1 Node (com.github.anba.es6draft.ast.Node)1 Variable (com.github.anba.es6draft.compiler.assembler.Variable)1 ScriptIterator (com.github.anba.es6draft.runtime.internal.ScriptIterator)1 ArrayList (java.util.ArrayList)1