Fix a few small issues in generators (#3919)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -39,9 +39,9 @@
|
||||
enum
|
||||
{
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN,
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT,
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW,
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator-prototype.inc.h"
|
||||
@@ -206,7 +206,13 @@ ecma_builtin_generator_prototype_dispatch_routine (uint16_t builtin_routine_id,
|
||||
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
{
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
if (builtin_routine_id != ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
{
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
|
||||
jcontext_raise_exception (ecma_copy_value (arguments_list_p[0]));
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
switch (builtin_routine_id)
|
||||
@@ -223,16 +229,13 @@ ecma_builtin_generator_prototype_dispatch_routine (uint16_t builtin_routine_id,
|
||||
arguments_list_p[0],
|
||||
ECMA_ITERATOR_THROW);
|
||||
}
|
||||
case ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN:
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN);
|
||||
return ecma_builtin_generator_prototype_object_do (executable_object_p,
|
||||
arguments_list_p[0],
|
||||
ECMA_ITERATOR_RETURN);
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
|
||||
@@ -69,7 +69,7 @@ check_result(f.throw("throw"), "z", false)
|
||||
check_throw("f.next()", "throw")
|
||||
check_result(f.next(), undefined, true)
|
||||
|
||||
function* gen3() {
|
||||
function/* generator */*/* generator */gen3() {
|
||||
try {
|
||||
return 8
|
||||
} finally {
|
||||
@@ -80,3 +80,15 @@ function* gen3() {
|
||||
f = gen3()
|
||||
check_result(f.next(), 1, false)
|
||||
check_throw("f.throw(2)", 2)
|
||||
|
||||
function
|
||||
/* generator */
|
||||
*
|
||||
/* generator */
|
||||
gen4()
|
||||
{
|
||||
}
|
||||
|
||||
f = gen4()
|
||||
check_result(f.next(), undefined, true)
|
||||
check_throw("f.throw('Str')", "Str")
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
<test id="built-ins/Function/StrictFunction_restricted-properties.js"><reason></reason></test>
|
||||
<test id="built-ins/GeneratorFunction/instance-restricted-properties.js"><reason></reason></test>
|
||||
<test id="built-ins/GeneratorPrototype/next/context-constructor-invocation.js"><reason></reason></test>
|
||||
<test id="built-ins/GeneratorPrototype/throw/from-state-completed.js"><reason></reason></test>
|
||||
<test id="built-ins/Map/prototype/Symbol.iterator.js"><reason></reason></test>
|
||||
<test id="built-ins/Number/15.7.4-1.js"><reason></reason></test>
|
||||
<test id="built-ins/Number/prototype/S15.7.3.1_A2_T1.js"><reason></reason></test>
|
||||
|
||||
Reference in New Issue
Block a user