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:
Csaba Repasi
2021-11-25 14:06:40 +01:00
committed by GitHub
parent fc4168f2b4
commit 271d9b2463
111 changed files with 1947 additions and 925 deletions
+32 -45
View File
@@ -57,7 +57,7 @@ ecma_proxy_create (ecma_value_t target, /**< proxy target */
/* ES11+: 1 - 2. */
if (!ecma_is_value_object (target) || !ecma_is_value_object (handler))
{
ecma_raise_type_error (ECMA_ERR_MSG ("Cannot create Proxy with a non-object target or handler"));
ecma_raise_type_error (ECMA_ERR_CANNOT_CREATE_PROXY);
return NULL;
}
@@ -240,7 +240,7 @@ ecma_validate_proxy_object (ecma_value_t handler, /**< proxy handler */
{
if (ecma_is_value_null (handler))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Handler cannot be null"));
return ecma_raise_type_error (ECMA_ERR_HANDLER_CANNOT_BE_NULL);
}
JERRY_ASSERT (ecma_is_value_object (handler));
@@ -308,7 +308,7 @@ ecma_proxy_object_get_prototype_of (ecma_object_t *obj_p) /**< proxy object */
{
ecma_free_value (handler_proto);
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned neither object nor null"));
return ecma_raise_type_error (ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL);
}
if (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)
@@ -349,8 +349,7 @@ ecma_proxy_object_get_prototype_of (ecma_object_t *obj_p) /**< proxy object */
{
ecma_free_value (handler_proto);
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Proxy target is non-extensible, but the trap did not "
"return its actual prototype"));
ret_value = ecma_raise_type_error (ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE);
}
ecma_free_value (target_proto);
@@ -471,8 +470,7 @@ ecma_proxy_object_set_prototype_of (ecma_object_t *obj_p, /**< proxy object */
/* 16. */
if (boolean_trap_result && (target_proto != proto))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Target object is non-extensible and trap "
"returned different prototype"));
ret_value = ecma_raise_type_error (ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED);
}
ecma_free_value (target_proto);
@@ -567,7 +565,7 @@ ecma_proxy_object_is_extensible (ecma_object_t *obj_p) /**< proxy object */
/* 12. */
if (boolean_trap_result != target_result)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap result does not reflect extensibility of Proxy target"));
return ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY);
}
return ecma_make_boolean_value (boolean_trap_result);
@@ -651,7 +649,7 @@ ecma_proxy_object_prevent_extensions (ecma_object_t *obj_p) /**< proxy object */
if (ecma_is_value_true (target_is_ext))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap result does not reflect inextensibility of Proxy target"));
return ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY);
}
}
@@ -723,7 +721,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
if (!ecma_is_value_object (trap_result) && !ecma_is_value_undefined (trap_result))
{
ecma_free_value (trap_result);
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap is neither an object nor undefined"));
return ecma_raise_type_error (ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED);
}
if (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)
@@ -768,8 +766,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE))
{
ecma_free_property_descriptor (&target_desc);
return ecma_raise_type_error (ECMA_ERR_MSG ("Given property is a non-configurable"
" data property on the proxy target"));
return ecma_raise_type_error (ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE);
}
/* .c */
@@ -788,7 +785,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
/* .f */
if (ecma_is_value_false (extensible_target))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Target not extensible"));
return ecma_raise_type_error (ECMA_ERR_TARGET_NOT_EXTENSIBLE);
}
/* .g */
@@ -846,7 +843,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
if (!is_valid)
{
ecma_free_property_descriptor (prop_desc_p);
return ecma_raise_type_error (ECMA_ERR_MSG ("The two descriptors are incompatible"));
return ecma_raise_type_error (ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE);
}
/* 22. */
@@ -858,7 +855,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy
|| ((prop_desc_p->flags & mask) == JERRY_PROP_IS_WRITABLE_DEFINED && target_is_writable))
{
ecma_free_property_descriptor (prop_desc_p);
return ecma_raise_type_error (ECMA_ERR_MSG ("The two descriptors are incompatible"));
return ecma_raise_type_error (ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE);
}
}
return ECMA_VALUE_TRUE;
@@ -981,14 +978,12 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object *
{
if (!is_target_ext)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for adding property "
"to the non-extensible target"));
return ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET);
}
if (setting_config_false)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property "
"which is non-existent in the target"));
return ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY);
}
}
/* 20. */
@@ -998,13 +993,11 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object *
if (!ecma_op_is_compatible_property_descriptor (prop_desc_p, &target_desc, is_target_ext))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for adding property that is "
"incompatible with the existing property in the target"));
ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP);
}
else if (setting_config_false && (target_desc.flags & JERRY_PROP_IS_CONFIGURABLE))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property "
"which is configurable in the target"));
ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY);
}
/* ES11: 16.c */
else if ((target_desc.flags & (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)) != 0
@@ -1013,8 +1006,7 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object *
&& (target_desc.flags & (JERRY_PROP_IS_WRITABLE | JERRY_PROP_IS_CONFIGURABLE)) == JERRY_PROP_IS_WRITABLE)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property "
"which is configurable in the target"));
ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY);
}
ecma_free_property_descriptor (&target_desc);
@@ -1110,8 +1102,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */
if (!prop_is_configurable)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned falsish for property which exists "
"in the proxy target as non-configurable"));
return ecma_raise_type_error (ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE);
}
ecma_value_t extensible_target = ecma_builtin_object_object_is_extensible (target_obj_p);
@@ -1123,8 +1114,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */
if (ecma_is_value_false (extensible_target))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned falsish for property but "
"the proxy target is not extensible"));
return ecma_raise_type_error (ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE);
}
}
}
@@ -1209,14 +1199,13 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */
if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)
&& !(target_desc.flags & JERRY_PROP_IS_WRITABLE) && !ecma_op_same_value (trap_result, target_desc.value))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect value is returned by a Proxy 'get' trap"));
ret_value = ecma_raise_type_error (ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP);
}
else if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)
&& (target_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED))
&& target_desc.get_p == NULL && !ecma_is_value_undefined (trap_result))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Property of a Proxy is non-configurable and "
"does not have a getter function"));
ret_value = ecma_raise_type_error (ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER);
}
ecma_free_property_descriptor (&target_desc);
@@ -1303,7 +1292,7 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */
{
if (is_strict)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Proxy trap returned falsish"));
return ecma_raise_type_error (ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH);
}
return ECMA_VALUE_FALSE;
@@ -1333,14 +1322,13 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */
if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)
&& !(target_desc.flags & JERRY_PROP_IS_WRITABLE) && !ecma_op_same_value (value, target_desc.value))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect value is returned by a Proxy 'set' trap"));
ret_value = ecma_raise_type_error (ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP);
}
else if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)
&& (target_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED))
&& target_desc.set_p == NULL)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("The property of a Proxy target is a non "
"configurable accessor without a setter"));
ret_value = ecma_raise_type_error (ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER);
}
ecma_free_property_descriptor (&target_desc);
@@ -1451,15 +1439,14 @@ ecma_proxy_object_delete_property (ecma_object_t *obj_p, /**< proxy object */
/* 15. */
if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for property which is "
"non-configurable in the proxy target"));
ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE);
}
/* ES11: 13-14 */
ecma_value_t extensible_target = ecma_builtin_object_object_is_extensible (target_obj_p);
if (!ecma_is_value_true (extensible_target))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for target is not extensible"));
ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE);
}
ecma_free_property_descriptor (&target_desc);
@@ -1551,7 +1538,7 @@ ecma_proxy_check_invariants_for_own_prop_keys (ecma_collection_t *trap_result,
unchecked_result_keys,
&unchecked_prop_name_counter)))
{
ecma_raise_type_error (ECMA_ERR_MSG ("Trap result did not include all non-configurable keys"));
ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS);
}
/* 22. */
else if (ecma_is_value_true (extensible_target))
@@ -1563,12 +1550,12 @@ ecma_proxy_check_invariants_for_own_prop_keys (ecma_collection_t *trap_result,
unchecked_result_keys,
&unchecked_prop_name_counter)))
{
ecma_raise_type_error (ECMA_ERR_MSG ("Trap result did not include all configurable keys"));
ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS);
}
/* 24. */
else if (unchecked_result_keys->item_count != unchecked_prop_name_counter)
{
ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned extra keys for a non-extensible Proxy target"));
ecma_raise_type_error (ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET);
}
/* 25. */
else
@@ -1649,7 +1636,7 @@ ecma_proxy_object_own_property_keys (ecma_object_t *obj_p) /**< proxy object */
if (ecma_collection_check_duplicated_entries (trap_result))
{
ecma_collection_free (trap_result);
ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned with duplicated entries"));
ecma_raise_type_error (ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES);
return NULL;
}
@@ -1760,7 +1747,7 @@ ecma_proxy_object_call (ecma_object_t *obj_p, /**< proxy object */
if (!ecma_op_proxy_object_is_callable (obj_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function));
return ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION);
}
ECMA_CHECK_STACK_USAGE ();
@@ -1873,7 +1860,7 @@ ecma_proxy_object_construct (ecma_object_t *obj_p, /**< proxy object */
{
ecma_free_value (new_obj);
return ecma_raise_type_error (ECMA_ERR_MSG ("Trap must return with an object"));
return ecma_raise_type_error (ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT);
}
/* 12. */