diff --git a/docs/02.API-REFERENCE.md b/docs/02.API-REFERENCE.md index 10c4c9d197..be1da0a437 100644 --- a/docs/02.API-REFERENCE.md +++ b/docs/02.API-REFERENCE.md @@ -324,7 +324,7 @@ Flags for [jerry_exec_snapshot](#jerry_exec_snapshot) functions: - JERRY_SNAPSHOT_EXEC_COPY_DATA - copy snapshot data into memory (see below) - JERRY_SNAPSHOT_EXEC_ALLOW_STATIC - allow executing static snapshots - JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION - load snapshot as function instead of executing it - - JERRY_SNAPSHOT_EXEC_HAS_RESOURCE - `source_name` field is valid + - JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME - `source_name` field is valid in [jerry_exec_snapshot_option_values_t](#jerry_exec_snapshot_option_values_t) - JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE - `user_value` field is valid in [jerry_exec_snapshot_option_values_t](#jerry_exec_snapshot_option_values_t) @@ -560,7 +560,7 @@ typedef struct uint32_t options; /**< combination of jerry_parse_option_enable_feature_t values */ jerry_value_t argument_list; /**< function argument list if JERRY_PARSE_HAS_ARGUMENT_LIST is set in options * Note: must be string value */ - jerry_value_t source_name; /**< resource name string (usually a file name) + jerry_value_t source_name; /**< source name string (usually a file name) * if JERRY_PARSE_HAS_SOURCE_NAME is set in options * Note: must be string value */ uint32_t start_line; /**< start line of the source code if JERRY_PARSE_HAS_START is set in options */ @@ -626,7 +626,7 @@ Source code location data retrieved by ```c typedef struct { - jerry_value_t source_name; /**< resource name */ + jerry_value_t source_name; /**< source name */ jerry_size_t line; /**< line index */ jerry_size_t column; /**< column index */ } jerry_frame_location_t; @@ -1398,8 +1398,8 @@ Various configuration options for [jerry_exec_snapshot](#jerry_exec_snapshot) ```c typedef struct { - jerry_value_t source_name; /**< resource name string (usually a file name) - * if JERRY_SNAPSHOT_EXEC_HAS_RESOURCE is set in exec_snapshot_opts + jerry_value_t source_name; /**< source name string (usually a file name) + * if JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME is set in exec_snapshot_opts * Note: non-string values are ignored */ jerry_value_t user_value; /**< user value assigned to all functions created by this script including * eval calls executed by the script if JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE @@ -11575,7 +11575,7 @@ main (void) **Summary** -Get the resource name (usually a file name) of the currently executed script or the given function object. +Get the source name (usually a file name) of the currently executed script or the given function object. This function is typically called from native callbacks. @@ -11592,17 +11592,17 @@ is no longer needed. jerry_value_t jerry_source_name (jerry_value_t value); ``` -- `value` - api value to obtain the resource name from +- `value` - api value to obtain the source name from - return string value constructed from - - the currently executed function object's resource name, if the given value is undefined - - resource name of the function object, if the given value is a function object + - the currently executed function object's source name, if the given value is undefined + - source name of the function object, if the given value is a function object - "", otherwise *New in version 2.2*. **Example** -[doctest]: # (name="02.API-REFERENCE-jsresourcename.c") +[doctest]: # (name="02.API-REFERENCE-jssourcename.c") ```c #include @@ -11628,10 +11628,10 @@ main (void) jerry_value_t global = jerry_current_realm (); - /* Register the "resourceName" method. */ + /* Register the sourceName" method. */ { jerry_value_t func = jerry_function_external (source_name_handler); - jerry_value_t name = jerry_string_sz ("resourceName"); + jerry_value_t name = jerry_string_sz ("sourceName"); jerry_value_t result = jerry_object_set (global, name, func); jerry_value_free (result); jerry_value_free (name); @@ -11640,7 +11640,7 @@ main (void) jerry_value_free (global); - const jerry_char_t source[] = "function myFunction() { return resourceName() }; myFunction()"; + const jerry_char_t source[] = "function myFunction() { return sourceName() }; myFunction()"; jerry_parse_options_t parse_options; parse_options.options = JERRY_PARSE_HAS_SOURCE_NAME; diff --git a/docs/07.DEBUGGER.md b/docs/07.DEBUGGER.md index ddf6aff86a..b3552aad70 100644 --- a/docs/07.DEBUGGER.md +++ b/docs/07.DEBUGGER.md @@ -74,8 +74,8 @@ Currently, `jerryx_debugger_rp_create ()` for raw packet transport layer and `jerryx_debugger_serial_create (const char* config)` for serial protocol are also available.) -The resource name provided to `jerry_parse ()` is used by the client -to identify the resource name of the source code. This resource name +The source name provided to `jerry_parse ()` is used by the client +to identify the source name of the source code. This source name is usually a file name. ## JerryScript debugger C-API interface @@ -103,8 +103,8 @@ typedef jerry_value_t size_t source_size, void *user_p); ``` -- `source_name_p` - resource (usually a file) name of the source code -- `source_name_size` - size of resource name +- `source_name_p` - source (usually a file) name of the source code +- `source_name_size` - size of source name - `source_p` - source code character data - `source_size` - size of source code - `user_p` - custom pointer passed to [jerry_debugger_wait_for_client_source](#jerry_debugger_wait_for_client_source) @@ -306,8 +306,8 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t * Runs the source code received by jerry_debugger_wait_for_client_source. */ static jerry_value_t -wait_for_source_callback (const jerry_char_t *source_name_p, /**< resource name */ - size_t source_name_size, /**< size of resource name */ +wait_for_source_callback (const jerry_char_t *source_name_p, /**< source name */ + size_t source_name_size, /**< size of source name */ const jerry_char_t *source_p, /**< source code */ size_t source_size, /**< source code size */ void *user_p /**< user pointer */) diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c index c57115747c..b9ae0b3a5a 100644 --- a/jerry-core/api/jerry-snapshot.c +++ b/jerry-core/api/jerry-snapshot.c @@ -643,10 +643,10 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th } #endif /* JERRY_ESNEXT */ -#if JERRY_RESOURCE_NAME - /* resource name */ +#if JERRY_SOURCE_NAME + /* source name */ extra_bytes += (uint32_t) sizeof (ecma_value_t); -#endif /* JERRY_RESOURCE_NAME */ +#endif /* JERRY_SOURCE_NAME */ new_code_size = JERRY_ALIGNUP (new_code_size + extra_bytes, JMEM_ALIGNMENT); @@ -880,7 +880,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */ uint32_t allowed_opts = (JERRY_SNAPSHOT_EXEC_COPY_DATA | JERRY_SNAPSHOT_EXEC_ALLOW_STATIC | JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION - | JERRY_SNAPSHOT_EXEC_HAS_RESOURCE | JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE); + | JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME | JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE); if ((exec_snapshot_opts & ~(allowed_opts)) != 0) { @@ -955,10 +955,10 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */ script_p->realm_p = (ecma_object_t *) JERRY_CONTEXT (global_object_p); #endif /* JERRY_BUILTIN_REALMS */ -#if JERRY_RESOURCE_NAME - ecma_value_t source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON); +#if JERRY_SOURCE_NAME + ecma_value_t source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); - if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_RESOURCE) && option_values_p != NULL + if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME) && option_values_p != NULL && ecma_is_value_string (option_values_p->source_name) > 0) { ecma_ref_ecma_string (ecma_get_string_from_value (option_values_p->source_name)); @@ -966,7 +966,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */ } script_p->source_name = source_name; -#endif /* JERRY_RESOURCE_NAME */ +#endif /* JERRY_SOURCE_NAME */ #if JERRY_FUNCTION_TO_STRING script_p->source_code = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY); diff --git a/jerry-core/api/jerryscript.c b/jerry-core/api/jerryscript.c index 0c6ea3d232..6f78dca5c7 100644 --- a/jerry-core/api/jerryscript.c +++ b/jerry-core/api/jerryscript.c @@ -5364,19 +5364,19 @@ jerry_frame_is_strict (jerry_frame_t *frame_p) /**< frame pointer */ } /* jerry_frame_is_strict */ /** - * Get the resource name (usually a file name) of the currently executed script or the given function object + * Get the source name (usually a file name) of the currently executed script or the given function object * * Note: returned value must be freed with jerry_value_free, when it is no longer needed * * @return JS string constructed from - * - the currently executed function object's resource name, if the given value is undefined - * - resource name of the function object, if the given value is a function object + * - the currently executed function object's source name, if the given value is undefined + * - source name of the function object, if the given value is a function object * - "", otherwise */ jerry_value_t jerry_source_name (const jerry_value_t value) /**< jerry api value */ { -#if JERRY_RESOURCE_NAME +#if JERRY_SOURCE_NAME if (ecma_is_value_undefined (value) && JERRY_CONTEXT (vm_top_context_p) != NULL) { return ecma_copy_value (ecma_get_source_name (JERRY_CONTEXT (vm_top_context_p)->shared_p->bytecode_header_p)); @@ -5386,16 +5386,16 @@ jerry_source_name (const jerry_value_t value) /**< jerry api value */ if (script_value == JMEM_CP_NULL) { - return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON); + return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); } const cbc_script_t *script_p = ECMA_GET_INTERNAL_VALUE_POINTER (cbc_script_t, script_value); return ecma_copy_value (script_p->source_name); -#else /* !JERRY_RESOURCE_NAME */ +#else /* !JERRY_SOURCE_NAME */ JERRY_UNUSED (value); - return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON); -#endif /* JERRY_RESOURCE_NAME */ + return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); +#endif /* JERRY_SOURCE_NAME */ } /* jerry_source_name */ /** diff --git a/jerry-core/config.h b/jerry-core/config.h index 4df0f9ecf3..7444fd9a40 100644 --- a/jerry-core/config.h +++ b/jerry-core/config.h @@ -716,12 +716,12 @@ #endif /* JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT */ /** - * Resource name related types into a single guard + * Source name related types into a single guard */ #if JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM -#define JERRY_RESOURCE_NAME 1 +#define JERRY_SOURCE_NAME 1 #else /* !(JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM) */ -#define JERRY_RESOURCE_NAME 0 +#define JERRY_SOURCE_NAME 0 #endif /* JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM */ #endif /* !JERRYSCRIPT_CONFIG_H */ diff --git a/jerry-core/ecma/base/ecma-helpers.c b/jerry-core/ecma/base/ecma-helpers.c index fc87744667..95fd4f4897 100644 --- a/jerry-core/ecma/base/ecma-helpers.c +++ b/jerry-core/ecma/base/ecma-helpers.c @@ -1433,9 +1433,9 @@ ecma_script_deref (ecma_value_t script_value) /**< script value */ } } -#if JERRY_RESOURCE_NAME +#if JERRY_SOURCE_NAME ecma_deref_ecma_string (ecma_get_string_from_value (script_p->source_name)); -#endif /* JERRY_RESOURCE_NAME */ +#endif /* JERRY_SOURCE_NAME */ #if JERRY_MODULE_SYSTEM if (type & CBC_SCRIPT_HAS_IMPORT_META) @@ -1773,27 +1773,27 @@ ecma_compiled_code_get_line_info (const ecma_compiled_code_t *bytecode_header_p) #endif /* JERRY_LINE_INFO */ /** - * Get the resource name of a compiled code. + * Get the source name of a compiled code. * - * @return resource name value + * @return source name value */ ecma_value_t ecma_get_source_name (const ecma_compiled_code_t *bytecode_p) /**< compiled code */ { -#if JERRY_RESOURCE_NAME +#if JERRY_SOURCE_NAME #if JERRY_SNAPSHOT_EXEC if (JERRY_UNLIKELY (bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)) { - return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON); + return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); } #endif /* JERRY_SNAPSHOT_EXEC */ ecma_value_t script_value = ((cbc_uint8_arguments_t *) bytecode_p)->script_value; return ECMA_GET_INTERNAL_VALUE_POINTER (cbc_script_t, script_value)->source_name; -#else /* !JERRY_RESOURCE_NAME */ +#else /* !JERRY_SOURCE_NAME */ JERRY_UNUSED (bytecode_p); - return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON); -#endif /* !JERRY_RESOURCE_NAME */ + return ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); +#endif /* !JERRY_SOURCE_NAME */ } /* ecma_get_source_name */ #if (JERRY_STACK_LIMIT != 0) diff --git a/jerry-core/ecma/operations/ecma-function-object.c b/jerry-core/ecma/operations/ecma-function-object.c index c641e3312e..3a5c6faacb 100644 --- a/jerry-core/ecma/operations/ecma-function-object.c +++ b/jerry-core/ecma/operations/ecma-function-object.c @@ -47,7 +47,7 @@ * * See also: ECMAScript v6, 9.2.1.1 * - * @return resource name as ecma-string + * @return source name as ecma-string */ ecma_value_t ecma_op_function_form_name (ecma_string_t *prop_name_p, /**< property name */ diff --git a/jerry-core/include/jerryscript-debugger.h b/jerry-core/include/jerryscript-debugger.h index ea128cf28a..6d5dec89b8 100644 --- a/jerry-core/include/jerryscript-debugger.h +++ b/jerry-core/include/jerryscript-debugger.h @@ -43,7 +43,7 @@ typedef enum /** * Callback for jerry_debugger_wait_and_run_client_source * - * The callback receives the resource name, source code and a user pointer. + * The callback receives the source name, source code and a user pointer. * * @return this value is passed back by jerry_debugger_wait_and_run_client_source */ diff --git a/jerry-core/include/jerryscript-snapshot.h b/jerry-core/include/jerryscript-snapshot.h index 93ad9579b8..82ef093df7 100644 --- a/jerry-core/include/jerryscript-snapshot.h +++ b/jerry-core/include/jerryscript-snapshot.h @@ -45,8 +45,8 @@ typedef enum JERRY_SNAPSHOT_EXEC_COPY_DATA = (1u << 0), /**< copy snashot data */ JERRY_SNAPSHOT_EXEC_ALLOW_STATIC = (1u << 1), /**< static snapshots allowed */ JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION = (1u << 2), /**< load snapshot as function instead of executing it */ - JERRY_SNAPSHOT_EXEC_HAS_RESOURCE = (1u << 3), /**< source_name field is valid - * in jerry_exec_snapshot_option_values_t */ + JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME = (1u << 3), /**< source_name field is valid + * in jerry_exec_snapshot_option_values_t */ JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE = (1u << 4), /**< user_value field is valid * in jerry_exec_snapshot_option_values_t */ } jerry_exec_snapshot_opts_t; @@ -56,8 +56,8 @@ typedef enum */ typedef struct { - jerry_value_t source_name; /**< resource name string (usually a file name) - * if JERRY_SNAPSHOT_EXEC_HAS_RESOURCE is set in exec_snapshot_opts + jerry_value_t source_name; /**< source name string (usually a file name) + * if JERRY_SNAPSHOT_EXEC_HAS_SOURCE_NAME is set in exec_snapshot_opts * Note: non-string values are ignored */ jerry_value_t user_value; /**< user value assigned to all functions created by this script including * eval calls executed by the script if JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE diff --git a/jerry-core/include/jerryscript-types.h b/jerry-core/include/jerryscript-types.h index 1618747277..4c12fb437f 100644 --- a/jerry-core/include/jerryscript-types.h +++ b/jerry-core/include/jerryscript-types.h @@ -441,7 +441,7 @@ typedef enum */ typedef struct { - jerry_value_t source_name; /**< resource name */ + jerry_value_t source_name; /**< source name */ jerry_size_t line; /**< line index */ jerry_size_t column; /**< column index */ } jerry_frame_location_t; diff --git a/jerry-core/lit/lit-magic-strings.inc.h b/jerry-core/lit/lit-magic-strings.inc.h index 115d89c0f5..7b2e7a91e7 100644 --- a/jerry-core/lit/lit-magic-strings.inc.h +++ b/jerry-core/lit/lit-magic-strings.inc.h @@ -340,9 +340,9 @@ LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_THROW, "throw") LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_TRUNC, "trunc") #endif /* JERRY_BUILTIN_MATH && JERRY_ESNEXT */ LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_VALUE, "value") -#if JERRY_PARSER && JERRY_RESOURCE_NAME -LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_RESOURCE_EVAL, "") -#endif /* JERRY_PARSER && JERRY_RESOURCE_NAME */ +#if JERRY_PARSER && JERRY_SOURCE_NAME +LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_SOURCE_NAME_EVAL, "") +#endif /* JERRY_PARSER && JERRY_SOURCE_NAME */ #if JERRY_BUILTIN_BIGINT LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_BIGINT_UL, "BigInt") #endif /* JERRY_BUILTIN_BIGINT */ @@ -807,7 +807,7 @@ LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_SET_UTC_DATE_UL, "setUTCDate") #if JERRY_BUILTIN_STRING && JERRY_ESNEXT LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_STARTS_WITH, "startsWith") #endif /* JERRY_BUILTIN_STRING && JERRY_ESNEXT */ -LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_RESOURCE_ANON, "") +LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_SOURCE_NAME_ANON, "") #if JERRY_BUILTIN_TYPEDARRAY LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_ARRAY_BUFFER_UL, "ArrayBuffer") #endif /* JERRY_BUILTIN_TYPEDARRAY */ @@ -1127,8 +1127,8 @@ LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (4, LIT_MAGIC_STRING_LN10_U) LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (4, LIT_MAGIC_STRING_NULL_UL) #endif /* JERRY_BUILTIN_MATH */ LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (5, LIT_MAGIC_STRING_ARRAY_UL) -#if JERRY_PARSER && JERRY_RESOURCE_NAME -LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (6, LIT_MAGIC_STRING_RESOURCE_EVAL) +#if JERRY_PARSER && JERRY_SOURCE_NAME +LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (6, LIT_MAGIC_STRING_SOURCE_NAME_EVAL) #elif JERRY_BUILTIN_BIGINT LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (6, LIT_MAGIC_STRING_BIGINT_UL) #elif JERRY_BUILTIN_MATH @@ -1170,7 +1170,7 @@ LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (10, LIT_MAGIC_STRING_COPY_WITHIN) LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (10, LIT_MAGIC_STRING_ENUMERABLE) #endif /* JERRY_BUILTIN_TYPEDARRAY \ || JERRY_ESNEXT */ -LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (11, LIT_MAGIC_STRING_RESOURCE_ANON) +LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (11, LIT_MAGIC_STRING_SOURCE_NAME_ANON) #if JERRY_BUILTIN_TYPEDARRAY LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE (12, LIT_MAGIC_STRING_FLOAT32_ARRAY_UL) #elif JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64 diff --git a/jerry-core/lit/lit-magic-strings.ini b/jerry-core/lit/lit-magic-strings.ini index fb9496891c..f2dc3e30d7 100644 --- a/jerry-core/lit/lit-magic-strings.ini +++ b/jerry-core/lit/lit-magic-strings.ini @@ -143,7 +143,7 @@ LIT_MAGIC_STRING_ATOMICS_STORE = "store" LIT_MAGIC_STRING_THROW = "throw" LIT_MAGIC_STRING_TRUNC = "trunc" LIT_MAGIC_STRING_VALUE = "value" -LIT_MAGIC_STRING_RESOURCE_EVAL = "" +LIT_MAGIC_STRING_SOURCE_NAME_EVAL = "" LIT_MAGIC_STRING_BIGINT_UL = "BigInt" LIT_MAGIC_STRING_ERRORS_UL = "errors" LIT_MAGIC_STRING_LOG10E_U = "LOG10E" @@ -323,7 +323,7 @@ LIT_MAGIC_STRING_SET_MINUTES_UL = "setMinutes" LIT_MAGIC_STRING_SET_SECONDS_UL = "setSeconds" LIT_MAGIC_STRING_SET_UTC_DATE_UL = "setUTCDate" LIT_MAGIC_STRING_STARTS_WITH = "startsWith" -LIT_MAGIC_STRING_RESOURCE_ANON = "" +LIT_MAGIC_STRING_SOURCE_NAME_ANON = "" LIT_MAGIC_STRING_ARRAY_BUFFER_UL = "ArrayBuffer" LIT_MAGIC_STRING_DESCRIPTION = "description" LIT_MAGIC_STRING_SYNTAX_ERROR_UL = "SyntaxError" diff --git a/jerry-core/parser/js/byte-code.h b/jerry-core/parser/js/byte-code.h index bdf7241a20..6eb6512fc6 100644 --- a/jerry-core/parser/js/byte-code.h +++ b/jerry-core/parser/js/byte-code.h @@ -981,9 +981,9 @@ typedef struct ecma_object_t *realm_p; /**< realm object */ #endif /* JERRY_BUILTIN_REALMS */ uint32_t refs_and_type; /**< reference counter and type of the function */ -#if JERRY_RESOURCE_NAME - ecma_value_t source_name; /**< resource name */ -#endif /* JERRY_RESOURCE_NAME */ +#if JERRY_SOURCE_NAME + ecma_value_t source_name; /**< source name */ +#endif /* JERRY_SOURCE_NAME */ #if JERRY_FUNCTION_TO_STRING ecma_value_t source_code; /**< source code */ #endif /* JERRY_FUNCTION_TO_STRING */ diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index 0640a9f6c8..e196420292 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -2108,8 +2108,8 @@ parser_parse_source (void *source_p, /**< source code */ context.user_value = context.options_p->user_value; } -#if JERRY_RESOURCE_NAME - ecma_value_t source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON); +#if JERRY_SOURCE_NAME + ecma_value_t source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_ANON); if (context.options_p != NULL && (context.options_p->options & JERRY_PARSE_HAS_SOURCE_NAME)) { @@ -2120,9 +2120,9 @@ parser_parse_source (void *source_p, /**< source code */ } else if (context.global_status_flags & ECMA_PARSE_EVAL) { - source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_EVAL); + source_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_SOURCE_NAME_EVAL); } -#endif /* JERRY_RESOURCE_NAME */ +#endif /* JERRY_SOURCE_NAME */ context.last_context_p = NULL; context.last_statement.current_p = NULL; @@ -2262,9 +2262,9 @@ parser_parse_source (void *source_p, /**< source code */ context.script_p->realm_p = (ecma_object_t *) JERRY_CONTEXT (global_object_p); #endif /* JERRY_BUILTIN_REALMS */ -#if JERRY_RESOURCE_NAME +#if JERRY_SOURCE_NAME context.script_p->source_name = source_name; -#endif /* JERRY_RESOURCE_NAME */ +#endif /* JERRY_SOURCE_NAME */ ECMA_SET_INTERNAL_VALUE_POINTER (context.script_value, context.script_p); @@ -2430,9 +2430,9 @@ parser_parse_source (void *source_p, /**< source code */ parser_free_literals (&context.literal_pool); parser_cbc_stream_free (&context.byte_code); -#if JERRY_RESOURCE_NAME +#if JERRY_SOURCE_NAME ecma_deref_ecma_string (ecma_get_string_from_value (context.script_p->source_name)); -#endif /* JERRY_RESOURCE_NAME */ +#endif /* JERRY_SOURCE_NAME */ if (context.script_p != NULL) { diff --git a/jerry-ext/CMakeLists.txt b/jerry-ext/CMakeLists.txt index e83b814729..a697ad781d 100644 --- a/jerry-ext/CMakeLists.txt +++ b/jerry-ext/CMakeLists.txt @@ -49,7 +49,7 @@ set(SOURCE_EXT handler/handler-gc.c handler/handler-print.c handler/handler-register.c - handler/handler-resource-name.c + handler/handler-source-name.c module/module.c ) diff --git a/jerry-ext/handler/handler-resource-name.c b/jerry-ext/handler/handler-source-name.c similarity index 82% rename from jerry-ext/handler/handler-resource-name.c rename to jerry-ext/handler/handler-source-name.c index 7536de9028..6701311360 100644 --- a/jerry-ext/handler/handler-resource-name.c +++ b/jerry-ext/handler/handler-source-name.c @@ -16,13 +16,13 @@ #include "jerryscript-ext/handler.h" /** - * Get the resource name (usually a file name) of the currently executed script or the given function object + * Get the source name (usually a file name) of the currently executed script or the given function object * * Note: returned value must be freed with jerry_value_free, when it is no longer needed * * @return JS string constructed from - * - the currently executed function object's resource name, if the given value is undefined - * - resource name of the function object, if the given value is a function object + * - the currently executed function object's source name, if the given value is undefined + * - source name of the function object, if the given value is a function object * - "", otherwise */ jerry_value_t diff --git a/jerry-main/main-utils.c b/jerry-main/main-utils.c index 023c675cf3..5f77ac682e 100644 --- a/jerry-main/main-utils.c +++ b/jerry-main/main-utils.c @@ -290,7 +290,7 @@ main_init_engine (main_args_t *arguments_p) /**< main arguments */ main_register_global_function ("assert", jerryx_handler_assert); main_register_global_function ("gc", jerryx_handler_gc); main_register_global_function ("print", jerryx_handler_print); - main_register_global_function ("resourceName", jerryx_handler_source_name); + main_register_global_function ("sourceName", jerryx_handler_source_name); main_register_global_function ("createRealm", main_create_realm); } /* main_init_engine */ @@ -449,8 +449,8 @@ main_print_unhandled_exception (jerry_value_t error_value) /**< error value */ * @return result fo the source code execution */ jerry_value_t -main_wait_for_source_callback (const jerry_char_t *source_name_p, /**< resource name */ - size_t source_name_size, /**< size of resource name */ +main_wait_for_source_callback (const jerry_char_t *source_name_p, /**< source name */ + size_t source_name_size, /**< size of source name */ const jerry_char_t *source_p, /**< source code */ size_t source_size, /**< source code size */ void *user_p) /**< user pointer */ diff --git a/tests/debugger/do_variables.expected b/tests/debugger/do_variables.expected index 977d92862c..e9d6e521d3 100644 --- a/tests/debugger/do_variables.expected +++ b/tests/debugger/do_variables.expected @@ -4,29 +4,29 @@ Stopped at tests/debugger/do_variables.js:15 level | type 0 | global (jerry-debugger) variables -name | type | value -f | Function | -addX | Function | -z | undefined | undefined -c | undefined | undefined -createRealm | Function | -resourceName | Function | -print | Function | -gc | Function | -assert | Function | +name | type | value +f | Function | +addX | Function | +z | undefined | undefined +c | undefined | undefined +createRealm | Function | +sourceName | Function | +print | Function | +gc | Function | +assert | Function | (jerry-debugger) variables 1 name | type | value (jerry-debugger) variables 0 -name | type | value -f | Function | -addX | Function | -z | undefined | undefined -c | undefined | undefined -createRealm | Function | -resourceName | Function | -print | Function | -gc | Function | -assert | Function | +name | type | value +f | Function | +addX | Function | +z | undefined | undefined +c | undefined | undefined +createRealm | Function | +sourceName | Function | +print | Function | +gc | Function | +assert | Function | (jerry-debugger) b tests/debugger/do_variables.js:20 Breakpoint 1 at tests/debugger/do_variables.js:20 (in function() at line:19, col:10) (jerry-debugger) c @@ -44,17 +44,17 @@ n | Number | 9 name | type | value x | Number | 3 (jerry-debugger) variables 2 -name | type | value -addThree | Function | -f | Function | -addX | Function | -z | Number | 5 -c | Number | 4 -createRealm | Function | -resourceName | Function | -print | Function | -gc | Function | -assert | Function | +name | type | value +addThree | Function | +f | Function | +addX | Function | +z | Number | 5 +c | Number | 4 +createRealm | Function | +sourceName | Function | +print | Function | +gc | Function | +assert | Function | (jerry-debugger) b tests/debugger/do_variables.js:30 Breakpoint 2 at tests/debugger/do_variables.js:30 (in f() at line:28, col:1) (jerry-debugger) c @@ -64,18 +64,18 @@ level | type 0 | local 1 | global (jerry-debugger) variables 1 -name | type | value -d | Number | 12 -addThree | Function | -f | Function | -addX | Function | -z | Number | 5 -c | Number | 4 -createRealm | Function | -resourceName | Function | -print | Function | -gc | Function | -assert | Function | +name | type | value +d | Number | 12 +addThree | Function | +f | Function | +addX | Function | +z | Number | 5 +c | Number | 4 +createRealm | Function | +sourceName | Function | +print | Function | +gc | Function | +assert | Function | (jerry-debugger) variables 0 name | type | value b | undefined | undefined diff --git a/tests/jerry/es.next/module-resource-name-export.mjs b/tests/jerry/es.next/module-source-name-export.mjs similarity index 80% rename from tests/jerry/es.next/module-resource-name-export.mjs rename to tests/jerry/es.next/module-source-name-export.mjs index 08d740d4e7..36415067fb 100644 --- a/tests/jerry/es.next/module-resource-name-export.mjs +++ b/tests/jerry/es.next/module-source-name-export.mjs @@ -13,11 +13,11 @@ // limitations under the License. export function getName() { - return resourceName(); + return sourceName(); } export function getNamePromise(collector) { - return new Promise((resolve) => { collector["start"] = resourceName(); resolve(); }) - .then(() => { collector["middle"] = resourceName(); }); + return new Promise((resolve) => { collector["start"] = sourceName(); resolve(); }) + .then(() => { collector["middle"] = sourceName(); }); } diff --git a/tests/jerry/es.next/module-resource-name.mjs b/tests/jerry/es.next/module-source-name.mjs similarity index 62% rename from tests/jerry/es.next/module-resource-name.mjs rename to tests/jerry/es.next/module-source-name.mjs index 33bf743d25..32dc39736f 100644 --- a/tests/jerry/es.next/module-resource-name.mjs +++ b/tests/jerry/es.next/module-source-name.mjs @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { getName, getNamePromise } from "./module-resource-name-export.mjs" +import { getName, getNamePromise } from "./module-source-name-export.mjs" -assert(getName().endsWith("module-resource-name-export.mjs")); +assert(getName().endsWith("module-source-name-export.mjs")); var collector = {}; -getNamePromise(collector).then(() => { collector["end"] = resourceName(); }); +getNamePromise(collector).then(() => { collector["end"] = sourceName(); }); function __checkAsync() { - assert(collector["start"].endsWith("module-resource-name-export.mjs")); - assert(collector["middle"].endsWith("module-resource-name-export.mjs")); - assert(collector["end"].endsWith("module-resource-name.mjs")); + assert(collector["start"].endsWith("module-source-name-export.mjs")); + assert(collector["middle"].endsWith("module-source-name-export.mjs")); + assert(collector["end"].endsWith("module-source-name.mjs")); assert(Object.keys(collector).length === 3); } diff --git a/tests/jerry/regression-test-issue-2105.js b/tests/jerry/regression-test-issue-2105.js index 95c7c24182..eefaba83a8 100644 --- a/tests/jerry/regression-test-issue-2105.js +++ b/tests/jerry/regression-test-issue-2105.js @@ -51,4 +51,4 @@ try { /* Check properties of a */ assert(Object.keys(a) == "one,two"); /* Check properties of global object */ -assert(Object.keys(this) == "assert,gc,print,resourceName,createRealm,a,fail,fail_two"); +assert(Object.keys(this) == "assert,gc,print,sourceName,createRealm,a,fail,fail_two"); diff --git a/tests/unit-core/CMakeLists.txt b/tests/unit-core/CMakeLists.txt index 782a7a7231..bc287a8b00 100644 --- a/tests/unit-core/CMakeLists.txt +++ b/tests/unit-core/CMakeLists.txt @@ -79,7 +79,7 @@ set(SOURCE_UNIT_TEST_MAIN_MODULES test-error-callback.c test-regexp.c test-regression-3588.c - test-resource-name.c + test-source-name.c test-script-user-value.c test-snapshot.c test-source-info.c diff --git a/tests/unit-core/test-backtrace.c b/tests/unit-core/test-backtrace.c index df5f53cabb..5e77832b47 100644 --- a/tests/unit-core/test-backtrace.c +++ b/tests/unit-core/test-backtrace.c @@ -251,7 +251,7 @@ register_callback (jerry_external_handler_t handler_p, /**< callback function */ } /* register_callback */ static jerry_value_t -run (const char *source_name_p, /**< resource name */ +run (const char *source_name_p, /**< source name */ const char *source_p) /**< source code */ { jerry_parse_options_t parse_options; diff --git a/tests/unit-core/test-resource-name.c b/tests/unit-core/test-source-name.c similarity index 75% rename from tests/unit-core/test-resource-name.c rename to tests/unit-core/test-source-name.c index ce8b60cd68..1bf2542e30 100644 --- a/tests/unit-core/test-resource-name.c +++ b/tests/unit-core/test-source-name.c @@ -47,10 +47,10 @@ main (void) jerry_value_t global = jerry_current_realm (); - /* Register the "resourceName" method. */ + /* Register the "sourceName" method. */ { jerry_value_t func = jerry_function_external (source_name_handler); - jerry_value_t name = jerry_string_sz ("resourceName"); + jerry_value_t name = jerry_string_sz ("sourceName"); jerry_value_t result = jerry_object_set (global, name, func); jerry_value_free (result); jerry_value_free (name); @@ -63,9 +63,9 @@ main (void) parse_options.options = JERRY_PARSE_HAS_SOURCE_NAME; const char *source_1 = ("function f1 () {\n" - " if (resourceName() !== 'demo1.js') return false; \n" - " if (resourceName(f1) !== 'demo1.js') return false; \n" - " if (resourceName(5) !== '') return false; \n" + " if (sourceName() !== 'demo1.js') return false; \n" + " if (sourceName(f1) !== 'demo1.js') return false; \n" + " if (sourceName(5) !== '') return false; \n" " return f1; \n" "} \n" "f1();"); @@ -79,23 +79,24 @@ main (void) TEST_ASSERT (!jerry_value_is_exception (run_result)); TEST_ASSERT (jerry_value_is_object (run_result)); - jerry_value_t resource_value = jerry_source_name (run_result); - jerry_value_t compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name); + jerry_value_t source_name_value = jerry_source_name (run_result); + jerry_value_t compare_result = + jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name); TEST_ASSERT (jerry_value_is_true (compare_result)); jerry_value_free (compare_result); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); jerry_value_free (parse_options.source_name); jerry_value_free (run_result); jerry_value_free (program); const char *source_2 = ("function f2 () { \n" - " if (resourceName() !== 'demo2.js') return false; \n" - " if (resourceName(f2) !== 'demo2.js') return false; \n" - " if (resourceName(f1) !== 'demo1.js') return false; \n" - " if (resourceName(Object.prototype) !== '') return false; \n" - " if (resourceName(Function) !== '') return false; \n" + " if (sourceName() !== 'demo2.js') return false; \n" + " if (sourceName(f2) !== 'demo2.js') return false; \n" + " if (sourceName(f1) !== 'demo1.js') return false; \n" + " if (sourceName(Object.prototype) !== '') return false; \n" + " if (sourceName(Function) !== '') return false; \n" " return f2; \n" "} \n" "f2(); \n"); @@ -109,12 +110,12 @@ main (void) TEST_ASSERT (!jerry_value_is_exception (run_result)); TEST_ASSERT (jerry_value_is_object (run_result)); - resource_value = jerry_source_name (run_result); - compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name); + source_name_value = jerry_source_name (run_result); + compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name); TEST_ASSERT (jerry_value_is_true (compare_result)); jerry_value_free (compare_result); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); jerry_value_free (parse_options.source_name); jerry_value_free (run_result); @@ -130,33 +131,33 @@ main (void) program = jerry_parse ((const jerry_char_t *) source_3, strlen (source_3), &parse_options); TEST_ASSERT (!jerry_value_is_exception (program)); - resource_value = jerry_source_name (program); - compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name); + source_name_value = jerry_source_name (program); + compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name); TEST_ASSERT (jerry_value_is_true (compare_result)); jerry_value_free (compare_result); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); run_result = jerry_module_link (program, NULL, NULL); TEST_ASSERT (!jerry_value_is_exception (run_result)); - resource_value = jerry_source_name (run_result); - compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, anon); + source_name_value = jerry_source_name (run_result); + compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, anon); TEST_ASSERT (jerry_value_is_true (compare_result)); jerry_value_free (compare_result); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); jerry_value_free (run_result); run_result = jerry_module_evaluate (program); TEST_ASSERT (!jerry_value_is_exception (run_result)); - resource_value = jerry_source_name (run_result); - compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, anon); + source_name_value = jerry_source_name (run_result); + compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, anon); TEST_ASSERT (jerry_value_is_true (compare_result)); jerry_value_free (compare_result); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); jerry_value_free (run_result); jerry_value_free (program); jerry_value_free (parse_options.source_name); @@ -174,12 +175,12 @@ main (void) TEST_ASSERT (!jerry_value_is_exception (run_result)); TEST_ASSERT (jerry_value_is_object (run_result)); - resource_value = jerry_source_name (run_result); - compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name); + source_name_value = jerry_source_name (run_result); + compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name); TEST_ASSERT (jerry_value_is_true (compare_result)); jerry_value_free (compare_result); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); jerry_value_free (parse_options.source_name); jerry_value_free (run_result); jerry_value_free (program); @@ -193,11 +194,11 @@ main (void) program = jerry_parse ((const jerry_char_t *) source_5, strlen (source_5), &parse_options); TEST_ASSERT (!jerry_value_is_exception (program)); - resource_value = jerry_source_name (program); - compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name); + source_name_value = jerry_source_name (program); + compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name); TEST_ASSERT (jerry_value_is_true (compare_result)); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); jerry_value_free (compare_result); jerry_value_free (parse_options.user_value); jerry_value_free (parse_options.source_name); @@ -211,11 +212,11 @@ main (void) program = jerry_parse ((const jerry_char_t *) source_6, strlen (source_6), &parse_options); if (!jerry_value_is_exception (program)) { - resource_value = jerry_source_name (program); - compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.source_name); + source_name_value = jerry_source_name (program); + compare_result = jerry_binary_op (JERRY_BIN_OP_STRICT_EQUAL, source_name_value, parse_options.source_name); TEST_ASSERT (jerry_value_is_true (compare_result)); - jerry_value_free (resource_value); + jerry_value_free (source_name_value); jerry_value_free (compare_result); }