Rename resource_name to source_name (#4846)
JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
* - "<anonymous>", 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 */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user