use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class ExpressionGenerator method visit.
/**
* 12.2.7.2 Runtime Semantics: Evaluation
*/
@Override
public ValType visit(GeneratorComprehension node, CodeVisitor mv) {
MethodName method = codegen.compile(node);
/* steps 1-8 */
mv.invoke(method);
mv.loadExecutionContext();
if (node.getComprehension() instanceof LegacyComprehension) {
mv.invoke(Methods.ScriptRuntime_EvaluateLegacyGeneratorComprehension);
} else if (node.isConstructor()) {
mv.invoke(Methods.ScriptRuntime_EvaluateConstructorGeneratorComprehension);
} else {
mv.invoke(Methods.ScriptRuntime_EvaluateGeneratorComprehension);
}
/* step 9 */
return ValType.Object;
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class ExpressionGenerator method visit.
@Override
public ValType visit(AsyncArrowFunction node, CodeVisitor mv) {
MethodName method = codegen.compile(node);
/* steps 1-4 */
mv.invoke(method);
mv.loadExecutionContext();
mv.invoke(Methods.ScriptRuntime_EvaluateAsyncArrowFunction);
/* step 5 */
return ValType.Object;
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class StatementGenerator method visit.
@Override
public Completion visit(StatementListMethod node, CodeVisitor mv) {
Entry<MethodName, LabelState> entry = codegen.compile(node, mv);
MethodName method = entry.getKey();
LabelState labelState = entry.getValue();
boolean hasCompletion = labelState.hasReturn() || (mv.hasCompletion() && node.hasCompletionValue());
boolean hasResume = node.hasResumePoint();
boolean hasTarget = hasResume || labelState.hasTargetInstruction();
mv.enterVariableScope();
Value<Object[]> completion;
if (hasCompletion) {
Variable<Object[]> completionVar = mv.newVariable("completion", Object[].class);
mv.anewarray(1, Types.Object);
mv.store(completionVar);
if (mv.hasCompletion()) {
mv.astore(completionVar, 0, mv.completionValue());
}
completion = completionVar;
} else {
completion = mv.anullValue();
}
MutableValue<Integer> target = hasTarget ? mv.newVariable("target", int.class) : new PopStoreValue<>();
// stack: [] -> []
// 0 = hint for stacktraces to omit this frame
mv.lineInfo(0);
if (hasResume) {
mv.callWithSuspendInt(method, target, completion);
} else {
mv.callWithResult(method, target, completion);
}
Value<Object> completionValue = mv.arrayElement(completion, 0, Object.class);
if (node.hasCompletionValue()) {
mv.storeCompletionValue(completionValue);
}
mv.labelSwitch(labelState, target, completionValue, false);
mv.exitVariableScope();
return labelState.completion;
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class RuntimeInfoGenerator method debugInfo.
private void debugInfo(MethodCode code, MethodName... names) {
InstructionAssembler asm = new InstructionAssembler(code);
asm.begin();
asm.anew(Types.DebugInfo, Methods.DebugInfo_init);
for (MethodName name : names) {
asm.dup();
asm.handle(name);
asm.invoke(Methods.DebugInfo_addMethod);
}
asm._return();
asm.end();
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class PropertyGenerator method visit.
@Override
public ValType visit(PropertyDefinitionsMethod node, CodeVisitor mv) {
MethodName method = codegen.compile(node, decorators != null, mv);
boolean hasResume = node.hasResumePoint();
mv.enterVariableScope();
Variable<OrdinaryObject> object = mv.newVariable("object", OrdinaryObject.class);
// stack: [<object>] -> []
mv.store(object);
// stack: [] -> []
// 0 = hint for stacktraces to omit this frame
mv.lineInfo(0);
if (hasResume) {
mv.callWithSuspend(method, object, decoratorsOrNull(mv));
} else {
mv.call(method, object, decoratorsOrNull(mv));
}
mv.exitVariableScope();
return null;
}
Aggregations