use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode 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.assembler.Code.MethodCode in project es6draft by anba.
the class CodeGenerator method compile.
MethodName compile(SpreadElementMethod node, CodeVisitor mv) {
if (!isCompiled(node)) {
MethodCode method = newMethod(node);
SpreadElementCodeVisitor body = new SpreadElementCodeVisitor(node, method, mv);
body.lineInfo(node);
body.begin();
body.loadArrayObject();
body.loadArrayIndex();
expression(node.getExpression(), body);
body._return();
body.end();
}
return methodDesc(node);
}
use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode 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.assembler.Code.MethodCode in project es6draft by anba.
the class CodeGenerator method compile.
MethodName compile(ExpressionMethod node, CodeVisitor mv) {
if (!isCompiled(node)) {
MethodCode method = newMethod(node);
ExpressionMethodVisitor body = new ExpressionMethodVisitor(node, method, mv);
body.lineInfo(node);
body.begin();
expressionBoxed(node.getExpression(), body);
body._return();
body.end();
}
return methodDesc(node);
}
use of com.github.anba.es6draft.compiler.assembler.Code.MethodCode in project es6draft by anba.
the class CodeGenerator method compile.
MethodName compile(BlockStatement node, List<Declaration> declarations, BlockDeclarationInstantiationGenerator generator) {
MethodCode method = newMethod2(node);
BlockDeclInitVisitor body = new BlockDeclInitVisitor(method);
body.lineInfo(node);
body.begin();
Variable<ExecutionContext> cx = body.getExecutionContext();
Variable<LexicalEnvironment<DeclarativeEnvironmentRecord>> env = body.getLexicalEnvironment();
generator.generateMethod(declarations, cx, env, body);
body._return();
body.end();
return methodDesc(node, method.methodName);
}
Aggregations