use of com.github.anba.es6draft.compiler.assembler.Value in project es6draft by anba.
the class DefaultCodeGenerator method delegatedYield.
/**
* 14.4 Generator Function Definitions
* <p>
* 14.4.14 Runtime Semantics: Evaluation
* <ul>
* <li>YieldExpression : yield * AssignmentExpression
* </ul>
* <p>
* stack: [value] {@literal ->} [value']
*
* @param node
* the expression node
* @param mv
* the code visitor
*/
protected final void delegatedYield(Expression node, CodeVisitor mv) {
if (!mv.isAsync()) {
delegatedYield(node, (iterator, received) -> {
IteratorNext(node, iterator, received, mv);
}, (iterator, received) -> {
mv.loadExecutionContext();
mv.load(iterator);
mv.load(received);
mv.checkcast(Types.ScriptException);
mv.invoke(Methods.ScriptRuntime_yieldThrowCompletion);
}, (iterator, received) -> {
mv.loadExecutionContext();
mv.load(iterator);
mv.load(received);
mv.checkcast(Types.ReturnValue);
mv.invoke(Methods.ScriptRuntime_yieldReturnCompletion);
}, mv);
} else {
delegatedYield(node, (iterator, received) -> {
IteratorNext(node, iterator, received, mv);
await(node, mv);
// FIXME: spec bug - missing type check
requireObjectResult(node, "next", mv);
}, (iterator, received) -> {
mv.enterVariableScope();
Variable<Callable> throwMethod = mv.newVariable("throwMethod", Callable.class);
GetMethod(node, iterator, "throw", mv);
mv.store(throwMethod);
Jump noThrow = new Jump(), nextYield = new Jump();
mv.load(throwMethod);
mv.ifnull(noThrow);
{
InvokeMethod(node, mv, throwMethod, iterator, __ -> {
mv.load(received);
mv.checkcast(Types.ScriptException);
mv.invoke(Methods.ScriptException_getValue);
});
await(node, mv);
requireObjectResult(node, "throw", mv);
mv.goTo(nextYield);
}
mv.mark(noThrow);
{
asyncIteratorClose(node, iterator, mv);
reportPropertyNotCallable(node, "throw", mv);
mv.athrow();
}
mv.mark(nextYield);
mv.exitVariableScope();
}, (iterator, received) -> {
mv.enterVariableScope();
Variable<Callable> returnMethod = mv.newVariable("returnMethod", Callable.class);
GetMethod(node, iterator, "return", mv);
mv.store(returnMethod);
Jump noReturn = new Jump(), nextYield = new Jump();
mv.load(returnMethod);
mv.ifnull(noReturn);
{
InvokeMethod(node, mv, returnMethod, iterator, __ -> {
mv.load(received);
mv.checkcast(Types.ReturnValue);
mv.invoke(Methods.ReturnValue_getValue);
});
await(node, mv);
requireObjectResult(node, "return", mv);
mv.goTo(nextYield);
}
mv.mark(noReturn);
{
mv.anull();
}
mv.mark(nextYield);
mv.exitVariableScope();
}, mv);
}
}
Aggregations