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:
@@ -46,9 +46,7 @@ bool jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p);
|
||||
bool jerry_run_simple (const jerry_char_t *script_source_p, size_t script_source_size, jerry_init_flag_t flags);
|
||||
jerry_value_t jerry_parse (const jerry_char_t *source_p, size_t source_size,
|
||||
const jerry_parse_options_t *options_p);
|
||||
jerry_value_t jerry_parse_function (const jerry_char_t *arg_list_p, size_t arg_list_size,
|
||||
const jerry_char_t *source_p, size_t source_size,
|
||||
const jerry_parse_options_t *options_p);
|
||||
jerry_value_t jerry_parse_value (const jerry_value_t source_value, const jerry_parse_options_t *options_p);
|
||||
jerry_value_t jerry_run (const jerry_value_t func_val);
|
||||
jerry_value_t jerry_eval (const jerry_char_t *source_p, size_t source_size, uint32_t parse_opts);
|
||||
|
||||
|
||||
@@ -70,14 +70,8 @@ typedef struct
|
||||
/**
|
||||
* Snapshot functions.
|
||||
*/
|
||||
jerry_value_t jerry_generate_snapshot (const jerry_char_t *source_p, size_t source_size,
|
||||
const jerry_parse_options_t *options_p, uint32_t generate_snapshot_opts,
|
||||
jerry_value_t jerry_generate_snapshot (jerry_value_t compiled_code, uint32_t generate_snapshot_opts,
|
||||
uint32_t *buffer_p, size_t buffer_size);
|
||||
jerry_value_t jerry_generate_function_snapshot (const jerry_char_t *source_p, size_t source_size,
|
||||
const jerry_char_t *args_p, size_t args_size,
|
||||
const jerry_parse_options_t *options_p,
|
||||
uint32_t generate_snapshot_opts,
|
||||
uint32_t *buffer_p, size_t buffer_size);
|
||||
|
||||
jerry_value_t jerry_exec_snapshot (const uint32_t *snapshot_p, size_t snapshot_size,
|
||||
size_t func_index, uint32_t exec_snapshot_opts,
|
||||
|
||||
@@ -167,9 +167,10 @@ typedef enum
|
||||
JERRY_PARSE_NO_OPTS = 0, /**< no options passed */
|
||||
JERRY_PARSE_STRICT_MODE = (1 << 0), /**< enable strict mode */
|
||||
JERRY_PARSE_MODULE = (1 << 1), /**< parse source as an ECMAScript module */
|
||||
JERRY_PARSE_HAS_RESOURCE = (1 << 2), /**< resource_name field is valid */
|
||||
JERRY_PARSE_HAS_START = (1 << 3), /**< start_line and start_column fields are valid */
|
||||
JERRY_PARSE_HAS_USER_VALUE = (1 << 4), /**< user_value field is valid */
|
||||
JERRY_PARSE_HAS_ARGUMENT_LIST = (1 << 2), /**< argument_list field is valid */
|
||||
JERRY_PARSE_HAS_RESOURCE = (1 << 3), /**< resource_name field is valid */
|
||||
JERRY_PARSE_HAS_START = (1 << 4), /**< start_line and start_column fields are valid */
|
||||
JERRY_PARSE_HAS_USER_VALUE = (1 << 5), /**< user_value field is valid */
|
||||
} jerry_parse_option_enable_feature_t;
|
||||
|
||||
/**
|
||||
@@ -178,9 +179,11 @@ typedef enum
|
||||
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 resource_name; /**< resource name string (usually a file name)
|
||||
* if JERRY_PARSE_HAS_RESOURCE is set in options
|
||||
* Note: non-string values are ignored */
|
||||
* Note: must be string value */
|
||||
uint32_t start_line; /**< start line of the source code if JERRY_PARSE_HAS_START is set in options */
|
||||
uint32_t start_column; /**< start column of the source code if JERRY_PARSE_HAS_START is set in options */
|
||||
jerry_value_t user_value; /**< user value assigned to all functions created by this script including eval
|
||||
|
||||
Reference in New Issue
Block a user