Implement function.toString operation (#4752)
May increase the memory consumtpion heavily. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -979,8 +979,13 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
user_value = option_values_p->user_value;
|
||||
}
|
||||
|
||||
uint32_t script_size = (user_value != ECMA_VALUE_EMPTY ? sizeof (cbc_script_user_t)
|
||||
: sizeof (cbc_script_t));
|
||||
size_t script_size = sizeof (cbc_script_t);
|
||||
|
||||
if (user_value != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
script_size += sizeof (ecma_value_t);
|
||||
}
|
||||
|
||||
cbc_script_t *script_p = jmem_heap_alloc_block (script_size);
|
||||
|
||||
CBC_SCRIPT_SET_TYPE (script_p, user_value, CBC_SCRIPT_REF_ONE);
|
||||
@@ -1003,6 +1008,10 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
script_p->resource_name = resource_name;
|
||||
#endif /* JERRY_RESOURCE_NAME */
|
||||
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
script_p->source_code = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
|
||||
const uint8_t *literal_base_p = snapshot_data_p + header_p->lit_table_offset;
|
||||
|
||||
bytecode_p = snapshot_load_compiled_code ((const uint8_t *) bytecode_p,
|
||||
@@ -1021,7 +1030,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
|
||||
if (user_value != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
((cbc_script_user_t *) script_p)->user_value = ecma_copy_value_if_not_object (user_value);
|
||||
CBC_SCRIPT_GET_USER_VALUE (script_p) = ecma_copy_value_if_not_object (user_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1841,6 +1841,9 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
|| feature == JERRY_FEATURE_MODULE
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
|| feature == JERRY_FEATURE_FUNCTION_TO_STRING
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
);
|
||||
} /* jerry_is_feature_enabled */
|
||||
|
||||
@@ -2801,7 +2804,7 @@ jerry_create_regexp_sz (const jerry_char_t *pattern_p, /**< zero-terminated UTF-
|
||||
jerry_assert_api_available ();
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
if (!lit_is_valid_utf8_string (pattern_p, pattern_size))
|
||||
if (!lit_is_valid_utf8_string (pattern_p, pattern_size, true))
|
||||
{
|
||||
return jerry_throw (ecma_raise_common_error (ECMA_ERR_MSG ("Input must be a valid utf8 string")));
|
||||
}
|
||||
@@ -5130,7 +5133,8 @@ jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, /**< UTF-8 string */
|
||||
jerry_size_t buf_size) /**< string size */
|
||||
{
|
||||
return lit_is_valid_utf8_string ((lit_utf8_byte_t *) utf8_buf_p,
|
||||
(lit_utf8_size_t) buf_size);
|
||||
(lit_utf8_size_t) buf_size,
|
||||
true);
|
||||
} /* jerry_is_valid_utf8_string */
|
||||
|
||||
/**
|
||||
@@ -5490,7 +5494,7 @@ jerry_get_user_value (const jerry_value_t value) /**< jerry api value */
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
return ecma_copy_value (((cbc_script_user_t *) script_p)->user_value);
|
||||
return ecma_copy_value (CBC_SCRIPT_GET_USER_VALUE (script_p));
|
||||
} /* jerry_get_user_value */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user