Replace duplicate ecma definitions (#4637)

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
This commit is contained in:
Tóth Béla
2021-03-31 11:52:33 +02:00
committed by GitHub
parent 6c484f3529
commit 6677fa0a12
23 changed files with 62 additions and 120 deletions
+2 -2
View File
@@ -314,7 +314,7 @@ static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< s
ecma_deref_ecma_string (literal_string_p); ecma_deref_ecma_string (literal_string_p);
ecma_object_t *error_object_p = ecma_new_standard_error (ECMA_ERROR_RANGE, ecma_object_t *error_object_p = ecma_new_standard_error (JERRY_ERROR_RANGE,
ecma_stringbuilder_finalize (&builder)); ecma_stringbuilder_finalize (&builder));
globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p); globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p);
@@ -1008,7 +1008,7 @@ jerry_snapshot_result (const uint32_t *snapshot_p, /**< snapshot */
} }
#if JERRY_PARSER_DUMP_BYTE_CODE #if JERRY_PARSER_DUMP_BYTE_CODE
if (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_SHOW_OPCODES) if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_SHOW_OPCODES)
{ {
util_print_cbc (bytecode_p); util_print_cbc (bytecode_p);
} }
+3 -23
View File
@@ -53,26 +53,6 @@
JERRY_STATIC_ASSERT (sizeof (jerry_value_t) == sizeof (ecma_value_t), JERRY_STATIC_ASSERT (sizeof (jerry_value_t) == sizeof (ecma_value_t),
size_of_jerry_value_t_must_be_equal_to_size_of_ecma_value_t); size_of_jerry_value_t_must_be_equal_to_size_of_ecma_value_t);
JERRY_STATIC_ASSERT ((int) ECMA_ERROR_NONE == (int) JERRY_ERROR_NONE
&& (int) ECMA_ERROR_COMMON == (int) JERRY_ERROR_COMMON
&& (int) ECMA_ERROR_EVAL == (int) JERRY_ERROR_EVAL
&& (int) ECMA_ERROR_RANGE == (int) JERRY_ERROR_RANGE
&& (int) ECMA_ERROR_REFERENCE == (int) JERRY_ERROR_REFERENCE
&& (int) ECMA_ERROR_SYNTAX == (int) JERRY_ERROR_SYNTAX
&& (int) ECMA_ERROR_TYPE == (int) JERRY_ERROR_TYPE
&& (int) ECMA_ERROR_URI == (int) JERRY_ERROR_URI,
ecma_standard_error_t_must_be_equal_to_jerry_error_t);
#if JERRY_BUILTIN_PROMISE
JERRY_STATIC_ASSERT ((int) ECMA_ERROR_AGGREGATE == (int) JERRY_ERROR_AGGREGATE,
ecma_standard_error_t_must_be_equal_to_jerry_error_t);
#endif /* JERRY_BUILTIN_PROMISE */
JERRY_STATIC_ASSERT ((int) ECMA_INIT_EMPTY == (int) JERRY_INIT_EMPTY
&& (int) ECMA_INIT_SHOW_OPCODES == (int) JERRY_INIT_SHOW_OPCODES
&& (int) ECMA_INIT_SHOW_REGEXP_OPCODES == (int) JERRY_INIT_SHOW_REGEXP_OPCODES
&& (int) ECMA_INIT_MEM_STATS == (int) JERRY_INIT_MEM_STATS,
ecma_init_flag_t_must_be_equal_to_jerry_init_flag_t);
JERRY_STATIC_ASSERT ((int) JERRY_PROP_NO_OPTS == (int) ECMA_PROP_NO_OPTS JERRY_STATIC_ASSERT ((int) JERRY_PROP_NO_OPTS == (int) ECMA_PROP_NO_OPTS
&& (int) JERRY_PROP_IS_CONFIGURABLE == (int) ECMA_PROP_IS_CONFIGURABLE && (int) JERRY_PROP_IS_CONFIGURABLE == (int) ECMA_PROP_IS_CONFIGURABLE
&& (int) JERRY_PROP_IS_ENUMERABLE == (int) ECMA_PROP_IS_ENUMERABLE && (int) JERRY_PROP_IS_ENUMERABLE == (int) ECMA_PROP_IS_ENUMERABLE
@@ -1772,7 +1752,7 @@ jerry_get_error_type (jerry_value_t value) /**< api value */
} }
ecma_object_t *object_p = ecma_get_object_from_value (value); ecma_object_t *object_p = ecma_get_object_from_value (value);
ecma_standard_error_t error_type = ecma_get_error_type (object_p); jerry_error_t error_type = ecma_get_error_type (object_p);
return (jerry_error_t) error_type; return (jerry_error_t) error_type;
} /* jerry_get_error_type */ } /* jerry_get_error_type */
@@ -2141,14 +2121,14 @@ jerry_create_error_sz (jerry_error_t error_type, /**< type of error */
if (message_p == NULL || message_size == 0) if (message_p == NULL || message_size == 0)
{ {
return ecma_create_error_object_reference (ecma_new_standard_error ((ecma_standard_error_t) error_type, NULL)); return ecma_create_error_object_reference (ecma_new_standard_error ((jerry_error_t) error_type, NULL));
} }
else else
{ {
ecma_string_t *message_string_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) message_p, ecma_string_t *message_string_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) message_p,
(lit_utf8_size_t) message_size); (lit_utf8_size_t) message_size);
ecma_object_t *error_object_p = ecma_new_standard_error ((ecma_standard_error_t) error_type, ecma_object_t *error_object_p = ecma_new_standard_error ((jerry_error_t) error_type,
message_string_p); message_string_p);
ecma_deref_ecma_string (message_string_p); ecma_deref_ecma_string (message_string_p);
-11
View File
@@ -49,17 +49,6 @@
* @} * @}
*/ */
/**
* JerryScript init flags.
*/
typedef enum
{
ECMA_INIT_EMPTY = (0u), /**< empty flag set */
ECMA_INIT_SHOW_OPCODES = (1u << 0), /**< dump byte-code to log after parse */
ECMA_INIT_SHOW_REGEXP_OPCODES = (1u << 1), /**< dump regexp byte-code to log after compilation */
ECMA_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */
} ecma_init_flag_t;
/** /**
* JerryScript status flags. * JerryScript status flags.
*/ */
-6
View File
@@ -1189,12 +1189,6 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
*prop_desc_p = ecma_make_empty_property_descriptor (); *prop_desc_p = ecma_make_empty_property_descriptor ();
} /* ecma_free_property_descriptor */ } /* ecma_free_property_descriptor */
/**
* The size of error reference must be 8 bytes to use jmem_pools_alloc().
*/
JERRY_STATIC_ASSERT (sizeof (ecma_extended_primitive_t) == 8,
ecma_error_reference_size_must_be_8_bytes);
/** /**
* Increase ref count of an extended primitve value. * Increase ref count of an extended primitve value.
*/ */
@@ -52,7 +52,7 @@ ecma_value_t
ecma_builtin_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_COMMON, arguments_list_p, arguments_list_len); return ecma_builtin_helper_error_dispatch_call (JERRY_ERROR_COMMON, arguments_list_p, arguments_list_len);
} /* ecma_builtin_error_dispatch_call */ } /* ecma_builtin_error_dispatch_call */
/** /**
@@ -54,7 +54,7 @@ ecma_value_t
ecma_builtin_eval_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_eval_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_EVAL, arguments_list_p, arguments_list_len); return ecma_builtin_helper_error_dispatch_call (JERRY_ERROR_EVAL, arguments_list_p, arguments_list_len);
} /* ecma_builtin_eval_error_dispatch_call */ } /* ecma_builtin_eval_error_dispatch_call */
/** /**
@@ -37,7 +37,7 @@
* @return ecma value * @return ecma value
*/ */
ecma_value_t ecma_value_t
ecma_builtin_helper_error_dispatch_call (ecma_standard_error_t error_type, /**< native error type */ ecma_builtin_helper_error_dispatch_call (jerry_error_t error_type, /**< native error type */
const ecma_value_t *arguments_list_p, /**< arguments list */ const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
@@ -229,7 +229,7 @@ ecma_builtin_helper_json_create_non_formatted_json (lit_utf8_byte_t left_bracket
/* ecma-builtin-helper-error.c */ /* ecma-builtin-helper-error.c */
ecma_value_t ecma_value_t
ecma_builtin_helper_error_dispatch_call (ecma_standard_error_t error_type, const ecma_value_t *arguments_list_p, ecma_builtin_helper_error_dispatch_call (jerry_error_t error_type, const ecma_value_t *arguments_list_p,
uint32_t arguments_list_len); uint32_t arguments_list_len);
/* ecma-builtin-helpers-sort.c */ /* ecma-builtin-helpers-sort.c */
@@ -54,7 +54,7 @@ ecma_value_t
ecma_builtin_range_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_range_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_RANGE, arguments_list_p, arguments_list_len); return ecma_builtin_helper_error_dispatch_call (JERRY_ERROR_RANGE, arguments_list_p, arguments_list_len);
} /* ecma_builtin_range_error_dispatch_call */ } /* ecma_builtin_range_error_dispatch_call */
/** /**
@@ -54,7 +54,7 @@ ecma_value_t
ecma_builtin_reference_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_reference_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_REFERENCE, arguments_list_p, arguments_list_len); return ecma_builtin_helper_error_dispatch_call (JERRY_ERROR_REFERENCE, arguments_list_p, arguments_list_len);
} /* ecma_builtin_reference_error_dispatch_call */ } /* ecma_builtin_reference_error_dispatch_call */
/** /**
@@ -54,7 +54,7 @@ ecma_value_t
ecma_builtin_syntax_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_syntax_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_SYNTAX, arguments_list_p, arguments_list_len); return ecma_builtin_helper_error_dispatch_call (JERRY_ERROR_SYNTAX, arguments_list_p, arguments_list_len);
} /* ecma_builtin_syntax_error_dispatch_call */ } /* ecma_builtin_syntax_error_dispatch_call */
/** /**
@@ -54,7 +54,7 @@ ecma_value_t
ecma_builtin_type_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_type_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_TYPE, arguments_list_p, arguments_list_len); return ecma_builtin_helper_error_dispatch_call (JERRY_ERROR_TYPE, arguments_list_p, arguments_list_len);
} /* ecma_builtin_type_error_dispatch_call */ } /* ecma_builtin_type_error_dispatch_call */
/** /**
@@ -54,7 +54,7 @@ ecma_value_t
ecma_builtin_uri_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */ ecma_builtin_uri_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
uint32_t arguments_list_len) /**< number of arguments */ uint32_t arguments_list_len) /**< number of arguments */
{ {
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_URI, arguments_list_p, arguments_list_len); return ecma_builtin_helper_error_dispatch_call (JERRY_ERROR_URI, arguments_list_p, arguments_list_len);
} /* ecma_builtin_uri_error_dispatch_call */ } /* ecma_builtin_uri_error_dispatch_call */
/** /**
@@ -574,7 +574,7 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */
} }
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
ecma_raise_standard_error_with_format (ECMA_ERROR_TYPE, ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE,
"Expected a % object", "Expected a % object",
ecma_make_string_value (ecma_get_magic_string (lit_id))); ecma_make_string_value (ecma_get_magic_string (lit_id)));
#else /* !JERRY_ERROR_MESSAGES */ #else /* !JERRY_ERROR_MESSAGES */
+34 -34
View File
@@ -43,7 +43,7 @@
*/ */
typedef struct typedef struct
{ {
ecma_standard_error_t error_type; /**< Native error type */ jerry_error_t error_type; /**< Native error type */
ecma_builtin_id_t error_prototype_id; /**< ID of the error prototype */ ecma_builtin_id_t error_prototype_id; /**< ID of the error prototype */
} ecma_error_mapping_t; } ecma_error_mapping_t;
@@ -53,17 +53,17 @@ typedef struct
const ecma_error_mapping_t ecma_error_mappings[] = const ecma_error_mapping_t ecma_error_mappings[] =
{ {
#define ERROR_ELEMENT(TYPE, ID) { TYPE, ID } #define ERROR_ELEMENT(TYPE, ID) { TYPE, ID }
ERROR_ELEMENT (ECMA_ERROR_COMMON, ECMA_BUILTIN_ID_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_COMMON, ECMA_BUILTIN_ID_ERROR_PROTOTYPE),
#if JERRY_BUILTIN_ERRORS #if JERRY_BUILTIN_ERRORS
ERROR_ELEMENT (ECMA_ERROR_EVAL, ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_EVAL, ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE),
ERROR_ELEMENT (ECMA_ERROR_RANGE, ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_RANGE, ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE),
ERROR_ELEMENT (ECMA_ERROR_REFERENCE, ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_REFERENCE, ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE),
ERROR_ELEMENT (ECMA_ERROR_TYPE, ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_TYPE, ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE),
ERROR_ELEMENT (ECMA_ERROR_URI, ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_URI, ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE),
ERROR_ELEMENT (ECMA_ERROR_SYNTAX, ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_SYNTAX, ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE),
#if JERRY_BUILTIN_PROMISE #if JERRY_BUILTIN_PROMISE
ERROR_ELEMENT (ECMA_ERROR_AGGREGATE, ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE), ERROR_ELEMENT (JERRY_ERROR_AGGREGATE, ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE),
#endif /* JERRY_BUILTIN_PROMISE */ #endif /* JERRY_BUILTIN_PROMISE */
#endif /* JERRY_BUILTIN_ERRORS */ #endif /* JERRY_BUILTIN_ERRORS */
@@ -77,14 +77,14 @@ const ecma_error_mapping_t ecma_error_mappings[] =
* message_string_p can be NULL. * message_string_p can be NULL.
* *
* Note: * Note:
* calling with ECMA_ERROR_NONE does not make sense thus it will * calling with JERRY_ERROR_NONE does not make sense thus it will
* cause a fault in the system. * cause a fault in the system.
* *
* @return pointer to ecma-object representing specified error * @return pointer to ecma-object representing specified error
* with reference counter set to one. * with reference counter set to one.
*/ */
ecma_object_t * ecma_object_t *
ecma_new_standard_error (ecma_standard_error_t error_type, /**< native error type */ ecma_new_standard_error (jerry_error_t error_type, /**< native error type */
ecma_string_t *message_string_p) /**< message string */ ecma_string_t *message_string_p) /**< message string */
{ {
#if JERRY_BUILTIN_ERRORS #if JERRY_BUILTIN_ERRORS
@@ -92,44 +92,44 @@ ecma_new_standard_error (ecma_standard_error_t error_type, /**< native error typ
switch (error_type) switch (error_type)
{ {
case ECMA_ERROR_EVAL: case JERRY_ERROR_EVAL:
{ {
prototype_id = ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE;
break; break;
} }
case ECMA_ERROR_RANGE: case JERRY_ERROR_RANGE:
{ {
prototype_id = ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE;
break; break;
} }
case ECMA_ERROR_REFERENCE: case JERRY_ERROR_REFERENCE:
{ {
prototype_id = ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE;
break; break;
} }
case ECMA_ERROR_TYPE: case JERRY_ERROR_TYPE:
{ {
prototype_id = ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE;
break; break;
} }
#if JERRY_BUILTIN_PROMISE #if JERRY_BUILTIN_PROMISE
case ECMA_ERROR_AGGREGATE: case JERRY_ERROR_AGGREGATE:
{ {
prototype_id = ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE;
break; break;
} }
#endif /* JERRY_BUILTIN_PROMISE */ #endif /* JERRY_BUILTIN_PROMISE */
case ECMA_ERROR_URI: case JERRY_ERROR_URI:
{ {
prototype_id = ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE;
break; break;
} }
case ECMA_ERROR_SYNTAX: case JERRY_ERROR_SYNTAX:
{ {
prototype_id = ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE;
break; break;
@@ -137,7 +137,7 @@ ecma_new_standard_error (ecma_standard_error_t error_type, /**< native error typ
default: default:
{ {
JERRY_ASSERT (error_type == ECMA_ERROR_COMMON); JERRY_ASSERT (error_type == JERRY_ERROR_COMMON);
prototype_id = ECMA_BUILTIN_ID_ERROR_PROTOTYPE; prototype_id = ECMA_BUILTIN_ID_ERROR_PROTOTYPE;
break; break;
@@ -220,12 +220,12 @@ ecma_new_aggregate_error (ecma_value_t error_list_val, /**< errors list */
return ECMA_VALUE_ERROR; return ECMA_VALUE_ERROR;
} }
new_error_object_p = ecma_new_standard_error (ECMA_ERROR_AGGREGATE, message_string_p); new_error_object_p = ecma_new_standard_error (JERRY_ERROR_AGGREGATE, message_string_p);
ecma_deref_ecma_string (message_string_p); ecma_deref_ecma_string (message_string_p);
} }
else else
{ {
new_error_object_p = ecma_new_standard_error (ECMA_ERROR_AGGREGATE, NULL); new_error_object_p = ecma_new_standard_error (JERRY_ERROR_AGGREGATE, NULL);
} }
ecma_value_t using_iterator = ecma_op_get_method_by_symbol_id (error_list_val, LIT_GLOBAL_SYMBOL_ITERATOR); ecma_value_t using_iterator = ecma_op_get_method_by_symbol_id (error_list_val, LIT_GLOBAL_SYMBOL_ITERATOR);
@@ -308,15 +308,15 @@ ecma_new_aggregate_error (ecma_value_t error_list_val, /**< errors list */
/** /**
* Return the error type for an Error object. * Return the error type for an Error object.
* *
* @return one of the ecma_standard_error_t value * @return one of the jerry_error_t value
* if it is not an Error object then ECMA_ERROR_NONE will be returned * if it is not an Error object then JERRY_ERROR_NONE will be returned
*/ */
ecma_standard_error_t jerry_error_t
ecma_get_error_type (ecma_object_t *error_object) /**< possible error object */ ecma_get_error_type (ecma_object_t *error_object) /**< possible error object */
{ {
if (error_object->u2.prototype_cp == JMEM_CP_NULL || ECMA_OBJECT_IS_PROXY (error_object)) if (error_object->u2.prototype_cp == JMEM_CP_NULL || ECMA_OBJECT_IS_PROXY (error_object))
{ {
return ECMA_ERROR_NONE; return JERRY_ERROR_NONE;
} }
ecma_object_t *prototype_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, error_object->u2.prototype_cp); ecma_object_t *prototype_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, error_object->u2.prototype_cp);
@@ -331,7 +331,7 @@ ecma_get_error_type (ecma_object_t *error_object) /**< possible error object */
} }
} }
return ECMA_ERROR_NONE; return JERRY_ERROR_NONE;
} /* ecma_get_error_type */ } /* ecma_get_error_type */
/** /**
@@ -341,7 +341,7 @@ ecma_get_error_type (ecma_object_t *error_object) /**< possible error object */
* Returned value must be freed with ecma_free_value * Returned value must be freed with ecma_free_value
*/ */
static ecma_value_t static ecma_value_t
ecma_raise_standard_error (ecma_standard_error_t error_type, /**< error type */ ecma_raise_standard_error (jerry_error_t error_type, /**< error type */
const lit_utf8_byte_t *msg_p) /**< error message */ const lit_utf8_byte_t *msg_p) /**< error message */
{ {
ecma_object_t *error_obj_p; ecma_object_t *error_obj_p;
@@ -371,7 +371,7 @@ ecma_raise_standard_error (ecma_standard_error_t error_type, /**< error type */
* Returned value must be freed with ecma_free_value * Returned value must be freed with ecma_free_value
*/ */
ecma_value_t ecma_value_t
ecma_raise_standard_error_with_format (ecma_standard_error_t error_type, /**< error type */ ecma_raise_standard_error_with_format (jerry_error_t error_type, /**< error type */
const char *format, /**< format string */ const char *format, /**< format string */
...) /**< ecma-values */ ...) /**< ecma-values */
{ {
@@ -459,7 +459,7 @@ ecma_raise_standard_error_with_format (ecma_standard_error_t error_type, /**< er
ecma_value_t ecma_value_t
ecma_raise_common_error (const char *msg_p) /**< error message */ ecma_raise_common_error (const char *msg_p) /**< error message */
{ {
return ecma_raise_standard_error (ECMA_ERROR_COMMON, (const lit_utf8_byte_t *) msg_p); return ecma_raise_standard_error (JERRY_ERROR_COMMON, (const lit_utf8_byte_t *) msg_p);
} /* ecma_raise_common_error */ } /* ecma_raise_common_error */
/** /**
@@ -473,7 +473,7 @@ ecma_raise_common_error (const char *msg_p) /**< error message */
ecma_value_t ecma_value_t
ecma_raise_range_error (const char *msg_p) /**< error message */ ecma_raise_range_error (const char *msg_p) /**< error message */
{ {
return ecma_raise_standard_error (ECMA_ERROR_RANGE, (const lit_utf8_byte_t *) msg_p); return ecma_raise_standard_error (JERRY_ERROR_RANGE, (const lit_utf8_byte_t *) msg_p);
} /* ecma_raise_range_error */ } /* ecma_raise_range_error */
/** /**
@@ -487,7 +487,7 @@ ecma_raise_range_error (const char *msg_p) /**< error message */
ecma_value_t ecma_value_t
ecma_raise_reference_error (const char *msg_p) /**< error message */ ecma_raise_reference_error (const char *msg_p) /**< error message */
{ {
return ecma_raise_standard_error (ECMA_ERROR_REFERENCE, (const lit_utf8_byte_t *) msg_p); return ecma_raise_standard_error (JERRY_ERROR_REFERENCE, (const lit_utf8_byte_t *) msg_p);
} /* ecma_raise_reference_error */ } /* ecma_raise_reference_error */
/** /**
@@ -501,7 +501,7 @@ ecma_raise_reference_error (const char *msg_p) /**< error message */
ecma_value_t ecma_value_t
ecma_raise_syntax_error (const char *msg_p) /**< error message */ ecma_raise_syntax_error (const char *msg_p) /**< error message */
{ {
return ecma_raise_standard_error (ECMA_ERROR_SYNTAX, (const lit_utf8_byte_t *) msg_p); return ecma_raise_standard_error (JERRY_ERROR_SYNTAX, (const lit_utf8_byte_t *) msg_p);
} /* ecma_raise_syntax_error */ } /* ecma_raise_syntax_error */
/** /**
@@ -515,7 +515,7 @@ ecma_raise_syntax_error (const char *msg_p) /**< error message */
ecma_value_t ecma_value_t
ecma_raise_type_error (const char *msg_p) /**< error message */ ecma_raise_type_error (const char *msg_p) /**< error message */
{ {
return ecma_raise_standard_error (ECMA_ERROR_TYPE, (const lit_utf8_byte_t *) msg_p); return ecma_raise_standard_error (JERRY_ERROR_TYPE, (const lit_utf8_byte_t *) msg_p);
} /* ecma_raise_type_error */ } /* ecma_raise_type_error */
/** /**
@@ -529,7 +529,7 @@ ecma_raise_type_error (const char *msg_p) /**< error message */
ecma_value_t ecma_value_t
ecma_raise_uri_error (const char *msg_p) /**< error message */ ecma_raise_uri_error (const char *msg_p) /**< error message */
{ {
return ecma_raise_standard_error (ECMA_ERROR_URI, (const lit_utf8_byte_t *) msg_p); return ecma_raise_standard_error (JERRY_ERROR_URI, (const lit_utf8_byte_t *) msg_p);
} /* ecma_raise_uri_error */ } /* ecma_raise_uri_error */
#if JERRY_BUILTIN_PROMISE #if JERRY_BUILTIN_PROMISE
+3 -24
View File
@@ -32,31 +32,10 @@
#define ECMA_ERR_MSG(msg) NULL #define ECMA_ERR_MSG(msg) NULL
#endif /* JERRY_ERROR_MESSAGES */ #endif /* JERRY_ERROR_MESSAGES */
/** jerry_error_t ecma_get_error_type (ecma_object_t *error_object);
* Native errors. ecma_object_t *ecma_new_standard_error (jerry_error_t error_type, ecma_string_t *message_string_p);
*
* See also: 15.11.1, 15.11.6
*/
typedef enum
{
ECMA_ERROR_NONE, /**< Not an Error */
ECMA_ERROR_COMMON, /**< Error */
ECMA_ERROR_EVAL, /**< EvalError */
ECMA_ERROR_RANGE, /**< RangeError */
ECMA_ERROR_REFERENCE, /**< ReferenceError */
ECMA_ERROR_SYNTAX, /**< SyntaxError */
ECMA_ERROR_TYPE, /**< TypeError */
ECMA_ERROR_URI, /**< URIError */
#if JERRY_BUILTIN_PROMISE
ECMA_ERROR_AGGREGATE, /**< AggregateError */
#endif /* JERRY_BUILTIN_PROMISE */
} ecma_standard_error_t;
ecma_standard_error_t ecma_get_error_type (ecma_object_t *error_object);
ecma_object_t *ecma_new_standard_error (ecma_standard_error_t error_type, ecma_string_t *message_string_p);
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
ecma_value_t ecma_raise_standard_error_with_format (ecma_standard_error_t error_type, const char *msg_p, ...); ecma_value_t ecma_raise_standard_error_with_format (jerry_error_t error_type, const char *msg_p, ...);
#endif /* JERRY_ERROR_MESSAGES */ #endif /* JERRY_ERROR_MESSAGES */
ecma_value_t ecma_raise_common_error (const char *msg_p); ecma_value_t ecma_raise_common_error (const char *msg_p);
ecma_value_t ecma_raise_range_error (const char *msg_p); ecma_value_t ecma_raise_range_error (const char *msg_p);
@@ -109,7 +109,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
*ref_base_lex_env_p = NULL; *ref_base_lex_env_p = NULL;
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
return ecma_raise_standard_error_with_format (ECMA_ERROR_REFERENCE, return ecma_raise_standard_error_with_format (JERRY_ERROR_REFERENCE,
"% is not defined", "% is not defined",
ecma_make_string_value (name_p)); ecma_make_string_value (name_p));
#else /* JERRY_ERROR_MESSAGES */ #else /* JERRY_ERROR_MESSAGES */
@@ -309,7 +309,7 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
if (is_strict) if (is_strict)
{ {
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
return ecma_raise_standard_error_with_format (ECMA_ERROR_REFERENCE, return ecma_raise_standard_error_with_format (JERRY_ERROR_REFERENCE,
"% is not defined", "% is not defined",
ecma_make_string_value (name_p)); ecma_make_string_value (name_p));
#else /* !JERRY_ERROR_MESSAGES */ #else /* !JERRY_ERROR_MESSAGES */
+1 -1
View File
@@ -32,7 +32,7 @@
* Reject with TypeError depending on 'is_throw' with the given format * Reject with TypeError depending on 'is_throw' with the given format
*/ */
#define ECMA_REJECT_WITH_FORMAT(is_throw, msg, ...) \ #define ECMA_REJECT_WITH_FORMAT(is_throw, msg, ...) \
((is_throw) ? ecma_raise_standard_error_with_format (ECMA_ERROR_TYPE, (msg), __VA_ARGS__) : ECMA_VALUE_FALSE) ((is_throw) ? ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE, (msg), __VA_ARGS__) : ECMA_VALUE_FALSE)
/** /**
* Reject with TypeError depending on 'is_throw' with the given message * Reject with TypeError depending on 'is_throw' with the given message
+1 -1
View File
@@ -385,7 +385,7 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
ecma_value_t name_val = ecma_make_string_value (name_p); ecma_value_t name_val = ecma_make_string_value (name_p);
ecma_value_t error_value = ecma_raise_standard_error_with_format (ECMA_ERROR_REFERENCE, ecma_value_t error_value = ecma_raise_standard_error_with_format (JERRY_ERROR_REFERENCE,
"% is not defined", "% is not defined",
name_val); name_val);
#else /* JERRY_ERROR_MESSAGES */ #else /* JERRY_ERROR_MESSAGES */
+1 -1
View File
@@ -161,7 +161,7 @@ jmem_finalize (void)
jmem_pools_finalize (); jmem_pools_finalize ();
#if JERRY_MEM_STATS #if JERRY_MEM_STATS
if (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_MEM_STATS) if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_MEM_STATS)
{ {
jmem_heap_stats_print (); jmem_heap_stats_print ();
} }
+2 -2
View File
@@ -1897,7 +1897,7 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
#endif /* !JERRY_NDEBUG */ #endif /* !JERRY_NDEBUG */
#if JERRY_PARSER_DUMP_BYTE_CODE #if JERRY_PARSER_DUMP_BYTE_CODE
context.is_show_opcodes = (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_SHOW_OPCODES); context.is_show_opcodes = (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_SHOW_OPCODES);
context.total_byte_code_size = 0; context.total_byte_code_size = 0;
if (context.is_show_opcodes) if (context.is_show_opcodes)
@@ -2122,7 +2122,7 @@ parser_parse_source (const uint8_t *arg_list_p, /**< function argument list */
ecma_value_t line_str_val = ecma_make_uint32_value (context.token.line); ecma_value_t line_str_val = ecma_make_uint32_value (context.token.line);
ecma_value_t col_str_val = ecma_make_uint32_value (context.token.column); ecma_value_t col_str_val = ecma_make_uint32_value (context.token.column);
ecma_raise_standard_error_with_format (ECMA_ERROR_SYNTAX, ecma_raise_standard_error_with_format (JERRY_ERROR_SYNTAX,
"% [%:%:%]", "% [%:%:%]",
err_str_val, err_str_val,
context.resource_name, context.resource_name,
+1 -1
View File
@@ -155,7 +155,7 @@ re_compile_bytecode (ecma_string_t *pattern_str_p, /**< pattern */
re_compiled_code_p->non_captures_count = re_ctx.non_captures_count; re_compiled_code_p->non_captures_count = re_ctx.non_captures_count;
#if JERRY_REGEXP_DUMP_BYTE_CODE #if JERRY_REGEXP_DUMP_BYTE_CODE
if (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_SHOW_REGEXP_OPCODES) if (JERRY_CONTEXT (jerry_init_flags) & JERRY_INIT_SHOW_REGEXP_OPCODES)
{ {
re_dump_bytecode (&re_ctx); re_dump_bytecode (&re_ctx);
} }
+2 -2
View File
@@ -118,7 +118,7 @@ vm_op_get_value (ecma_value_t object, /**< base object */
if (JERRY_UNLIKELY (ecma_is_value_undefined (object) || ecma_is_value_null (object))) if (JERRY_UNLIKELY (ecma_is_value_undefined (object) || ecma_is_value_null (object)))
{ {
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
ecma_value_t error_value = ecma_raise_standard_error_with_format (ECMA_ERROR_TYPE, ecma_value_t error_value = ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE,
"Cannot read property '%' of %", "Cannot read property '%' of %",
property, property,
object); object);
@@ -165,7 +165,7 @@ vm_op_set_value (ecma_value_t base, /**< base object */
if (JERRY_UNLIKELY (ecma_is_value_null (base) || ecma_is_value_undefined (base))) if (JERRY_UNLIKELY (ecma_is_value_null (base) || ecma_is_value_undefined (base)))
{ {
#if JERRY_ERROR_MESSAGES #if JERRY_ERROR_MESSAGES
result = ecma_raise_standard_error_with_format (ECMA_ERROR_TYPE, result = ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE,
"Cannot set property '%' of %", "Cannot set property '%' of %",
property, property,
base); base);