Outsource magic error messages (#4821)
Modify tools/gen-magic-strings.py to generate error messages. JerryScript-DCO-1.0-Signed-off-by: Csaba Repasi repasics@inf.u-szeged.hu
This commit is contained in:
@@ -303,7 +303,7 @@ opfunc_unary_operation (ecma_value_t left_value, /**< left value */
|
||||
|
||||
if (is_plus)
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Unary plus is not allowed for BigInts"));
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -157,7 +157,7 @@ do_number_bitwise_logic (number_bitwise_logic_op op, /**< number bitwise logic o
|
||||
{
|
||||
JERRY_ASSERT (op == NUMBER_BITWISE_SHIFT_URIGHT);
|
||||
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Unsigned right shift is not allowed for BigInts"));
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ opfunc_instanceof (ecma_value_t left_value, /**< left value */
|
||||
{
|
||||
if (!ecma_is_value_object (right_value))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Right value of 'instanceof' must be an object"));
|
||||
return ecma_raise_type_error (ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT);
|
||||
}
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@@ -153,7 +153,7 @@ opfunc_in (ecma_value_t left_value, /**< left value */
|
||||
{
|
||||
if (!ecma_is_value_object (right_value))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Right value of 'in' must be an object"));
|
||||
return ecma_raise_type_error (ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT);
|
||||
}
|
||||
|
||||
ecma_string_t *property_name_p = ecma_op_to_property_key (left_value);
|
||||
|
||||
@@ -218,7 +218,7 @@ vm_op_delete_prop (ecma_value_t object, /**< base object */
|
||||
#if JERRY_ESNEXT
|
||||
if (is_strict && ecma_is_value_false (delete_op_ret))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Operator delete returned false in strict mode"));
|
||||
return ecma_raise_type_error (ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE);
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -1159,7 +1159,7 @@ opfunc_init_class (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
/* 6.f, 6.g.i */
|
||||
if (!ecma_is_constructor (super_class))
|
||||
{
|
||||
return ecma_raise_type_error ("Class extends value is not a constructor or null");
|
||||
return ecma_raise_type_error (ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR);
|
||||
}
|
||||
|
||||
ecma_object_t *parent_p = ecma_get_object_from_value (super_class);
|
||||
@@ -1186,7 +1186,7 @@ opfunc_init_class (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
else
|
||||
{
|
||||
ecma_free_value (proto_parent);
|
||||
return ecma_raise_type_error ("Property 'prototype' is not an object or null");
|
||||
return ecma_raise_type_error (ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT);
|
||||
}
|
||||
|
||||
/* 6.g.v */
|
||||
@@ -1391,8 +1391,7 @@ opfunc_form_super_reference (ecma_value_t **vm_stack_top_p, /**< current vm stac
|
||||
|
||||
if (!ecma_op_this_binding_is_initialized (environment_record_p))
|
||||
{
|
||||
return ecma_raise_reference_error (ECMA_ERR_MSG ("Must call super constructor in derived class before "
|
||||
"accessing 'this' or returning from it"));
|
||||
return ecma_raise_reference_error (ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1400,7 +1399,7 @@ opfunc_form_super_reference (ecma_value_t **vm_stack_top_p, /**< current vm stac
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (parent))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot invoke nullable super method"));
|
||||
return ecma_raise_type_error (ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD);
|
||||
}
|
||||
|
||||
if (!ecma_op_require_object_coercible (parent))
|
||||
|
||||
@@ -417,7 +417,7 @@ vm_stack_find_finally (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
|
||||
|
||||
if (!is_object)
|
||||
{
|
||||
result = ecma_raise_type_error (ECMA_ERR_MSG ("Iterator 'return' result is not object"));
|
||||
result = ecma_raise_type_error (ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-19
@@ -23,6 +23,7 @@
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-comparison.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-errors.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
@@ -124,7 +125,7 @@ vm_op_get_value (ecma_value_t object, /**< base object */
|
||||
ecma_value_t error_value =
|
||||
ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE, "Cannot read property '%' of %", property, object);
|
||||
#else /* !JERRY_ERROR_MESSAGES */
|
||||
ecma_value_t error_value = ecma_raise_type_error (NULL);
|
||||
ecma_value_t error_value = ecma_raise_type_error (ECMA_ERR_EMPTY);
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
return error_value;
|
||||
}
|
||||
@@ -168,7 +169,7 @@ vm_op_set_value (ecma_value_t base, /**< base object */
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
result = ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE, "Cannot set property '%' of %", property, base);
|
||||
#else /* !JERRY_ERROR_MESSAGES */
|
||||
result = ecma_raise_type_error (NULL);
|
||||
result = ecma_raise_type_error (ECMA_ERR_EMPTY);
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
ecma_free_value (property);
|
||||
return result;
|
||||
@@ -323,7 +324,7 @@ vm_run_eval (ecma_compiled_code_t *bytecode_data_p, /**< byte-code data */
|
||||
{
|
||||
ecma_bytecode_deref (bytecode_data_p);
|
||||
ecma_free_value (this_binding);
|
||||
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid scope chain index for eval"));
|
||||
return ecma_raise_range_error (ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL);
|
||||
}
|
||||
|
||||
lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp);
|
||||
@@ -568,7 +569,7 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
if (!ecma_is_constructor (func_value))
|
||||
{
|
||||
completion_value = ecma_raise_type_error (ECMA_ERR_MSG ("Value for class heritage is not a constructor"));
|
||||
completion_value = ecma_raise_type_error (ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -579,7 +580,7 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
if (!ECMA_IS_VALUE_ERROR (completion_value) && ecma_op_this_binding_is_initialized (environment_record_p))
|
||||
{
|
||||
ecma_free_value (completion_value);
|
||||
completion_value = ecma_raise_reference_error (ECMA_ERR_MSG ("Super constructor may only be called once"));
|
||||
completion_value = ecma_raise_reference_error (ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -659,10 +660,10 @@ vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
if (frame_ctx_p->byte_code_p[1] == CBC_EXT_SPREAD_NEW)
|
||||
{
|
||||
const char *constructor_message_p = ecma_check_constructor (func_value);
|
||||
if (constructor_message_p != ECMA_IS_VALID_CONSTRUCTOR)
|
||||
ecma_error_msg_t constructor_message_id = ecma_check_constructor (func_value);
|
||||
if (constructor_message_id != ECMA_IS_VALID_CONSTRUCTOR)
|
||||
{
|
||||
completion_value = ecma_raise_type_error (constructor_message_p);
|
||||
completion_value = ecma_raise_type_error (constructor_message_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -680,7 +681,7 @@ vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
if (!ecma_is_value_object (func_value) || !ecma_op_object_is_callable (ecma_get_object_from_value (func_value)))
|
||||
{
|
||||
completion_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function));
|
||||
completion_value = ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -831,10 +832,10 @@ opfunc_construct (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
ecma_value_t constructor_value = stack_top_p[-1];
|
||||
ecma_value_t completion_value;
|
||||
|
||||
const char *constructor_message_p = ecma_check_constructor (constructor_value);
|
||||
if (constructor_message_p != ECMA_IS_VALID_CONSTRUCTOR)
|
||||
ecma_error_msg_t constructor_message_id = ecma_check_constructor (constructor_value);
|
||||
if (constructor_message_id != ECMA_IS_VALID_CONSTRUCTOR)
|
||||
{
|
||||
completion_value = ecma_raise_type_error (constructor_message_p);
|
||||
completion_value = ecma_raise_type_error (constructor_message_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1591,7 +1592,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
if (binding_p != NULL)
|
||||
{
|
||||
result = ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_local_variable_is_redeclared));
|
||||
result = ecma_raise_syntax_error (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1616,7 +1617,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
{
|
||||
if (ecma_is_value_true (result))
|
||||
{
|
||||
result = ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_local_variable_is_redeclared));
|
||||
result = ecma_raise_syntax_error (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (result));
|
||||
@@ -1637,7 +1638,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
if (ecma_is_value_true (result))
|
||||
{
|
||||
result = ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_local_variable_is_redeclared));
|
||||
result = ecma_raise_syntax_error (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1705,7 +1706,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
case VM_OC_THROW_CONST_ERROR:
|
||||
{
|
||||
result = ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned"));
|
||||
result = ecma_raise_type_error (ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED);
|
||||
goto error;
|
||||
}
|
||||
case VM_OC_COPY_TO_GLOBAL:
|
||||
@@ -1891,7 +1892,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (prop_name_p, LIT_MAGIC_STRING_PROTOTYPE))
|
||||
&& !(opcode_data & VM_OC_NON_STATIC_FLAG))
|
||||
{
|
||||
result = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_class_is_non_configurable));
|
||||
result = ecma_raise_type_error (ECMA_ERR_CLASS_IS_NON_CONFIGURABLE);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1924,7 +1925,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (prop_name_p, LIT_MAGIC_STRING_PROTOTYPE))
|
||||
&& !(opcode_data & VM_OC_NON_STATIC_FLAG))
|
||||
{
|
||||
result = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_class_is_non_configurable));
|
||||
result = ecma_raise_type_error (ECMA_ERR_CLASS_IS_NON_CONFIGURABLE);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -3064,7 +3065,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
case VM_OC_THROW_REFERENCE_ERROR:
|
||||
{
|
||||
result = ecma_raise_reference_error (ECMA_ERR_MSG ("Undefined reference"));
|
||||
result = ecma_raise_reference_error (ECMA_ERR_UNDEFINED_REFERENCE);
|
||||
goto error;
|
||||
}
|
||||
case VM_OC_EVAL:
|
||||
|
||||
Reference in New Issue
Block a user