Introduce jerry_get_resource_name API function (#3236)
This new API function adds possibility to query the resource name of the currently executed script (including modules) or a function object. This patch closes #2170. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
55423ab82a
commit
525c35f148
@@ -52,8 +52,10 @@ typedef struct vm_frame_ctx_t
|
||||
#endif /* defined (JERRY_DEBUGGER) || ENABLED (JERRY_LINE_INFO) */
|
||||
ecma_value_t this_binding; /**< this binding */
|
||||
ecma_value_t block_result; /**< block result */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
ecma_value_t resource_name; /**< current resource name (usually a file name) */
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
uint32_t current_line; /**< currently executed line */
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
uint16_t context_depth; /**< current context depth */
|
||||
|
||||
+7
-27
@@ -3384,36 +3384,14 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
case VM_OC_RESOURCE_NAME:
|
||||
{
|
||||
ecma_length_t formal_params_number = 0;
|
||||
|
||||
if (CBC_NON_STRICT_ARGUMENTS_NEEDED (bytecode_header_p))
|
||||
{
|
||||
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_header_p;
|
||||
|
||||
formal_params_number = args_p->argument_end;
|
||||
}
|
||||
else
|
||||
{
|
||||
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_header_p;
|
||||
|
||||
formal_params_number = args_p->argument_end;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *byte_p = (uint8_t *) bytecode_header_p;
|
||||
byte_p += ((size_t) bytecode_header_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
ecma_value_t *resource_name_p = (ecma_value_t *) byte_p;
|
||||
resource_name_p -= formal_params_number;
|
||||
|
||||
frame_ctx_p->resource_name = resource_name_p[-1];
|
||||
frame_ctx_p->resource_name = ecma_op_resource_name (bytecode_header_p);
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
case VM_OC_LINE:
|
||||
{
|
||||
uint32_t value = 0;
|
||||
@@ -3840,8 +3818,10 @@ vm_run (const ecma_compiled_code_t *bytecode_header_p, /**< byte-code data heade
|
||||
#endif /* defined (JERRY_DEBUGGER) || ENABLED (JERRY_LINE_INFO) */
|
||||
frame_ctx.this_binding = this_binding_value;
|
||||
frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
frame_ctx.resource_name = ECMA_VALUE_UNDEFINED;
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
frame_ctx.current_line = 0;
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
frame_ctx.context_depth = 0;
|
||||
|
||||
Reference in New Issue
Block a user