Revise ES2015 feature guards (#3240)
All the basic language element guards are merged into JERRY_ES2015 macro guard. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
59e0d6e262
commit
3b73562fa5
@@ -110,7 +110,7 @@ opfunc_instanceof (ecma_value_t left_value, /**< left value */
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object in 'instanceof' check."));
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ecma_value_t has_instance_method = ecma_op_get_method_by_symbol_id (right_value, LIT_MAGIC_STRING_HAS_INSTANCE);
|
||||
if (ECMA_IS_VALUE_ERROR (has_instance_method))
|
||||
{
|
||||
@@ -134,7 +134,7 @@ opfunc_instanceof (ecma_value_t left_value, /**< left value */
|
||||
|
||||
return ecma_make_boolean_value (has_instance);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
|
||||
return ecma_op_object_has_instance (right_value_obj_p, left_value);
|
||||
|
||||
@@ -67,9 +67,9 @@ vm_stack_context_abort (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
/* FALLTHRU */
|
||||
}
|
||||
case VM_CONTEXT_WITH:
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_CONTEXT_SUPER_CLASS:
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
{
|
||||
ecma_object_t *lex_env_p = frame_ctx_p->lex_env_p;
|
||||
JERRY_ASSERT (lex_env_p->u2.outer_reference_cp != JMEM_CP_NULL);
|
||||
@@ -80,7 +80,7 @@ vm_stack_context_abort (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
vm_stack_top_p -= PARSER_WITH_CONTEXT_STACK_ALLOCATION;
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_CONTEXT_FOR_OF:
|
||||
{
|
||||
ecma_free_value (vm_stack_top_p[-2]);
|
||||
@@ -89,7 +89,7 @@ vm_stack_context_abort (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
vm_stack_top_p -= PARSER_FOR_OF_CONTEXT_STACK_ALLOCATION;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (VM_GET_CONTEXT_TYPE (vm_stack_top_p[-1]) == VM_CONTEXT_FOR_IN);
|
||||
|
||||
@@ -40,13 +40,11 @@ typedef enum
|
||||
VM_CONTEXT_TRY, /**< try context */
|
||||
VM_CONTEXT_CATCH, /**< catch context */
|
||||
VM_CONTEXT_WITH, /**< with context */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
VM_CONTEXT_SUPER_CLASS, /**< super class context */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
VM_CONTEXT_FOR_IN, /**< for-in context */
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
VM_CONTEXT_FOR_OF, /**< for-of context */
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
VM_CONTEXT_SUPER_CLASS, /**< super class context */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
} vm_stack_context_type_t;
|
||||
|
||||
ecma_value_t *vm_stack_context_abort (vm_frame_ctx_t *frame_ctx_p, ecma_value_t *vm_stack_top_p);
|
||||
|
||||
+26
-26
@@ -88,12 +88,12 @@ vm_op_get_value (ecma_value_t object, /**< base object */
|
||||
property_name_p = ecma_get_string_from_value (property);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (ecma_is_value_symbol (property))
|
||||
{
|
||||
property_name_p = ecma_get_symbol_from_value (property);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (property_name_p != NULL)
|
||||
{
|
||||
@@ -411,13 +411,13 @@ vm_construct_literal_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
|
||||
ecma_object_t *func_obj_p;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION))
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015_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_ARROW_FUNCTION)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -425,7 +425,7 @@ vm_construct_literal_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
bytecode_p,
|
||||
frame_ctx_p->this_binding);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_ARROW_FUNCTION) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
return ecma_make_object_value (func_obj_p);
|
||||
} /* vm_construct_literal_object */
|
||||
@@ -465,7 +465,7 @@ static const uint8_t vm_error_byte_code_p[] =
|
||||
CBC_EXT_OPCODE, CBC_EXT_ERROR
|
||||
};
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* 'super(...)' function call handler.
|
||||
*/
|
||||
@@ -540,7 +540,7 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
frame_ctx_p->stack_top_p = stack_top_p;
|
||||
} /* vm_super_call */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* 'Function call' opcode handler.
|
||||
@@ -1199,7 +1199,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
*stack_top_p++ = left_value;
|
||||
continue;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_OC_SET_COMPUTED_PROPERTY:
|
||||
{
|
||||
/* Swap values. */
|
||||
@@ -1208,7 +1208,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
left_value ^= right_value;
|
||||
/* FALLTHRU */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case VM_OC_SET_PROPERTY:
|
||||
{
|
||||
JERRY_STATIC_ASSERT (VM_OC_NON_STATIC_FLAG == VM_OC_BACKWARD_BRANCH,
|
||||
@@ -1224,7 +1224,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (prop_name_p, LIT_MAGIC_STRING_PROTOTYPE))
|
||||
&& !(opcode_data & VM_OC_NON_STATIC_FLAG))
|
||||
{
|
||||
@@ -1233,9 +1233,9 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
|
||||
const int index = (int) (opcode_data >> VM_OC_NON_STATIC_SHIFT) - 2;
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
const int index = -1;
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (stack_top_p[index]);
|
||||
|
||||
@@ -1284,7 +1284,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (prop_name_p, LIT_MAGIC_STRING_PROTOTYPE))
|
||||
&& !(opcode_data & VM_OC_NON_STATIC_FLAG))
|
||||
{
|
||||
@@ -1293,9 +1293,9 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
|
||||
const int index = (int) (opcode_data >> VM_OC_NON_STATIC_SHIFT) - 2;
|
||||
#else /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
const int index = -1;
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
opfunc_set_accessor (VM_OC_GROUP_GET_INDEX (opcode_data) == VM_OC_SET_GETTER,
|
||||
stack_top_p[index],
|
||||
@@ -1312,7 +1312,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
*stack_top_p++ = ecma_make_object_value (ecma_op_new_fast_array_object (0));
|
||||
continue;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_OC_SUPER_CALL:
|
||||
{
|
||||
frame_ctx_p->call_operation = VM_EXEC_SUPER_CALL;
|
||||
@@ -1637,7 +1637,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
goto error;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case VM_OC_PUSH_ELISON:
|
||||
{
|
||||
*stack_top_p++ = ECMA_VALUE_ARRAY_HOLE;
|
||||
@@ -2935,7 +2935,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_OC_FOR_OF_CREATE_CONTEXT:
|
||||
{
|
||||
ecma_value_t value = *(--stack_top_p);
|
||||
@@ -3021,7 +3021,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case VM_OC_TRY:
|
||||
{
|
||||
/* Try opcode simply creates the try context. */
|
||||
@@ -3547,9 +3547,9 @@ vm_execute (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
|
||||
frame_ctx_p->stack_top_p = frame_ctx_p->registers_p + register_end;
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
uint32_t function_call_argument_count = arg_list_len;
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
if (arg_list_len > argument_end)
|
||||
{
|
||||
@@ -3573,7 +3573,7 @@ vm_execute (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_REST_PARAMETER)
|
||||
{
|
||||
JERRY_ASSERT (function_call_argument_count >= arg_list_len);
|
||||
@@ -3584,7 +3584,7 @@ vm_execute (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
frame_ctx_p->registers_p[argument_end] = new_array;
|
||||
arg_list_len++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_FUNCTION_REST_PARAMETER) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_DIRECT_EVAL;
|
||||
|
||||
@@ -3604,13 +3604,13 @@ vm_execute (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
opfunc_call (frame_ctx_p);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_EXEC_SUPER_CALL:
|
||||
{
|
||||
vm_super_call (frame_ctx_p);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
case VM_EXEC_CONSTRUCT:
|
||||
{
|
||||
opfunc_construct (frame_ctx_p);
|
||||
|
||||
+28
-28
@@ -122,9 +122,7 @@ typedef enum
|
||||
VM_OC_PUSH_OBJECT, /**< push object */
|
||||
VM_OC_PUSH_NAMED_FUNC_EXPR, /**< push named function expression */
|
||||
VM_OC_SET_PROPERTY, /**< set property */
|
||||
#if ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
VM_OC_SET_COMPUTED_PROPERTY, /**< set computed property */
|
||||
#endif /* ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
|
||||
VM_OC_SET_GETTER, /**< set getter */
|
||||
VM_OC_SET_SETTER, /**< set setter */
|
||||
VM_OC_PUSH_UNDEFINED_BASE, /**< push undefined base */
|
||||
@@ -208,17 +206,28 @@ typedef enum
|
||||
VM_OC_FOR_IN_CREATE_CONTEXT, /**< for in create context */
|
||||
VM_OC_FOR_IN_GET_NEXT, /**< get next */
|
||||
VM_OC_FOR_IN_HAS_NEXT, /**< has next */
|
||||
#if ENABLED (JERRY_ES2015_FOR_OF)
|
||||
VM_OC_FOR_OF_CREATE_CONTEXT, /**< for of create context */
|
||||
VM_OC_FOR_OF_GET_NEXT, /**< get next */
|
||||
VM_OC_FOR_OF_HAS_NEXT, /**< has next */
|
||||
#endif /* ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
|
||||
VM_OC_TRY, /**< try */
|
||||
VM_OC_CATCH, /**< catch */
|
||||
VM_OC_FINALLY, /**< finally */
|
||||
VM_OC_CONTEXT_END, /**< context end */
|
||||
VM_OC_JUMP_AND_EXIT_CONTEXT, /**< jump and exit context */
|
||||
#if ENABLED (JERRY_ES2015_CLASS)
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
VM_OC_BREAKPOINT_ENABLED, /**< enabled breakpoint for debugger */
|
||||
VM_OC_BREAKPOINT_DISABLED, /**< disabled breakpoint for debugger */
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
VM_OC_RESOURCE_NAME, /**< resource name of the current function */
|
||||
VM_OC_LINE, /**< line number of the next statement */
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
VM_OC_SET_COMPUTED_PROPERTY, /**< set computed property */
|
||||
|
||||
VM_OC_FOR_OF_CREATE_CONTEXT, /**< for of create context */
|
||||
VM_OC_FOR_OF_GET_NEXT, /**< get next */
|
||||
VM_OC_FOR_OF_HAS_NEXT, /**< has next */
|
||||
|
||||
VM_OC_CLASS_HERITAGE, /**< create a super class context */
|
||||
VM_OC_CLASS_INHERITANCE, /**< inherit properties from the 'super' class */
|
||||
VM_OC_PUSH_CLASS_CONSTRUCTOR_AND_PROTOTYPE, /**< push class constructor */
|
||||
@@ -232,15 +241,7 @@ typedef enum
|
||||
VM_OC_PUSH_CONSTRUCTOR_SUPER, /**< push 'super' inside a class constructor */
|
||||
VM_OC_PUSH_CONSTRUCTOR_THIS, /**< push 'this' inside a class constructor */
|
||||
VM_OC_CONSTRUCTOR_RET, /**< explicit return from a class constructor */
|
||||
#endif /* ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
VM_OC_BREAKPOINT_ENABLED, /**< enabled breakpoint for debugger */
|
||||
VM_OC_BREAKPOINT_DISABLED, /**< disabled breakpoint for debugger */
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
VM_OC_RESOURCE_NAME, /**< resource name of the current function */
|
||||
VM_OC_LINE, /**< line number of the next statement */
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
VM_OC_NONE, /**< a special opcode for unsupported byte codes */
|
||||
} vm_oc_types;
|
||||
|
||||
@@ -249,9 +250,6 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
#if !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER)
|
||||
VM_OC_SET_COMPUTED_PROPERTY = VM_OC_NONE, /**< set computed property is unused */
|
||||
#endif /* !ENABLED (JERRY_ES2015_OBJECT_INITIALIZER) */
|
||||
#if !ENABLED (JERRY_DEBUGGER)
|
||||
VM_OC_BREAKPOINT_ENABLED = VM_OC_NONE, /**< enabled breakpoint for debugger is unused */
|
||||
VM_OC_BREAKPOINT_DISABLED = VM_OC_NONE, /**< disabled breakpoint for debugger is unused */
|
||||
@@ -260,7 +258,13 @@ typedef enum
|
||||
VM_OC_RESOURCE_NAME = VM_OC_NONE, /**< resource name of the current function is unused */
|
||||
VM_OC_LINE = VM_OC_NONE, /**< line number of the next statement is unused */
|
||||
#endif /* !ENABLED (JERRY_LINE_INFO) */
|
||||
#if !ENABLED (JERRY_ES2015_CLASS)
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
VM_OC_SET_COMPUTED_PROPERTY = VM_OC_NONE, /**< set computed property is unused */
|
||||
|
||||
VM_OC_FOR_OF_CREATE_CONTEXT = VM_OC_NONE, /**< for of create context */
|
||||
VM_OC_FOR_OF_GET_NEXT = VM_OC_NONE, /**< get next */
|
||||
VM_OC_FOR_OF_HAS_NEXT = VM_OC_NONE, /**< has next */
|
||||
|
||||
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_AND_PROTOTYPE = VM_OC_NONE, /**< push class constructor */
|
||||
@@ -274,12 +278,8 @@ typedef enum
|
||||
VM_OC_PUSH_CONSTRUCTOR_SUPER = VM_OC_NONE, /**< push 'super' inside a class constructor */
|
||||
VM_OC_PUSH_CONSTRUCTOR_THIS = VM_OC_NONE, /**< push 'this' inside a class constructor */
|
||||
VM_OC_CONSTRUCTOR_RET = VM_OC_NONE, /**< explicit return from a class constructor */
|
||||
#endif /* !ENABLED (JERRY_ES2015_CLASS) */
|
||||
#if !ENABLED (JERRY_ES2015_FOR_OF)
|
||||
VM_OC_FOR_OF_CREATE_CONTEXT = VM_OC_NONE, /**< for of create context */
|
||||
VM_OC_FOR_OF_GET_NEXT = VM_OC_NONE, /**< get next */
|
||||
VM_OC_FOR_OF_HAS_NEXT = VM_OC_NONE, /**< has next */
|
||||
#endif /* !ENABLED (JERRY_ES2015_FOR_OF) */
|
||||
#endif /* !ENABLED (JERRY_ES2015S) */
|
||||
|
||||
VM_OC_UNUSED = VM_OC_NONE /**< placeholder if the list is empty */
|
||||
} vm_oc_unused_types;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user