use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class ExpressionGenerator method visit.
@Override
public ValType visit(ExpressionMethod node, CodeVisitor mv) {
MethodName method = codegen.compile(node, mv);
boolean hasResume = node.hasResumePoint();
// stack: [] -> [result]
// 0 = hint for stacktraces to omit this frame
mv.lineInfo(0);
if (hasResume) {
mv.callWithSuspend(method);
} else {
mv.call(method);
}
return ValType.Any;
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class ExpressionGenerator method visit.
/**
* 12.2.4.1.3 Runtime Semantics: Evaluation<br>
* 12.2.4.1.2 Runtime Semantics: Array Accumulation
*/
@Override
public ValType visit(SpreadElementMethod node, CodeVisitor mv) {
MethodName method = codegen.compile(node, mv);
boolean hasResume = node.hasResumePoint();
mv.enterVariableScope();
Variable<ArrayObject> array = mv.newVariable("array", ArrayObject.class);
Variable<Integer> nextIndex = mv.newVariable("nextIndex", int.class);
// stack: [array, nextIndex] -> [array]
mv.store(nextIndex);
mv.dup();
mv.store(array);
// stack: [array] -> [array, nextIndex']
// 0 = hint for stacktraces to omit this frame
mv.lineInfo(0);
if (hasResume) {
mv.callWithSuspend(method, array, nextIndex);
} else {
mv.call(method, array, nextIndex);
}
mv.exitVariableScope();
return ValType.Any;
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class ExpressionGenerator method visit.
/**
* 14.4.14 Runtime Semantics: Evaluation
*/
@Override
public ValType visit(GeneratorExpression node, CodeVisitor mv) {
MethodName method = codegen.compile(node);
/* steps 1-7/11 */
mv.invoke(method);
mv.loadExecutionContext();
if (node.isConstructor()) {
mv.invoke(Methods.ScriptRuntime_EvaluateConstructorGeneratorExpression);
} else {
mv.invoke(Methods.ScriptRuntime_EvaluateGeneratorExpression);
}
/* step 8/12 */
return ValType.Object;
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class ExpressionGenerator method visit.
/**
* Extension: 'do' expression
*/
@Override
public ValType visit(DoExpression node, CodeVisitor mv) {
Entry<MethodName, LabelState> entry = codegen.compile(node, mv);
MethodName method = entry.getKey();
LabelState labelState = entry.getValue();
boolean hasCompletion = labelState.hasReturn() || node.hasCompletion();
boolean hasResume = node.hasYieldOrAwait();
boolean hasTarget = hasResume || labelState.size() > 0;
mv.enterVariableScope();
Value<Object[]> completion;
if (hasCompletion) {
Variable<Object[]> completionVar = mv.newVariable("completion", Object[].class);
mv.anewarray(1, Types.Object);
mv.store(completionVar);
if (node.hasCompletion()) {
mv.astore(completionVar, 0, mv.undefinedValue());
}
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);
mv.labelSwitch(labelState, target, completionValue, true);
if (node.hasCompletion()) {
mv.load(completionValue);
}
mv.exitVariableScope();
return node.hasCompletion() ? ValType.Any : ValType.Empty;
}
use of com.github.anba.es6draft.compiler.assembler.MethodName in project es6draft by anba.
the class ExpressionGenerator method visit.
/**
* 14.1.17 Runtime Semantics: Evaluation
*/
@Override
public ValType visit(FunctionExpression node, CodeVisitor mv) {
MethodName method = codegen.compile(node);
/* steps 1-5/10 */
mv.invoke(method);
mv.loadExecutionContext();
if (isLegacy(node)) {
mv.invoke(Methods.ScriptRuntime_EvaluateLegacyFunctionExpression);
} else {
mv.invoke(Methods.ScriptRuntime_EvaluateFunctionExpression);
}
/* step 6/11 */
return ValType.Object;
}
Aggregations