Add builtin GeneratorFunction support (#3499)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-01-15 12:01:58 +01:00
committed by GitHub
parent e3decffdd3
commit 4a331b2edc
24 changed files with 659 additions and 152 deletions
+6 -1
View File
@@ -571,10 +571,15 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p) /**< frame context
size_t total_size = JERRY_ALIGNUP (sizeof (vm_executable_object_t) + size, sizeof (uintptr_t));
ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_GENERATOR_PROTOTYPE),
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_function_obj_p),
ECMA_BUILTIN_ID_GENERATOR_PROTOTYPE);
ecma_object_t *object_p = ecma_create_object (proto_p,
total_size,
ECMA_OBJECT_TYPE_CLASS);
ecma_deref_object (proto_p);
vm_executable_object_t *executable_object_p = (vm_executable_object_t *) object_p;
executable_object_p->extended_object.u.class_prop.class_id = LIT_MAGIC_STRING_GENERATOR_UL;
+19 -9
View File
@@ -414,19 +414,22 @@ vm_construct_literal_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
ecma_object_t *func_obj_p;
#if ENABLED (JERRY_ES2015)
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION))
{
#endif /* ENABLED (JERRY_ES2015) */
func_obj_p = ecma_op_create_function_object (frame_ctx_p->lex_env_p,
bytecode_p);
#if ENABLED (JERRY_ES2015)
}
else
if (bytecode_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION)
{
func_obj_p = ecma_op_create_arrow_function_object (frame_ctx_p->lex_env_p,
bytecode_p,
frame_ctx_p->this_binding);
}
else if (bytecode_p->status_flags & CBC_CODE_FLAGS_GENERATOR)
{
func_obj_p = ecma_op_create_generator_function_object (frame_ctx_p->lex_env_p, bytecode_p);
}
else
{
#endif /* ENABLED (JERRY_ES2015) */
func_obj_p = ecma_op_create_simple_function_object (frame_ctx_p->lex_env_p, bytecode_p);
#if ENABLED (JERRY_ES2015)
}
#endif /* ENABLED (JERRY_ES2015) */
return ecma_make_object_value (func_obj_p);
@@ -2077,7 +2080,14 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
frame_ctx_p->call_operation = VM_EXEC_RETURN;
frame_ctx_p->byte_code_p = byte_code_p;
frame_ctx_p->stack_top_p = stack_top_p;
return opfunc_create_executable_object (frame_ctx_p);
result = opfunc_create_executable_object (frame_ctx_p);
if (ECMA_IS_VALUE_ERROR (result))
{
goto error;
}
return result;
}
case VM_OC_YIELD:
{