use of com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState in project es6draft by anba.
the class CodeGenerator method compile.
Entry<MethodName, LabelState> compile(DoExpression node, CodeVisitor mv) {
if (!isCompiled(node)) {
if (!isEnabled(Compiler.Option.NoCompletion)) {
CompletionValueVisitor.performCompletion(node);
}
MethodCode method = newMethod(mv.getTopLevelNode(), node);
DoExpressionCodeVisitor body = new DoExpressionCodeVisitor(node, method, mv);
body.lineInfo(node);
// force line-number entry
body.nop();
body.begin();
GeneratorState generatorState = null;
if (node.hasYieldOrAwait()) {
generatorState = body.generatorPrologue();
}
body.labelPrologue();
Completion result = statement(node.getStatement(), body);
if (!result.isAbrupt()) {
// fall-thru, return `0`.
body.iconst(0);
body._return();
}
LabelState labelState = body.labelEpilogue(result);
if (generatorState != null) {
body.generatorEpilogue(generatorState);
}
body.end();
doExpressionCompletions.put(node, labelState);
}
return new SimpleImmutableEntry<>(methodDesc(node), doExpressionCompletions.get(node));
}
use of com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState in project es6draft by anba.
the class CodeGenerator method generatorComprehensionBody.
private boolean generatorComprehensionBody(GeneratorComprehension node) {
MethodCode method = newMethod(node, FunctionName.Code);
GeneratorCodeVisitor body = new GeneratorCodeVisitor(method, node);
body.lineInfo(node);
body.begin();
GeneratorState generatorState = body.generatorPrologue();
body.enterFunction(node);
EvaluateGeneratorComprehension(this, node, body);
body.exitFunction();
body.loadUndefined();
body._return();
body.generatorEpilogue(generatorState);
body.end();
return body.hasTailCalls();
}
use of com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState in project es6draft by anba.
the class CodeGenerator method compile.
Entry<MethodName, LabelState> compile(StatementListMethod node, CodeVisitor mv) {
if (!isCompiled(node)) {
MethodCode method = newMethod(mv.getTopLevelNode(), node);
StatementListMethodCodeVisitor body = new StatementListMethodCodeVisitor(node, method, mv);
body.lineInfo(node);
// force line-number entry
body.nop();
body.begin();
GeneratorState generatorState = null;
if (node.hasResumePoint()) {
generatorState = body.generatorPrologue();
}
body.labelPrologue();
Completion result = statements(node.getStatements(), body);
if (!result.isAbrupt()) {
// fall-thru, return `0`.
body.iconst(0);
body._return();
}
LabelState labelState = body.labelEpilogue(result);
if (generatorState != null) {
body.generatorEpilogue(generatorState);
}
body.end();
statementCompletions.put(node, labelState);
}
return new SimpleImmutableEntry<>(methodDesc(node), statementCompletions.get(node));
}
use of com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState in project es6draft by anba.
the class CodeGenerator method conciseAsyncFunctionBody.
private boolean conciseAsyncFunctionBody(AsyncArrowFunction node) {
MethodCode method = newMethod(node, FunctionName.Code);
GeneratorCodeVisitor body = new GeneratorCodeVisitor(method, node);
body.lineInfo(node);
body.begin();
GeneratorState generatorState = body.generatorPrologue();
body.enterFunction(node);
expressionBoxed(node.getExpression(), body);
body.exitFunction();
body._return();
body.generatorEpilogue(generatorState);
body.end();
return body.hasTailCalls();
}
use of com.github.anba.es6draft.compiler.CodeVisitor.GeneratorState in project es6draft by anba.
the class CodeGenerator method generatorBody.
private boolean generatorBody(FunctionNode node) {
MethodCode method = newMethod(node, FunctionName.Code);
GeneratorCodeVisitor body = new GeneratorCodeVisitor(method, node);
body.lineInfo(node);
body.begin();
GeneratorState generatorState = body.generatorPrologue();
body.enterFunction(node);
Completion result = statements(node.getStatements(), body);
body.exitFunction();
if (!result.isAbrupt()) {
// fall-thru, return undefined from function
body.loadUndefined();
body._return();
}
body.generatorEpilogue(generatorState);
body.end();
return body.hasTailCalls();
}
Aggregations