Support parsing of scripts / functions stored in string values (#4728)
Function arguments must be passed as string values. Snapshots are generated from compiled code rather than source code. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
+44
-113
@@ -134,7 +134,7 @@ snapshot_write_to_buffer_by_offset (uint8_t *buffer_p, /**< buffer */
|
||||
* @return start offset
|
||||
*/
|
||||
static uint32_t
|
||||
snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled code */
|
||||
snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< compiled code */
|
||||
uint8_t *snapshot_buffer_p, /**< snapshot buffer */
|
||||
size_t snapshot_buffer_size, /**< snapshot buffer size */
|
||||
snapshot_globals_t *globals_p) /**< snapshot globals */
|
||||
@@ -328,7 +328,7 @@ static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< s
|
||||
* @return start offset
|
||||
*/
|
||||
static uint32_t
|
||||
static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled code */
|
||||
static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< compiled code */
|
||||
uint8_t *snapshot_buffer_p, /**< snapshot buffer */
|
||||
size_t snapshot_buffer_size, /**< snapshot buffer size */
|
||||
snapshot_globals_t *globals_p) /**< snapshot globals */
|
||||
@@ -750,8 +750,6 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
|
||||
/**
|
||||
* Generate snapshot from specified source and arguments
|
||||
*
|
||||
@@ -760,28 +758,54 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
* and snapshot support is enabled in current configuration through JERRY_SNAPSHOT_SAVE),
|
||||
* error object otherwise
|
||||
*/
|
||||
static jerry_value_t
|
||||
jerry_generate_snapshot_with_args (const jerry_char_t *source_p, /**< script source */
|
||||
size_t source_size, /**< script source size */
|
||||
const jerry_char_t *args_p, /**< arguments string */
|
||||
size_t args_size, /**< arguments string size */
|
||||
const jerry_parse_options_t *options_p, /**< parsing options,
|
||||
* can be NULL if not used */
|
||||
uint32_t generate_snapshot_opts, /**< jerry_generate_snapshot_opts_t option bits */
|
||||
uint32_t *buffer_p, /**< buffer to save snapshot to */
|
||||
size_t buffer_size) /**< the buffer's size */
|
||||
jerry_value_t
|
||||
jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or function */
|
||||
uint32_t generate_snapshot_opts, /**< jerry_generate_snapshot_opts_t option bits */
|
||||
uint32_t *buffer_p, /**< buffer to save snapshot to */
|
||||
size_t buffer_size) /**< the buffer's size */
|
||||
{
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
uint32_t allowed_options = JERRY_SNAPSHOT_SAVE_STATIC;
|
||||
uint32_t allowed_parse_options = (JERRY_PARSE_STRICT_MODE
|
||||
| JERRY_PARSE_HAS_RESOURCE
|
||||
| JERRY_PARSE_HAS_START);
|
||||
|
||||
if ((generate_snapshot_opts & ~allowed_options) != 0
|
||||
|| (options_p != NULL && (options_p->options & ~allowed_parse_options) != 0))
|
||||
if ((generate_snapshot_opts & ~allowed_options) != 0)
|
||||
{
|
||||
return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_snapshot_flag_not_supported);
|
||||
}
|
||||
|
||||
const ecma_compiled_code_t *bytecode_data_p = NULL;
|
||||
|
||||
if (ecma_is_value_object (compiled_code))
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (compiled_code);
|
||||
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SCRIPT))
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
}
|
||||
else if (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_FUNCTION)
|
||||
{
|
||||
JERRY_ASSERT (!ecma_get_object_is_builtin (object_p));
|
||||
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
|
||||
|
||||
uint16_t type = CBC_FUNCTION_GET_TYPE (bytecode_data_p->status_flags);
|
||||
|
||||
if (type != CBC_FUNCTION_NORMAL)
|
||||
{
|
||||
bytecode_data_p = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (JERRY_UNLIKELY (bytecode_data_p == NULL))
|
||||
{
|
||||
return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ECMA_ERR_MSG ("Unsupported compiled code"));
|
||||
}
|
||||
|
||||
snapshot_globals_t globals;
|
||||
const uint32_t aligned_header_size = JERRY_ALIGNUP (sizeof (jerry_snapshot_header_t),
|
||||
JMEM_ALIGNMENT);
|
||||
@@ -791,21 +815,6 @@ jerry_generate_snapshot_with_args (const jerry_char_t *source_p, /**< script sou
|
||||
globals.regex_found = false;
|
||||
globals.class_found = false;
|
||||
|
||||
uint32_t status_flags = ECMA_PARSE_NO_OPTS;
|
||||
|
||||
if (options_p != NULL)
|
||||
{
|
||||
status_flags |= (options_p->options & ECMA_PARSE_STRICT_MODE);
|
||||
}
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
bytecode_data_p = parser_parse_script (args_p, args_size, source_p, source_size, status_flags, options_p);
|
||||
|
||||
if (JERRY_UNLIKELY (bytecode_data_p == NULL))
|
||||
{
|
||||
return ecma_create_error_reference_from_context ();
|
||||
}
|
||||
|
||||
if (generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STATIC)
|
||||
{
|
||||
static_snapshot_add_compiled_code (bytecode_data_p, (uint8_t *) buffer_p, buffer_size, &globals);
|
||||
@@ -817,7 +826,6 @@ jerry_generate_snapshot_with_args (const jerry_char_t *source_p, /**< script sou
|
||||
|
||||
if (!ecma_is_value_empty (globals.snapshot_error))
|
||||
{
|
||||
ecma_bytecode_deref (bytecode_data_p);
|
||||
return globals.snapshot_error;
|
||||
}
|
||||
|
||||
@@ -846,7 +854,6 @@ jerry_generate_snapshot_with_args (const jerry_char_t *source_p, /**< script sou
|
||||
&literals_num))
|
||||
{
|
||||
JERRY_ASSERT (lit_map_p == NULL);
|
||||
ecma_bytecode_deref (bytecode_data_p);
|
||||
return jerry_create_error (JERRY_ERROR_COMMON, (const jerry_char_t *) ecma_error_cannot_allocate_memory_literals);
|
||||
}
|
||||
|
||||
@@ -868,43 +875,9 @@ jerry_generate_snapshot_with_args (const jerry_char_t *source_p, /**< script sou
|
||||
jmem_heap_free_block (lit_map_p, literals_num * sizeof (lit_mem_to_snapshot_id_map_entry_t));
|
||||
}
|
||||
|
||||
ecma_bytecode_deref (bytecode_data_p);
|
||||
|
||||
return ecma_make_number_value ((ecma_number_t) globals.snapshot_buffer_write_offset);
|
||||
} /* jerry_generate_snapshot_with_args */
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
/**
|
||||
* Generate snapshot from specified source and arguments
|
||||
*
|
||||
* @return size of snapshot (a number value), if it was generated succesfully
|
||||
* (i.e. there are no syntax errors in source code, buffer size is sufficient,
|
||||
* and snapshot support is enabled in current configuration through JERRY_SNAPSHOT_SAVE),
|
||||
* error object otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_generate_snapshot (const jerry_char_t *source_p, /**< script source */
|
||||
size_t source_size, /**< script source size */
|
||||
const jerry_parse_options_t *options_p, /**< parsing options,
|
||||
* can be NULL if not used */
|
||||
uint32_t generate_snapshot_opts, /**< jerry_generate_snapshot_opts_t option bits */
|
||||
uint32_t *buffer_p, /**< buffer to save snapshot to */
|
||||
size_t buffer_size) /**< the buffer's size */
|
||||
{
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
return jerry_generate_snapshot_with_args (source_p,
|
||||
source_size,
|
||||
NULL,
|
||||
0,
|
||||
options_p,
|
||||
generate_snapshot_opts,
|
||||
buffer_p,
|
||||
buffer_size);
|
||||
#else /* !JERRY_SNAPSHOT_SAVE */
|
||||
JERRY_UNUSED (source_p);
|
||||
JERRY_UNUSED (source_size);
|
||||
JERRY_UNUSED (options_p);
|
||||
JERRY_UNUSED (compiled_code);
|
||||
JERRY_UNUSED (generate_snapshot_opts);
|
||||
JERRY_UNUSED (buffer_p);
|
||||
JERRY_UNUSED (buffer_size);
|
||||
@@ -1815,45 +1788,3 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
|
||||
return 0;
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
} /* jerry_get_literals_from_snapshot */
|
||||
|
||||
/**
|
||||
* Generate snapshot function from specified source and arguments
|
||||
*
|
||||
* @return size of snapshot (a number value), if it was generated succesfully
|
||||
* (i.e. there are no syntax errors in source code, buffer size is sufficient,
|
||||
* and snapshot support is enabled in current configuration through JERRY_SNAPSHOT_SAVE),
|
||||
* error object otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_generate_function_snapshot (const jerry_char_t *source_p, /**< script source */
|
||||
size_t source_size, /**< script source size */
|
||||
const jerry_char_t *args_p, /**< arguments string */
|
||||
size_t args_size, /**< arguments string size */
|
||||
const jerry_parse_options_t *options_p, /**< parsing options,
|
||||
* can be NULL if not used */
|
||||
uint32_t generate_snapshot_opts, /**< jerry_generate_snapshot_opts_t option bits */
|
||||
uint32_t *buffer_p, /**< buffer to save snapshot to */
|
||||
size_t buffer_size) /**< the buffer's size */
|
||||
{
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
return jerry_generate_snapshot_with_args (source_p,
|
||||
source_size,
|
||||
args_p,
|
||||
args_size,
|
||||
options_p,
|
||||
generate_snapshot_opts,
|
||||
buffer_p,
|
||||
buffer_size);
|
||||
#else /* !JERRY_SNAPSHOT_SAVE */
|
||||
JERRY_UNUSED (source_p);
|
||||
JERRY_UNUSED (source_size);
|
||||
JERRY_UNUSED (args_p);
|
||||
JERRY_UNUSED (args_size);
|
||||
JERRY_UNUSED (options_p);
|
||||
JERRY_UNUSED (generate_snapshot_opts);
|
||||
JERRY_UNUSED (buffer_p);
|
||||
JERRY_UNUSED (buffer_size);
|
||||
|
||||
return jerry_create_error (JERRY_ERROR_COMMON, (const jerry_char_t *) "Snapshot save is not supported");
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
} /* jerry_generate_function_snapshot */
|
||||
|
||||
+80
-96
@@ -376,34 +376,43 @@ jerry_run_simple (const jerry_char_t *script_source_p, /**< script source */
|
||||
return result;
|
||||
} /* jerry_run_simple */
|
||||
|
||||
#if JERRY_PARSER
|
||||
|
||||
/**
|
||||
* Parse script and construct an EcmaScript function. The lexical
|
||||
* environment is set to the global lexical environment.
|
||||
* Common code for parsing a script, module, or function.
|
||||
*
|
||||
* @return function object value - if script was parsed successfully,
|
||||
* thrown error - otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
size_t source_size, /**< script source size */
|
||||
const jerry_parse_options_t *options_p) /**< parsing options, can be NULL if not used */
|
||||
static jerry_value_t
|
||||
jerry_parse_common (void *source_p, /**< script source */
|
||||
const jerry_parse_options_t *options_p, /**< parsing options, can be NULL if not used */
|
||||
uint32_t parse_opts) /**< internal parsing options */
|
||||
{
|
||||
#if JERRY_PARSER
|
||||
jerry_assert_api_available ();
|
||||
|
||||
uint32_t allowed_parse_options = (JERRY_PARSE_STRICT_MODE
|
||||
| JERRY_PARSE_MODULE
|
||||
| JERRY_PARSE_HAS_RESOURCE
|
||||
| JERRY_PARSE_HAS_START
|
||||
| JERRY_PARSE_HAS_USER_VALUE);
|
||||
|
||||
if (options_p != NULL && (options_p->options & ~allowed_parse_options) != 0)
|
||||
if (options_p != NULL)
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
#endif /* JERRY_PARSER */
|
||||
const uint32_t allowed_options = (JERRY_PARSE_STRICT_MODE
|
||||
| JERRY_PARSE_MODULE
|
||||
| JERRY_PARSE_HAS_ARGUMENT_LIST
|
||||
| JERRY_PARSE_HAS_RESOURCE
|
||||
| JERRY_PARSE_HAS_START
|
||||
| JERRY_PARSE_HAS_USER_VALUE);
|
||||
uint32_t options = options_p->options;
|
||||
|
||||
#if JERRY_DEBUGGER && JERRY_PARSER
|
||||
if ((options & ~allowed_options) != 0
|
||||
|| ((options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)
|
||||
&& ((options_p->options & JERRY_PARSE_MODULE)
|
||||
|| !ecma_is_value_string (options_p->argument_list)))
|
||||
|| ((options_p->options & JERRY_PARSE_HAS_RESOURCE)
|
||||
&& !ecma_is_value_string (options_p->resource_name)))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
}
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
&& options_p != NULL
|
||||
&& (options_p->options & JERRY_PARSE_HAS_RESOURCE)
|
||||
@@ -418,10 +427,7 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
resource_name_size);
|
||||
ECMA_FINALIZE_UTF8_STRING (resource_name_start_p, resource_name_size);
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER && JERRY_PARSER */
|
||||
|
||||
#if JERRY_PARSER
|
||||
uint32_t parse_opts = 0;
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
if (options_p != NULL)
|
||||
{
|
||||
@@ -438,7 +444,7 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
}
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
bytecode_data_p = parser_parse_script (NULL, 0, source_p, source_size, parse_opts, options_p);
|
||||
bytecode_data_p = parser_parse_script (source_p, parse_opts, options_p);
|
||||
|
||||
if (JERRY_UNLIKELY (bytecode_data_p == NULL))
|
||||
{
|
||||
@@ -464,6 +470,22 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
}
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
if (JERRY_UNLIKELY (options_p != NULL
|
||||
&& (options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)))
|
||||
{
|
||||
ecma_object_t *global_object_p = ecma_builtin_get_global ();
|
||||
|
||||
#if JERRY_BUILTIN_REALMS
|
||||
JERRY_ASSERT (global_object_p == (ecma_object_t *) ecma_op_function_get_realm (bytecode_data_p));
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
|
||||
ecma_object_t *lex_env_p = ecma_get_global_environment (global_object_p);
|
||||
ecma_object_t *func_obj_p = ecma_op_create_simple_function_object (lex_env_p, bytecode_data_p);
|
||||
ecma_bytecode_deref (bytecode_data_p);
|
||||
|
||||
return ecma_make_object_value (func_obj_p);
|
||||
}
|
||||
|
||||
ecma_object_t *object_p = ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
@@ -471,6 +493,27 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.cls.u3.value, bytecode_data_p);
|
||||
|
||||
return ecma_make_object_value (object_p);
|
||||
} /* jerry_parse_common */
|
||||
|
||||
#endif /* JERRY_PARSER */
|
||||
|
||||
/**
|
||||
* Parse a script, module, or function and create a compiled code using a character string
|
||||
*
|
||||
* @return function object value - if script was parsed successfully,
|
||||
* thrown error - otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
size_t source_size, /**< script source size */
|
||||
const jerry_parse_options_t *options_p) /**< parsing options, can be NULL if not used */
|
||||
{
|
||||
#if JERRY_PARSER
|
||||
parser_source_char_t source_char;
|
||||
source_char.source_p = source_p;
|
||||
source_char.source_size = source_size;
|
||||
|
||||
return jerry_parse_common ((void *) &source_char, options_p, JERRY_PARSE_NO_OPTS);
|
||||
#else /* !JERRY_PARSER */
|
||||
JERRY_UNUSED (source_p);
|
||||
JERRY_UNUSED (source_size);
|
||||
@@ -481,93 +524,32 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */
|
||||
} /* jerry_parse */
|
||||
|
||||
/**
|
||||
* Parse function and construct an EcmaScript function. The lexical
|
||||
* environment is set to the global lexical environment.
|
||||
* Parse a script, module, or function and create a compiled code using a string value
|
||||
*
|
||||
* @return function object value - if script was parsed successfully,
|
||||
* thrown error - otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_parse_function (const jerry_char_t *arg_list_p, /**< script source */
|
||||
size_t arg_list_size, /**< script source size */
|
||||
const jerry_char_t *source_p, /**< script source */
|
||||
size_t source_size, /**< script source size */
|
||||
const jerry_parse_options_t *options_p) /**< parsing options, can be NULL if not used */
|
||||
jerry_parse_value (const jerry_value_t source_value, /**< script source */
|
||||
const jerry_parse_options_t *options_p) /**< parsing options, can be NULL if not used */
|
||||
{
|
||||
#if JERRY_PARSER
|
||||
jerry_assert_api_available ();
|
||||
|
||||
uint32_t allowed_parse_options = (JERRY_PARSE_STRICT_MODE
|
||||
| JERRY_PARSE_HAS_RESOURCE
|
||||
| JERRY_PARSE_HAS_START
|
||||
| JERRY_PARSE_HAS_USER_VALUE);
|
||||
|
||||
if (options_p != NULL && (options_p->options & ~allowed_parse_options) != 0)
|
||||
if (!ecma_is_value_string (source_value))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
#endif /* JERRY_PARSER */
|
||||
|
||||
#if JERRY_DEBUGGER && JERRY_PARSER
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
&& options_p != NULL
|
||||
&& (options_p->options & JERRY_PARSE_HAS_RESOURCE)
|
||||
&& ecma_is_value_string (options_p->resource_name))
|
||||
{
|
||||
ECMA_STRING_TO_UTF8_STRING (ecma_get_string_from_value (options_p->resource_name),
|
||||
resource_name_start_p,
|
||||
resource_name_size);
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_SOURCE_CODE_NAME,
|
||||
JERRY_DEBUGGER_NO_SUBTYPE,
|
||||
resource_name_start_p,
|
||||
resource_name_size);
|
||||
ECMA_FINALIZE_UTF8_STRING (resource_name_start_p, resource_name_size);
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER && JERRY_PARSER */
|
||||
ecma_value_t source[1];
|
||||
source[0] = source_value;
|
||||
|
||||
#if JERRY_PARSER
|
||||
uint32_t parse_opts = 0;
|
||||
|
||||
if (options_p != NULL)
|
||||
{
|
||||
parse_opts |= options_p->options & JERRY_PARSE_STRICT_MODE;
|
||||
}
|
||||
|
||||
if (arg_list_p == NULL)
|
||||
{
|
||||
/* Must not be a NULL value. */
|
||||
arg_list_p = (const jerry_char_t *) "";
|
||||
}
|
||||
|
||||
ecma_compiled_code_t *bytecode_p;
|
||||
bytecode_p = parser_parse_script (arg_list_p, arg_list_size, source_p, source_size, parse_opts, options_p);
|
||||
|
||||
if (JERRY_UNLIKELY (bytecode_p == NULL))
|
||||
{
|
||||
return ecma_create_error_reference_from_context ();
|
||||
}
|
||||
|
||||
ecma_object_t *global_object_p = ecma_builtin_get_global ();
|
||||
|
||||
#if JERRY_BUILTIN_REALMS
|
||||
JERRY_ASSERT (global_object_p == (ecma_object_t *) ecma_op_function_get_realm (bytecode_p));
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
|
||||
ecma_object_t *lex_env_p = ecma_get_global_environment (global_object_p);
|
||||
ecma_object_t *func_obj_p = ecma_op_create_simple_function_object (lex_env_p, bytecode_p);
|
||||
ecma_bytecode_deref (bytecode_p);
|
||||
|
||||
return ecma_make_object_value (func_obj_p);
|
||||
return jerry_parse_common ((void *) source, options_p, ECMA_PARSE_HAS_SOURCE_VALUE);
|
||||
#else /* !JERRY_PARSER */
|
||||
JERRY_UNUSED (arg_list_p);
|
||||
JERRY_UNUSED (arg_list_size);
|
||||
JERRY_UNUSED (source_p);
|
||||
JERRY_UNUSED (source_size);
|
||||
JERRY_UNUSED (source_value);
|
||||
JERRY_UNUSED (options_p);
|
||||
|
||||
return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_parser_not_supported_p)));
|
||||
#endif /* JERRY_PARSER */
|
||||
} /* jerry_parse_function */
|
||||
} /* jerry_parse_value */
|
||||
|
||||
/**
|
||||
* Run a Script or Module created by jerry_parse.
|
||||
@@ -632,9 +614,11 @@ jerry_eval (const jerry_char_t *source_p, /**< source code */
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
|
||||
return jerry_return (ecma_op_eval_chars_buffer ((const lit_utf8_byte_t *) source_p,
|
||||
source_size,
|
||||
parse_opts));
|
||||
parser_source_char_t source_char;
|
||||
source_char.source_p = source_p;
|
||||
source_char.source_size = source_size;
|
||||
|
||||
return jerry_return (ecma_op_eval_chars_buffer ((void *) &source_char, parse_opts));
|
||||
} /* jerry_eval */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user