Set constructor to prototype for ES2015 Classes (#2818)
JerryScript-DCO-1.0-Signed-off-by: legendecas legendecas@gmail.com
This commit is contained in:
+16
-10
@@ -1384,14 +1384,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
ecma_object_t *child_class_p = ecma_get_object_from_value (child_value);
|
||||
ecma_object_t *child_prototype_class_p = ecma_get_object_from_value (child_prototype_value);
|
||||
ecma_property_value_t *prop_value_p;
|
||||
|
||||
prop_value_p = ecma_create_named_data_property (child_prototype_class_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_CONSTRUCTOR),
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
|
||||
NULL);
|
||||
|
||||
ecma_named_data_property_assign_value (child_prototype_class_p, prop_value_p, child_value);
|
||||
|
||||
ecma_object_t *super_class_p = ecma_get_lex_env_binding_object (frame_ctx_p->lex_env_p);
|
||||
|
||||
@@ -1420,7 +1412,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
continue;
|
||||
}
|
||||
case VM_OC_PUSH_CLASS_CONSTRUCTOR:
|
||||
case VM_OC_PUSH_CLASS_CONSTRUCTOR_AND_PROTOTYPE:
|
||||
{
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
|
||||
|
||||
@@ -1431,7 +1423,21 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
ecma_extended_object_t *ext_func_obj_p = (ecma_extended_object_t *) function_obj_p;
|
||||
ext_func_obj_p->u.external_handler_cb = ecma_op_function_implicit_constructor_handler_cb;
|
||||
|
||||
*stack_top_p++ = ecma_make_object_value (function_obj_p);
|
||||
ecma_value_t function_obj_value = ecma_make_object_value (function_obj_p);
|
||||
*stack_top_p++ = function_obj_value;
|
||||
|
||||
ecma_object_t *prototype_class_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE),
|
||||
0,
|
||||
ECMA_OBJECT_TYPE_GENERAL);
|
||||
*stack_top_p++ = ecma_make_object_value (prototype_class_p);
|
||||
|
||||
/* 14.5.14.18 Set constructor to prototype */
|
||||
ecma_property_value_t *prop_value_p;
|
||||
prop_value_p = ecma_create_named_data_property (prototype_class_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_CONSTRUCTOR),
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
|
||||
NULL);
|
||||
ecma_named_data_property_assign_value (prototype_class_p, prop_value_p, function_obj_value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
+2
-2
@@ -215,7 +215,7 @@ typedef enum
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
VM_OC_CLASS_HERITAGE, /**< create a super class context */
|
||||
VM_OC_CLASS_INHERITANCE, /**< inherit properties from the 'super' class */
|
||||
VM_OC_PUSH_CLASS_CONSTRUCTOR, /**< push class constructor */
|
||||
VM_OC_PUSH_CLASS_CONSTRUCTOR_AND_PROTOTYPE, /**< push class constructor */
|
||||
VM_OC_SET_CLASS_CONSTRUCTOR, /**< set class constructor to the given function literal */
|
||||
VM_OC_PUSH_IMPL_CONSTRUCTOR, /**< create implicit class constructor */
|
||||
VM_OC_CLASS_EXPR_CONTEXT_END, /**< class expression heritage context end */
|
||||
@@ -257,7 +257,7 @@ typedef enum
|
||||
#if !ENABLED (JERRY_ES2015_CLASS)
|
||||
VM_OC_CLASS_HERITAGE = VM_OC_NONE, /**< create a super class context */
|
||||
VM_OC_CLASS_INHERITANCE = VM_OC_NONE, /**< inherit properties from the 'super' class */
|
||||
VM_OC_PUSH_CLASS_CONSTRUCTOR = VM_OC_NONE, /**< push class constructor */
|
||||
VM_OC_PUSH_CLASS_CONSTRUCTOR_AND_PROTOTYPE = VM_OC_NONE, /**< push class constructor */
|
||||
VM_OC_SET_CLASS_CONSTRUCTOR = VM_OC_NONE, /**< set class constructor to the given function literal */
|
||||
VM_OC_PUSH_IMPL_CONSTRUCTOR = VM_OC_NONE, /**< create implicit class constructor */
|
||||
VM_OC_CLASS_EXPR_CONTEXT_END = VM_OC_NONE, /**< class expression heritage context end */
|
||||
|
||||
Reference in New Issue
Block a user