Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
@@ -14,10 +14,12 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "jrt.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "jrt.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
|
||||
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
|
||||
@@ -51,7 +53,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <=
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_number_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_number (void)
|
||||
{
|
||||
return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t));
|
||||
@@ -71,7 +73,7 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_object (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -99,7 +101,7 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_object (size_t size) /**< size of object */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -128,7 +130,7 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -156,7 +158,7 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -184,7 +186,7 @@ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extende
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_external_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_external_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_external_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -212,7 +214,7 @@ ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< externa
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string_buffer (size_t size) /**< size of string */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@@ -241,7 +243,7 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_property_pair_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_pair_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_property_pair (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
*/
|
||||
|
||||
#include "ecma-errors.h"
|
||||
|
||||
@@ -20,114 +20,114 @@
|
||||
/**
|
||||
* Error message, if an argument is has an error flag
|
||||
*/
|
||||
const char * const ecma_error_value_msg_p = "Argument cannot be marked as error";
|
||||
const char* const ecma_error_value_msg_p = "Argument cannot be marked as error";
|
||||
|
||||
/**
|
||||
* Error message, if an argument has a wrong type
|
||||
*/
|
||||
const char * const ecma_error_wrong_args_msg_p = "This type of argument is not allowed";
|
||||
const char* const ecma_error_wrong_args_msg_p = "This type of argument is not allowed";
|
||||
|
||||
#if !JERRY_PARSER
|
||||
/**
|
||||
* Error message, if parsing is disabled
|
||||
*/
|
||||
const char * const ecma_error_parser_not_supported_p = "Source code parsing is disabled";
|
||||
const char* const ecma_error_parser_not_supported_p = "Source code parsing is disabled";
|
||||
#endif /* !JERRY_PARSER */
|
||||
|
||||
#if !JERRY_BUILTIN_JSON
|
||||
/**
|
||||
* Error message, if JSON support is disabled
|
||||
*/
|
||||
const char * const ecma_error_json_not_supported_p = "JSON support is disabled";
|
||||
const char* const ecma_error_json_not_supported_p = "JSON support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_JSON */
|
||||
|
||||
#if !JERRY_ESNEXT
|
||||
/**
|
||||
* Error message, if Symbol support is disabled
|
||||
*/
|
||||
const char * const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
|
||||
const char* const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
|
||||
/**
|
||||
* Error message, if Promise support is disabled
|
||||
*/
|
||||
const char * const ecma_error_promise_not_supported_p = "Promise support is disabled";
|
||||
const char* const ecma_error_promise_not_supported_p = "Promise support is disabled";
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
|
||||
#if !JERRY_BUILTIN_TYPEDARRAY
|
||||
/**
|
||||
* Error message, if TypedArray support is disabled
|
||||
*/
|
||||
const char * const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled";
|
||||
const char* const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
/**
|
||||
* Error message, if SharedArrayBuffer support is disabled
|
||||
*/
|
||||
const char * const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled";
|
||||
const char* const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
|
||||
#if !JERRY_BUILTIN_DATAVIEW
|
||||
/**
|
||||
* Error message, if DataView support is disabled
|
||||
*/
|
||||
const char * const ecma_error_data_view_not_supported_p = "DataView support is disabled";
|
||||
const char* const ecma_error_data_view_not_supported_p = "DataView support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if !JERRY_BUILTIN_BIGINT
|
||||
/**
|
||||
* Error message, if BigInt support is disabled
|
||||
*/
|
||||
const char * const ecma_error_bigint_not_supported_p = "BigInt support is disabled";
|
||||
const char* const ecma_error_bigint_not_supported_p = "BigInt support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if !JERRY_BUILTIN_CONTAINER
|
||||
/**
|
||||
* Error message, if Container support is disabled
|
||||
*/
|
||||
const char * const ecma_error_container_not_supported_p = "Container support is disabled";
|
||||
const char* const ecma_error_container_not_supported_p = "Container support is disabled";
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
/**
|
||||
* Error message, if argument is not a module
|
||||
*/
|
||||
const char * const ecma_error_not_module_p = "Argument is not a module";
|
||||
const char* const ecma_error_not_module_p = "Argument is not a module";
|
||||
|
||||
/**
|
||||
* Error message, if a native module export is not found
|
||||
*/
|
||||
const char * const ecma_error_unknown_export_p = "Native module export not found";
|
||||
const char* const ecma_error_unknown_export_p = "Native module export not found";
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
/**
|
||||
* Error message, if Module support is disabled
|
||||
*/
|
||||
const char * const ecma_error_module_not_supported_p = "Module support is disabled";
|
||||
const char* const ecma_error_module_not_supported_p = "Module support is disabled";
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/**
|
||||
* Error message, if callback function is not callable
|
||||
*/
|
||||
const char * const ecma_error_callback_is_not_callable = "Callback function is not callable";
|
||||
* Error message, if callback function is not callable
|
||||
*/
|
||||
const char* const ecma_error_callback_is_not_callable = "Callback function is not callable";
|
||||
|
||||
/**
|
||||
* Error message, if arrayBuffer is detached
|
||||
*/
|
||||
const char * const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached";
|
||||
const char* const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached";
|
||||
|
||||
/**
|
||||
* Error message, cannot convert undefined or null to object
|
||||
*/
|
||||
const char * const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object";
|
||||
const char* const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object";
|
||||
|
||||
/**
|
||||
* Error message, prototype property of a class is non-configurable
|
||||
*/
|
||||
const char * const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable";
|
||||
const char* const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable";
|
||||
|
||||
/**
|
||||
* Error message, argument is not an object
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_an_object = "Argument is not an object";
|
||||
const char* const ecma_error_argument_is_not_an_object = "Argument is not an object";
|
||||
|
||||
/**
|
||||
* Error message length of 'ecma_error_argument_is_not_an_object'
|
||||
@@ -137,45 +137,45 @@ const int ecma_error_argument_is_not_an_object_length = 25;
|
||||
/**
|
||||
* Error message, argument is not a Proxy object
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object";
|
||||
const char* const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object";
|
||||
|
||||
/**
|
||||
* Error message, target is not a constructor
|
||||
*/
|
||||
const char * const ecma_error_target_is_not_a_constructor = "Target is not a constructor";
|
||||
const char* const ecma_error_target_is_not_a_constructor = "Target is not a constructor";
|
||||
|
||||
/**
|
||||
* Error message, argument is not an regexp
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object";
|
||||
const char* const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object";
|
||||
|
||||
/**
|
||||
* Error message, invalid array length
|
||||
*/
|
||||
const char * const ecma_error_invalid_array_length = "Invalid Array length";
|
||||
const char* const ecma_error_invalid_array_length = "Invalid Array length";
|
||||
|
||||
/**
|
||||
* Error message, local variable is redeclared
|
||||
*/
|
||||
const char * const ecma_error_local_variable_is_redeclared = "Local variable is redeclared";
|
||||
const char* const ecma_error_local_variable_is_redeclared = "Local variable is redeclared";
|
||||
|
||||
/**
|
||||
* Error message, expected a function
|
||||
*/
|
||||
const char * const ecma_error_expected_a_function = "Expected a function";
|
||||
const char* const ecma_error_expected_a_function = "Expected a function";
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/**
|
||||
* Error message, class constructor invoked without new keyword
|
||||
*/
|
||||
const char * const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
|
||||
const char* const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
|
||||
|
||||
/**
|
||||
* Error message, variables declared by let/const must be initialized before reading their value
|
||||
*/
|
||||
const char * const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
|
||||
" initialized before reading their value");
|
||||
const char* const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
|
||||
" initialized before reading their value");
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -186,31 +186,31 @@ const char * const ecma_error_let_const_not_initialized = ("Variables declared b
|
||||
/**
|
||||
* Error message, maximum snapshot size reached
|
||||
*/
|
||||
const char * const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached";
|
||||
const char* const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached";
|
||||
|
||||
/**
|
||||
* Error message, regular expressions literals are not supported
|
||||
*/
|
||||
const char * const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported";
|
||||
const char* const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported";
|
||||
|
||||
/**
|
||||
* Error message, snapshot buffer too small
|
||||
*/
|
||||
const char * const ecma_error_snapshot_buffer_small = "Snapshot buffer too small";
|
||||
const char* const ecma_error_snapshot_buffer_small = "Snapshot buffer too small";
|
||||
|
||||
/**
|
||||
* Error message, Unsupported generate snapshot flags specified
|
||||
*/
|
||||
const char * const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified";
|
||||
const char* const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified";
|
||||
|
||||
/**
|
||||
* Error message, Cannot allocate memory for literals
|
||||
*/
|
||||
const char * const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals";
|
||||
const char* const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals";
|
||||
|
||||
/**
|
||||
* Error message, Unsupported feature: tagged template literals
|
||||
*/
|
||||
const char * const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals";
|
||||
const char* const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals";
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC */
|
||||
|
||||
@@ -20,75 +20,75 @@
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
|
||||
extern const char * const ecma_error_value_msg_p;
|
||||
extern const char * const ecma_error_wrong_args_msg_p;
|
||||
extern const char* const ecma_error_value_msg_p;
|
||||
extern const char* const ecma_error_wrong_args_msg_p;
|
||||
|
||||
#if !JERRY_PARSER
|
||||
extern const char * const ecma_error_parser_not_supported_p;
|
||||
extern const char* const ecma_error_parser_not_supported_p;
|
||||
#endif /* !JERRY_PARSER */
|
||||
|
||||
#if !JERRY_BUILTIN_JSON
|
||||
extern const char * const ecma_error_json_not_supported_p;
|
||||
extern const char* const ecma_error_json_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_JSON */
|
||||
|
||||
#if !JERRY_ESNEXT
|
||||
extern const char * const ecma_error_symbol_not_supported_p;
|
||||
extern const char* const ecma_error_symbol_not_supported_p;
|
||||
|
||||
extern const char * const ecma_error_promise_not_supported_p;
|
||||
extern const char* const ecma_error_promise_not_supported_p;
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
|
||||
#if !JERRY_BUILTIN_TYPEDARRAY
|
||||
extern const char * const ecma_error_typed_array_not_supported_p;
|
||||
extern const char* const ecma_error_typed_array_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
extern const char * const ecma_error_shared_arraybuffer_not_supported_p;
|
||||
extern const char* const ecma_error_shared_arraybuffer_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
|
||||
#if !JERRY_BUILTIN_DATAVIEW
|
||||
extern const char * const ecma_error_data_view_not_supported_p;
|
||||
extern const char* const ecma_error_data_view_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if !JERRY_BUILTIN_BIGINT
|
||||
extern const char * const ecma_error_bigint_not_supported_p;
|
||||
extern const char* const ecma_error_bigint_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if !JERRY_BUILTIN_CONTAINER
|
||||
extern const char * const ecma_error_container_not_supported_p;
|
||||
extern const char* const ecma_error_container_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
extern const char * const ecma_error_not_module_p;
|
||||
extern const char * const ecma_error_unknown_export_p;
|
||||
extern const char* const ecma_error_not_module_p;
|
||||
extern const char* const ecma_error_unknown_export_p;
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
extern const char * const ecma_error_module_not_supported_p;
|
||||
extern const char* const ecma_error_module_not_supported_p;
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
extern const char * const ecma_error_callback_is_not_callable;
|
||||
extern const char * const ecma_error_arraybuffer_is_detached;
|
||||
extern const char * const ecma_error_cannot_convert_to_object;
|
||||
extern const char * const ecma_error_class_is_non_configurable;
|
||||
extern const char * const ecma_error_argument_is_not_an_object;
|
||||
extern const char* const ecma_error_callback_is_not_callable;
|
||||
extern const char* const ecma_error_arraybuffer_is_detached;
|
||||
extern const char* const ecma_error_cannot_convert_to_object;
|
||||
extern const char* const ecma_error_class_is_non_configurable;
|
||||
extern const char* const ecma_error_argument_is_not_an_object;
|
||||
extern const int ecma_error_argument_is_not_an_object_length;
|
||||
extern const char * const ecma_error_argument_is_not_a_proxy;
|
||||
extern const char * const ecma_error_target_is_not_a_constructor;
|
||||
extern const char * const ecma_error_argument_is_not_an_regexp;
|
||||
extern const char * const ecma_error_invalid_array_length;
|
||||
extern const char * const ecma_error_local_variable_is_redeclared;
|
||||
extern const char * const ecma_error_expected_a_function;
|
||||
extern const char* const ecma_error_argument_is_not_a_proxy;
|
||||
extern const char* const ecma_error_target_is_not_a_constructor;
|
||||
extern const char* const ecma_error_argument_is_not_an_regexp;
|
||||
extern const char* const ecma_error_invalid_array_length;
|
||||
extern const char* const ecma_error_local_variable_is_redeclared;
|
||||
extern const char* const ecma_error_expected_a_function;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
extern const char * const ecma_error_class_constructor_new;
|
||||
extern const char * const ecma_error_let_const_not_initialized;
|
||||
extern const char* const ecma_error_class_constructor_new;
|
||||
extern const char* const ecma_error_let_const_not_initialized;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
|
||||
/* snapshot errors */
|
||||
extern const char * const ecma_error_maximum_snapshot_size;
|
||||
extern const char * const ecma_error_regular_expression_not_supported;
|
||||
extern const char * const ecma_error_snapshot_buffer_small;
|
||||
extern const char * const ecma_error_snapshot_flag_not_supported;
|
||||
extern const char * const ecma_error_cannot_allocate_memory_literals;
|
||||
extern const char * const ecma_error_tagged_template_literals;
|
||||
#endif /* !ECMA_ERRORS_H */
|
||||
extern const char* const ecma_error_maximum_snapshot_size;
|
||||
extern const char* const ecma_error_regular_expression_not_supported;
|
||||
extern const char* const ecma_error_snapshot_buffer_small;
|
||||
extern const char* const ecma_error_snapshot_flag_not_supported;
|
||||
extern const char* const ecma_error_cannot_allocate_memory_literals;
|
||||
extern const char* const ecma_error_tagged_template_literals;
|
||||
#endif /* !ECMA_ERRORS_H */
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-extended-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -41,8 +43,7 @@ ecma_extended_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer *
|
||||
{
|
||||
source_p--;
|
||||
value = (value << ECMA_EXTENDED_INFO_VLQ_SHIFT) | (*source_p & ECMA_EXTENDED_INFO_VLQ_MASK);
|
||||
}
|
||||
while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
} while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
@@ -71,8 +72,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
|
||||
{
|
||||
current_value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
}
|
||||
while (current_value > 0);
|
||||
} while (current_value > 0);
|
||||
|
||||
destination_p -= length;
|
||||
*buffer_p = destination_p;
|
||||
@@ -81,8 +81,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
|
||||
{
|
||||
*destination_p++ = (uint8_t) (value | ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
}
|
||||
while (value > 0);
|
||||
} while (value > 0);
|
||||
|
||||
**buffer_p &= ECMA_EXTENDED_INFO_VLQ_MASK;
|
||||
} /* ecma_extended_info_encode_vlq */
|
||||
@@ -101,8 +100,7 @@ ecma_extended_info_get_encoded_length (uint32_t value) /**< encoded value */
|
||||
{
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
}
|
||||
while (value > 0);
|
||||
} while (value > 0);
|
||||
|
||||
return length;
|
||||
} /* ecma_extended_info_get_encoded_length */
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
/**
|
||||
* Vlq encoding: flag which is set for all bytes except the last one.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* Garbage collector implementation
|
||||
*/
|
||||
|
||||
#include "ecma-gc.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
@@ -24,16 +26,16 @@
|
||||
#include "ecma-container-object.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
#include "re-compiler.h"
|
||||
#include "vm-defines.h"
|
||||
#include "vm-stack.h"
|
||||
@@ -300,8 +302,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
|
||||
if (!ECMA_PROPERTY_IS_INTERNAL (property))
|
||||
{
|
||||
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED
|
||||
|| property == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED || property == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -314,8 +315,8 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
case LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD:
|
||||
{
|
||||
ecma_environment_record_t *environment_record_p;
|
||||
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t,
|
||||
property_pair_p->values[index].value);
|
||||
environment_record_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t, property_pair_p->values[index].value);
|
||||
|
||||
if (environment_record_p->this_binding != ECMA_VALUE_UNINITIALIZED)
|
||||
{
|
||||
@@ -397,8 +398,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (*value_p));
|
||||
}
|
||||
}
|
||||
while (++value_p < end_p);
|
||||
} while (++value_p < end_p);
|
||||
|
||||
if (property & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)
|
||||
{
|
||||
@@ -406,8 +406,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
item_p = &(((ecma_native_pointer_chain_t *) item_p)->next_p->data);
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -460,8 +459,8 @@ ecma_gc_mark_bound_function_object (ecma_object_t *object_p) /**< bound function
|
||||
ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) object_p;
|
||||
|
||||
ecma_object_t *target_func_p;
|
||||
target_func_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
bound_func_p->header.u.bound_function.target_function);
|
||||
target_func_p =
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function);
|
||||
|
||||
ecma_gc_set_object_visited (target_func_p);
|
||||
|
||||
@@ -547,12 +546,11 @@ ecma_gc_mark_map_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
|
||||
{
|
||||
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
|
||||
|
||||
@@ -582,12 +580,11 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
|
||||
{
|
||||
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
|
||||
|
||||
@@ -598,8 +595,7 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_object (entry_p->key));
|
||||
|
||||
if (ecma_is_value_object (entry_p->value)
|
||||
&& ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
|
||||
if (ecma_is_value_object (entry_p->value) && ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (entry_p->value));
|
||||
}
|
||||
@@ -615,12 +611,11 @@ ecma_gc_mark_set_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_VALUE_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_VALUE_SIZE)
|
||||
{
|
||||
ecma_value_t *entry_p = start_p + i;
|
||||
|
||||
@@ -728,8 +723,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
do
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (*(--context_top_p)));
|
||||
}
|
||||
while (context_top_p > last_item_p);
|
||||
} while (context_top_p > last_item_p);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -750,8 +744,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
|
||||
JERRY_ASSERT (context_top_p >= context_end_p + offsets);
|
||||
context_top_p -= offsets;
|
||||
}
|
||||
while (context_top_p > context_end_p);
|
||||
} while (context_top_p > context_end_p);
|
||||
}
|
||||
|
||||
register_end_p = executable_object_p->frame_ctx.stack_top_p;
|
||||
@@ -891,8 +884,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_CLASS_SCRIPT:
|
||||
{
|
||||
const ecma_compiled_code_t *compiled_code_p;
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
JERRY_ASSERT (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
|
||||
ecma_gc_mark_compiled_code (((cbc_uint8_arguments_t *) compiled_code_p)->script_value);
|
||||
@@ -910,8 +902,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_CLASS_MODULE_NAMESPACE:
|
||||
{
|
||||
JERRY_ASSERT (proto_cp == JMEM_CP_NULL);
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.cls.u3.value));
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ext_object_p->u.cls.u3.value));
|
||||
ecma_gc_mark_properties (object_p, true);
|
||||
return;
|
||||
}
|
||||
@@ -1114,8 +1105,8 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_TYPE_FUNCTION:
|
||||
{
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
ext_func_p->u.function.scope_cp));
|
||||
ecma_gc_set_object_visited (
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_func_p->u.function.scope_cp));
|
||||
|
||||
const ecma_compiled_code_t *compiled_code_p = ecma_op_function_get_compiled_code (ext_func_p);
|
||||
|
||||
@@ -1249,8 +1240,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_TYPE_NATIVE_FUNCTION:
|
||||
{
|
||||
ecma_native_function_t *native_function_p = (ecma_native_function_t *) object_p;
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
native_function_p->realm_value));
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, native_function_p->realm_value));
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
@@ -1322,8 +1312,7 @@ ecma_gc_free_native_pointer (ecma_property_t property, /**< property descriptor
|
||||
jmem_heap_free_block (item_p, sizeof (ecma_native_pointer_chain_t));
|
||||
|
||||
item_p = next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
} /* ecma_gc_free_native_pointer */
|
||||
|
||||
/**
|
||||
@@ -1347,8 +1336,8 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
|
||||
if (!(mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE))
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
{
|
||||
ecma_compiled_code_t *byte_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
mapped_arguments_p->u.byte_code);
|
||||
ecma_compiled_code_t *byte_code_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, mapped_arguments_p->u.byte_code);
|
||||
|
||||
ecma_bytecode_deref (byte_code_p);
|
||||
}
|
||||
@@ -1363,8 +1352,7 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
|
||||
ecma_free_value_if_not_object (argv_p[i]);
|
||||
}
|
||||
|
||||
uint32_t saved_argument_count = JERRY_MAX (arguments_number,
|
||||
arguments_p->header.u.cls.u2.formal_params_number);
|
||||
uint32_t saved_argument_count = JERRY_MAX (arguments_number, arguments_p->header.u.cls.u2.formal_params_number);
|
||||
|
||||
return object_size + (saved_argument_count * sizeof (ecma_value_t));
|
||||
} /* ecma_free_arguments_object */
|
||||
@@ -1485,8 +1473,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
|
||||
do
|
||||
{
|
||||
ecma_free_value_if_not_object (*(--context_top_p));
|
||||
}
|
||||
while (context_top_p > last_item_p);
|
||||
} while (context_top_p > last_item_p);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -1506,8 +1493,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
|
||||
}
|
||||
|
||||
context_top_p = vm_stack_context_abort (&executable_object_p->frame_ctx, context_top_p);
|
||||
}
|
||||
while (context_top_p > context_end_p);
|
||||
} while (context_top_p > context_end_p);
|
||||
}
|
||||
|
||||
register_end_p = executable_object_p->frame_ctx.stack_top_p;
|
||||
@@ -1526,8 +1512,7 @@ JERRY_STATIC_ASSERT (!ECMA_PROPERTY_IS_RAW (ECMA_PROPERTY_TYPE_DELETED),
|
||||
ecma_property_type_deleted_must_not_be_raw_property);
|
||||
JERRY_STATIC_ASSERT ((ECMA_PROPERTY_TYPE_DELETED & ECMA_PROPERTY_FLAG_LCACHED) == 0,
|
||||
ecma_property_type_deleted_must_not_have_lcached_flag);
|
||||
JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1,
|
||||
ecma_gc_free_second_must_be_one);
|
||||
JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1, ecma_gc_free_second_must_be_one);
|
||||
|
||||
/**
|
||||
* Free property of an object
|
||||
@@ -1575,8 +1560,8 @@ ecma_gc_free_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_pair_p->values[index].getter_setter_pair_cp);
|
||||
getter_setter_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_pair_p->values[index].getter_setter_pair_cp);
|
||||
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
return;
|
||||
@@ -1655,8 +1640,7 @@ ecma_gc_free_properties (ecma_object_t *object_p, /**< object */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
ecma_property_hashmap_free (object_p);
|
||||
@@ -1791,8 +1775,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
case ECMA_OBJECT_CLASS_SCRIPT:
|
||||
{
|
||||
ecma_compiled_code_t *compiled_code_p;
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
ecma_bytecode_deref (compiled_code_p);
|
||||
break;
|
||||
@@ -1813,8 +1796,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
case ECMA_OBJECT_CLASS_REGEXP:
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
ecma_compiled_code_t *bytecode_p =
|
||||
ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
ecma_bytecode_deref (bytecode_p);
|
||||
|
||||
@@ -1886,8 +1869,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
case ECMA_OBJECT_CLASS_CONTAINER:
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_op_container_free_entries (object_p);
|
||||
ecma_collection_destroy (container_p);
|
||||
break;
|
||||
@@ -1978,8 +1961,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
if (ext_func_p->u.function.bytecode_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
ecma_compiled_code_t *byte_code_p = (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_func_p->u.function.bytecode_cp));
|
||||
ecma_compiled_code_t *byte_code_p =
|
||||
(ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_func_p->u.function.bytecode_cp));
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (CBC_FUNCTION_IS_ARROW (byte_code_p->status_flags))
|
||||
@@ -2227,8 +2210,7 @@ ecma_gc_run (void)
|
||||
|
||||
obj_iter_cp = obj_next_cp;
|
||||
}
|
||||
}
|
||||
while (marked_anything_during_current_iteration);
|
||||
} while (marked_anything_during_current_iteration);
|
||||
|
||||
black_end_p->gc_next_cp = JMEM_CP_NULL;
|
||||
JERRY_CONTEXT (ecma_gc_objects_cp) = black_list_head.gc_next_cp;
|
||||
@@ -2320,8 +2302,7 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
|
||||
if (!ecma_is_lexical_environment (obj_iter_p)
|
||||
|| ecma_get_lex_env_type (obj_iter_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
{
|
||||
if (!ecma_is_lexical_environment (obj_iter_p)
|
||||
&& ecma_op_object_is_fast_array (obj_iter_p))
|
||||
if (!ecma_is_lexical_environment (obj_iter_p) && ecma_op_object_is_fast_array (obj_iter_p))
|
||||
{
|
||||
obj_iter_cp = obj_iter_p->gc_next_cp;
|
||||
continue;
|
||||
@@ -2338,7 +2319,6 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
|
||||
ecma_property_hashmap_free (obj_iter_p);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
obj_iter_cp = obj_iter_p->gc_next_cp;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ECMA_GC_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
+136
-170
@@ -17,10 +17,11 @@
|
||||
#define ECMA_GLOBALS_H
|
||||
|
||||
#include "ecma-errors.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "jmem.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -37,7 +38,7 @@
|
||||
*/
|
||||
#define ECMA_NULL_POINTER JMEM_CP_NULL
|
||||
|
||||
#if defined (JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY)
|
||||
#if defined(JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY)
|
||||
|
||||
/**
|
||||
* JMEM_ALIGNMENT_LOG aligned pointers can be stored directly in ecma_value_t
|
||||
@@ -55,16 +56,16 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
|
||||
ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
|
||||
ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
|
||||
ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
ECMA_STATUS_HIGH_PRESSURE_GC = (1u << 2), /**< last gc was under high pressure */
|
||||
ECMA_STATUS_HIGH_PRESSURE_GC = (1u << 2), /**< last gc was under high pressure */
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
|
||||
ECMA_STATUS_ABORT = (1u << 4), /**< last exception is an abort */
|
||||
ECMA_STATUS_ERROR_UPDATE = (1u << 5), /**< the error_object_created_callback_p is called */
|
||||
ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
|
||||
ECMA_STATUS_ABORT = (1u << 4), /**< last exception is an abort */
|
||||
ECMA_STATUS_ERROR_UPDATE = (1u << 5), /**< the error_object_created_callback_p is called */
|
||||
#if JERRY_VM_THROW
|
||||
ECMA_STATUS_ERROR_THROWN = (1u << 6), /**< the vm_throw_callback_p is called */
|
||||
ECMA_STATUS_ERROR_THROWN = (1u << 6), /**< the vm_throw_callback_p is called */
|
||||
#endif /* JERRY_VM_THROW */
|
||||
} ecma_status_flag_t;
|
||||
|
||||
@@ -190,8 +191,7 @@ typedef int32_t ecma_integer_value_t;
|
||||
/**
|
||||
* ECMA make simple value
|
||||
*/
|
||||
#define ECMA_MAKE_VALUE(value) \
|
||||
((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
|
||||
#define ECMA_MAKE_VALUE(value) ((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
|
||||
|
||||
/**
|
||||
* Simple ecma values
|
||||
@@ -237,7 +237,7 @@ enum
|
||||
/**
|
||||
* Maximum integer number for an ecma value
|
||||
*/
|
||||
#define ECMA_INTEGER_NUMBER_MAX 0x7fffff
|
||||
#define ECMA_INTEGER_NUMBER_MAX 0x7fffff
|
||||
/**
|
||||
* Maximum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
|
||||
*/
|
||||
@@ -257,7 +257,7 @@ enum
|
||||
/**
|
||||
* Minimum integer number for an ecma value
|
||||
*/
|
||||
#define ECMA_INTEGER_NUMBER_MIN -0x7fffff
|
||||
#define ECMA_INTEGER_NUMBER_MIN -0x7fffff
|
||||
/**
|
||||
* Minimum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
|
||||
*/
|
||||
@@ -275,13 +275,12 @@ enum
|
||||
|
||||
#if ECMA_DIRECT_SHIFT != 4
|
||||
#error "Please update ECMA_INTEGER_NUMBER_MIN/MAX_SHIFTED according to the new value of ECMA_DIRECT_SHIFT."
|
||||
#endif
|
||||
#endif /* ECMA_DIRECT_SHIFT != 4 */
|
||||
|
||||
/**
|
||||
* Checks whether the integer number is in the integer number range.
|
||||
*/
|
||||
#define ECMA_IS_INTEGER_NUMBER(num) \
|
||||
(ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
|
||||
#define ECMA_IS_INTEGER_NUMBER(num) (ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
|
||||
|
||||
/**
|
||||
* Maximum integer number, which if squared, still fits in ecma_integer_value_t
|
||||
@@ -295,8 +294,7 @@ enum
|
||||
/**
|
||||
* Checks whether the error flag is set.
|
||||
*/
|
||||
#define ECMA_IS_VALUE_ERROR(value) \
|
||||
(JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
|
||||
#define ECMA_IS_VALUE_ERROR(value) (JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
|
||||
|
||||
/**
|
||||
* Callback which tells whether the ECMAScript execution should be stopped.
|
||||
@@ -422,32 +420,27 @@ typedef enum
|
||||
/**
|
||||
* Property flags configurable, enumerable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE \
|
||||
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
|
||||
|
||||
/**
|
||||
* Property flags configurable, enumerable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flag built-in.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_FIXED \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN)
|
||||
#define ECMA_PROPERTY_BUILT_IN_FIXED (ECMA_PROPERTY_FLAG_BUILT_IN)
|
||||
|
||||
/**
|
||||
* Property flags enumerable, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_ENUMERABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_ENUMERABLE_WRITABLE (ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable, enumerable.
|
||||
@@ -458,14 +451,12 @@ typedef enum
|
||||
/**
|
||||
* Property flags built-in, configurable, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable, enumerable, writable.
|
||||
@@ -495,8 +486,7 @@ typedef enum
|
||||
/**
|
||||
* Type of hash-map property.
|
||||
*/
|
||||
#define ECMA_PROPERTY_TYPE_HASHMAP \
|
||||
(ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
#define ECMA_PROPERTY_TYPE_HASHMAP (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
|
||||
/**
|
||||
* Type of deleted property.
|
||||
@@ -523,7 +513,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether a property is not found.
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_FOUND(property) \
|
||||
#define ECMA_PROPERTY_IS_FOUND(property) \
|
||||
(((property) & (ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))) \
|
||||
!= (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
@@ -606,20 +596,17 @@ typedef struct
|
||||
/**
|
||||
* Get property name type.
|
||||
*/
|
||||
#define ECMA_PROPERTY_GET_NAME_TYPE(property) \
|
||||
((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
#define ECMA_PROPERTY_GET_NAME_TYPE(property) ((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
|
||||
/**
|
||||
* Returns true if the property pointer is a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) \
|
||||
((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) ((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
|
||||
/**
|
||||
* Property value of all internal properties
|
||||
*/
|
||||
#define ECMA_PROPERTY_INTERNAL \
|
||||
(ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
#define ECMA_PROPERTY_INTERNAL (ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
/**
|
||||
* Checks whether a property is internal property
|
||||
@@ -629,25 +616,23 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a property is raw data or accessor property
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_RAW(property) \
|
||||
((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
#define ECMA_PROPERTY_IS_RAW(property) ((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
/**
|
||||
* Checks whether a property is raw data property (should only be used in assertions)
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_RAW_DATA(property) \
|
||||
(((property) & ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL)
|
||||
(((property) &ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL)
|
||||
|
||||
/**
|
||||
* Create internal property.
|
||||
*/
|
||||
#define ECMA_CREATE_INTERNAL_PROPERTY(object_p, name_p, property_p, property_value_p) \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_CREATE_INTERNAL_PROPERTY(object_p, name_p, property_p, property_value_p) \
|
||||
do \
|
||||
{ \
|
||||
(property_value_p) = ecma_create_named_data_property ((object_p), (name_p), 0, &(property_p)); \
|
||||
JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \
|
||||
} \
|
||||
while (0)
|
||||
JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Property type of all virtual properties
|
||||
@@ -657,7 +642,7 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a property is virtual property
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL(property)
|
||||
#define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL (property)
|
||||
|
||||
/**
|
||||
* Returns true if the property is named property.
|
||||
@@ -681,8 +666,7 @@ typedef struct
|
||||
* Compute the property data pointer of a property.
|
||||
* The property must be part of a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_VALUE_PTR(property_p) \
|
||||
((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
|
||||
#define ECMA_PROPERTY_VALUE_PTR(property_p) ((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
|
||||
|
||||
/**
|
||||
* Property reference. It contains the value pointer
|
||||
@@ -768,7 +752,7 @@ typedef enum
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE, /**< Module Namespace (ECMAScript v11, 9.4.6) */
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
#if JERRY_ESNEXT
|
||||
ECMA_OBJECT_CLASS_GENERATOR, /**< Generator object (ECMAScript v6, 25.2) */
|
||||
ECMA_OBJECT_CLASS_ASYNC_GENERATOR, /**< Async generator object (ECMAScript v11, 25.3) */
|
||||
@@ -781,7 +765,7 @@ typedef enum
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_OBJECT_CLASS_MODULE, /**< Module (ECMAScript v6, 15.2) */
|
||||
#endif
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_ESNEXT
|
||||
ECMA_OBJECT_CLASS_PROMISE, /**< Promise (ECMAScript v6, 25.4) */
|
||||
ECMA_OBJECT_CLASS_PROMISE_CAPABILITY, /**< Promise capability (ECMAScript v6, 25.4.1.1) */
|
||||
@@ -852,10 +836,10 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ITERATOR_KEYS, /**< keys iterator */
|
||||
ECMA_ITERATOR_VALUES, /**< values iterator */
|
||||
ECMA_ITERATOR_ENTRIES, /**< entries iterator */
|
||||
ECMA_ITERATOR__COUNT, /**< number of iterator kinds */
|
||||
ECMA_ITERATOR_KEYS, /**< keys iterator */
|
||||
ECMA_ITERATOR_VALUES, /**< values iterator */
|
||||
ECMA_ITERATOR_ENTRIES, /**< entries iterator */
|
||||
ECMA_ITERATOR__COUNT, /**< number of iterator kinds */
|
||||
} ecma_iterator_kind_t;
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
@@ -868,9 +852,9 @@ typedef enum
|
||||
/**
|
||||
* Set JERRY_CONTEXT (status_flags) top 8 bits to the specified 'opts'.
|
||||
*/
|
||||
#define ECMA_SET_LOCAL_PARSE_OPTS(opts) \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_SET_LOCAL_PARSE_OPTS(opts) \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) |= ((uint32_t) opts << ECMA_LOCAL_PARSE_OPTS_OFFSET) | ECMA_STATUS_DIRECT_EVAL; \
|
||||
} while (0)
|
||||
|
||||
@@ -883,9 +867,9 @@ typedef enum
|
||||
/**
|
||||
* Clear JERRY_CONTEXT (status_flags) top 8 bits.
|
||||
*/
|
||||
#define ECMA_CLEAR_LOCAL_PARSE_OPTS() \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_CLEAR_LOCAL_PARSE_OPTS() \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) &= ((1 << ECMA_LOCAL_PARSE_OPTS_OFFSET) - 1); \
|
||||
} while (0)
|
||||
|
||||
@@ -971,8 +955,8 @@ typedef struct
|
||||
{
|
||||
jmem_cpointer_t property_list_cp; /**< compressed pointer to object's
|
||||
* or declerative lexical environments's property list */
|
||||
jmem_cpointer_t bound_object_cp; /**< compressed pointer to lexical environments's the bound object */
|
||||
jmem_cpointer_t home_object_cp; /**< compressed pointer to lexical environments's the home object */
|
||||
jmem_cpointer_t bound_object_cp; /**< compressed pointer to lexical environments's the bound object */
|
||||
jmem_cpointer_t home_object_cp; /**< compressed pointer to lexical environments's the home object */
|
||||
} u1;
|
||||
|
||||
/** object prototype or outer reference */
|
||||
@@ -1038,11 +1022,11 @@ typedef ecma_value_t (*ecma_builtin_handler_t) (ecma_object_t *function_obj_p,
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS = 0, /**< No options are provided */
|
||||
ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED = (1u << 0), /**< 'length' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED = (1u << 1), /**< 'name' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_GETTER = (1u << 2), /**< this routine is getter */
|
||||
ECMA_BUILTIN_ROUTINE_SETTER = (1u << 3), /**< this routine is setter */
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS = 0, /**< No options are provided */
|
||||
ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED = (1u << 0), /**< 'length' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED = (1u << 1), /**< 'name' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_GETTER = (1u << 2), /**< this routine is getter */
|
||||
ECMA_BUILTIN_ROUTINE_SETTER = (1u << 3), /**< this routine is setter */
|
||||
} ecma_builtin_routine_flags_t;
|
||||
|
||||
/**
|
||||
@@ -1239,13 +1223,13 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_IS_FUNCTION check tells whether the byte code
|
||||
* is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_IS_FUNCTION check tells whether the byte code
|
||||
* is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
} ecma_compiled_code_t;
|
||||
|
||||
/**
|
||||
@@ -1331,26 +1315,22 @@ typedef struct
|
||||
/**
|
||||
* Size of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_GET_SIZE(container_p) \
|
||||
(container_p->buffer_p[0])
|
||||
#define ECMA_CONTAINER_GET_SIZE(container_p) (container_p->buffer_p[0])
|
||||
|
||||
/**
|
||||
* Remove the size field of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_SET_SIZE(container_p, size) \
|
||||
(container_p->buffer_p[0] = (ecma_value_t) (size))
|
||||
#define ECMA_CONTAINER_SET_SIZE(container_p, size) (container_p->buffer_p[0] = (ecma_value_t) (size))
|
||||
|
||||
/**
|
||||
* Number of entries of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_ENTRY_COUNT(collection_p) \
|
||||
(collection_p->item_count - 1)
|
||||
#define ECMA_CONTAINER_ENTRY_COUNT(collection_p) (collection_p->item_count - 1)
|
||||
|
||||
/**
|
||||
* Pointer to the first entry of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_START(collection_p) \
|
||||
(collection_p->buffer_p + 1)
|
||||
#define ECMA_CONTAINER_START(collection_p) (collection_p->buffer_p + 1)
|
||||
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
@@ -1380,17 +1360,15 @@ typedef struct
|
||||
* - is_value_defined : true
|
||||
* - is_configurable_defined, is_writable_defined, is_enumerable_defined : true
|
||||
*/
|
||||
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS ((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED \
|
||||
| JERRY_PROP_IS_CONFIGURABLE_DEFINED \
|
||||
| JERRY_PROP_IS_ENUMERABLE_DEFINED \
|
||||
| JERRY_PROP_IS_WRITABLE_DEFINED))
|
||||
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS \
|
||||
((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE_DEFINED \
|
||||
| JERRY_PROP_IS_WRITABLE_DEFINED))
|
||||
|
||||
/**
|
||||
* Bitmask to get a the physical property flags from an ecma_property_descriptor
|
||||
*/
|
||||
#define ECMA_PROPERTY_FLAGS_MASK ((uint16_t) (JERRY_PROP_IS_CONFIGURABLE \
|
||||
| JERRY_PROP_IS_ENUMERABLE \
|
||||
| JERRY_PROP_IS_WRITABLE))
|
||||
#define ECMA_PROPERTY_FLAGS_MASK \
|
||||
((uint16_t) (JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_ENUMERABLE | JERRY_PROP_IS_WRITABLE))
|
||||
|
||||
#if !JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
@@ -1412,7 +1390,7 @@ typedef union
|
||||
/**
|
||||
* Maximum number of significant digits that ecma-number can store
|
||||
*/
|
||||
#define ECMA_NUMBER_MAX_DIGITS (9)
|
||||
#define ECMA_NUMBER_MAX_DIGITS (9)
|
||||
|
||||
/**
|
||||
* Width of sign field
|
||||
@@ -1420,7 +1398,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
|
||||
/**
|
||||
* Width of biased exponent field
|
||||
@@ -1436,7 +1414,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (23)
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (23)
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
* Description of an ecma-number
|
||||
@@ -1457,7 +1435,7 @@ typedef union
|
||||
/**
|
||||
* Maximum number of significant digits that ecma-number can store
|
||||
*/
|
||||
#define ECMA_NUMBER_MAX_DIGITS (19)
|
||||
#define ECMA_NUMBER_MAX_DIGITS (19)
|
||||
|
||||
/**
|
||||
* Width of sign field
|
||||
@@ -1465,7 +1443,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
|
||||
/**
|
||||
* Width of biased exponent field
|
||||
@@ -1473,7 +1451,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
|
||||
|
||||
/**
|
||||
* Width of fraction field
|
||||
@@ -1481,7 +1459,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (52)
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (52)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
@@ -1492,12 +1470,12 @@ typedef union
|
||||
/**
|
||||
* Value '1' of ecma_number_t
|
||||
*/
|
||||
#define ECMA_NUMBER_ONE ((ecma_number_t) 1)
|
||||
#define ECMA_NUMBER_ONE ((ecma_number_t) 1)
|
||||
|
||||
/**
|
||||
* Value '2' of ecma_number_t
|
||||
*/
|
||||
#define ECMA_NUMBER_TWO ((ecma_number_t) 2)
|
||||
#define ECMA_NUMBER_TWO ((ecma_number_t) 2)
|
||||
|
||||
/**
|
||||
* Value '0.5' of ecma_number_t
|
||||
@@ -1515,74 +1493,74 @@ typedef union
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.3
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
|
||||
#define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
|
||||
/**
|
||||
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.2
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
|
||||
#define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
|
||||
/**
|
||||
* Number.EPSILON
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.1
|
||||
*/
|
||||
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
|
||||
|
||||
/**
|
||||
* Number.MAX_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.6
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
|
||||
|
||||
/**
|
||||
* Number.MIN_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.8
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.2
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
|
||||
#define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
|
||||
|
||||
/**
|
||||
* Number.MIN_VALUE (i.e., the smallest positive value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.3
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
|
||||
#define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
|
||||
|
||||
/**
|
||||
* Number.EPSILON
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.1
|
||||
*/
|
||||
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
|
||||
|
||||
/**
|
||||
* Number.MAX_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.6
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
|
||||
|
||||
/**
|
||||
* Number.MIN_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.8
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Euler number
|
||||
*/
|
||||
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
|
||||
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
|
||||
|
||||
/**
|
||||
* Natural logarithm of 10
|
||||
@@ -1607,17 +1585,17 @@ typedef union
|
||||
/**
|
||||
* Pi number
|
||||
*/
|
||||
#define ECMA_NUMBER_PI ((ecma_number_t) 3.1415926535897932)
|
||||
#define ECMA_NUMBER_PI ((ecma_number_t) 3.1415926535897932)
|
||||
|
||||
/**
|
||||
* Square root of 0.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SQRT_1_2 ((ecma_number_t) 0.7071067811865476)
|
||||
#define ECMA_NUMBER_SQRT_1_2 ((ecma_number_t) 0.7071067811865476)
|
||||
|
||||
/**
|
||||
* Square root of 2
|
||||
*/
|
||||
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
|
||||
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
|
||||
|
||||
/**
|
||||
* Maximum number of characters in string representation of ecma-number
|
||||
@@ -1657,8 +1635,7 @@ typedef struct
|
||||
/**
|
||||
* Compute the total allocated size of the collection based on it's capacity
|
||||
*/
|
||||
#define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) \
|
||||
(uint32_t) (capacity * sizeof (ecma_value_t))
|
||||
#define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) (uint32_t) (capacity * sizeof (ecma_value_t))
|
||||
|
||||
/**
|
||||
* Initial allocated size of an ecma-collection
|
||||
@@ -1724,8 +1701,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the string is direct.
|
||||
*/
|
||||
#define ECMA_IS_DIRECT_STRING(string_p) \
|
||||
((((uintptr_t) (string_p)) & 0x1) != 0)
|
||||
#define ECMA_IS_DIRECT_STRING(string_p) ((((uintptr_t) (string_p)) & 0x1) != 0)
|
||||
|
||||
/**
|
||||
* Checks whether the string is direct.
|
||||
@@ -1736,8 +1712,7 @@ typedef enum
|
||||
/**
|
||||
* Returns the type of a direct string.
|
||||
*/
|
||||
#define ECMA_GET_DIRECT_STRING_TYPE(string_p) \
|
||||
((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
|
||||
#define ECMA_GET_DIRECT_STRING_TYPE(string_p) ((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
|
||||
|
||||
/**
|
||||
* Shift applied to type conversions.
|
||||
@@ -1753,8 +1728,7 @@ typedef enum
|
||||
/**
|
||||
* Returns the value of a direct string.
|
||||
*/
|
||||
#define ECMA_GET_DIRECT_STRING_VALUE(string_p) \
|
||||
(((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
|
||||
#define ECMA_GET_DIRECT_STRING_VALUE(string_p) (((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
|
||||
|
||||
/**
|
||||
* Maximum number of bytes that a long-utf8-string is able to store
|
||||
@@ -1799,14 +1773,12 @@ typedef enum
|
||||
/**
|
||||
* Set an ecma-string as static string
|
||||
*/
|
||||
#define ECMA_SET_STRING_AS_STATIC(string_p) \
|
||||
(string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
|
||||
#define ECMA_SET_STRING_AS_STATIC(string_p) (string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
|
||||
|
||||
/**
|
||||
* Checks whether the ecma-string is static string
|
||||
*/
|
||||
#define ECMA_STRING_IS_STATIC(string_p) \
|
||||
((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
|
||||
#define ECMA_STRING_IS_STATIC(string_p) ((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
|
||||
|
||||
/**
|
||||
* Returns with the container type of a string.
|
||||
@@ -1817,8 +1789,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the reference counter is 1 of a string.
|
||||
*/
|
||||
#define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) \
|
||||
(((string_desc_p)->refs_and_container >> 4) == 1)
|
||||
#define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) (((string_desc_p)->refs_and_container >> 4) == 1)
|
||||
|
||||
/**
|
||||
* Checks whether the reference counter is 1 of an extended primitive.
|
||||
@@ -1878,38 +1849,34 @@ typedef struct
|
||||
/**
|
||||
* Header size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_HEADER_SIZE \
|
||||
((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
|
||||
#define ECMA_ASCII_STRING_HEADER_SIZE ((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
|
||||
|
||||
/**
|
||||
* Get the size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_GET_SIZE(string_p) \
|
||||
((lit_utf8_size_t) *((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1)
|
||||
((lit_utf8_size_t) * ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1)
|
||||
|
||||
/**
|
||||
* Set the size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_SET_SIZE(string_p, size) \
|
||||
(*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) - 1))
|
||||
(*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) -1))
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_GET_BUFFER(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
|
||||
#define ECMA_ASCII_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma UTF8 string
|
||||
*/
|
||||
#define ECMA_SHORT_STRING_GET_BUFFER(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
|
||||
#define ECMA_SHORT_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma long CESU8 string
|
||||
*/
|
||||
#define ECMA_LONG_STRING_BUFFER_START(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
|
||||
#define ECMA_LONG_STRING_BUFFER_START(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
|
||||
|
||||
/**
|
||||
* ECMA extended string-value descriptor
|
||||
@@ -2074,18 +2041,18 @@ typedef ecma_value_t (*ecma_typedarray_setter_fn_t) (lit_utf8_byte_t *src, ecma_
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_INT8_ARRAY, /**< Int8Array */
|
||||
ECMA_UINT8_ARRAY, /**< Uint8Array */
|
||||
ECMA_INT8_ARRAY, /**< Int8Array */
|
||||
ECMA_UINT8_ARRAY, /**< Uint8Array */
|
||||
ECMA_UINT8_CLAMPED_ARRAY, /**< Uint8ClampedArray */
|
||||
ECMA_INT16_ARRAY, /**< Int16Array */
|
||||
ECMA_UINT16_ARRAY, /**< Uint16Array */
|
||||
ECMA_INT32_ARRAY, /**< Int32Array */
|
||||
ECMA_UINT32_ARRAY, /**< Uint32Array */
|
||||
ECMA_FLOAT32_ARRAY, /**< Float32Array */
|
||||
ECMA_FLOAT64_ARRAY, /**< Float64Array */
|
||||
ECMA_INT16_ARRAY, /**< Int16Array */
|
||||
ECMA_UINT16_ARRAY, /**< Uint16Array */
|
||||
ECMA_INT32_ARRAY, /**< Int32Array */
|
||||
ECMA_UINT32_ARRAY, /**< Uint32Array */
|
||||
ECMA_FLOAT32_ARRAY, /**< Float32Array */
|
||||
ECMA_FLOAT64_ARRAY, /**< Float64Array */
|
||||
/* ECMA_TYPEDARRAY_IS_BIGINT_TYPE macro should be updated when new types are added */
|
||||
ECMA_BIGINT64_ARRAY, /**< BigInt64Array */
|
||||
ECMA_BIGUINT64_ARRAY, /**< BigUInt64Array */
|
||||
ECMA_BIGINT64_ARRAY, /**< BigInt64Array */
|
||||
ECMA_BIGUINT64_ARRAY, /**< BigUInt64Array */
|
||||
} ecma_typedarray_type_t;
|
||||
|
||||
/**
|
||||
@@ -2145,8 +2112,7 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a given typedarray is BigInt type or not.
|
||||
**/
|
||||
#define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) \
|
||||
((id) >= ECMA_BIGINT64_ARRAY)
|
||||
#define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) ((id) >= ECMA_BIGINT64_ARRAY)
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
@@ -2187,7 +2153,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the executable object is waiting for resuming.
|
||||
*/
|
||||
#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \
|
||||
#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \
|
||||
(!((executable_object_p)->extended_object.u.cls.u2.executable_obj_flags \
|
||||
& (ECMA_EXECUTABLE_OBJECT_COMPLETED | ECMA_EXECUTABLE_OBJECT_RUNNING)))
|
||||
|
||||
@@ -2306,21 +2272,21 @@ typedef struct
|
||||
* Check the current stack usage. If the limit is reached a RangeError is raised.
|
||||
* The macro argument specifies the return value which is usally ECMA_VALUE_ERROR or NULL.
|
||||
*/
|
||||
#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
|
||||
{ \
|
||||
ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
|
||||
return RETURN_VALUE; \
|
||||
} \
|
||||
} while (0)
|
||||
#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
|
||||
{ \
|
||||
ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
|
||||
return RETURN_VALUE; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Specialized version of ECMA_CHECK_STACK_USAGE_RETURN which returns ECMA_VALUE_ERROR.
|
||||
* This version should be used in most cases.
|
||||
*/
|
||||
#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN(ECMA_VALUE_ERROR)
|
||||
#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN (ECMA_VALUE_ERROR)
|
||||
#else /* JERRY_STACK_LIMIT == 0) */
|
||||
/**
|
||||
* If the stack limit is unlimited, this check is an empty macro.
|
||||
@@ -2446,11 +2412,11 @@ typedef struct
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ARGUMENTS_OBJECT_NO_FLAGS = 0, /* unmapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_MAPPED = (1 << 0), /* mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE = (1 << 1), /* static mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED = (1 << 2), /* 'callee' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED = (1 << 3), /* 'length' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_NO_FLAGS = 0, /* unmapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_MAPPED = (1 << 0), /* mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE = (1 << 1), /* static mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED = (1 << 2), /* 'callee' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED = (1 << 3), /* 'length' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED = (1 << 4), /* 'Symbol.iterator' property has been lazy initialized */
|
||||
} ecma_arguments_object_flags_t;
|
||||
|
||||
@@ -2522,4 +2488,4 @@ typedef struct
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_GLOBALS_H */
|
||||
#endif /* !ECMA_GLOBALS_H */
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
@@ -55,8 +56,7 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
uint64_t masked_lo = num_p->lo & ~(1ULL << 63u);
|
||||
uint64_t masked_hi = num_p->hi & 0x1;
|
||||
|
||||
if ((num_p->lo >> 63u != 0)
|
||||
&& (masked_lo > 0 || masked_hi != 0))
|
||||
if ((num_p->lo >> 63u != 0) && (masked_lo > 0 || masked_hi != 0))
|
||||
{
|
||||
return (num_p->hi + 1);
|
||||
}
|
||||
@@ -66,53 +66,52 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
/**
|
||||
* Check if 128-bit integer is zero
|
||||
*/
|
||||
#define ECMA_UINT128_IS_ZERO(name) \
|
||||
(name.hi == 0 && name.lo == 0)
|
||||
#define ECMA_UINT128_IS_ZERO(name) (name.hi == 0 && name.lo == 0)
|
||||
|
||||
/**
|
||||
* Left shift 128-bit integer by max 63 bits
|
||||
*/
|
||||
#define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \
|
||||
name.lo <<= (shift); \
|
||||
}
|
||||
#define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \
|
||||
name.lo <<= (shift); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Right shift 128-bit integer by max 63 bits
|
||||
*/
|
||||
#define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \
|
||||
name.hi >>= (shift); \
|
||||
}
|
||||
#define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \
|
||||
name.hi >>= (shift); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 128-bit integer
|
||||
*/
|
||||
#define ECMA_UINT128_ADD(name_add_to, name_to_add) \
|
||||
{ \
|
||||
name_add_to.hi += name_to_add.hi; \
|
||||
name_add_to.lo += name_to_add.lo; \
|
||||
if (name_add_to.lo < name_to_add.lo) \
|
||||
{ \
|
||||
name_add_to.hi++; \
|
||||
} \
|
||||
}
|
||||
{ \
|
||||
name_add_to.hi += name_to_add.hi; \
|
||||
name_add_to.lo += name_to_add.lo; \
|
||||
if (name_add_to.lo < name_to_add.lo) \
|
||||
{ \
|
||||
name_add_to.hi++; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply 128-bit integer by 10
|
||||
*/
|
||||
#define ECMA_UINT128_MUL10(name) \
|
||||
{ \
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \
|
||||
\
|
||||
ecma_uint128_t name ## _tmp = name; \
|
||||
\
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name ## _tmp, 2u); \
|
||||
\
|
||||
ECMA_UINT128_ADD (name, name ## _tmp); \
|
||||
}
|
||||
#define ECMA_UINT128_MUL10(name) \
|
||||
{ \
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \
|
||||
\
|
||||
ecma_uint128_t name##_tmp = name; \
|
||||
\
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name##_tmp, 2u); \
|
||||
\
|
||||
ECMA_UINT128_ADD (name, name##_tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide 128-bit integer by 10
|
||||
@@ -129,84 +128,82 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
*
|
||||
* Q = Q3 *2^96 + Q2 *2^64 + Q1 *2^32 + Q0 *2^0 // 128-bit quotient
|
||||
*/
|
||||
#define ECMA_UINT128_DIV10(name) \
|
||||
{ \
|
||||
/* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \
|
||||
const uint64_t tenth_l = 0x9999999aul; \
|
||||
const uint64_t tenth_m = 0x99999999ul; \
|
||||
const uint64_t tenth_h = 0x19999999ul; \
|
||||
\
|
||||
uint64_t l0 = ((uint32_t) name.lo) * tenth_l; \
|
||||
uint64_t l1 = (name.lo >> 32u) * tenth_l; \
|
||||
uint64_t l2 = ((uint32_t) name.hi) * tenth_l; \
|
||||
uint64_t l3 = (name.hi >> 32u) * tenth_l; \
|
||||
uint64_t m0 = ((uint32_t) name.lo) * tenth_m; \
|
||||
uint64_t m1 = (name.lo >> 32u) * tenth_m; \
|
||||
uint64_t m2 = ((uint32_t) name.hi) * tenth_m; \
|
||||
uint64_t m3 = (name.hi >> 32u) * tenth_m; \
|
||||
uint64_t h0 = ((uint32_t) name.lo) * tenth_h; \
|
||||
uint64_t h1 = (name.lo >> 32u) * tenth_h; \
|
||||
uint64_t h2 = ((uint32_t) name.hi) * tenth_h; \
|
||||
uint64_t h3 = (name.hi >> 32u) * tenth_h; \
|
||||
\
|
||||
uint64_t q0 = l0 >> 32u; \
|
||||
q0 += (uint32_t) l1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) h0; \
|
||||
\
|
||||
q0 >>=32u; \
|
||||
q0 += l3 >> 32u; \
|
||||
q0 += m2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += h0 >> 32u; \
|
||||
q0 += (uint32_t) m3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) h1; \
|
||||
\
|
||||
uint64_t q1 = q0 >> 32u; \
|
||||
q1 += m3 >> 32u; \
|
||||
q1 += m2 >> 32u; \
|
||||
q1 += h1 >> 32u; \
|
||||
q1 += (uint32_t) m3; \
|
||||
q1 += (uint32_t) h2; \
|
||||
\
|
||||
uint64_t q32 = q1 >> 32u; \
|
||||
q32 += m3 >> 32u; \
|
||||
q32 += h2 >> 32u; \
|
||||
q32 += h3; \
|
||||
\
|
||||
name.lo = (q1 << 32u) | ((uint32_t) q0); \
|
||||
name.hi = q32; \
|
||||
}
|
||||
#define ECMA_UINT128_DIV10(name) \
|
||||
{ \
|
||||
/* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \
|
||||
const uint64_t tenth_l = 0x9999999aul; \
|
||||
const uint64_t tenth_m = 0x99999999ul; \
|
||||
const uint64_t tenth_h = 0x19999999ul; \
|
||||
\
|
||||
uint64_t l0 = ((uint32_t) name.lo) * tenth_l; \
|
||||
uint64_t l1 = (name.lo >> 32u) * tenth_l; \
|
||||
uint64_t l2 = ((uint32_t) name.hi) * tenth_l; \
|
||||
uint64_t l3 = (name.hi >> 32u) * tenth_l; \
|
||||
uint64_t m0 = ((uint32_t) name.lo) * tenth_m; \
|
||||
uint64_t m1 = (name.lo >> 32u) * tenth_m; \
|
||||
uint64_t m2 = ((uint32_t) name.hi) * tenth_m; \
|
||||
uint64_t m3 = (name.hi >> 32u) * tenth_m; \
|
||||
uint64_t h0 = ((uint32_t) name.lo) * tenth_h; \
|
||||
uint64_t h1 = (name.lo >> 32u) * tenth_h; \
|
||||
uint64_t h2 = ((uint32_t) name.hi) * tenth_h; \
|
||||
uint64_t h3 = (name.hi >> 32u) * tenth_h; \
|
||||
\
|
||||
uint64_t q0 = l0 >> 32u; \
|
||||
q0 += (uint32_t) l1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) h0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l3 >> 32u; \
|
||||
q0 += m2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += h0 >> 32u; \
|
||||
q0 += (uint32_t) m3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) h1; \
|
||||
\
|
||||
uint64_t q1 = q0 >> 32u; \
|
||||
q1 += m3 >> 32u; \
|
||||
q1 += m2 >> 32u; \
|
||||
q1 += h1 >> 32u; \
|
||||
q1 += (uint32_t) m3; \
|
||||
q1 += (uint32_t) h2; \
|
||||
\
|
||||
uint64_t q32 = q1 >> 32u; \
|
||||
q32 += m3 >> 32u; \
|
||||
q32 += h2 >> 32u; \
|
||||
q32 += h3; \
|
||||
\
|
||||
name.lo = (q1 << 32u) | ((uint32_t) q0); \
|
||||
name.hi = q32; \
|
||||
}
|
||||
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 64 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) \
|
||||
__builtin_clzll (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) __builtin_clzll (name.hi)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 4 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) \
|
||||
__builtin_clzll (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) __builtin_clzll (name.hi)
|
||||
|
||||
#else /* !__GNUC__ && !__clang__ */
|
||||
|
||||
@@ -238,14 +235,12 @@ static const uint8_t ecma_uint4_clz[] = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||
/**
|
||||
* Count leading zeros in the topmost 64 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) \
|
||||
ecma_uint64_clz (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) ecma_uint64_clz (name.hi)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 4 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) \
|
||||
ecma_uint4_clz[name.hi >> 60]
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) ecma_uint4_clz[name.hi >> 60]
|
||||
|
||||
#endif /* __GNUC__ || __clang__ */
|
||||
|
||||
@@ -308,7 +303,7 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
{
|
||||
lit_code_point_t upper_limit = LIT_CHAR_0 + radix;
|
||||
|
||||
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
@@ -328,22 +323,19 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*iter_p >= LIT_CHAR_0
|
||||
&& *iter_p <= LIT_CHAR_9)
|
||||
if (*iter_p >= LIT_CHAR_0 && *iter_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_value = (*iter_p - LIT_CHAR_0);
|
||||
}
|
||||
else if (*iter_p >= LIT_CHAR_LOWERCASE_A
|
||||
&& *iter_p <= LIT_CHAR_LOWERCASE_F)
|
||||
else if (*iter_p >= LIT_CHAR_LOWERCASE_A && *iter_p <= LIT_CHAR_LOWERCASE_F)
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_LOWERCASE_A);
|
||||
}
|
||||
else if (*iter_p >= LIT_CHAR_UPPERCASE_A
|
||||
&& *iter_p <= LIT_CHAR_UPPERCASE_F)
|
||||
else if (*iter_p >= LIT_CHAR_UPPERCASE_A && *iter_p <= LIT_CHAR_UPPERCASE_F)
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
|
||||
}
|
||||
@@ -393,20 +385,19 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
return ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
if (end_p >= str_p + 2
|
||||
&& str_p[0] == LIT_CHAR_0)
|
||||
if (end_p >= str_p + 2 && str_p[0] == LIT_CHAR_0)
|
||||
{
|
||||
switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
|
||||
{
|
||||
case LIT_CHAR_LOWERCASE_X :
|
||||
case LIT_CHAR_LOWERCASE_X:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_O :
|
||||
case LIT_CHAR_LOWERCASE_O:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_B :
|
||||
case LIT_CHAR_LOWERCASE_B:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options);
|
||||
}
|
||||
@@ -455,8 +446,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
@@ -489,8 +479,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
str_p++;
|
||||
}
|
||||
|
||||
if (str_p <= end_p
|
||||
&& *str_p == LIT_CHAR_DOT)
|
||||
if (str_p <= end_p && *str_p == LIT_CHAR_DOT)
|
||||
{
|
||||
str_p++;
|
||||
|
||||
@@ -504,8 +493,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
@@ -539,9 +527,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
int32_t e_in_lit = 0;
|
||||
bool e_in_lit_sign = false;
|
||||
|
||||
if (str_p <= end_p
|
||||
&& (*str_p == LIT_CHAR_LOWERCASE_E
|
||||
|| *str_p == LIT_CHAR_UPPERCASE_E))
|
||||
if (str_p <= end_p && (*str_p == LIT_CHAR_LOWERCASE_E || *str_p == LIT_CHAR_UPPERCASE_E))
|
||||
{
|
||||
str_p++;
|
||||
|
||||
@@ -569,8 +555,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
@@ -587,7 +572,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
}
|
||||
|
||||
e_in_lit = e_in_lit * 10 + digit_value;
|
||||
int32_t e_check = e + (int32_t) digits - 1 + (e_in_lit_sign ? -e_in_lit : e_in_lit);
|
||||
int32_t e_check = e + (int32_t) digits - 1 + (e_in_lit_sign ? -e_in_lit : e_in_lit);
|
||||
|
||||
if (e_check > NUMBER_MAX_DECIMAL_EXPONENT)
|
||||
{
|
||||
@@ -764,8 +749,7 @@ ecma_uint32_to_utf8_string (uint32_t value, /**< value to convert */
|
||||
buf_p--;
|
||||
*buf_p = (lit_utf8_byte_t) ((value % 10) + LIT_CHAR_0);
|
||||
value /= 10;
|
||||
}
|
||||
while (value != 0);
|
||||
} while (value != 0);
|
||||
|
||||
JERRY_ASSERT (buf_p >= out_buffer_p);
|
||||
|
||||
@@ -807,8 +791,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
if (abs_num >= num_2_pow_32)
|
||||
{
|
||||
num_in_uint32_range = ecma_number_calc_remainder (abs_num,
|
||||
num_2_pow_32);
|
||||
num_in_uint32_range = ecma_number_calc_remainder (abs_num, num_2_pow_32);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -822,8 +805,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
|
||||
const uint32_t ret = sign ? -uint32_num : uint32_num;
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
if (sign
|
||||
&& uint32_num != 0)
|
||||
if (sign && uint32_num != 0)
|
||||
{
|
||||
JERRY_ASSERT (ret == uint64_2_pow_32 - uint32_num);
|
||||
}
|
||||
@@ -885,16 +867,16 @@ ecma_number_to_int32 (ecma_number_t num) /**< ecma-number */
|
||||
} /* ecma_number_to_int32 */
|
||||
|
||||
/**
|
||||
* Perform conversion of ecma-number to decimal representation with decimal exponent.
|
||||
*
|
||||
* Note:
|
||||
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
|
||||
* - parameter out_digits_p corresponds to s, the digits of the number;
|
||||
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
|
||||
* - return value corresponds to k, the number of digits.
|
||||
*
|
||||
* @return the number of digits
|
||||
*/
|
||||
* Perform conversion of ecma-number to decimal representation with decimal exponent.
|
||||
*
|
||||
* Note:
|
||||
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
|
||||
* - parameter out_digits_p corresponds to s, the digits of the number;
|
||||
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
|
||||
* - return value corresponds to k, the number of digits.
|
||||
*
|
||||
* @return the number of digits
|
||||
*/
|
||||
lit_utf8_size_t
|
||||
ecma_number_to_decimal (ecma_number_t num, /**< ecma-number */
|
||||
lit_utf8_byte_t *out_digits_p, /**< [out] buffer to fill with digits */
|
||||
@@ -951,7 +933,8 @@ ecma_number_to_utf8_string (ecma_number_t num, /**< ecma-number */
|
||||
if (ecma_number_is_infinity (num))
|
||||
{
|
||||
/* 4. */
|
||||
dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL, dst_p,
|
||||
dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL,
|
||||
dst_p,
|
||||
(lit_utf8_size_t) (buffer_p + buffer_size - dst_p));
|
||||
JERRY_ASSERT (dst_p <= buffer_p + buffer_size);
|
||||
return (lit_utf8_size_t) (dst_p - buffer_p);
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -185,8 +185,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
|
||||
value_p->value);
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
if (native_pointer_p->native_info_p == native_info_p)
|
||||
{
|
||||
@@ -215,8 +214,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
}
|
||||
|
||||
item_p = item_p->next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_get_native_pointer_value */
|
||||
@@ -259,8 +257,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
|
||||
value_p->value);
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
if (native_pointer_p->native_info_p != native_info_p)
|
||||
{
|
||||
@@ -326,8 +323,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
|
||||
prev_p = item_p;
|
||||
item_p = item_p->next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
return false;
|
||||
} /* ecma_delete_native_pointer_property */
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "ecma-conversion.h"
|
||||
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -28,20 +29,17 @@
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) == sizeof (ecma_integer_value_t),
|
||||
size_of_ecma_value_t_must_be_equal_to_the_size_of_ecma_integer_value_t);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1,
|
||||
currently_directly_encoded_values_has_one_extra_flag);
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1, currently_directly_encoded_values_has_one_extra_flag);
|
||||
|
||||
JERRY_STATIC_ASSERT (((1 << (ECMA_DIRECT_SHIFT - 1)) | ECMA_TYPE_DIRECT) == ECMA_DIRECT_TYPE_SIMPLE_VALUE,
|
||||
currently_directly_encoded_values_start_after_direct_type_simple_value);
|
||||
/**
|
||||
* Position of the sign bit in ecma-numbers
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + \
|
||||
ECMA_NUMBER_BIASED_EXP_WIDTH)
|
||||
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + ECMA_NUMBER_BIASED_EXP_WIDTH)
|
||||
|
||||
#if !JERRY_NUMBER_TYPE_FLOAT64
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t),
|
||||
size_of_ecma_number_t_must_be_equal_to_4_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t), size_of_ecma_number_t_must_be_equal_to_4_bytes);
|
||||
|
||||
/**
|
||||
* Packing sign, fraction and biased exponent to ecma-number
|
||||
@@ -56,9 +54,8 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
|
||||
uint32_t packed_value = (((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) |
|
||||
(biased_exp << ECMA_NUMBER_FRACTION_WIDTH) |
|
||||
((uint32_t) fraction));
|
||||
uint32_t packed_value =
|
||||
(((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) | (biased_exp << ECMA_NUMBER_FRACTION_WIDTH) | ((uint32_t) fraction));
|
||||
|
||||
ecma_number_accessor_t u;
|
||||
u.as_uint32_t = packed_value;
|
||||
@@ -103,8 +100,7 @@ ecma_number_unpack (ecma_number_t num, /**< ecma-number */
|
||||
const int32_t ecma_number_exponent_bias = 127;
|
||||
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t),
|
||||
size_of_ecma_number_t_must_be_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t), size_of_ecma_number_t_must_be_equal_to_8_bytes);
|
||||
|
||||
/**
|
||||
* Packing sign, fraction and biased exponent to ecma-number
|
||||
@@ -116,9 +112,8 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
uint32_t biased_exp, /**< biased exponent */
|
||||
uint64_t fraction) /**< fraction */
|
||||
{
|
||||
uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS) |
|
||||
(((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) |
|
||||
fraction);
|
||||
uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS)
|
||||
| (((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) | fraction);
|
||||
|
||||
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
@@ -228,9 +223,8 @@ ecma_number_is_nan (ecma_number_t num) /**< ecma-number */
|
||||
uint32_t biased_exp = ecma_number_get_biased_exponent_field (num);
|
||||
uint64_t fraction = ecma_number_get_fraction_field (num);
|
||||
|
||||
/* IEEE-754 2008, 3.4, a */
|
||||
bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)
|
||||
&& (fraction != 0));
|
||||
/* IEEE-754 2008, 3.4, a */
|
||||
bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction != 0));
|
||||
|
||||
JERRY_ASSERT (is_nan == is_nan_ieee754);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@@ -251,7 +245,7 @@ ecma_number_make_nan (void)
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
f.as_uint64_t = 0x7ff8000000000000ull; /* double QNaN, same as the C99 nan("") returns. */
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
f.as_uint32_t = 0x7fc00000u; /* float QNaN, same as the C99 nanf("") returns. */
|
||||
f.as_uint32_t = 0x7fc00000u; /* float QNaN, same as the C99 nanf("") returns. */
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
return f.as_ecma_number_t;
|
||||
} /* ecma_number_make_nan */
|
||||
@@ -304,8 +298,8 @@ ecma_number_is_zero (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* IEEE-754 2008, 3.4, e */
|
||||
bool is_zero_ieee754 = (ecma_number_get_fraction_field (num) == 0
|
||||
&& ecma_number_get_biased_exponent_field (num) == 0);
|
||||
bool is_zero_ieee754 =
|
||||
(ecma_number_get_fraction_field (num) == 0 && ecma_number_get_biased_exponent_field (num) == 0);
|
||||
|
||||
JERRY_ASSERT (is_zero == is_zero_ieee754);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@@ -327,8 +321,7 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
|
||||
uint64_t fraction = ecma_number_get_fraction_field (num);
|
||||
|
||||
/* IEEE-754 2008, 3.4, b */
|
||||
return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)
|
||||
&& (fraction == 0));
|
||||
return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction == 0));
|
||||
} /* ecma_number_is_infinity */
|
||||
|
||||
/**
|
||||
@@ -340,11 +333,11 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_number_is_finite (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_isfinite (num);
|
||||
#elif defined (_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
return isfinite (num);
|
||||
#else
|
||||
#else /* !(defined(__GNUC__) || defined(__clang__) || defined(_WIN32)) */
|
||||
return !ecma_number_is_nan (num) && !ecma_number_is_infinity (num);
|
||||
#endif /* defined (__GNUC__) || defined (__clang__) */
|
||||
} /* ecma_number_is_finite */
|
||||
@@ -422,9 +415,7 @@ ecma_number_make_normal_positive_from_fraction_and_exponent (uint64_t fraction,
|
||||
JERRY_ASSERT ((fraction & ~((1ull << (ECMA_NUMBER_FRACTION_WIDTH + 1)) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) != 0);
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
|
||||
return ecma_number_pack (false, biased_exp, fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
|
||||
} /* ecma_number_make_normal_positive_from_fraction_and_exponent */
|
||||
|
||||
/**
|
||||
@@ -463,8 +454,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
|
||||
}
|
||||
|
||||
/* Normalizing mantissa */
|
||||
while (mantissa != 0
|
||||
&& ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
|
||||
while (mantissa != 0 && ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
|
||||
{
|
||||
exponent--;
|
||||
mantissa <<= 1;
|
||||
@@ -507,9 +497,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
|
||||
JERRY_ASSERT (biased_exp < (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1);
|
||||
JERRY_ASSERT ((mantissa & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
|
||||
return ecma_number_pack (sign,
|
||||
biased_exp,
|
||||
mantissa);
|
||||
return ecma_number_pack (sign, biased_exp, mantissa);
|
||||
} /* ecma_number_make_from_sign_mantissa_and_exponent */
|
||||
|
||||
/**
|
||||
@@ -542,9 +530,7 @@ ecma_number_get_prev (ecma_number_t num) /**< ecma-number */
|
||||
fraction--;
|
||||
}
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction);
|
||||
return ecma_number_pack (false, biased_exp, fraction);
|
||||
} /* ecma_number_get_prev */
|
||||
|
||||
/**
|
||||
@@ -581,9 +567,7 @@ ecma_number_get_next (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
fraction &= ~(1ull << ECMA_NUMBER_FRACTION_WIDTH);
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction);
|
||||
return ecma_number_pack (false, biased_exp, fraction);
|
||||
} /* ecma_number_get_next */
|
||||
|
||||
/**
|
||||
@@ -609,8 +593,7 @@ ecma_number_trunc (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
fraction &= ~((1ull << (dot_shift - exponent)) - 1);
|
||||
|
||||
ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction,
|
||||
exponent);
|
||||
ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction, exponent);
|
||||
if (sign)
|
||||
{
|
||||
return -tmp;
|
||||
@@ -639,18 +622,15 @@ ecma_number_t
|
||||
ecma_number_calc_remainder (ecma_number_t left_num, /**< left operand */
|
||||
ecma_number_t right_num) /**< right operand */
|
||||
{
|
||||
JERRY_ASSERT (!ecma_number_is_nan (left_num)
|
||||
&& !ecma_number_is_zero (left_num)
|
||||
JERRY_ASSERT (!ecma_number_is_nan (left_num) && !ecma_number_is_zero (left_num)
|
||||
&& !ecma_number_is_infinity (left_num));
|
||||
JERRY_ASSERT (!ecma_number_is_nan (right_num)
|
||||
&& !ecma_number_is_zero (right_num)
|
||||
JERRY_ASSERT (!ecma_number_is_nan (right_num) && !ecma_number_is_zero (right_num)
|
||||
&& !ecma_number_is_infinity (right_num));
|
||||
|
||||
const ecma_number_t q = ecma_number_trunc (left_num / right_num);
|
||||
ecma_number_t r = left_num - right_num * q;
|
||||
|
||||
if (ecma_number_is_zero (r)
|
||||
&& ecma_number_is_negative (left_num))
|
||||
if (ecma_number_is_zero (r) && ecma_number_is_negative (left_num))
|
||||
{
|
||||
r = -r;
|
||||
}
|
||||
@@ -667,8 +647,7 @@ ecma_number_t
|
||||
ecma_number_pow (ecma_number_t x, /**< left operand */
|
||||
ecma_number_t y) /**< right operand */
|
||||
{
|
||||
if (ecma_number_is_nan (y) ||
|
||||
(ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
|
||||
if (ecma_number_is_nan (y) || (ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
|
||||
{
|
||||
/* Handle differences between ES5.1 and ISO C standards for pow. */
|
||||
return ecma_number_make_nan ();
|
||||
@@ -692,7 +671,7 @@ extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
|
||||
ecma_integer_value_t right_integer) /**< right operand */
|
||||
{
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
/* Check if left_integer is power of 2 */
|
||||
if (JERRY_UNLIKELY ((left_integer & (left_integer - 1)) == 0))
|
||||
{
|
||||
@@ -720,16 +699,16 @@ ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
|
||||
ecma_value_t
|
||||
ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
|
||||
* string buffer */
|
||||
lit_utf8_size_t string_buff_size, /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
ecma_value_t radix) /**< routine's second argument */
|
||||
lit_utf8_size_t string_buff_size, /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
ecma_value_t radix) /**< routine's second argument */
|
||||
{
|
||||
if (string_buff_size == 0)
|
||||
{
|
||||
return ecma_make_nan_value ();
|
||||
}
|
||||
|
||||
/* 2. Remove leading whitespace. */
|
||||
/* 2. Remove leading whitespace. */
|
||||
|
||||
const lit_utf8_byte_t *string_end_p = string_buff + string_buff_size;
|
||||
const lit_utf8_byte_t *start_p = ecma_string_trim_front (string_buff, string_end_p);
|
||||
@@ -796,9 +775,7 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
}
|
||||
|
||||
/* 10. */
|
||||
if (strip_prefix
|
||||
&& ((end_p - start_p) >= 2)
|
||||
&& (current == LIT_CHAR_0))
|
||||
if (strip_prefix && ((end_p - start_p) >= 2) && (current == LIT_CHAR_0))
|
||||
{
|
||||
ecma_char_t next = *string_curr_p;
|
||||
if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X)
|
||||
@@ -896,8 +873,8 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
ecma_value_t
|
||||
ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
|
||||
* string buffer */
|
||||
lit_utf8_size_t string_buff_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
lit_utf8_size_t string_buff_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
{
|
||||
if (string_buff_size == 0)
|
||||
{
|
||||
@@ -937,8 +914,7 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
/* The input string should be at least the length of "Infinity" to be correctly processed as
|
||||
* the infinity value.
|
||||
*/
|
||||
if ((str_end_p - str_curr_p) >= (int) infinity_length
|
||||
&& memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
|
||||
if ((str_end_p - str_curr_p) >= (int) infinity_length && memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
|
||||
{
|
||||
/* String matched Infinity. */
|
||||
return ecma_make_number_value (ecma_number_make_infinity (sign));
|
||||
@@ -1021,15 +997,13 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
}
|
||||
|
||||
/* Check exponent. */
|
||||
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E)
|
||||
&& (has_whole_part || has_fraction_part)
|
||||
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E) && (has_whole_part || has_fraction_part)
|
||||
&& str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
|
||||
/* Check sign of exponent. */
|
||||
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS)
|
||||
&& str_curr_p < str_end_p)
|
||||
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS) && str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
@@ -41,8 +42,7 @@ JERRY_STATIC_ASSERT ((ECMA_STRING_MAX_REF | ECMA_STRING_CONTAINER_MASK | ECMA_ST
|
||||
JERRY_STATIC_ASSERT (ECMA_STRING_NOT_ARRAY_INDEX == UINT32_MAX,
|
||||
ecma_string_not_array_index_must_be_equal_to_uint32_max);
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0,
|
||||
ecma_type_direct_string_must_be_odd_number);
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0, ecma_type_direct_string_must_be_odd_number);
|
||||
|
||||
JERRY_STATIC_ASSERT (LIT_MAGIC_STRING__COUNT <= ECMA_DIRECT_STRING_MAX_IMM,
|
||||
all_magic_strings_must_be_encoded_as_direct_string);
|
||||
@@ -96,8 +96,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
|
||||
}
|
||||
|
||||
index = (index * 10) + (uint32_t) (*string_p++ - LIT_CHAR_0);
|
||||
}
|
||||
while (string_p < string_end_p);
|
||||
} while (string_p < string_end_p);
|
||||
|
||||
if (string_size < ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32)
|
||||
{
|
||||
@@ -107,9 +106,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
|
||||
|
||||
/* Overflow must be checked as well when size is
|
||||
* equal to ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32. */
|
||||
if (*string_p > LIT_CHAR_9
|
||||
|| *string_p < LIT_CHAR_0
|
||||
|| index > (UINT32_MAX / 10)
|
||||
if (*string_p > LIT_CHAR_9 || *string_p < LIT_CHAR_0 || index > (UINT32_MAX / 10)
|
||||
|| (index == (UINT32_MAX / 10) && *string_p > LIT_CHAR_5))
|
||||
{
|
||||
return false;
|
||||
@@ -241,8 +238,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
|
||||
{
|
||||
JERRY_ASSERT (string_p != NULL);
|
||||
|
||||
return (!ECMA_IS_DIRECT_STRING (string_p)
|
||||
&& ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
|
||||
return (!ECMA_IS_DIRECT_STRING (string_p) && ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
|
||||
} /* ecma_prop_name_is_symbol */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -251,7 +247,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_size_t length, /**< length of the buffer */
|
||||
lit_utf8_size_t size, /**< size of the buffer */
|
||||
lit_utf8_byte_t **data_p) /**< [out] pointer to the start of the string buffer */
|
||||
@@ -382,9 +378,8 @@ ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, /**< utf-8 stri
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size),
|
||||
string_size,
|
||||
&data_p);
|
||||
string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size), string_size, &data_p);
|
||||
|
||||
string_desc_p->u.hash = lit_utf8_string_calc_hash (string_p, string_size);
|
||||
memcpy (data_p, string_p, string_size);
|
||||
@@ -446,9 +441,8 @@ ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string
|
||||
JERRY_ASSERT (lit_is_valid_utf8_string (string_p, string_size, false));
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (converted_string_length,
|
||||
converted_string_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (converted_string_length, converted_string_size, &data_p);
|
||||
|
||||
const lit_utf8_byte_t *const begin_data_p = data_p;
|
||||
pos = 0;
|
||||
@@ -661,8 +655,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
if (ecma_number_is_infinity (num))
|
||||
{
|
||||
lit_magic_string_id_t id = (ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
|
||||
: LIT_MAGIC_STRING_INFINITY_UL);
|
||||
lit_magic_string_id_t id =
|
||||
(ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL : LIT_MAGIC_STRING_INFINITY_UL);
|
||||
return ecma_get_magic_string (id);
|
||||
}
|
||||
|
||||
@@ -676,9 +670,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size),
|
||||
str_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size), str_size, &data_p);
|
||||
|
||||
string_desc_p->u.hash = lit_utf8_string_calc_hash (str_buf, str_size);
|
||||
memcpy (data_p, str_buf, str_size);
|
||||
@@ -694,7 +687,7 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string */
|
||||
{
|
||||
JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT);
|
||||
@@ -709,7 +702,7 @@ ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_internal_string (lit_magic_string_id_t id) /**< identifier of magic string */
|
||||
{
|
||||
JERRY_ASSERT (id >= LIT_NON_INTERNAL_MAGIC_STRING__COUNT && id < LIT_MAGIC_STRING__COUNT);
|
||||
@@ -743,11 +736,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
|
||||
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
|
||||
const lit_utf8_byte_t *cesu8_string1_p = ecma_string_get_chars (string1_p,
|
||||
&cesu8_string1_size,
|
||||
&cesu8_string1_length,
|
||||
uint32_to_string_buffer,
|
||||
&flags);
|
||||
const lit_utf8_byte_t *cesu8_string1_p =
|
||||
ecma_string_get_chars (string1_p, &cesu8_string1_size, &cesu8_string1_length, uint32_to_string_buffer, &flags);
|
||||
|
||||
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
|
||||
JERRY_ASSERT (cesu8_string1_length > 0);
|
||||
@@ -762,10 +752,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
}
|
||||
|
||||
lit_magic_string_id_t magic_string_id;
|
||||
magic_string_id = lit_is_utf8_string_pair_magic (cesu8_string1_p,
|
||||
cesu8_string1_size,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size);
|
||||
magic_string_id =
|
||||
lit_is_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
|
||||
|
||||
if (magic_string_id != LIT_MAGIC_STRING__COUNT)
|
||||
{
|
||||
@@ -789,10 +777,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
if (lit_get_magic_string_ex_count () > 0)
|
||||
{
|
||||
lit_magic_string_ex_id_t magic_string_ex_id;
|
||||
magic_string_ex_id = lit_is_ex_utf8_string_pair_magic (cesu8_string1_p,
|
||||
cesu8_string1_size,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size);
|
||||
magic_string_ex_id =
|
||||
lit_is_ex_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
|
||||
|
||||
if (magic_string_ex_id < lit_get_magic_string_ex_count ())
|
||||
{
|
||||
@@ -802,9 +788,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length,
|
||||
new_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length, new_size, &data_p);
|
||||
|
||||
lit_string_hash_t hash_start;
|
||||
|
||||
@@ -857,18 +842,13 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
|
||||
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
|
||||
|
||||
const lit_utf8_byte_t *cesu8_string2_p = ecma_string_get_chars (string2_p,
|
||||
&cesu8_string2_size,
|
||||
&cesu8_string2_length,
|
||||
uint32_to_string_buffer,
|
||||
&flags);
|
||||
const lit_utf8_byte_t *cesu8_string2_p =
|
||||
ecma_string_get_chars (string2_p, &cesu8_string2_size, &cesu8_string2_length, uint32_to_string_buffer, &flags);
|
||||
|
||||
JERRY_ASSERT (cesu8_string2_p != NULL);
|
||||
|
||||
ecma_string_t *result_p = ecma_append_chars_to_string (string1_p,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size,
|
||||
cesu8_string2_length);
|
||||
ecma_string_t *result_p =
|
||||
ecma_append_chars_to_string (string1_p, cesu8_string2_p, cesu8_string2_size, cesu8_string2_length);
|
||||
|
||||
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
|
||||
|
||||
@@ -1200,10 +1180,7 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_p, /**< ecma-string
|
||||
return size;
|
||||
}
|
||||
|
||||
size = lit_convert_cesu8_string_to_utf8_string (chars_p,
|
||||
size,
|
||||
buffer_p,
|
||||
buffer_size);
|
||||
size = lit_convert_cesu8_string_to_utf8_string (chars_p, size, buffer_p, buffer_size);
|
||||
|
||||
if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
|
||||
{
|
||||
@@ -1606,7 +1583,6 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
JERRY_ASSERT (length == size);
|
||||
*flags_p |= ECMA_STRING_FLAG_IS_UINT32 | ECMA_STRING_FLAG_REHASH_NEEDED;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
@@ -1634,8 +1610,7 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
*length_p = length;
|
||||
}
|
||||
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII)
|
||||
&& length != size)
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII) && length != size)
|
||||
{
|
||||
*flags_p = (uint8_t) (*flags_p & (uint8_t) ~ECMA_STRING_FLAG_IS_ASCII);
|
||||
}
|
||||
@@ -1685,7 +1660,7 @@ ecma_string_is_length (const ecma_string_t *string_p) /**< property name */
|
||||
*
|
||||
* @return pointer to the converted ecma string
|
||||
*/
|
||||
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_property_to_string (ecma_property_t property, /**< property name type */
|
||||
jmem_cpointer_t prop_name_cp) /**< property name compressed pointer */
|
||||
{
|
||||
@@ -1964,8 +1939,7 @@ bool
|
||||
ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-string */
|
||||
const ecma_string_t *string2_p) /**< ecma-string */
|
||||
{
|
||||
if (ecma_compare_ecma_strings (string1_p,
|
||||
string2_p))
|
||||
if (ecma_compare_ecma_strings (string1_p, string2_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -2038,10 +2012,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
|
||||
}
|
||||
}
|
||||
|
||||
return lit_compare_utf8_strings_relational (utf8_string1_p,
|
||||
utf8_string1_size,
|
||||
utf8_string2_p,
|
||||
utf8_string2_size);
|
||||
return lit_compare_utf8_strings_relational (utf8_string1_p, utf8_string1_size, utf8_string2_p, utf8_string2_size);
|
||||
} /* ecma_compare_ecma_strings_relational */
|
||||
|
||||
/**
|
||||
@@ -2071,8 +2042,7 @@ ecma_string_get_ascii_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
return ECMA_STRING_NO_ASCII_SIZE;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id),
|
||||
lit_get_magic_string_size (id)));
|
||||
JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id), lit_get_magic_string_size (id)));
|
||||
|
||||
return lit_get_magic_string_size (id);
|
||||
}
|
||||
@@ -2120,8 +2090,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@@ -2137,8 +2106,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_length */
|
||||
|
||||
/**
|
||||
@@ -2162,8 +2130,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@@ -2196,8 +2163,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_utf8_length */
|
||||
|
||||
/**
|
||||
@@ -2259,8 +2225,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@@ -2291,8 +2256,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_utf8_size */
|
||||
|
||||
/**
|
||||
@@ -2511,7 +2475,7 @@ ecma_string_substr (const ecma_string_t *string_p, /**< pointer to an ecma strin
|
||||
*/
|
||||
const lit_utf8_byte_t *
|
||||
ecma_string_trim_front (const lit_utf8_byte_t *start_p, /**< current string's start position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
{
|
||||
ecma_char_t ch;
|
||||
|
||||
@@ -2540,7 +2504,7 @@ ecma_string_trim_front (const lit_utf8_byte_t *start_p, /**< current string's st
|
||||
*/
|
||||
const lit_utf8_byte_t *
|
||||
ecma_string_trim_back (const lit_utf8_byte_t *start_p, /**< current string's start position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
{
|
||||
ecma_char_t ch;
|
||||
|
||||
@@ -2568,7 +2532,7 @@ ecma_string_trim_back (const lit_utf8_byte_t *start_p, /**< current string's sta
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, /**< [in, out] current string position */
|
||||
lit_utf8_size_t *utf8_str_size) /**< [in, out] size of the given string */
|
||||
lit_utf8_size_t *utf8_str_size) /**< [in, out] size of the given string */
|
||||
{
|
||||
const lit_utf8_byte_t *end_p = *utf8_str_p + *utf8_str_size;
|
||||
const lit_utf8_byte_t *start_p = *utf8_str_p;
|
||||
@@ -2622,11 +2586,10 @@ ecma_string_trim (const ecma_string_t *string_p) /**< pointer to an ecma string
|
||||
ecma_value_t
|
||||
ecma_string_pad (ecma_value_t original_string_p, /**< Input ecma string */
|
||||
ecma_value_t max_length, /**< Length to pad to, including original length */
|
||||
ecma_value_t fill_string, /**< The string to pad with */
|
||||
ecma_value_t fill_string, /**< The string to pad with */
|
||||
bool pad_on_start) /**< true - if we are padding to the start, calling with padStart
|
||||
false - if we are padding to the end, calling with padEnd */
|
||||
{
|
||||
|
||||
/* 3 */
|
||||
ecma_length_t int_max_length;
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (max_length, &int_max_length)))
|
||||
@@ -2723,7 +2686,7 @@ ecma_stringbuilder_create (void)
|
||||
jmem_stats_allocate_string_bytes (initial_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create */
|
||||
|
||||
@@ -2744,12 +2707,11 @@ ecma_stringbuilder_create_from (ecma_string_t *string_p) /**< ecma string */
|
||||
jmem_stats_allocate_string_bytes (initial_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p,
|
||||
ECMA_STRINGBUILDER_STRING_PTR (header_p),
|
||||
string_size);
|
||||
size_t copied_size =
|
||||
ecma_string_copy_to_cesu8_buffer (string_p, ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
|
||||
JERRY_ASSERT (copied_size == string_size);
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create_from */
|
||||
|
||||
@@ -2772,7 +2734,7 @@ ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, /**< pointer to da
|
||||
|
||||
memcpy (ECMA_STRINGBUILDER_STRING_PTR (header_p), data_p, data_size);
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create_raw */
|
||||
|
||||
@@ -2797,7 +2759,7 @@ ecma_stringbuilder_grow (ecma_stringbuilder_t *builder_p, /**< string builder */
|
||||
jmem_stats_allocate_string_bytes (required_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return ((lit_utf8_byte_t *) header_p) + header_p->current_size - required_size;
|
||||
return ((lit_utf8_byte_t *) header_p) + header_p->current_size - required_size;
|
||||
} /* ecma_stringbuilder_grow */
|
||||
|
||||
/**
|
||||
@@ -2860,9 +2822,7 @@ ecma_stringbuilder_append (ecma_stringbuilder_t *builder_p, /**< string builder
|
||||
const lit_utf8_size_t string_size = ecma_string_get_size (string_p);
|
||||
lit_utf8_byte_t *dest_p = ecma_stringbuilder_grow (builder_p, string_size);
|
||||
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p,
|
||||
dest_p,
|
||||
string_size);
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p, dest_p, string_size);
|
||||
JERRY_ASSERT (copied_size == string_size);
|
||||
} /* ecma_stringbuilder_append */
|
||||
|
||||
@@ -2953,7 +2913,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
builder_p->header_p = NULL;
|
||||
#endif
|
||||
#endif /* !defined (JERRY_NDEBUG) */
|
||||
|
||||
size_t container_size = sizeof (ecma_short_string_t);
|
||||
const lit_string_hash_t hash = lit_utf8_string_calc_hash (string_begin_p, string_size);
|
||||
@@ -2978,9 +2938,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
|
||||
|
||||
const size_t utf8_string_size = string_size + container_size;
|
||||
header_p = jmem_heap_realloc_block (header_p, header_p->current_size, utf8_string_size);
|
||||
memmove (((lit_utf8_byte_t *) header_p + container_size),
|
||||
ECMA_STRINGBUILDER_STRING_PTR (header_p),
|
||||
string_size);
|
||||
memmove (((lit_utf8_byte_t *) header_p + container_size), ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
|
||||
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (container_size - ECMA_ASCII_STRING_HEADER_SIZE);
|
||||
@@ -3021,7 +2979,7 @@ ecma_stringbuilder_destroy (ecma_stringbuilder_t *builder_p) /**< string builder
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
builder_p->header_p = NULL;
|
||||
#endif
|
||||
#endif /* !defined (JERRY_NDEBUG) */
|
||||
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (size);
|
||||
|
||||
@@ -15,20 +15,18 @@
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
#include "ecma-function-object.h"
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK,
|
||||
ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT),
|
||||
ecma_value_part_must_start_after_flags);
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT), ecma_value_part_must_start_after_flags);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
|
||||
ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log);
|
||||
@@ -42,18 +40,16 @@ JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (jmem_cpointer_tag_t),
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
/* cppcheck-suppress zerodiv */
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t),
|
||||
uintptr_t_must_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), uintptr_t_must_fit_in_ecma_value_t);
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t),
|
||||
uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE_TRUE
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
only_the_lowest_bit_must_be_different_for_simple_value_true_and_false);
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
@@ -110,7 +106,7 @@ ecma_pointer_to_ecma_value (const void *ptr) /**< pointer */
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
static inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline void *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
|
||||
{
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@@ -277,8 +273,7 @@ extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */
|
||||
ecma_value_t second_value) /**< second ecma value */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0,
|
||||
ecma_direct_type_integer_value_must_be_zero);
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, ecma_direct_type_integer_value_must_be_zero);
|
||||
|
||||
return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
|
||||
} /* ecma_are_values_integer_numbers */
|
||||
@@ -304,8 +299,7 @@ ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_number (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_is_value_integer_number (value)
|
||||
|| ecma_is_value_float_number (value));
|
||||
return (ecma_is_value_integer_number (value) || ecma_is_value_float_number (value));
|
||||
} /* ecma_is_value_number */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING,
|
||||
@@ -362,12 +356,12 @@ ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_bigint (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
|
||||
#else /* !JERRY_BUILTIN_BIGINT */
|
||||
#else /* !JERRY_BUILTIN_BIGINT */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
} /* ecma_is_value_bigint */
|
||||
|
||||
/**
|
||||
@@ -441,14 +435,9 @@ ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
|
||||
void
|
||||
ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value)
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_string (value)
|
||||
|| ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value)
|
||||
|| ecma_is_value_object (value));
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value) || ecma_is_value_null (value) || ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value) || ecma_is_value_string (value) || ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value) || ecma_is_value_object (value));
|
||||
} /* ecma_check_value_type_is_spec_defined */
|
||||
|
||||
/**
|
||||
@@ -768,7 +757,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return floating point value
|
||||
*/
|
||||
extern inline ecma_number_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
|
||||
@@ -797,7 +786,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_string (value));
|
||||
@@ -816,7 +805,7 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_symbol (value));
|
||||
@@ -830,7 +819,7 @@ ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_prop_name (value));
|
||||
@@ -848,7 +837,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (value));
|
||||
@@ -861,7 +850,7 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern inline ecma_extended_primitive_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_primitive_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
@@ -892,7 +881,7 @@ ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
@@ -951,7 +940,7 @@ ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT) ? value : ecma_copy_value (value);
|
||||
} /* ecma_fast_copy_value */
|
||||
@@ -1006,8 +995,7 @@ void
|
||||
ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
ecma_value_t ecma_value) /**< value to assign */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0,
|
||||
ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
|
||||
if (*value_p == ecma_value)
|
||||
{
|
||||
@@ -1018,8 +1006,7 @@ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
{
|
||||
*value_p = ecma_value;
|
||||
}
|
||||
else if (ecma_is_value_float_number (ecma_value)
|
||||
&& ecma_is_value_float_number (*value_p))
|
||||
else if (ecma_is_value_float_number (ecma_value) && ecma_is_value_float_number (*value_p))
|
||||
{
|
||||
const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value);
|
||||
ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p);
|
||||
|
||||
@@ -13,20 +13,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "ecma-line-info.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "jcontext.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "byte-code.h"
|
||||
#include "re-compiler.h"
|
||||
#include "ecma-builtins.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
#include "debugger.h"
|
||||
@@ -62,13 +64,13 @@ JERRY_STATIC_ASSERT (ECMA_PROPERTY_FLAGS_MASK == ECMA_PROPERTY_CONFIGURABLE_ENUM
|
||||
|
||||
/* These checks are needed by ecma_get_object_base_type. */
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_GENERAL == ((int) ECMA_OBJECT_TYPE_GENERAL | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_GENERAL & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_GENERAL & 0x1) == 0,
|
||||
ecma_object_type_built_in_general_has_unexpected_value);
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_CLASS == ((int) ECMA_OBJECT_TYPE_CLASS | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_CLASS & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_CLASS & 0x1) == 0,
|
||||
ecma_object_type_built_in_class_has_unexpected_value);
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_ARRAY == ((int) ECMA_OBJECT_TYPE_ARRAY | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_ARRAY & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_ARRAY & 0x1) == 0,
|
||||
ecma_object_type_built_in_array_has_unexpected_value);
|
||||
|
||||
/**
|
||||
@@ -147,8 +149,7 @@ ecma_object_t *
|
||||
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
|
||||
ecma_object_t *binding_obj_p) /**< binding object */
|
||||
{
|
||||
JERRY_ASSERT (binding_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (binding_obj_p));
|
||||
JERRY_ASSERT (binding_obj_p != NULL && !ecma_is_lexical_environment (binding_obj_p));
|
||||
|
||||
ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
|
||||
|
||||
@@ -156,8 +157,7 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
|
||||
|
||||
ecma_init_gc_info (new_lexical_environment_p);
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp,
|
||||
binding_obj_p);
|
||||
ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp, binding_obj_p);
|
||||
|
||||
ECMA_SET_POINTER (new_lexical_environment_p->u2.outer_reference_cp, outer_lexical_environment_p);
|
||||
|
||||
@@ -298,7 +298,7 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
|
||||
*
|
||||
* @return pointer to ecma object
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_PURE
|
||||
extern inline ecma_object_t *JERRY_ATTR_PURE
|
||||
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -381,8 +381,7 @@ ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, /**< declarative
|
||||
}
|
||||
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
}
|
||||
while (prop_iter_cp != JMEM_CP_NULL);
|
||||
} while (prop_iter_cp != JMEM_CP_NULL);
|
||||
|
||||
ecma_deref_object (lex_env_p);
|
||||
return new_lex_env_p;
|
||||
@@ -411,8 +410,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
if (*property_list_head_p != ECMA_NULL_POINTER)
|
||||
{
|
||||
/* If the first entry is free (deleted), it is reused. */
|
||||
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
ecma_property_header_t *first_property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
bool has_hashmap = false;
|
||||
@@ -420,8 +419,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
property_list_head_p = &first_property_p->next_property_cp;
|
||||
first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
has_hashmap = true;
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
@@ -433,8 +431,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_property_pair_t *first_property_pair_p = (ecma_property_pair_t *) first_property_p;
|
||||
|
||||
ecma_property_t name_type;
|
||||
first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p,
|
||||
&name_type);
|
||||
first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p, &name_type);
|
||||
first_property_p->types[0] = (ecma_property_t) (type_and_flags | name_type);
|
||||
|
||||
ecma_property_t *property_p = first_property_p->types + 0;
|
||||
@@ -456,10 +453,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (has_hashmap)
|
||||
{
|
||||
ecma_property_hashmap_insert (object_p,
|
||||
name_p,
|
||||
first_property_pair_p,
|
||||
0);
|
||||
ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 0);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@@ -478,8 +472,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (*property_list_head_p != ECMA_NULL_POINTER)
|
||||
{
|
||||
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
ecma_property_header_t *first_property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
|
||||
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
@@ -495,8 +489,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
first_property_pair_p->names_cp[0] = LIT_INTERNAL_MAGIC_STRING_DELETED;
|
||||
|
||||
ecma_property_t name_type;
|
||||
first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p,
|
||||
&name_type);
|
||||
first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p, &name_type);
|
||||
|
||||
first_property_pair_p->header.types[1] = (ecma_property_t) (type_and_flags | name_type);
|
||||
|
||||
@@ -518,10 +511,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (has_hashmap)
|
||||
{
|
||||
ecma_property_hashmap_insert (object_p,
|
||||
name_p,
|
||||
first_property_pair_p,
|
||||
1);
|
||||
ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 1);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@@ -542,8 +532,7 @@ ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
|
||||
* if this field is non-NULL */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|
||||
|| !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
|
||||
|
||||
@@ -570,8 +559,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
* if this field is non-NULL */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|
||||
|| !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE) == 0);
|
||||
|
||||
@@ -630,8 +618,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL);
|
||||
JERRY_ASSERT (name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|
||||
|| !ecma_op_object_is_fast_array (obj_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|
||||
|
||||
#if JERRY_LCACHE
|
||||
ecma_property_t *property_p = ecma_lcache_lookup (obj_p, name_p);
|
||||
@@ -648,17 +635,13 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
jmem_cpointer_t property_real_name_cp;
|
||||
property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p,
|
||||
name_p,
|
||||
&property_real_name_cp);
|
||||
property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p, name_p, &property_real_name_cp);
|
||||
#if JERRY_LCACHE
|
||||
if (property_p != NULL
|
||||
&& !ecma_is_property_lcached (property_p))
|
||||
if (property_p != NULL && !ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_insert (obj_p, property_real_name_cp, property_p);
|
||||
}
|
||||
@@ -682,8 +665,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
@@ -717,8 +699,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
{
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
@@ -763,8 +744,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
#if JERRY_LCACHE
|
||||
if (property_p != NULL
|
||||
&& !ecma_is_property_lcached (property_p))
|
||||
if (property_p != NULL && !ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_insert (obj_p, property_name_cp, property_p);
|
||||
}
|
||||
@@ -788,8 +768,7 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL);
|
||||
JERRY_ASSERT (name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|
||||
|| !ecma_op_object_is_fast_array (obj_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
@@ -816,8 +795,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
if (cur_prop_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
cur_prop_cp);
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
|
||||
|
||||
if (cur_prop_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
@@ -830,8 +808,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
while (cur_prop_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
cur_prop_cp);
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (cur_prop_p));
|
||||
|
||||
@@ -846,9 +823,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP)
|
||||
{
|
||||
hashmap_status = ecma_property_hashmap_delete (object_p,
|
||||
prop_pair_p->names_cp[i],
|
||||
cur_prop_p->types + i);
|
||||
hashmap_status = ecma_property_hashmap_delete (object_p, prop_pair_p->names_cp[i], cur_prop_p->types + i);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@@ -988,8 +963,7 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_value_p->getter_setter_pair_cp);
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->getter_cp, getter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.getter_cp, getter_p);
|
||||
@@ -1008,8 +982,7 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_value_p->getter_setter_pair_cp);
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->setter_cp, setter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.setter_cp, setter_p);
|
||||
@@ -1059,7 +1032,7 @@ ecma_property_to_reference (ecma_property_t *property_p) /**< data or reference
|
||||
*
|
||||
* @return pointer to the value
|
||||
*/
|
||||
extern inline ecma_property_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_value_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_property_value_from_named_reference (ecma_property_value_t *reference_p) /**< data property reference */
|
||||
{
|
||||
ecma_value_t value = reference_p->value;
|
||||
@@ -1248,14 +1221,12 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
|
||||
ecma_free_value (prop_desc_p->value);
|
||||
}
|
||||
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED)
|
||||
&& prop_desc_p->get_p != NULL)
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) && prop_desc_p->get_p != NULL)
|
||||
{
|
||||
ecma_deref_object (prop_desc_p->get_p);
|
||||
}
|
||||
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED)
|
||||
&& prop_desc_p->set_p != NULL)
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED) && prop_desc_p->set_p != NULL)
|
||||
{
|
||||
ecma_deref_object (prop_desc_p->set_p);
|
||||
}
|
||||
@@ -1551,8 +1522,8 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
|
||||
for (uint32_t i = const_literal_end; i < literal_end; i++)
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_literal_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_start_p[i]);
|
||||
ecma_compiled_code_t *bytecode_literal_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
|
||||
|
||||
/* Self references are ignored. */
|
||||
if (bytecode_literal_p != bytecode_p)
|
||||
@@ -1606,8 +1577,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
jerry_debugger_byte_code_free_t *first_byte_code_free_p;
|
||||
|
||||
first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t,
|
||||
byte_code_free_head);
|
||||
first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_head);
|
||||
first_byte_code_free_p->prev_cp = byte_code_free_cp;
|
||||
}
|
||||
|
||||
@@ -1629,8 +1599,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
}
|
||||
|
||||
jmem_heap_free_block (bytecode_p,
|
||||
((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
jmem_heap_free_block (bytecode_p, ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
} /* ecma_bytecode_deref */
|
||||
|
||||
/**
|
||||
@@ -1659,8 +1628,7 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
|
||||
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT)
|
||||
{
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1687,8 +1655,8 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
object_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
ext_object_p->u.bound_function.target_function);
|
||||
object_p =
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_object_p->u.bound_function.target_function);
|
||||
continue;
|
||||
}
|
||||
#if JERRY_ESNEXT
|
||||
@@ -1741,7 +1709,7 @@ ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode
|
||||
*
|
||||
* @return position of the function name of the compiled code
|
||||
*/
|
||||
extern inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ECMA_HELPERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-strings.h"
|
||||
|
||||
@@ -47,8 +48,8 @@
|
||||
* Set value of non-null compressed pointer so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \
|
||||
non_compressed_pointer)
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||
JMEM_CP_SET_NON_NULL_POINTER (field, non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Set value of pointer-tag value so that it will correspond
|
||||
@@ -88,42 +89,38 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_REHASH_NEEDED = (1 << 1), /**< The hash of the string must be recalculated.
|
||||
* For more details see ecma_append_chars_to_string */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
|
||||
} ecma_string_flag_t;
|
||||
|
||||
/**
|
||||
* Underscore is ignored when this option is passed.
|
||||
*/
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
|
||||
/**
|
||||
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
|
||||
*/
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
utf8_str_size) /**< [out] output buffer size */ \
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr ## flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, \
|
||||
&utf8_str_size, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
&utf8_ptr ## flags);
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr##flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, &utf8_str_size, NULL, NULL, &utf8_ptr##flags);
|
||||
|
||||
/**
|
||||
* Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
|
||||
*/
|
||||
#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr ## flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr##flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
}
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@@ -131,64 +128,54 @@ typedef enum
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ((type *) field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ((type *) field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) NULL))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) NULL))
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
ECMA_SET_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ECMA_SET_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
ECMA_GET_POINTER (type, field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ECMA_GET_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@@ -264,7 +251,7 @@ ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_exte
|
||||
uint32_t type);
|
||||
ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value);
|
||||
ecma_number_t * ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t *ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value);
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value);
|
||||
#if JERRY_ESNEXT
|
||||
@@ -299,14 +286,12 @@ ecma_length_t ecma_op_advance_string_index (ecma_string_t *str_p, ecma_length_t
|
||||
ecma_string_t *ecma_new_map_key_string (ecma_value_t value);
|
||||
bool ecma_prop_name_is_map_key (ecma_string_t *string_p);
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size,
|
||||
void *user_p);
|
||||
ecma_string_t *
|
||||
ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size, void *user_p);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
|
||||
#if JERRY_ESNEXT
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
|
||||
@@ -331,28 +316,24 @@ void ecma_destroy_ecma_string (ecma_string_t *string_p);
|
||||
ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
|
||||
uint32_t ecma_string_get_array_index (const ecma_string_t *str_p);
|
||||
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
void
|
||||
ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size);
|
||||
const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p,
|
||||
lit_utf8_size_t *size_p,
|
||||
lit_utf8_size_t *length_p,
|
||||
@@ -369,7 +350,8 @@ jmem_cpointer_t ecma_string_to_property_name (ecma_string_t *prop_name_p, ecma_p
|
||||
ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp,
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property,
|
||||
jmem_cpointer_t prop_name_cp,
|
||||
const ecma_string_t *string_p);
|
||||
|
||||
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
@@ -387,20 +369,16 @@ lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
|
||||
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
|
||||
const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p,
|
||||
lit_utf8_size_t *utf8_str_size);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, lit_utf8_size_t *utf8_str_size);
|
||||
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
|
||||
#if JERRY_ESNEXT
|
||||
ecma_value_t ecma_string_pad (ecma_value_t original_string_p,
|
||||
ecma_value_t max_length,
|
||||
ecma_value_t fill_string,
|
||||
bool pad_on_start);
|
||||
ecma_value_t
|
||||
ecma_string_pad (ecma_value_t original_string_p, ecma_value_t max_length, ecma_value_t fill_string, bool pad_on_start);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create (void);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p,
|
||||
const lit_utf8_size_t data_size);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, const lit_utf8_size_t data_size);
|
||||
lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p);
|
||||
lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p);
|
||||
void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size);
|
||||
@@ -425,18 +403,15 @@ bool ecma_number_is_negative (ecma_number_t num);
|
||||
bool ecma_number_is_zero (ecma_number_t num);
|
||||
bool ecma_number_is_infinity (ecma_number_t num);
|
||||
bool ecma_number_is_finite (ecma_number_t num);
|
||||
ecma_number_t
|
||||
ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
|
||||
ecma_number_t ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
|
||||
ecma_number_t ecma_number_get_prev (ecma_number_t num);
|
||||
ecma_number_t ecma_number_get_next (ecma_number_t num);
|
||||
ecma_number_t ecma_number_trunc (ecma_number_t num);
|
||||
ecma_number_t ecma_number_calc_remainder (ecma_number_t left_num, ecma_number_t right_num);
|
||||
ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y);
|
||||
ecma_value_t ecma_number_parse_int (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size,
|
||||
ecma_value_t radix);
|
||||
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size);
|
||||
ecma_value_t
|
||||
ecma_number_parse_int (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size, ecma_value_t radix);
|
||||
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size);
|
||||
ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer);
|
||||
lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p);
|
||||
|
||||
@@ -476,30 +451,33 @@ ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecm
|
||||
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
|
||||
ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values);
|
||||
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_accessor_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_object_t *get_p,
|
||||
ecma_object_t *set_p, uint8_t prop_attributes, ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *ecma_create_named_data_property (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *ecma_create_named_accessor_property (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_object_t *get_p,
|
||||
ecma_object_t *set_p,
|
||||
uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
void ecma_create_named_reference_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_value_t reference);
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ecma_property_t *
|
||||
ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_value_t *
|
||||
ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_value_t *ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
|
||||
void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p);
|
||||
|
||||
void ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_value_t value);
|
||||
void
|
||||
ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, ecma_value_t value);
|
||||
|
||||
ecma_getter_setter_pointers_t *
|
||||
ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_getter_setter_pointers_t *ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *getter_p);
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *setter_p);
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ecma_value_t ecma_property_to_reference (ecma_property_t *property_p);
|
||||
@@ -549,15 +527,15 @@ uintptr_t ecma_get_current_stack_usage (void);
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
|
||||
/* ecma-helpers-external-pointers.c */
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p, void *native_p,
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p,
|
||||
void *native_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_object_native_info_t *native_info_p);
|
||||
|
||||
/* ecma-helpers-conversion.c */
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size,
|
||||
uint32_t option);
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, uint32_t option);
|
||||
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
|
||||
uint32_t ecma_number_to_uint32 (ecma_number_t num);
|
||||
int32_t ecma_number_to_int32 (ecma_number_t num);
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-init-finalize.h"
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-init-finalize.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
#include "jmem.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -89,8 +91,7 @@ ecma_finalize (void)
|
||||
{
|
||||
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS);
|
||||
}
|
||||
}
|
||||
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
} while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp);
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -98,7 +100,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
|
||||
do
|
||||
@@ -109,8 +111,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
ecma_lcache_invalidate_entry (--entry_p);
|
||||
@@ -136,7 +137,7 @@ insert:
|
||||
* @return a pointer to an ecma_property_t if the lookup is successful
|
||||
* NULL otherwise
|
||||
*/
|
||||
extern inline ecma_property_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
const ecma_string_t *prop_name_p) /**< property's name */
|
||||
{
|
||||
@@ -161,7 +162,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp);
|
||||
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp);
|
||||
|
||||
@@ -173,8 +174,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
return entry_p->prop_p;
|
||||
}
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_lcache_lookup */
|
||||
@@ -195,12 +195,12 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
|
||||
while (true)
|
||||
{
|
||||
/* The property must be present. */
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache)[row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
|
||||
if (entry_p->id != 0 && entry_p->prop_p == prop_p)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_LCACHE
|
||||
void ecma_lcache_insert (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p);
|
||||
ecma_property_t *ecma_lcache_lookup (const ecma_object_t *object_p, const ecma_string_t *prop_name_p);
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-line-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#if JERRY_LINE_INFO
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -45,8 +46,7 @@ ecma_line_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
|
||||
do
|
||||
{
|
||||
value = (value << ECMA_LINE_INFO_VLQ_SHIFT) | (*source_p & ECMA_LINE_INFO_VLQ_MASK);
|
||||
}
|
||||
while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
|
||||
} while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
@@ -169,8 +169,7 @@ ecma_line_info_get (uint8_t *line_info_p, /**< line info buffer */
|
||||
column = ecma_line_info_difference_update (column, value);
|
||||
|
||||
end_offset += end_offset_increase;
|
||||
}
|
||||
while (end_offset_increase != 0 && end_offset <= offset);
|
||||
} while (end_offset_increase != 0 && end_offset <= offset);
|
||||
|
||||
location_p->line = line;
|
||||
location_p->column = column;
|
||||
|
||||
@@ -90,8 +90,7 @@
|
||||
/**
|
||||
* Minimum size of a stream (except the last one).
|
||||
*/
|
||||
#define ECMA_LINE_INFO_STREAM_SIZE_MIN \
|
||||
((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
|
||||
#define ECMA_LINE_INFO_STREAM_SIZE_MIN ((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
|
||||
|
||||
/* Helper functions for parser/js/js-parser-line-info-create.c. */
|
||||
uint32_t ecma_line_info_decode_vlq (uint8_t **buffer_p);
|
||||
@@ -99,8 +98,7 @@ uint32_t ecma_line_info_difference_update (uint32_t current_value, uint32_t diff
|
||||
|
||||
/* General functions. */
|
||||
void ecma_line_info_free (uint8_t *line_info_p);
|
||||
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset,
|
||||
jerry_backtrace_location_t *location_p);
|
||||
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset, jerry_backtrace_location_t *location_p);
|
||||
|
||||
#if JERRY_PARSER_DUMP_BYTE_CODE
|
||||
void ecma_line_info_dump (uint8_t *line_info_p);
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -42,8 +44,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
|
||||
{
|
||||
if (symbol_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
symbol_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, symbol_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_deref_ecma_string (string_p);
|
||||
@@ -71,8 +72,7 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
|
||||
{
|
||||
if (string_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_destroy_ecma_string (string_p);
|
||||
@@ -93,8 +93,7 @@ ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
|
||||
{
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@@ -120,15 +119,14 @@ ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
|
||||
{
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (bigint_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_extended_primitive_t *bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
ecma_extended_primitive_t *bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p));
|
||||
ecma_deref_bigint (bigint_p);
|
||||
}
|
||||
@@ -168,8 +166,8 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
lit_utf8_size_t size, /**< size of the string */
|
||||
bool is_ascii) /**< encode of the string */
|
||||
{
|
||||
ecma_string_t *string_p = (is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size)
|
||||
: ecma_new_ecma_string_from_utf8 (chars_p, size));
|
||||
ecma_string_t *string_p =
|
||||
(is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size) : ecma_new_ecma_string_from_utf8 (chars_p, size));
|
||||
|
||||
if (ECMA_IS_DIRECT_STRING (string_p))
|
||||
{
|
||||
@@ -194,8 +192,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (string_p, value_p))
|
||||
{
|
||||
@@ -256,8 +253,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@@ -270,8 +266,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t,
|
||||
number_list_p->values[i]);
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]);
|
||||
|
||||
if (*number_p == number_arg)
|
||||
{
|
||||
@@ -330,8 +325,7 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@@ -344,8 +338,8 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
ecma_extended_primitive_t *other_bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);
|
||||
|
||||
if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
|
||||
@@ -417,8 +411,9 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
/**
|
||||
* Append the value at the end of the appropriate list if it is not present there.
|
||||
*/
|
||||
void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
void
|
||||
ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
{
|
||||
/* Unlike direct numbers, direct strings are converted to character literals. */
|
||||
if (!ecma_is_value_string (value)
|
||||
@@ -498,11 +493,9 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
|
||||
|
||||
for (uint32_t i = const_literal_end; i < literal_end; i++)
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_p[i]);
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_p[i]);
|
||||
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& bytecode_p != compiled_code_p)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags) && bytecode_p != compiled_code_p)
|
||||
{
|
||||
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ECMA_LIT_STORAGE_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-globals.h"
|
||||
|
||||
@@ -48,18 +49,19 @@ ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
|
||||
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p,
|
||||
uint32_t *buffer_p,
|
||||
size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p,
|
||||
lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
uint32_t *out_map_len_p);
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
#if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
|
||||
ecma_value_t
|
||||
ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
|
||||
ecma_value_t *
|
||||
ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p, uint8_t *byte_code_end_p);
|
||||
ecma_value_t ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
|
||||
ecma_value_t *ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p,
|
||||
uint8_t *byte_code_end_p);
|
||||
#endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "ecma-module.h"
|
||||
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
@@ -21,8 +21,9 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-module.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "vm.h"
|
||||
|
||||
@@ -104,15 +105,15 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_ERROR;
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL
|
||||
&& !jcontext_has_pending_abort ())
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL && !jcontext_has_pending_abort ())
|
||||
{
|
||||
jerry_value_t exception = jcontext_take_exception ();
|
||||
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_ERROR,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
exception,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_ERROR,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
exception,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
jcontext_raise_exception (exception);
|
||||
}
|
||||
} /* ecma_module_set_error_state */
|
||||
@@ -122,7 +123,7 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
|
||||
*
|
||||
* @return module pointer
|
||||
*/
|
||||
static inline ecma_module_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_module_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_module_get_from_object (ecma_value_t module_val) /**< module */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (module_val));
|
||||
@@ -210,8 +211,7 @@ ecma_module_resolve_set_append (ecma_module_resolve_set_t *set_p, /**< resolve s
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (current_p->module_p == module_p
|
||||
&& ecma_compare_ecma_strings (current_p->name_p, export_name_p))
|
||||
if (current_p->module_p == module_p && ecma_compare_ecma_strings (current_p->name_p, export_name_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -339,16 +339,14 @@ ecma_module_resolve_import (ecma_module_resolve_result_t *resolve_result_p, /**<
|
||||
{
|
||||
JERRY_ASSERT (import_node_p != NULL);
|
||||
|
||||
for (ecma_module_names_t *import_names_p = import_node_p->module_names_p;
|
||||
import_names_p != NULL;
|
||||
for (ecma_module_names_t *import_names_p = import_node_p->module_names_p; import_names_p != NULL;
|
||||
import_names_p = import_names_p->next_p)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (local_name_p, import_names_p->local_name_p))
|
||||
{
|
||||
ecma_module_t *imported_module_p = ecma_module_get_from_object (import_node_p->u.path_or_module);
|
||||
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace import. */
|
||||
ecma_value_t namespace = ecma_make_object_value (imported_module_p->namespace_object_p);
|
||||
@@ -401,19 +399,18 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
|
||||
if (current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE)
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (current_module_p->namespace_object_p,
|
||||
current_export_name_p);
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (current_module_p->namespace_object_p, current_export_name_p);
|
||||
|
||||
if (property_p != NULL)
|
||||
{
|
||||
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
JERRY_ASSERT ((!(*property_p & ECMA_PROPERTY_FLAG_DATA)
|
||||
&& !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG))
|
||||
|| ((*property_p & ECMA_PROPERTY_FLAG_DATA)
|
||||
&& ecma_is_value_object (property_value_p->value)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (property_value_p->value),
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE)));
|
||||
JERRY_ASSERT (
|
||||
(!(*property_p & ECMA_PROPERTY_FLAG_DATA) && !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG))
|
||||
|| ((*property_p & ECMA_PROPERTY_FLAG_DATA) && ecma_is_value_object (property_value_p->value)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (property_value_p->value),
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE)));
|
||||
|
||||
if (!ecma_module_resolve_update (resolve_result_p, property_value_p->value))
|
||||
{
|
||||
@@ -432,8 +429,8 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
{
|
||||
if (ecma_compare_ecma_strings (current_export_name_p, export_names_p->imex_name_p))
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (current_module_p->scope_p,
|
||||
export_names_p->local_name_p);
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (current_module_p->scope_p, export_names_p->local_name_p);
|
||||
|
||||
if (property_p != NULL)
|
||||
{
|
||||
@@ -473,8 +470,7 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
{
|
||||
ecma_module_t *target_module_p = ecma_module_get_from_object (*indirect_export_p->u.module_object_p);
|
||||
|
||||
if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace export. */
|
||||
ecma_value_t namespace = ecma_make_object_value (target_module_p->namespace_object_p);
|
||||
@@ -525,10 +521,9 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
star_export_p = star_export_p->next_p;
|
||||
}
|
||||
|
||||
next_iteration:
|
||||
next_iteration:
|
||||
current_set_p = current_set_p->next_p;
|
||||
}
|
||||
while (current_set_p != NULL);
|
||||
} while (current_set_p != NULL);
|
||||
|
||||
exit:
|
||||
ecma_module_resolve_set_cleanup (resolve_set_p);
|
||||
@@ -586,10 +581,11 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
|
||||
{
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_EVALUATED,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
ret_value,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_EVALUATED,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
ret_value,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -746,8 +742,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
@@ -802,8 +797,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
export_names_p = export_names_p->next_p;
|
||||
}
|
||||
while (export_names_p != NULL);
|
||||
} while (export_names_p != NULL);
|
||||
}
|
||||
|
||||
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
|
||||
@@ -848,8 +842,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
current_set_p = current_set_p->next_p;
|
||||
}
|
||||
while (current_set_p != NULL);
|
||||
} while (current_set_p != NULL);
|
||||
|
||||
ecma_value_t *buffer_p = properties_p->buffer_p;
|
||||
uint32_t item_count = properties_p->item_count;
|
||||
@@ -863,8 +856,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
end -= 2;
|
||||
ecma_module_heap_sort_shift_down (buffer_p, item_count, end);
|
||||
}
|
||||
while (end > 0);
|
||||
} while (end > 0);
|
||||
|
||||
end = item_count - 2;
|
||||
|
||||
@@ -880,8 +872,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
|
||||
ecma_module_heap_sort_shift_down (buffer_p, end, 0);
|
||||
end -= 2;
|
||||
}
|
||||
while (end > 0);
|
||||
} while (end > 0);
|
||||
}
|
||||
|
||||
ecma_value_t *buffer_end_p = properties_p->buffer_p + item_count;
|
||||
@@ -989,15 +980,12 @@ ecma_module_connect_imports (ecma_module_t *module_p)
|
||||
|
||||
while (import_names_p != NULL)
|
||||
{
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace import. */
|
||||
ecma_property_value_t *value_p;
|
||||
value_p = ecma_create_named_data_property (module_p->scope_p,
|
||||
import_names_p->local_name_p,
|
||||
ECMA_PROPERTY_FIXED,
|
||||
NULL);
|
||||
value_p =
|
||||
ecma_create_named_data_property (module_p->scope_p, import_names_p->local_name_p, ECMA_PROPERTY_FIXED, NULL);
|
||||
value_p->value = ecma_make_object_value (imported_module_p->namespace_object_p);
|
||||
}
|
||||
else
|
||||
@@ -1021,9 +1009,7 @@ ecma_module_connect_imports (ecma_module_t *module_p)
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_create_named_reference_property (module_p->scope_p,
|
||||
import_names_p->local_name_p,
|
||||
resolve_result.result);
|
||||
ecma_create_named_reference_property (module_p->scope_p, import_names_p->local_name_p, resolve_result.result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1253,9 +1239,8 @@ restart:
|
||||
|
||||
if (current_module_p->namespace_object_p == NULL)
|
||||
{
|
||||
ecma_object_t *namespace_object_p = ecma_create_object (NULL,
|
||||
sizeof (ecma_extended_object_t),
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_object_t *namespace_object_p =
|
||||
ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
namespace_object_p->type_flags_refs &= (ecma_object_descriptor_t) ~ECMA_OBJECT_FLAG_EXTENSIBLE;
|
||||
|
||||
@@ -1297,8 +1282,7 @@ restart:
|
||||
}
|
||||
|
||||
iterator_p = iterator_p->prev_p;
|
||||
}
|
||||
while (iterator_p != end_p);
|
||||
} while (iterator_p != end_p);
|
||||
|
||||
iterator_p = last_p;
|
||||
|
||||
@@ -1313,8 +1297,7 @@ restart:
|
||||
}
|
||||
|
||||
iterator_p = iterator_p->prev_p;
|
||||
}
|
||||
while (iterator_p != end_p);
|
||||
} while (iterator_p != end_p);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -1325,16 +1308,16 @@ restart:
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
|
||||
{
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_LINKED,
|
||||
ecma_make_object_value (&last_p->module_p->header.object),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_LINKED,
|
||||
ecma_make_object_value (&last_p->module_p->header.object),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
}
|
||||
|
||||
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
|
||||
last_p = prev_p;
|
||||
}
|
||||
while (last_p != end_p);
|
||||
} while (last_p != end_p);
|
||||
|
||||
if (current_p == NULL)
|
||||
{
|
||||
@@ -1357,8 +1340,7 @@ error:
|
||||
|
||||
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
|
||||
last_p = prev_p;
|
||||
}
|
||||
while (last_p != NULL);
|
||||
} while (last_p != NULL);
|
||||
|
||||
return ECMA_VALUE_ERROR;
|
||||
} /* ecma_module_link */
|
||||
@@ -1397,8 +1379,7 @@ ecma_module_import (ecma_value_t specifier, /**< module specifier */
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ecma_is_value_object (result)
|
||||
&& ecma_is_promise (ecma_get_object_from_value (result)))
|
||||
if (ecma_is_value_object (result) && ecma_is_promise (ecma_get_object_from_value (result)))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
#ifndef ECMA_MODULE_H
|
||||
#define ECMA_MODULE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
|
||||
#define ECMA_MODULE_MAX_PATH 255u
|
||||
@@ -40,8 +41,8 @@ typedef enum
|
||||
typedef struct ecma_module_names
|
||||
{
|
||||
struct ecma_module_names *next_p; /**< next linked list node */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
} ecma_module_names_t;
|
||||
|
||||
/**
|
||||
@@ -54,19 +55,19 @@ typedef struct ecma_module_names
|
||||
typedef struct ecma_module
|
||||
{
|
||||
/* Note: state is stored in header.u.class_prop.extra_info */
|
||||
ecma_extended_object_t header; /**< header part */
|
||||
ecma_extended_object_t header; /**< header part */
|
||||
/* TODO(dbatyai): These could be compressed pointers */
|
||||
ecma_object_t *scope_p; /**< lexical lenvironment of the module */
|
||||
ecma_object_t *namespace_object_p; /**< namespace object of the module */
|
||||
struct ecma_module_node *imports_p; /**< import requests of the module */
|
||||
ecma_module_names_t *local_exports_p; /**< local exports of the module */
|
||||
struct ecma_module_node *indirect_exports_p; /**< indirect exports of the module */
|
||||
struct ecma_module_node *star_exports_p; /**< star exports of the module */
|
||||
ecma_object_t *scope_p; /**< lexical lenvironment of the module */
|
||||
ecma_object_t *namespace_object_p; /**< namespace object of the module */
|
||||
struct ecma_module_node *imports_p; /**< import requests of the module */
|
||||
ecma_module_names_t *local_exports_p; /**< local exports of the module */
|
||||
struct ecma_module_node *indirect_exports_p; /**< indirect exports of the module */
|
||||
struct ecma_module_node *star_exports_p; /**< star exports of the module */
|
||||
|
||||
/* Code used for evaluating a module */
|
||||
union
|
||||
{
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
|
||||
jerry_native_module_evaluate_callback_t callback; /**< callback for evaluating native modules */
|
||||
} u;
|
||||
} ecma_module_t;
|
||||
@@ -98,8 +99,8 @@ typedef struct ecma_module_node
|
||||
typedef struct ecma_module_resolve_set
|
||||
{
|
||||
struct ecma_module_resolve_set *next_p; /**< next in linked list */
|
||||
ecma_module_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
ecma_module_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
} ecma_module_resolve_set_t;
|
||||
|
||||
/**
|
||||
@@ -108,17 +109,15 @@ typedef struct ecma_module_resolve_set
|
||||
typedef struct ecma_module_resolve_stack
|
||||
{
|
||||
struct ecma_module_resolve_stack *next_p; /**< next in linked list */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
} ecma_module_resolve_stack_t;
|
||||
|
||||
ecma_value_t ecma_module_initialize (ecma_module_t *module_p);
|
||||
ecma_module_t *ecma_module_get_resolved_module (ecma_value_t module_val);
|
||||
|
||||
ecma_value_t ecma_module_link (ecma_module_t *module_p,
|
||||
jerry_module_resolve_callback_t callback_p,
|
||||
void *user_p);
|
||||
ecma_value_t ecma_module_link (ecma_module_t *module_p, jerry_module_resolve_callback_t callback_p, void *user_p);
|
||||
ecma_value_t ecma_module_evaluate (ecma_module_t *module_p);
|
||||
ecma_value_t ecma_module_import (ecma_value_t specifier, ecma_value_t user_value);
|
||||
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -42,28 +44,26 @@
|
||||
/**
|
||||
* Stepping values for searching items in the hashmap.
|
||||
*/
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA =
|
||||
{
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = {
|
||||
3, 5, 7, 11, 13, 17, 19, 23
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] & (1 << ((index) & 0x7)))
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) ((byte_p)[(index) >> 3] & (1 << ((index) &0x7)))
|
||||
|
||||
/**
|
||||
* Clear the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Set the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Create a new property hashmap for the object.
|
||||
@@ -156,8 +156,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
|
||||
ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i],
|
||||
property_pair_p->names_cp[i]);
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], property_pair_p->names_cp[i]);
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
|
||||
entry_index &= mask;
|
||||
@@ -202,8 +201,8 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
/* Property hash must be exists and must be the first property. */
|
||||
JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL);
|
||||
|
||||
ecma_property_header_t *property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_header_t *property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -211,8 +210,7 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
|
||||
object_p->u1.property_list_cp = property_p->next_property_cp;
|
||||
|
||||
jmem_heap_free_block (hashmap_p,
|
||||
ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
jmem_heap_free_block (hashmap_p, ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
} /* ecma_property_hashmap_free */
|
||||
|
||||
/**
|
||||
@@ -226,8 +224,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT (property_pair_p != NULL);
|
||||
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -300,8 +298,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
jmem_cpointer_t name_cp, /**< property name */
|
||||
ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -337,8 +335,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
if ((property_pair_p->header.types + offset) == property_p)
|
||||
{
|
||||
@@ -393,9 +391,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
{
|
||||
if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
|
||||
{
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i],
|
||||
prop_pair_p->names_cp[i],
|
||||
name_p))
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i], name_p))
|
||||
{
|
||||
/* Property is found */
|
||||
property_found = true;
|
||||
@@ -437,8 +433,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
@@ -486,8 +482,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef ECMA_PROPERTY_HASHMAP_H
|
||||
#define ECMA_PROPERTY_HASHMAP_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
@@ -67,12 +69,15 @@ typedef enum
|
||||
|
||||
void ecma_property_hashmap_create (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_free (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p, int property_index);
|
||||
ecma_property_hashmap_delete_status ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp,
|
||||
ecma_property_t *property_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p,
|
||||
int property_index);
|
||||
ecma_property_hashmap_delete_status
|
||||
ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p);
|
||||
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, ecma_string_t *name_p,
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p,
|
||||
ecma_string_t *name_p,
|
||||
jmem_cpointer_t *property_real_name_cp);
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@@ -30,7 +31,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -25,19 +25,13 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.8 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_AGGREGATE_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_AGGREGATE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.9 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_AGGREGATE_ERROR_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.10 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE,
|
||||
LIT_MAGIC_STRING__EMPTY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -14,19 +14,20 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "jrt.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
@@ -34,7 +35,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -24,21 +24,15 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
2,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 2, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_AGGREGATE_ERROR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
@@ -39,7 +39,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID array_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -130,10 +130,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
index = (ecma_length_t) (ecma_get_number_from_value (index_value) + 1);
|
||||
}
|
||||
|
||||
ecma_value_t put_result = ecma_op_object_put (obj_p,
|
||||
prop_name_p,
|
||||
ecma_make_length_value (index),
|
||||
true);
|
||||
ecma_value_t put_result = ecma_op_object_put (obj_p, prop_name_p, ecma_make_length_value (index), true);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_result));
|
||||
|
||||
@@ -183,8 +180,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
|
||||
/* 17.b */
|
||||
ecma_value_t entry_array_value;
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value,
|
||||
ecma_make_length_value (index));
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value, ecma_make_length_value (index));
|
||||
|
||||
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
|
||||
ecma_free_value (entry_array_value);
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_ITERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype-unscopables.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@@ -21,49 +21,27 @@
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_AT,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_AT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
enum
|
||||
{
|
||||
ECMA_ARRAY_PROTOTYPE_ROUTINE_START = 0,
|
||||
/* Note: these 2 routine ids must be in this order */
|
||||
/* Note: these 2 routine ids must be in this order */
|
||||
#if !JERRY_ESNEXT
|
||||
ECMA_ARRAY_PROTOTYPE_TO_STRING,
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
@@ -85,7 +86,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -109,15 +110,12 @@ ecma_builtin_array_prototype_helper_set_length (ecma_object_t *object, /**< obje
|
||||
ecma_number_t length) /**< new length */
|
||||
{
|
||||
ecma_value_t length_value = ecma_make_number_value (length);
|
||||
ecma_value_t ret_value = ecma_op_object_put (object,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
length_value,
|
||||
true);
|
||||
ecma_value_t ret_value =
|
||||
ecma_op_object_put (object, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), length_value, true);
|
||||
|
||||
ecma_free_value (length_value);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ret_value)
|
||||
|| ecma_is_value_empty (ret_value)
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ret_value) || ecma_is_value_empty (ret_value)
|
||||
|| ECMA_IS_VALUE_ERROR (ret_value));
|
||||
return ret_value;
|
||||
} /* ecma_builtin_array_prototype_helper_set_length */
|
||||
@@ -202,9 +200,8 @@ ecma_builtin_array_prototype_object_concat (const ecma_value_t args[], /**< argu
|
||||
ecma_length_t new_length = 0;
|
||||
|
||||
/* 5.b - 5.c for this_arg */
|
||||
ecma_value_t concat_this_value = ecma_builtin_helper_array_concat_value (new_array_p,
|
||||
&new_length,
|
||||
ecma_make_object_value (obj_p));
|
||||
ecma_value_t concat_this_value =
|
||||
ecma_builtin_helper_array_concat_value (new_array_p, &new_length, ecma_make_object_value (obj_p));
|
||||
if (ECMA_IS_VALUE_ERROR (concat_this_value))
|
||||
{
|
||||
ecma_deref_object (new_array_p);
|
||||
@@ -227,8 +224,8 @@ ecma_builtin_array_prototype_object_concat (const ecma_value_t args[], /**< argu
|
||||
JERRY_ASSERT (ecma_is_value_empty (concat_value));
|
||||
}
|
||||
|
||||
ecma_value_t set_length_value = ecma_builtin_array_prototype_helper_set_length (new_array_p,
|
||||
((ecma_number_t) new_length));
|
||||
ecma_value_t set_length_value =
|
||||
ecma_builtin_array_prototype_helper_set_length (new_array_p, ((ecma_number_t) new_length));
|
||||
if (ECMA_IS_VALUE_ERROR (set_length_value))
|
||||
{
|
||||
ecma_deref_object (new_array_p);
|
||||
@@ -279,8 +276,7 @@ ecma_op_array_get_to_string_at_index (ecma_object_t *obj_p, /**< this object */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ecma_is_value_undefined (index_value)
|
||||
|| ecma_is_value_null (index_value))
|
||||
if (ecma_is_value_undefined (index_value) || ecma_is_value_null (index_value))
|
||||
{
|
||||
return ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
@@ -370,7 +366,7 @@ static ecma_value_t
|
||||
ecma_builtin_array_prototype_object_pop (ecma_object_t *obj_p, /**< object */
|
||||
ecma_length_t len) /**< object's length */
|
||||
{
|
||||
/* 4. */
|
||||
/* 4. */
|
||||
if (len == 0)
|
||||
{
|
||||
/* 4.a */
|
||||
@@ -523,14 +519,12 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg, /**< this ar
|
||||
ecma_object_t *obj_p, /**< object */
|
||||
ecma_length_t len) /**< object's length */
|
||||
{
|
||||
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
uint32_t middle = (uint32_t) len / 2;
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE
|
||||
&& len != 0)
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
|
||||
{
|
||||
ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp);
|
||||
|
||||
@@ -674,7 +668,7 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg, /**< this ar
|
||||
|
||||
ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
clean_up:
|
||||
clean_up:
|
||||
ecma_free_value (upper_value);
|
||||
ecma_free_value (lower_value);
|
||||
ecma_deref_ecma_string (lower_str_p);
|
||||
@@ -714,8 +708,7 @@ ecma_builtin_array_prototype_object_shift (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE
|
||||
&& len != 0)
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
|
||||
{
|
||||
ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp);
|
||||
ecma_value_t ret_value = buffer_p[0];
|
||||
@@ -817,9 +810,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
|
||||
ecma_length_t start = 0, end = len;
|
||||
|
||||
/* 5. 6.*/
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1,
|
||||
len,
|
||||
&start)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1, len, &start)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@@ -832,9 +823,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
|
||||
else
|
||||
{
|
||||
/* 7. part 2, 8.*/
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2,
|
||||
len,
|
||||
&end)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2, len, &end)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@@ -946,10 +935,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
|
||||
#else /* !JERRY_ESNEXT */
|
||||
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
n,
|
||||
get_value,
|
||||
prop_flags);
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, n, get_value, prop_flags);
|
||||
ecma_free_value (get_value);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@@ -1057,10 +1043,7 @@ ecma_builtin_array_prototype_object_sort_compare_helper (ecma_value_t lhs, /**<
|
||||
|
||||
ecma_value_t compare_args[] = { lhs, rhs };
|
||||
|
||||
ecma_value_t call_value = ecma_op_function_call (comparefn_obj_p,
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
compare_args,
|
||||
2);
|
||||
ecma_value_t call_value = ecma_op_function_call (comparefn_obj_p, ECMA_VALUE_UNDEFINED, compare_args, 2);
|
||||
if (ECMA_IS_VALUE_ERROR (call_value))
|
||||
{
|
||||
return call_value;
|
||||
@@ -1178,11 +1161,8 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum
|
||||
if (copied_num > 1)
|
||||
{
|
||||
const ecma_builtin_helper_sort_compare_fn_t sort_cb = &ecma_builtin_array_prototype_object_sort_compare_helper;
|
||||
ecma_value_t sort_value = ecma_builtin_helper_array_merge_sort_helper (values_buffer,
|
||||
(uint32_t) (copied_num),
|
||||
arg1,
|
||||
sort_cb,
|
||||
NULL);
|
||||
ecma_value_t sort_value =
|
||||
ecma_builtin_helper_array_merge_sort_helper (values_buffer, (uint32_t) (copied_num), arg1, sort_cb, NULL);
|
||||
if (ECMA_IS_VALUE_ERROR (sort_value))
|
||||
{
|
||||
goto clean_up;
|
||||
@@ -1271,9 +1251,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
if (args_number > 0)
|
||||
{
|
||||
/* ES5.1: 6, ES11: 4. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (args[0],
|
||||
len,
|
||||
&actual_start)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (args[0], len, &actual_start)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@@ -1295,8 +1273,8 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
}
|
||||
|
||||
/* ES5.1: 7 */
|
||||
actual_delete_count = (ecma_length_t) (JERRY_MIN (JERRY_MAX (delete_num, 0),
|
||||
(ecma_number_t) (len - actual_start)));
|
||||
actual_delete_count =
|
||||
(ecma_length_t) (JERRY_MIN (JERRY_MAX (delete_num, 0), (ecma_number_t) (len - actual_start)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1344,10 +1322,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
k,
|
||||
from_present,
|
||||
prop_flags);
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, k, from_present, prop_flags);
|
||||
ecma_free_value (from_present);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@@ -1364,8 +1339,8 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
/* ES11: 12. */
|
||||
ecma_value_t set_length = ecma_builtin_array_prototype_helper_set_length (new_array_p,
|
||||
((ecma_number_t) actual_delete_count));
|
||||
ecma_value_t set_length =
|
||||
ecma_builtin_array_prototype_helper_set_length (new_array_p, ((ecma_number_t) actual_delete_count));
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (set_length))
|
||||
{
|
||||
@@ -1465,10 +1440,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
uint32_t idx = 0;
|
||||
for (uint32_t arg_index = 2; arg_index < args_number; arg_index++, idx++)
|
||||
{
|
||||
ecma_value_t put_value = ecma_op_object_put_by_index (obj_p,
|
||||
actual_start + idx,
|
||||
args[arg_index],
|
||||
true);
|
||||
ecma_value_t put_value = ecma_op_object_put_by_index (obj_p, actual_start + idx, args[arg_index], true);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (put_value))
|
||||
{
|
||||
@@ -1506,13 +1478,11 @@ ecma_builtin_array_prototype_object_unshift (const ecma_value_t args[], /**< arg
|
||||
ecma_object_t *obj_p, /**< object */
|
||||
ecma_length_t len) /**< object's length */
|
||||
{
|
||||
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE
|
||||
&& len != 0)
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
|
||||
{
|
||||
if (args_number > UINT32_MAX - len)
|
||||
{
|
||||
@@ -1730,8 +1700,7 @@ ecma_builtin_array_prototype_object_index_of (const ecma_value_t args[], /**< ar
|
||||
}
|
||||
|
||||
/* 9.b.i, 9.b.ii */
|
||||
if (ecma_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (args[0], get_value))
|
||||
if (ecma_is_value_found (get_value) && ecma_op_strict_equality_compare (args[0], get_value))
|
||||
{
|
||||
ecma_free_value (get_value);
|
||||
return ecma_make_length_value (from_idx);
|
||||
@@ -1822,7 +1791,7 @@ ecma_builtin_array_prototype_object_last_index_of (const ecma_value_t args[], /*
|
||||
}
|
||||
}
|
||||
|
||||
/* 8. */
|
||||
/* 8. */
|
||||
while (from_idx < len)
|
||||
{
|
||||
/* 8.a */
|
||||
@@ -1834,8 +1803,7 @@ ecma_builtin_array_prototype_object_last_index_of (const ecma_value_t args[], /*
|
||||
}
|
||||
|
||||
/* 8.b.i, 8.b.ii */
|
||||
if (ecma_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (search_element, get_value))
|
||||
if (ecma_is_value_found (get_value) && ecma_op_strict_equality_compare (search_element, get_value))
|
||||
{
|
||||
ecma_free_value (get_value);
|
||||
return ecma_make_length_value (from_idx);
|
||||
@@ -2023,10 +1991,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */
|
||||
#else /* !JERRY_ESNEXT */
|
||||
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
index,
|
||||
mapped_value,
|
||||
prop_flags);
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, index, mapped_value, prop_flags);
|
||||
|
||||
ecma_free_value (mapped_value);
|
||||
ecma_free_value (current_value);
|
||||
@@ -2124,10 +2089,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn *
|
||||
if (ecma_op_to_boolean (call_value))
|
||||
{
|
||||
ecma_value_t put_comp;
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
new_array_index,
|
||||
get_value,
|
||||
prop_flags);
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, new_array_index, get_value, prop_flags);
|
||||
#if JERRY_ESNEXT
|
||||
if (ECMA_IS_VALUE_ERROR (put_comp))
|
||||
{
|
||||
@@ -2206,8 +2168,7 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu
|
||||
k_present = true;
|
||||
|
||||
/* 8.b.ii-iii */
|
||||
ecma_value_t current_value = ecma_op_object_find_by_index (obj_p, start_from_left ? index
|
||||
: last_index - index);
|
||||
ecma_value_t current_value = ecma_op_object_find_by_index (obj_p, start_from_left ? index : last_index - index);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (current_value))
|
||||
{
|
||||
@@ -2253,12 +2214,9 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu
|
||||
{
|
||||
/* 9.c.i, 9.c.ii */
|
||||
current_index = ecma_make_length_value (corrected_index);
|
||||
ecma_value_t call_args[] = {accumulator, current_value, current_index, ecma_make_object_value (obj_p)};
|
||||
ecma_value_t call_args[] = { accumulator, current_value, current_index, ecma_make_object_value (obj_p) };
|
||||
|
||||
ecma_value_t call_value = ecma_op_function_call (func_object_p,
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
call_args,
|
||||
4);
|
||||
ecma_value_t call_value = ecma_op_function_call (func_object_p, ECMA_VALUE_UNDEFINED, call_args, 4);
|
||||
ecma_free_value (current_index);
|
||||
ecma_free_value (accumulator);
|
||||
ecma_free_value (current_value);
|
||||
@@ -2298,9 +2256,7 @@ ecma_builtin_array_prototype_fill (ecma_value_t value, /**< value */
|
||||
ecma_length_t k, final;
|
||||
|
||||
/* 5. 6. 7. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (start_val,
|
||||
len,
|
||||
&k)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (start_val, len, &k)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@@ -2313,9 +2269,7 @@ ecma_builtin_array_prototype_fill (ecma_value_t value, /**< value */
|
||||
else
|
||||
{
|
||||
/* 8 part 2, 9, 10 */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (end_val,
|
||||
len,
|
||||
&final)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (end_val, len, &final)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@@ -2728,7 +2682,7 @@ ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will con
|
||||
{
|
||||
/* i-ii. */
|
||||
ecma_value_t source_val = ecma_make_length_value (source_index);
|
||||
ecma_value_t args[] = {element, source_val, ecma_make_object_value (source)};
|
||||
ecma_value_t args[] = { element, source_val, ecma_make_object_value (source) };
|
||||
ecma_value_t temp_element = ecma_op_function_call (ecma_get_object_from_value (mapped_value), thisArg, args, 3);
|
||||
|
||||
ecma_free_value (element);
|
||||
@@ -2787,10 +2741,8 @@ ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will con
|
||||
|
||||
/* vi. */
|
||||
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
|
||||
ecma_value_t element_temp = ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target),
|
||||
target_index,
|
||||
element,
|
||||
flags);
|
||||
ecma_value_t element_temp =
|
||||
ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target), target_index, element, flags);
|
||||
|
||||
ecma_free_value (element);
|
||||
|
||||
@@ -2885,13 +2837,8 @@ ecma_builtin_array_prototype_object_flat_map (ecma_value_t callback, /**< callba
|
||||
}
|
||||
|
||||
/* 5. */
|
||||
ecma_value_t flatten_val = ecma_builtin_array_flatten_into_array (ecma_make_object_value (new_array_p),
|
||||
obj_p,
|
||||
len,
|
||||
0,
|
||||
1,
|
||||
callback,
|
||||
this_arg);
|
||||
ecma_value_t flatten_val =
|
||||
ecma_builtin_array_flatten_into_array (ecma_make_object_value (new_array_p), obj_p, len, 0, 1, callback, this_arg);
|
||||
if (ECMA_IS_VALUE_ERROR (flatten_val))
|
||||
{
|
||||
ecma_deref_object (new_array_p);
|
||||
@@ -2937,16 +2884,11 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_SORT)
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_sort (this_arg,
|
||||
arguments_list_p[0],
|
||||
obj_p);
|
||||
|
||||
ret_value = ecma_builtin_array_prototype_object_sort (this_arg, arguments_list_p[0], obj_p);
|
||||
}
|
||||
else if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_CONCAT)
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_concat (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p);
|
||||
ret_value = ecma_builtin_array_prototype_object_concat (arguments_list_p, arguments_number, obj_p);
|
||||
}
|
||||
|
||||
ecma_deref_object (obj_p);
|
||||
@@ -3004,10 +2946,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_PUSH:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_push (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_push (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_REVERSE:
|
||||
@@ -3022,49 +2961,32 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_SLICE:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_slice (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_slice (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_SPLICE:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_splice (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_splice (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_UNSHIFT:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_unshift (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_unshift (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_AT:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_at (arguments_list_p[0],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_at (arguments_list_p[0], obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_INDEX_OF:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_index_of (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_index_of (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_LAST_INDEX_OF:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_last_index_of (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_last_index_of (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_EVERY:
|
||||
@@ -3080,10 +3002,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_MAP:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_map (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_map (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_REDUCE:
|
||||
@@ -3099,10 +3018,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
#if JERRY_ESNEXT
|
||||
case ECMA_ARRAY_PROTOTYPE_COPY_WITHIN:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_copy_within (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_copy_within (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_FIND:
|
||||
@@ -3126,26 +3042,18 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_INCLUDES:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_includes (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_includes (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_FLAT:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_flat (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_flat (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_FLATMAP:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_flat_map (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value =
|
||||
ecma_builtin_array_prototype_object_flat_map (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
@@ -3153,10 +3061,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
{
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_FILTER);
|
||||
|
||||
ret_value = ecma_builtin_array_prototype_object_filter (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_filter (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
/* ECMA-262 v6, 22.1.3.31 */
|
||||
@@ -40,9 +38,7 @@ OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.4 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
0,
|
||||
ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@@ -82,11 +78,12 @@ ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_INCLUDES, ECMA_ARRAY_PROTOTYPE_INCLUDES, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLAT, ECMA_ARRAY_PROTOTYPE_FLAT, 1, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLATMAP, ECMA_ARRAY_PROTOTYPE_FLATMAP, 2, 1)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL,
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES,
|
||||
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR,
|
||||
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
@@ -24,7 +25,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-array-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
@@ -53,7 +54,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array
|
||||
#define BUILTIN_UNDERSCORED_ID array
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -185,10 +186,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
{
|
||||
/* 6.g.iv.1 */
|
||||
ecma_value_t len_value = ecma_make_uint32_value (k);
|
||||
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len_value,
|
||||
true);
|
||||
ecma_value_t set_status =
|
||||
ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
/* 6.g.iv.2 */
|
||||
@@ -255,7 +254,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
k++;
|
||||
}
|
||||
|
||||
iterator_cleanup:
|
||||
iterator_cleanup:
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
ecma_deref_object (array_obj_p);
|
||||
@@ -376,10 +375,8 @@ iterator_cleanup:
|
||||
|
||||
/* 17. */
|
||||
len_value = ecma_make_length_value (k);
|
||||
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len_value,
|
||||
true);
|
||||
ecma_value_t set_status =
|
||||
ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
/* 18. */
|
||||
@@ -420,10 +417,8 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
ecma_value_t len = ecma_make_uint32_value (arguments_list_len);
|
||||
|
||||
ecma_value_t ret_val = ecma_op_function_construct (ecma_get_object_from_value (this_arg),
|
||||
ecma_get_object_from_value (this_arg),
|
||||
&len,
|
||||
1);
|
||||
ecma_value_t ret_val =
|
||||
ecma_op_function_construct (ecma_get_object_from_value (this_arg), ecma_get_object_from_value (this_arg), &len, 1);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ret_val))
|
||||
{
|
||||
@@ -437,10 +432,8 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
while (k < arguments_list_len)
|
||||
{
|
||||
ecma_value_t define_status = ecma_builtin_helper_def_prop_by_index (obj_p,
|
||||
k,
|
||||
arguments_list_p[k],
|
||||
prop_status_flags);
|
||||
ecma_value_t define_status =
|
||||
ecma_builtin_helper_def_prop_by_index (obj_p, k, arguments_list_p[k], prop_status_flags);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (define_status))
|
||||
{
|
||||
@@ -452,10 +445,7 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
k++;
|
||||
}
|
||||
|
||||
ret_val = ecma_op_object_put (obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len,
|
||||
true);
|
||||
ret_val = ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len, true);
|
||||
|
||||
ecma_free_value (len);
|
||||
|
||||
@@ -482,8 +472,7 @@ ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len != 1
|
||||
|| !ecma_is_value_number (arguments_list_p[0]))
|
||||
if (arguments_list_len != 1 || !ecma_is_value_number (arguments_list_p[0]))
|
||||
{
|
||||
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
@@ -514,8 +503,8 @@ ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**
|
||||
#if !JERRY_ESNEXT
|
||||
return ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* JERRY_ESNEXT */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
|
||||
ecma_object_t *proto_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
|
||||
@@ -25,21 +25,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ARRAY_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
/* Routine properties:
|
||||
@@ -50,9 +44,7 @@ ROUTINE (LIT_MAGIC_STRING_FROM, ECMA_ARRAY_ROUTINE_FROM, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0)
|
||||
|
||||
/* ECMA-262 v6, 22.1.2.5 */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
|
||||
ECMA_ARRAY_ROUTINE_SPECIES_GET,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ECMA_ARRAY_ROUTINE_SPECIES_GET, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* !(JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
@@ -22,9 +23,9 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
|
||||
@@ -32,7 +33,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Readonly accessor properties */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
@@ -34,9 +32,7 @@ ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 24.1.4.4 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
@@ -29,7 +30,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -24,20 +24,14 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@@ -46,9 +40,7 @@ STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
|
||||
|
||||
/* ES2015 24.1.3.3 */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
|
||||
ecma_builtin_arraybuffer_species_get,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ecma_builtin_arraybuffer_species_get, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jerryscript-types.h"
|
||||
|
||||
#include "ecma-builtin-handlers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
@@ -23,8 +25,8 @@
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript-types.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "lit-strings.h"
|
||||
@@ -37,8 +39,8 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@@ -53,7 +55,7 @@ enum
|
||||
} ecma_async_from_sync_iterator_operation_type_t;
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-from-sync-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_from_sync_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_from_sync_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -146,9 +148,8 @@ ecma_builtin_async_from_sync_iterator_prototype_next (ecma_async_from_sync_itera
|
||||
ecma_value_t value) /**< routine's 'value' argument */
|
||||
{
|
||||
/* 5. */
|
||||
ecma_value_t next_result = ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator,
|
||||
iter_p->sync_next_method,
|
||||
value);
|
||||
ecma_value_t next_result =
|
||||
ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator, iter_p->sync_next_method, value);
|
||||
|
||||
/* 6. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&next_result, capability_p)))
|
||||
@@ -224,10 +225,8 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
|
||||
}
|
||||
|
||||
/* 7.b. */
|
||||
ecma_value_t resolve = ecma_op_function_call (ecma_get_object_from_value (func_obj),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
&call_arg,
|
||||
arg_size);
|
||||
ecma_value_t resolve =
|
||||
ecma_op_function_call (ecma_get_object_from_value (func_obj), ECMA_VALUE_UNDEFINED, &call_arg, arg_size);
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (resolve));
|
||||
ecma_free_value (resolve);
|
||||
|
||||
@@ -273,10 +272,8 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
|
||||
ecma_value_t type_error = ecma_make_object_value (type_error_obj_p);
|
||||
|
||||
/* 10.a. */
|
||||
ecma_value_t reject = ecma_op_function_call (ecma_get_object_from_value (capability_p->reject),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
&type_error,
|
||||
1);
|
||||
ecma_value_t reject =
|
||||
ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ECMA_VALUE_UNDEFINED, &type_error, 1);
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (reject));
|
||||
ecma_deref_object (type_error_obj_p);
|
||||
ecma_free_value (reject);
|
||||
@@ -292,11 +289,11 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
|
||||
} /* ecma_builtin_async_from_sync_iterator_prototype_do */
|
||||
|
||||
/**
|
||||
* Dispatcher of the %AsyncFromSyncIteratorPrototype% built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
* Dispatcher of the %AsyncFromSyncIteratorPrototype% built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_from_sync_iterator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide
|
||||
* routine
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_function_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_function_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -22,14 +22,10 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_FUNCTION,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.2 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_function
|
||||
#define BUILTIN_UNDERSCORED_ID async_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -47,9 +47,7 @@ ecma_builtin_async_function_dispatch_call (const ecma_value_t *arguments_list_p,
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_op_create_dynamic_function (arguments_list_p,
|
||||
arguments_list_len,
|
||||
ECMA_PARSE_ASYNC_FUNCTION);
|
||||
return ecma_op_create_dynamic_function (arguments_list_p, arguments_list_len, ECMA_PARSE_ASYNC_FUNCTION);
|
||||
} /* ecma_builtin_async_function_dispatch_call */
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,24 +22,16 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v11, 25.7.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 25.7.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v10, 25.7.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.2 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_function
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -22,19 +22,13 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v10, 25.3.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v10, 25.3.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "opcodes.h"
|
||||
#include "vm-defines.h"
|
||||
@@ -31,8 +32,8 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@@ -47,7 +48,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -64,26 +65,26 @@ enum
|
||||
* Convert routine type to operation type..
|
||||
*/
|
||||
#define ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION(type) \
|
||||
((ecma_async_generator_operation_type_t) ((type) - ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
((ecma_async_generator_operation_type_t) ((type) -ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
|
||||
== ECMA_ASYNC_GENERATOR_DO_NEXT,
|
||||
== ECMA_ASYNC_GENERATOR_DO_NEXT,
|
||||
convert_ecma_async_generator_routine_next_to_ecma_async_generator_do_next_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
== ECMA_ASYNC_GENERATOR_DO_THROW,
|
||||
== ECMA_ASYNC_GENERATOR_DO_THROW,
|
||||
convert_ecma_async_generator_routine_throw_to_ecma_async_generator_do_throw_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN)
|
||||
== ECMA_ASYNC_GENERATOR_DO_RETURN,
|
||||
== ECMA_ASYNC_GENERATOR_DO_RETURN,
|
||||
convert_ecma_async_generator_routine_return_to_ecma_async_generator_do_return_failed);
|
||||
|
||||
/**
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
|
||||
@@ -25,14 +25,10 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 25.3.1.5 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_GENERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -22,14 +22,10 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.3 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
|
||||
@@ -37,7 +37,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
@@ -51,7 +52,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-atomics.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID atomics
|
||||
#define BUILTIN_UNDERSCORED_ID atomics
|
||||
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
@@ -76,7 +77,7 @@ enum
|
||||
static ecma_value_t
|
||||
ecma_builtin_atomics_compare_exchange (ecma_value_t typedarray, /**< typedArray argument */
|
||||
ecma_value_t index, /**< index argument */
|
||||
ecma_value_t expected_value, /**< expectedValue argument */
|
||||
ecma_value_t expected_value, /**< expectedValue argument */
|
||||
ecma_value_t replacement_value) /**< replacementValue argument*/
|
||||
{
|
||||
JERRY_UNUSED (typedarray);
|
||||
|
||||
@@ -22,9 +22,7 @@
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
|
||||
/* ECMA-262 v11, 24.4.14 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ATOMICS_U,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ATOMICS_U, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@@ -38,7 +38,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID bigint_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -25,14 +25,10 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_BIGINT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_BIGINT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v11, 20.2.3.5 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_BIGINT_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint
|
||||
#define BUILTIN_UNDERSCORED_ID bigint
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -25,22 +25,16 @@
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_BIGINT_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.2.3 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_BIGINT_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_BIGINT_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_BOOLEAN
|
||||
@@ -45,7 +46,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-boolean-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID boolean_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID boolean_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -25,14 +25,12 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.6.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_BOOLEAN,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_BOOLEAN, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF, 0, 0)
|
||||
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_BOOLEAN
|
||||
@@ -30,7 +31,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-boolean.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID boolean
|
||||
#define BUILTIN_UNDERSCORED_ID boolean
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -25,21 +25,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.6.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_BOOLEAN_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_BOOLEAN_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
@@ -74,7 +74,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-dataview-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID dataview_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID dataview_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -179,7 +179,8 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
|
||||
return ecma_op_dataview_get_set_view_value (this_arg,
|
||||
arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
ECMA_VALUE_EMPTY, id);
|
||||
ECMA_VALUE_EMPTY,
|
||||
id);
|
||||
}
|
||||
case ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32:
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
|
||||
@@ -25,14 +25,10 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 24.2.3 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_DATAVIEW,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_DATAVIEW, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.2.4.21 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_DATAVIEW_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@@ -64,9 +60,7 @@ ROUTINE (LIT_MAGIC_STRING_SET_BIGUINT64, ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64,
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/* ECMA-262 v6, 24.2.4.1 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER,
|
||||
ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER, ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 24.2.4.2 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-dataview.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID dataview
|
||||
#define BUILTIN_UNDERSCORED_ID dataview
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -25,22 +25,16 @@
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.2 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.1 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_DATAVIEW_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.2.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
* Checks whether the function uses UTC time zone.
|
||||
*/
|
||||
#define BUILTIN_DATE_FUNCTION_IS_UTC(builtin_routine_id) \
|
||||
(((builtin_routine_id) - ECMA_DATE_PROTOTYPE_GET_FULL_YEAR) & 0x1)
|
||||
(((builtin_routine_id) -ECMA_DATE_PROTOTYPE_GET_FULL_YEAR) & 0x1)
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
@@ -108,7 +108,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-date-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID date_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID date_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -311,7 +311,7 @@ ecma_builtin_date_prototype_dispatch_get (uint16_t builtin_routine_id, /**< buil
|
||||
* Returns true, if the built-in id sets a year.
|
||||
*/
|
||||
#define ECMA_DATE_PROTOTYPE_IS_SET_YEAR_ROUTINE(builtin_routine_id) \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
|| (builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_UTC_FULL_YEAR \
|
||||
|| (builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_YEAR)
|
||||
|
||||
@@ -321,7 +321,7 @@ ecma_builtin_date_prototype_dispatch_get (uint16_t builtin_routine_id, /**< buil
|
||||
* Returns true, if the built-in id sets a year.
|
||||
*/
|
||||
#define ECMA_DATE_PROTOTYPE_IS_SET_YEAR_ROUTINE(builtin_routine_id) \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
|| (builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_UTC_FULL_YEAR)
|
||||
|
||||
#endif /* JERRY_BUILTIN_ANNEXB */
|
||||
@@ -677,7 +677,6 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
|
||||
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_SET_UTC_MILLISECONDS)
|
||||
{
|
||||
|
||||
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_GET_UTC_TIMEZONE_OFFSET)
|
||||
{
|
||||
if (!BUILTIN_DATE_FUNCTION_IS_UTC (builtin_routine_id))
|
||||
@@ -706,10 +705,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
return ecma_builtin_date_prototype_dispatch_get (builtin_routine_id, date_value);
|
||||
}
|
||||
|
||||
return ecma_builtin_date_prototype_dispatch_set (builtin_routine_id,
|
||||
this_obj_p,
|
||||
arguments_list,
|
||||
arguments_number);
|
||||
return ecma_builtin_date_prototype_dispatch_set (builtin_routine_id, this_obj_p, arguments_list, arguments_number);
|
||||
}
|
||||
|
||||
if (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_ISO_STRING)
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_DATE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_DATE, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_DATE_STRING_UL, ECMA_DATE_PROTOTYPE_TO_DATE_STRING, 0, 0)
|
||||
@@ -69,10 +67,12 @@ ROUTINE (LIT_MAGIC_STRING_TO_ISO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_ISO_STRING, 0
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_JSON_UL, ECMA_DATE_PROTOTYPE_TO_JSON, 1, 1)
|
||||
#if JERRY_ESNEXT
|
||||
ROUTINE_CONFIGURABLE_ONLY (LIT_GLOBAL_SYMBOL_TO_PRIMITIVE, ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, 1, 1)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#if JERRY_BUILTIN_ANNEXB
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL,
|
||||
LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_ANNEXB */
|
||||
#else /* !JERRY_ESNEXT */
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
@@ -48,7 +49,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-date.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID date
|
||||
#define BUILTIN_UNDERSCORED_ID date
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -148,8 +149,7 @@ ecma_date_check_two_chars (const lit_utf8_byte_t *str_p, /**< pointer to the ces
|
||||
ecma_char_t expected_char1, /**< first expected character */
|
||||
ecma_char_t expected_char2) /**< second expected character */
|
||||
{
|
||||
return (str_p < str_end_p
|
||||
&& (*str_p == expected_char1 || *str_p == expected_char2));
|
||||
return (str_p < str_end_p && (*str_p == expected_char1 || *str_p == expected_char2));
|
||||
} /* ecma_date_check_two_chars */
|
||||
|
||||
/**
|
||||
@@ -236,21 +236,20 @@ ecma_date_parse_month_name (const lit_utf8_byte_t **str_p, /**< pointer to the c
|
||||
} /* ecma_date_parse_month_name */
|
||||
|
||||
/**
|
||||
* Calculate MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)) for Date constructor and UTC
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.4.3.4
|
||||
*
|
||||
* @return false - if the operation fails
|
||||
* true - otherwise
|
||||
*/
|
||||
* Calculate MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)) for Date constructor and UTC
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.4.3.4
|
||||
*
|
||||
* @return false - if the operation fails
|
||||
* true - otherwise
|
||||
*/
|
||||
static bool
|
||||
ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to the Date constructor */
|
||||
uint32_t args_len, /**< number of arguments */
|
||||
ecma_number_t *tv_p) /**< [out] time value */
|
||||
{
|
||||
ecma_number_t date_nums[7] =
|
||||
{
|
||||
ecma_number_t date_nums[7] = {
|
||||
ECMA_NUMBER_ZERO, /* year */
|
||||
ECMA_NUMBER_ZERO, /* month */
|
||||
ECMA_NUMBER_ONE, /* date */
|
||||
@@ -287,13 +286,8 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t
|
||||
}
|
||||
|
||||
/* 10. */
|
||||
*tv_p = ecma_date_make_date (ecma_date_make_day (date_nums[0],
|
||||
date_nums[1],
|
||||
date_nums[2]),
|
||||
ecma_date_make_time (date_nums[3],
|
||||
date_nums[4],
|
||||
date_nums[5],
|
||||
date_nums[6]));
|
||||
*tv_p = ecma_date_make_date (ecma_date_make_day (date_nums[0], date_nums[1], date_nums[2]),
|
||||
ecma_date_make_time (date_nums[3], date_nums[4], date_nums[5], date_nums[6]));
|
||||
return true;
|
||||
} /* ecma_date_construct_helper */
|
||||
|
||||
@@ -324,10 +318,8 @@ ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p, /**< date
|
||||
year_limit = 999999;
|
||||
}
|
||||
|
||||
ecma_number_t year = ecma_date_parse_date_chars (&date_str_curr_p,
|
||||
date_str_end_p,
|
||||
year_digits,
|
||||
ECMA_DATE_LIMIT (0, year_limit));
|
||||
ecma_number_t year =
|
||||
ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, year_digits, ECMA_DATE_LIMIT (0, year_limit));
|
||||
if (is_year_sign_negative)
|
||||
{
|
||||
year = -year;
|
||||
@@ -466,8 +458,7 @@ ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p, /**< date
|
||||
* @return the parsed date as ecma_number_t or NaN otherwise
|
||||
*/
|
||||
static ecma_number_t
|
||||
ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p,
|
||||
const lit_utf8_byte_t *date_str_end_p)
|
||||
ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p, const lit_utf8_byte_t *date_str_end_p)
|
||||
{
|
||||
const ecma_number_t nan = ecma_number_make_nan ();
|
||||
|
||||
@@ -582,8 +573,7 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
}
|
||||
|
||||
const char gmt_p[] = " GMT";
|
||||
if (date_str_end_p - date_str_curr_p < 4
|
||||
|| memcmp (date_str_curr_p, gmt_p, 4) != 0)
|
||||
if (date_str_end_p - date_str_curr_p < 4 || memcmp (date_str_curr_p, gmt_p, 4) != 0)
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
@@ -725,8 +715,8 @@ ecma_builtin_date_create (ecma_number_t tv)
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) != NULL);
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
ecma_object_t *prototype_obj_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
@@ -787,7 +777,6 @@ ecma_value_t
|
||||
ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
|
||||
/* 20.4.2.3 */
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
@@ -804,7 +793,6 @@ ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**<
|
||||
if (ecma_is_value_object (argument)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (argument), ECMA_OBJECT_CLASS_DATE))
|
||||
{
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
tv = ((ecma_date_object_t *) ecma_get_object_from_value (argument))->date_value;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
|
||||
@@ -22,22 +22,16 @@
|
||||
#if JERRY_BUILTIN_DATE
|
||||
|
||||
/* ECMA-262 v5, 15.9.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_DATE_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
7,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 7, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
ROUTINE (LIT_MAGIC_STRING_PARSE, ECMA_DATE_ROUTINE_PARSE, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_UTC_U, ECMA_DATE_ROUTINE_UTC, NON_FIXED, 7)
|
||||
ROUTINE (LIT_MAGIC_STRING_NOW, ECMA_DATE_ROUTINE_NOW, 0, 0)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_DATE_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_DATE_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
|
||||
@@ -20,18 +20,19 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-error-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID error_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID error_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -105,18 +106,16 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
ecma_string_t *name_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p,
|
||||
LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ERROR_UL);
|
||||
ecma_string_t *name_string_p =
|
||||
ecma_builtin_error_prototype_object_to_string_helper (obj_p, LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL);
|
||||
|
||||
if (JERRY_UNLIKELY (name_string_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_string_t *msg_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p,
|
||||
LIT_MAGIC_STRING_MESSAGE,
|
||||
LIT_MAGIC_STRING__EMPTY);
|
||||
ecma_string_t *msg_string_p =
|
||||
ecma_builtin_error_prototype_object_to_string_helper (obj_p, LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
if (JERRY_UNLIKELY (msg_string_p == NULL))
|
||||
{
|
||||
@@ -136,7 +135,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
|
||||
ecma_stringbuilder_t builder = ecma_stringbuilder_create_from (name_string_p);
|
||||
|
||||
ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *)": ", 2);
|
||||
ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *) ": ", 2);
|
||||
ecma_stringbuilder_append (&builder, msg_string_p);
|
||||
|
||||
ecma_deref_ecma_string (name_string_p);
|
||||
|
||||
@@ -23,19 +23,13 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.4.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.4.3 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE,
|
||||
LIT_MAGIC_STRING__EMPTY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@@ -14,23 +14,24 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-error.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID error
|
||||
#define BUILTIN_UNDERSCORED_ID error
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -67,8 +68,8 @@ ecma_builtin_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**
|
||||
#if !JERRY_ESNEXT
|
||||
return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* JERRY_ESNEXT */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE);
|
||||
ecma_object_t *proto_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_ERROR_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
|
||||
@@ -22,22 +22,16 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.7.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ERRORS
|
||||
@@ -30,7 +31,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-evalerror-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
|
||||
@@ -25,19 +25,13 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.8 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_EVAL_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.9 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_EVAL_ERROR_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_EVAL_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.10 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE,
|
||||
LIT_MAGIC_STRING__EMPTY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
|
||||
|
||||
@@ -14,17 +14,18 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ERRORS
|
||||
|
||||
@@ -32,7 +33,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-evalerror.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -69,8 +70,8 @@ ecma_builtin_eval_error_dispatch_construct (const ecma_value_t *arguments_list_p
|
||||
#if !JERRY_ESNEXT
|
||||
return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* JERRY_ESNEXT */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE);
|
||||
ecma_object_t *proto_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
|
||||
@@ -24,22 +24,16 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_EVAL_ERROR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_EVAL_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
|
||||
@@ -13,20 +13,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-function-prototype.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-extended-info.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
#include "ecma-builtin-function-prototype.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -52,7 +54,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-function-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID function_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID function_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -209,7 +211,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
/* 2. */
|
||||
if (ecma_is_value_null (arg2) || ecma_is_value_undefined (arg2))
|
||||
{
|
||||
return ecma_op_function_call (func_obj_p, arg1, NULL, 0);
|
||||
return ecma_op_function_call (func_obj_p, arg1, NULL, 0);
|
||||
}
|
||||
|
||||
/* 3. */
|
||||
@@ -256,10 +258,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
JERRY_ASSERT (index == length);
|
||||
ret_value = ecma_op_function_call (func_obj_p,
|
||||
arg1,
|
||||
arguments_list_p,
|
||||
(uint32_t) length);
|
||||
ret_value = ecma_op_function_call (func_obj_p, arg1, arguments_list_p, (uint32_t) length);
|
||||
}
|
||||
|
||||
for (uint32_t remove_index = 0; remove_index < index; remove_index++)
|
||||
@@ -282,17 +281,14 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< this argument object */
|
||||
ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p, /**< this argument object */
|
||||
const ecma_value_t *arguments_list_p, /**< list of arguments */
|
||||
uint32_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
if (arguments_number == 0)
|
||||
{
|
||||
/* Even a 'this' argument is missing. */
|
||||
return ecma_op_function_call (func_obj_p,
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
NULL,
|
||||
0);
|
||||
return ecma_op_function_call (func_obj_p, ECMA_VALUE_UNDEFINED, NULL, 0);
|
||||
}
|
||||
|
||||
return ecma_op_function_call (func_obj_p,
|
||||
@@ -311,7 +307,7 @@ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< th
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**< this argument object */
|
||||
ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p, /**< this argument object */
|
||||
const ecma_value_t *arguments_list_p, /**< list of arguments */
|
||||
uint32_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
@@ -353,18 +349,13 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
ecma_object_t *function_p;
|
||||
ecma_bound_function_t *bound_func_p;
|
||||
|
||||
if (arguments_number == 0
|
||||
|| (arguments_number == 1 && !ecma_is_value_integer_number (arguments_list_p[0])))
|
||||
if (arguments_number == 0 || (arguments_number == 1 && !ecma_is_value_integer_number (arguments_list_p[0])))
|
||||
{
|
||||
function_p = ecma_create_object (prototype_obj_p,
|
||||
sizeof (ecma_bound_function_t),
|
||||
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
function_p = ecma_create_object (prototype_obj_p, sizeof (ecma_bound_function_t), ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
|
||||
/* 8. */
|
||||
bound_func_p = (ecma_bound_function_t *) function_p;
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function,
|
||||
this_arg_obj_p,
|
||||
0);
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, this_arg_obj_p, 0);
|
||||
|
||||
bound_func_p->header.u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
@@ -379,15 +370,11 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
|
||||
size_t obj_size = sizeof (ecma_bound_function_t) + (arguments_number * sizeof (ecma_value_t));
|
||||
|
||||
function_p = ecma_create_object (prototype_obj_p,
|
||||
obj_size,
|
||||
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
function_p = ecma_create_object (prototype_obj_p, obj_size, ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
|
||||
/* 8. */
|
||||
bound_func_p = (ecma_bound_function_t *) function_p;
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function,
|
||||
this_arg_obj_p,
|
||||
0);
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, this_arg_obj_p, 0);
|
||||
|
||||
/* NOTE: This solution provides temporary false data about the object's size
|
||||
but prevents GC from freeing it until it's not fully initialized. */
|
||||
@@ -413,9 +400,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
|
||||
ecma_string_t *len_string = ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH);
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p,
|
||||
len_string,
|
||||
&prop_desc);
|
||||
ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p, len_string, &prop_desc);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (ECMA_IS_VALUE_ERROR (status))
|
||||
@@ -428,8 +413,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
if (ecma_is_value_true (status))
|
||||
{
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
ecma_value_t len_value = ecma_op_object_get (this_arg_obj_p,
|
||||
len_string);
|
||||
ecma_value_t len_value = ecma_op_object_get (this_arg_obj_p, len_string);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
{
|
||||
@@ -552,9 +536,7 @@ ecma_builtin_function_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
|
||||
}
|
||||
case ECMA_FUNCTION_PROTOTYPE_APPLY:
|
||||
{
|
||||
return ecma_builtin_function_prototype_object_apply (func_obj_p,
|
||||
arguments_list_p[0],
|
||||
arguments_list_p[1]);
|
||||
return ecma_builtin_function_prototype_object_apply (func_obj_p, arguments_list_p[0], arguments_list_p[1]);
|
||||
}
|
||||
case ECMA_FUNCTION_PROTOTYPE_CALL:
|
||||
{
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
#ifndef ECMA_BUILTIN_FUNCTION_PROTOTYPE_H
|
||||
#define ECMA_BUILTIN_FUNCTION_PROTOTYPE_H
|
||||
|
||||
ecma_value_t ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p,
|
||||
ecma_value_t arg1,
|
||||
ecma_value_t arg2);
|
||||
#include "ecma-globals.h"
|
||||
|
||||
ecma_value_t
|
||||
ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, ecma_value_t arg1, ecma_value_t arg2);
|
||||
|
||||
#endif /* !ECMA_BUILTIN_FUNCTION_PROTOTYPE_H */
|
||||
|
||||
@@ -23,21 +23,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.3.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_FUNCTION,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_FUNCTION, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
0,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING__EMPTY,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
/* Routine properties:
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-eval.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-lex-env.h"
|
||||
|
||||
#include "js-parser.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
@@ -27,7 +28,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID function
|
||||
#define BUILTIN_UNDERSCORED_ID function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -23,21 +23,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.3.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID generator_function
|
||||
#define BUILTIN_UNDERSCORED_ID generator_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -53,7 +53,7 @@ ecma_builtin_generator_function_dispatch_call (const ecma_value_t *arguments_lis
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in GeneratorFunction object
|
||||
*
|
||||
* @return constructed generator function object - if success
|
||||
* @return constructed generator function object - if success
|
||||
* raised error otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
|
||||
@@ -22,19 +22,13 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v6, 25.2.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_GENERATOR,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_GENERATOR, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "opcodes.h"
|
||||
#include "vm-defines.h"
|
||||
@@ -29,8 +30,8 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@@ -45,7 +46,7 @@ enum
|
||||
} ecma_generator_operation_type_t;
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID generator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID generator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -62,18 +63,17 @@ enum
|
||||
* Convert routine type to operation type..
|
||||
*/
|
||||
#define ECMA_GENERATOR_ROUTINE_TO_OPERATION(type) \
|
||||
((ecma_iterator_command_type_t) ((type) - ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
((ecma_iterator_command_type_t) ((type) -ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
|
||||
== ECMA_ITERATOR_NEXT,
|
||||
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT) == ECMA_ITERATOR_NEXT,
|
||||
convert_ecma_generator_routine_next_to_ecma_iterator_next_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
== ECMA_ITERATOR_THROW,
|
||||
== ECMA_ITERATOR_THROW,
|
||||
convert_ecma_generator_routine_throw_to_ecma_iterator_throw_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN)
|
||||
== ECMA_ITERATOR_RETURN,
|
||||
== ECMA_ITERATOR_RETURN,
|
||||
convert_ecma_generator_routine_return_to_ecma_iterator_return_failed);
|
||||
|
||||
/**
|
||||
@@ -161,9 +161,8 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
|
||||
if (byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR)
|
||||
{
|
||||
ecma_value_t iterator = ecma_op_get_iterator (value,
|
||||
ECMA_VALUE_SYNC_ITERATOR,
|
||||
generator_object_p->frame_ctx.stack_top_p);
|
||||
ecma_value_t iterator =
|
||||
ecma_op_get_iterator (value, ECMA_VALUE_SYNC_ITERATOR, generator_object_p->frame_ctx.stack_top_p);
|
||||
ecma_free_value (value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
@@ -195,11 +194,11 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
} /* ecma_builtin_generator_prototype_object_do */
|
||||
|
||||
/**
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
|
||||
@@ -25,14 +25,10 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 25.3.1.5 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_GENERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_GENERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_GENERATOR,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_GENERATOR, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID generator
|
||||
#define BUILTIN_UNDERSCORED_ID generator
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@@ -22,19 +22,13 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_GENERATOR_FUNCTION,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_GENERATOR_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_GENERATOR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_GENERATOR_PROTOTYPE, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.3 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -21,14 +21,15 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "lit-strings.h"
|
||||
#include "vm.h"
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -59,7 +60,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-global.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID global
|
||||
#define BUILTIN_UNDERSCORED_ID global
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -137,8 +138,7 @@ ecma_builtin_global_object_is_nan (ecma_number_t arg_num) /**< routine's first a
|
||||
static ecma_value_t
|
||||
ecma_builtin_global_object_is_finite (ecma_number_t arg_num) /**< routine's first argument */
|
||||
{
|
||||
bool is_finite = !(ecma_number_is_nan (arg_num)
|
||||
|| ecma_number_is_infinity (arg_num));
|
||||
bool is_finite = !(ecma_number_is_nan (arg_num) || ecma_number_is_infinity (arg_num));
|
||||
|
||||
return ecma_make_boolean_value (is_finite);
|
||||
} /* ecma_builtin_global_object_is_finite */
|
||||
@@ -161,22 +161,16 @@ ecma_builtin_global_object_character_is_in (uint32_t character, /**< character *
|
||||
* One bit for each character between 0 - 127.
|
||||
* Bit is set if the character is in the unescaped URI set.
|
||||
*/
|
||||
static const uint8_t unescaped_uri_set[16] =
|
||||
{
|
||||
0x0, 0x0, 0x0, 0x0, 0xda, 0xff, 0xff, 0xaf,
|
||||
0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47
|
||||
};
|
||||
static const uint8_t unescaped_uri_set[16] = { 0x0, 0x0, 0x0, 0x0, 0xda, 0xff, 0xff, 0xaf,
|
||||
0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47 };
|
||||
|
||||
/**
|
||||
* Unescaped URI component characters bitset:
|
||||
* One bit for each character between 0 - 127.
|
||||
* Bit is set if the character is in the unescaped component URI set.
|
||||
*/
|
||||
static const uint8_t unescaped_uri_component_set[16] =
|
||||
{
|
||||
0x0, 0x0, 0x0, 0x0, 0x82, 0x67, 0xff, 0x3,
|
||||
0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47
|
||||
};
|
||||
static const uint8_t unescaped_uri_component_set[16] = { 0x0, 0x0, 0x0, 0x0, 0x82, 0x67, 0xff, 0x3,
|
||||
0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47 };
|
||||
|
||||
/**
|
||||
* Format is a percent sign followed by two hex digits.
|
||||
@@ -283,8 +277,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_valid
|
||||
|| !lit_is_valid_utf8_string (octets, bytes_count, true))
|
||||
if (!is_valid || !lit_is_valid_utf8_string (octets, bytes_count, true))
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 string"));
|
||||
@@ -293,8 +286,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
lit_code_point_t cp;
|
||||
lit_read_code_point_from_utf8 (octets, bytes_count, &cp);
|
||||
|
||||
if (lit_is_code_point_utf16_high_surrogate (cp)
|
||||
|| lit_is_code_point_utf16_low_surrogate (cp))
|
||||
if (lit_is_code_point_utf16_high_surrogate (cp) || lit_is_code_point_utf16_low_surrogate (cp))
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 codepoint"));
|
||||
@@ -431,11 +423,8 @@ ecma_builtin_global_object_encode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
* Bit is set if the character does not need to be converted to %xx form.
|
||||
* These characters are: a-z A-Z 0-9 @ * _ + - . /
|
||||
*/
|
||||
static const uint8_t ecma_escape_set[16] =
|
||||
{
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0xec, 0xff, 0x3,
|
||||
0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x7
|
||||
};
|
||||
static const uint8_t ecma_escape_set[16] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0xec, 0xff, 0x3,
|
||||
0xff, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x7 };
|
||||
|
||||
/**
|
||||
* The Global object's 'escape' routine
|
||||
@@ -502,7 +491,7 @@ ecma_builtin_global_object_escape (lit_utf8_byte_t *input_start_p, /**< routine'
|
||||
* @return number of characters processed during the escape resolve
|
||||
*/
|
||||
static uint8_t
|
||||
ecma_builtin_global_object_unescape_resolve_escape (const lit_utf8_byte_t *buffer_p, /**< character buffer */
|
||||
ecma_builtin_global_object_unescape_resolve_escape (const lit_utf8_byte_t *buffer_p, /**< character buffer */
|
||||
bool unicode_sequence, /**< true if unescaping unicode sequence */
|
||||
ecma_char_t *out_result_p) /**< [out] resolved character */
|
||||
{
|
||||
@@ -643,15 +632,12 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
|
||||
|
||||
if (builtin_routine_id == ECMA_GLOBAL_PARSE_INT)
|
||||
{
|
||||
ret_value = ecma_number_parse_int (string_buff,
|
||||
string_buff_size,
|
||||
arguments_list_p[1]);
|
||||
ret_value = ecma_number_parse_int (string_buff, string_buff_size, arguments_list_p[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_GLOBAL_PARSE_FLOAT);
|
||||
ret_value = ecma_number_parse_float (string_buff,
|
||||
string_buff_size);
|
||||
ret_value = ecma_number_parse_float (string_buff, string_buff_size);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE_UTF8_STRING (string_buff, string_buff_size);
|
||||
@@ -661,9 +647,7 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
|
||||
|
||||
lit_utf8_size_t input_size = ecma_string_get_size (str_p);
|
||||
|
||||
JMEM_DEFINE_LOCAL_ARRAY (input_start_p,
|
||||
input_size + 1,
|
||||
lit_utf8_byte_t);
|
||||
JMEM_DEFINE_LOCAL_ARRAY (input_start_p, input_size + 1, lit_utf8_byte_t);
|
||||
|
||||
ecma_string_to_utf8_bytes (str_p, input_start_p, input_size);
|
||||
|
||||
@@ -686,8 +670,8 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
|
||||
case ECMA_GLOBAL_DECODE_URI:
|
||||
case ECMA_GLOBAL_DECODE_URI_COMPONENT:
|
||||
{
|
||||
const uint8_t *uri_set = (builtin_routine_id == ECMA_GLOBAL_DECODE_URI ? unescaped_uri_set
|
||||
: unescaped_uri_component_set);
|
||||
const uint8_t *uri_set =
|
||||
(builtin_routine_id == ECMA_GLOBAL_DECODE_URI ? unescaped_uri_set : unescaped_uri_component_set);
|
||||
|
||||
ret_value = ecma_builtin_global_object_decode_uri_helper (input_start_p, input_size, uri_set);
|
||||
break;
|
||||
@@ -697,8 +681,8 @@ ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_GLOBAL_ENCODE_URI
|
||||
|| builtin_routine_id == ECMA_GLOBAL_ENCODE_URI_COMPONENT);
|
||||
|
||||
const uint8_t *uri_set = (builtin_routine_id == ECMA_GLOBAL_ENCODE_URI ? unescaped_uri_set
|
||||
: unescaped_uri_component_set);
|
||||
const uint8_t *uri_set =
|
||||
(builtin_routine_id == ECMA_GLOBAL_ENCODE_URI ? unescaped_uri_set : unescaped_uri_component_set);
|
||||
|
||||
ret_value = ecma_builtin_global_object_encode_uri_helper (input_start_p, input_size, uri_set);
|
||||
break;
|
||||
|
||||
@@ -23,147 +23,101 @@
|
||||
* (property name, simple value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v5, 15.1.1.3 */
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_UNDEFINED,
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_UNDEFINED, ECMA_VALUE_UNDEFINED, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v5, 15.1.1.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_NAN,
|
||||
ECMA_BUILTIN_NUMBER_NAN,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_NAN, ECMA_BUILTIN_NUMBER_NAN, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ECMA-262 v5, 15.1.1.2 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_INFINITY_UL,
|
||||
ECMA_BUILTIN_NUMBER_POSITIVE_INFINITY,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_INFINITY_UL, ECMA_BUILTIN_NUMBER_POSITIVE_INFINITY, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_OBJECT_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_OBJECT_UL, ECMA_BUILTIN_ID_OBJECT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_FUNCTION_UL,
|
||||
ECMA_BUILTIN_ID_FUNCTION,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_FUNCTION_UL, ECMA_BUILTIN_ID_FUNCTION, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.3 */
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_UL, ECMA_BUILTIN_ID_ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
|
||||
#if JERRY_BUILTIN_STRING
|
||||
/* ECMA-262 v5, 15.1.4.4 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_STRING_UL,
|
||||
ECMA_BUILTIN_ID_STRING,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_STRING_UL, ECMA_BUILTIN_ID_STRING, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
|
||||
#if JERRY_BUILTIN_BOOLEAN
|
||||
/* ECMA-262 v5, 15.1.4.5 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BOOLEAN_UL,
|
||||
ECMA_BUILTIN_ID_BOOLEAN,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BOOLEAN_UL, ECMA_BUILTIN_ID_BOOLEAN, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
|
||||
#if JERRY_BUILTIN_NUMBER
|
||||
/* ECMA-262 v5, 15.1.4.6 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_NUMBER_UL,
|
||||
ECMA_BUILTIN_ID_NUMBER,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_NUMBER_UL, ECMA_BUILTIN_ID_NUMBER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_NUMBER */
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
/* ECMA-262 v5, 15.1.4.7 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_DATE_UL,
|
||||
ECMA_BUILTIN_ID_DATE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_DATE_UL, ECMA_BUILTIN_ID_DATE, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
/* ECMA-262 v5, 15.1.4.8 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_REGEXP_UL,
|
||||
ECMA_BUILTIN_ID_REGEXP,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_REGEXP_UL, ECMA_BUILTIN_ID_REGEXP, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.9 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ERROR_UL, ECMA_BUILTIN_ID_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if JERRY_BUILTIN_ERRORS
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.10 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_EVAL_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_EVAL_ERROR_UL, ECMA_BUILTIN_ID_EVAL_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.11 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_RANGE_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_RANGE_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_RANGE_ERROR_UL, ECMA_BUILTIN_ID_RANGE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.12 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_REFERENCE_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_REFERENCE_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_REFERENCE_ERROR_UL, ECMA_BUILTIN_ID_REFERENCE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.13 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SYNTAX_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_SYNTAX_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SYNTAX_ERROR_UL, ECMA_BUILTIN_ID_SYNTAX_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.14 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_TYPE_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_TYPE_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_TYPE_ERROR_UL, ECMA_BUILTIN_ID_TYPE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.1.4.15 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_URI_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_URI_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_URI_ERROR_UL, ECMA_BUILTIN_ID_URI_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
|
||||
#if JERRY_BUILTIN_MATH
|
||||
/* ECMA-262 v5, 15.1.5.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_MATH_UL,
|
||||
ECMA_BUILTIN_ID_MATH,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_MATH_UL, ECMA_BUILTIN_ID_MATH, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_MATH */
|
||||
#if JERRY_BUILTIN_REFLECT
|
||||
/* ECMA-262 v6, 26.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_REFLECT_UL,
|
||||
ECMA_BUILTIN_ID_REFLECT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_REFLECT_UL, ECMA_BUILTIN_ID_REFLECT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_REFLECT */
|
||||
|
||||
#if JERRY_BUILTIN_JSON
|
||||
/* ECMA-262 v5, 15.1.5.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_JSON_U,
|
||||
ECMA_BUILTIN_ID_JSON,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_JSON_U, ECMA_BUILTIN_ID_JSON, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_JSON */
|
||||
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
/* ECMA-262 v5, 15.1.5.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ATOMICS_U,
|
||||
ECMA_BUILTIN_ID_ATOMICS,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ATOMICS_U, ECMA_BUILTIN_ID_ATOMICS, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_ATOMICS */
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SHARED_ARRAY_BUFFER_UL,
|
||||
@@ -171,48 +125,28 @@ OBJECT_VALUE (LIT_MAGIC_STRING_SHARED_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_INT8_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_INT8ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_INT8_ARRAY_UL, ECMA_BUILTIN_ID_INT8ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_UINT8ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_ARRAY_UL, ECMA_BUILTIN_ID_UINT8ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_INT16_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_INT16ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_INT16_ARRAY_UL, ECMA_BUILTIN_ID_INT16ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT16_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_UINT16ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT16_ARRAY_UL, ECMA_BUILTIN_ID_UINT16ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_INT32_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_INT32ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_INT32_ARRAY_UL, ECMA_BUILTIN_ID_INT32ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT32_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_UINT32ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT32_ARRAY_UL, ECMA_BUILTIN_ID_UINT32ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT32_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_FLOAT32ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT32_ARRAY_UL, ECMA_BUILTIN_ID_FLOAT32ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT64_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_FLOAT64ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT64_ARRAY_UL, ECMA_BUILTIN_ID_FLOAT64ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT64_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_BIGINT64ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT64_ARRAY_UL, ECMA_BUILTIN_ID_BIGINT64ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGUINT64_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_BIGUINT64ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGUINT64_ARRAY_UL, ECMA_BUILTIN_ID_BIGUINT64ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL,
|
||||
@@ -223,73 +157,49 @@ OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL,
|
||||
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKSET_UL,
|
||||
ECMA_BUILTIN_ID_WEAKSET,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKSET_UL, ECMA_BUILTIN_ID_WEAKSET, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_BUILTIN_ID_MAP,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_MAP_UL, ECMA_BUILTIN_ID_MAP, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SET_UL,
|
||||
ECMA_BUILTIN_ID_SET,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SET_UL, ECMA_BUILTIN_ID_SET, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKMAP_UL,
|
||||
ECMA_BUILTIN_ID_WEAKMAP,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKMAP_UL, ECMA_BUILTIN_ID_WEAKMAP, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKREF_UL,
|
||||
ECMA_BUILTIN_ID_WEAKREF,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKREF_UL, ECMA_BUILTIN_ID_WEAKREF, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_AGGREGATE_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_AGGREGATE_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_BUILTIN_ID_AGGREGATE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROMISE_UL,
|
||||
ECMA_BUILTIN_ID_PROMISE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROMISE_UL, ECMA_BUILTIN_ID_PROMISE, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v6, 19.4.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SYMBOL_UL,
|
||||
ECMA_BUILTIN_ID_SYMBOL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SYMBOL_UL, ECMA_BUILTIN_ID_SYMBOL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#if JERRY_BUILTIN_GLOBAL_THIS
|
||||
/* ECMA-262 v11, 18.1.1 */
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL_THIS_UL,
|
||||
ECMA_VALUE_GLOBAL_THIS,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL_THIS_UL, ECMA_VALUE_GLOBAL_THIS, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_GLOBAL_THIS */
|
||||
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_DATAVIEW_UL,
|
||||
ECMA_BUILTIN_ID_DATAVIEW,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_BUILTIN_ID_DATAVIEW, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
/* ECMA-262 v6, 26.2.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROXY_UL,
|
||||
ECMA_BUILTIN_ID_PROXY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROXY_UL, ECMA_BUILTIN_ID_PROXY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_BUILTIN_ID_BIGINT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT_UL, ECMA_BUILTIN_ID_BIGINT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/* Routine properties:
|
||||
|
||||
@@ -18,18 +18,16 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
#include "ecma-builtin-handlers.h"
|
||||
#include "ecma-promise-object.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
static const ecma_builtin_handler_t ecma_native_handlers[] =
|
||||
{
|
||||
static const ecma_builtin_handler_t ecma_native_handlers[] = {
|
||||
#define ECMA_NATIVE_HANDLER(id, handler, length) handler,
|
||||
#include "ecma-builtin-handlers.inc.h"
|
||||
#undef ECMA_NATIVE_HANDLER
|
||||
};
|
||||
|
||||
static const uint8_t ecma_native_handler_lengths[] =
|
||||
{
|
||||
static const uint8_t ecma_native_handler_lengths[] = {
|
||||
#define ECMA_NATIVE_HANDLER(id, handler, length) length,
|
||||
#include "ecma-builtin-handlers.inc.h"
|
||||
#undef ECMA_NATIVE_HANDLER
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-promise-object.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
|
||||
@@ -46,10 +46,8 @@ typedef enum
|
||||
*/
|
||||
#define ECMA_NATIVE_HANDLER_COMMON_FLAGS_SHIFT 2
|
||||
|
||||
ecma_builtin_handler_t
|
||||
ecma_builtin_handler_get (ecma_native_handler_id_t id);
|
||||
uint8_t
|
||||
ecma_builtin_handler_get_length (ecma_native_handler_id_t id);
|
||||
ecma_builtin_handler_t ecma_builtin_handler_get (ecma_native_handler_id_t id);
|
||||
uint8_t ecma_builtin_handler_get_length (ecma_native_handler_id_t id);
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
@@ -35,16 +36,12 @@
|
||||
/**
|
||||
* Day names
|
||||
*/
|
||||
const char day_names_p[7][3] =
|
||||
{
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
||||
};
|
||||
const char day_names_p[7][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
|
||||
/**
|
||||
* Month names
|
||||
*/
|
||||
const char month_names_p[12][3] =
|
||||
{
|
||||
const char month_names_p[12][3] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
@@ -79,15 +76,10 @@ ecma_date_day_from_year (int32_t year) /**< year value */
|
||||
{
|
||||
if (JERRY_LIKELY (year >= 1970))
|
||||
{
|
||||
return (int32_t) (365 * (year - 1970)
|
||||
+ ((year - 1969) / 4)
|
||||
- ((year - 1901) / 100)
|
||||
+ ((year - 1601) / 400));
|
||||
return (int32_t) (365 * (year - 1970) + ((year - 1969) / 4) - ((year - 1901) / 100) + ((year - 1601) / 400));
|
||||
}
|
||||
|
||||
return (int32_t) (365 * (year - 1970)
|
||||
+ floor ((year - 1969) / 4.0)
|
||||
- floor ((year - 1901) / 100.0)
|
||||
return (int32_t) (365 * (year - 1970) + floor ((year - 1969) / 4.0) - floor ((year - 1901) / 100.0)
|
||||
+ floor ((year - 1601) / 400.0));
|
||||
} /* ecma_date_day_from_year */
|
||||
|
||||
@@ -102,8 +94,7 @@ ecma_date_day_from_year (int32_t year) /**< year value */
|
||||
static int
|
||||
ecma_date_days_in_year (int32_t year) /**< year */
|
||||
{
|
||||
if (year % 4 != 0
|
||||
|| (year % 100 == 0 && (year % 400 != 0)))
|
||||
if (year % 4 != 0 || (year % 100 == 0 && (year % 400 != 0)))
|
||||
{
|
||||
return ECMA_DATE_DAYS_IN_YEAR;
|
||||
}
|
||||
@@ -129,16 +120,34 @@ ecma_date_in_leap_year (int32_t year) /**< time value */
|
||||
/**
|
||||
* First days of months in normal and leap years
|
||||
*/
|
||||
static const uint16_t first_day_in_month[2][12] =
|
||||
{
|
||||
{
|
||||
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, /* normal year */
|
||||
}
|
||||
,
|
||||
{
|
||||
0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 /* leap year */
|
||||
}
|
||||
};
|
||||
static const uint16_t first_day_in_month[2][12] = { {
|
||||
0,
|
||||
31,
|
||||
59,
|
||||
90,
|
||||
120,
|
||||
151,
|
||||
181,
|
||||
212,
|
||||
243,
|
||||
273,
|
||||
304,
|
||||
334, /* normal year */
|
||||
},
|
||||
{
|
||||
0,
|
||||
31,
|
||||
60,
|
||||
91,
|
||||
121,
|
||||
152,
|
||||
182,
|
||||
213,
|
||||
244,
|
||||
274,
|
||||
305,
|
||||
335 /* leap year */
|
||||
} };
|
||||
|
||||
/**
|
||||
* Abstract operation: YearFromTime
|
||||
@@ -383,9 +392,7 @@ ecma_date_make_time (ecma_number_t hour, /**< hour value */
|
||||
ecma_number_t sec, /**< second value */
|
||||
ecma_number_t ms) /**< millisecond value */
|
||||
{
|
||||
if (!ecma_number_is_finite (hour)
|
||||
|| !ecma_number_is_finite (min)
|
||||
|| !ecma_number_is_finite (sec)
|
||||
if (!ecma_number_is_finite (hour) || !ecma_number_is_finite (min) || !ecma_number_is_finite (sec)
|
||||
|| !ecma_number_is_finite (ms))
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
@@ -396,10 +403,7 @@ ecma_date_make_time (ecma_number_t hour, /**< hour value */
|
||||
ecma_number_t s = ecma_number_trunc (sec);
|
||||
ecma_number_t milli = ecma_number_trunc (ms);
|
||||
|
||||
return (ecma_number_t) ((h * ECMA_DATE_MS_PER_HOUR
|
||||
+ m * ECMA_DATE_MS_PER_MINUTE
|
||||
+ s * ECMA_DATE_MS_PER_SECOND
|
||||
+ milli));
|
||||
return h * ECMA_DATE_MS_PER_HOUR + m * ECMA_DATE_MS_PER_MINUTE + s * ECMA_DATE_MS_PER_SECOND + milli;
|
||||
} /* ecma_date_make_time */
|
||||
|
||||
/**
|
||||
@@ -416,9 +420,7 @@ ecma_date_make_day (ecma_number_t year, /**< year value */
|
||||
ecma_number_t date) /**< date value */
|
||||
{
|
||||
/* 1. */
|
||||
if (!ecma_number_is_finite (year)
|
||||
|| !ecma_number_is_finite (month)
|
||||
|| !ecma_number_is_finite (date)
|
||||
if (!ecma_number_is_finite (year) || !ecma_number_is_finite (month) || !ecma_number_is_finite (date)
|
||||
|| fabs (year) > INT32_MAX)
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
@@ -441,9 +443,7 @@ ecma_date_make_day (ecma_number_t year, /**< year value */
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
ecma_number_t days = (ecma_date_day_from_year (ym)
|
||||
+ first_day_in_month[ecma_date_in_leap_year (ym)][mn]
|
||||
+ (dt - 1));
|
||||
ecma_number_t days = (ecma_date_day_from_year (ym) + first_day_in_month[ecma_date_in_leap_year (ym)][mn] + (dt - 1));
|
||||
return days * ECMA_DATE_MS_PER_DAY;
|
||||
} /* ecma_date_make_day */
|
||||
|
||||
@@ -459,8 +459,7 @@ ecma_number_t
|
||||
ecma_date_make_date (ecma_number_t day, /**< day value */
|
||||
ecma_number_t time) /**< time value */
|
||||
{
|
||||
if (!ecma_number_is_finite (day)
|
||||
|| !ecma_number_is_finite (time))
|
||||
if (!ecma_number_is_finite (day) || !ecma_number_is_finite (time))
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
@@ -479,8 +478,7 @@ ecma_date_make_date (ecma_number_t day, /**< day value */
|
||||
ecma_number_t
|
||||
ecma_date_time_clip (ecma_number_t time) /**< time value */
|
||||
{
|
||||
if (!ecma_number_is_finite (time)
|
||||
|| fabs (time) > ECMA_DATE_MAX_VALUE)
|
||||
if (!ecma_number_is_finite (time) || fabs (time) > ECMA_DATE_MAX_VALUE)
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
@@ -674,14 +672,13 @@ ecma_date_to_string_format (ecma_number_t datetime_number, /**< datetime */
|
||||
buffer_p--;
|
||||
*buffer_p = (lit_utf8_byte_t) ((number % 10) + (int32_t) LIT_CHAR_0);
|
||||
number /= 10;
|
||||
}
|
||||
while (--number_length);
|
||||
} while (--number_length);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (dest_p <= date_buffer + date_buffer_length);
|
||||
|
||||
return ecma_make_string_value (ecma_new_ecma_string_from_ascii (date_buffer,
|
||||
(lit_utf8_size_t) (dest_p - date_buffer)));
|
||||
return ecma_make_string_value (
|
||||
ecma_new_ecma_string_from_ascii (date_buffer, (lit_utf8_size_t) (dest_p - date_buffer)));
|
||||
} /* ecma_date_to_string_format */
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,14 +14,15 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -43,8 +44,7 @@ ecma_builtin_helper_error_dispatch_call (jerry_error_t error_type, /**< native e
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len != 0
|
||||
&& !ecma_is_value_undefined (arguments_list_p[0]))
|
||||
if (arguments_list_len != 0 && !ecma_is_value_undefined (arguments_list_p[0]))
|
||||
{
|
||||
ecma_string_t *message_string_p = ecma_op_to_string (arguments_list_p[0]);
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_BUILTIN_JSON
|
||||
|
||||
@@ -19,14 +19,15 @@
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jmem.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -61,8 +62,7 @@ ecma_builtin_helper_object_to_string_tag_helper (ecma_value_t tag_value) /**< st
|
||||
|
||||
lit_utf8_byte_t *buffer_ptr = str_buffer;
|
||||
|
||||
const lit_magic_string_id_t magic_string_ids[] =
|
||||
{
|
||||
const lit_magic_string_id_t magic_string_ids[] = {
|
||||
LIT_MAGIC_STRING_LEFT_SQUARE_CHAR,
|
||||
LIT_MAGIC_STRING_OBJECT,
|
||||
LIT_MAGIC_STRING_SPACE_CHAR,
|
||||
@@ -71,20 +71,23 @@ ecma_builtin_helper_object_to_string_tag_helper (ecma_value_t tag_value) /**< st
|
||||
/* Copy to buffer the "[object " string */
|
||||
for (uint32_t i = 0; i < sizeof (magic_string_ids) / sizeof (lit_magic_string_id_t); ++i)
|
||||
{
|
||||
buffer_ptr = lit_copy_magic_string_to_buffer (magic_string_ids[i], buffer_ptr,
|
||||
buffer_ptr = lit_copy_magic_string_to_buffer (magic_string_ids[i],
|
||||
buffer_ptr,
|
||||
(lit_utf8_size_t) ((str_buffer + buffer_size) - buffer_ptr));
|
||||
|
||||
JERRY_ASSERT (buffer_ptr <= str_buffer + buffer_size);
|
||||
}
|
||||
|
||||
/* Copy to buffer the #@@toStringTag# string */
|
||||
buffer_ptr += ecma_string_copy_to_cesu8_buffer (tag_str_p, buffer_ptr,
|
||||
buffer_ptr += ecma_string_copy_to_cesu8_buffer (tag_str_p,
|
||||
buffer_ptr,
|
||||
(lit_utf8_size_t) ((str_buffer + buffer_size) - buffer_ptr));
|
||||
|
||||
JERRY_ASSERT (buffer_ptr <= str_buffer + buffer_size);
|
||||
|
||||
/* Copy to buffer the "]" string */
|
||||
buffer_ptr = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_RIGHT_SQUARE_CHAR, buffer_ptr,
|
||||
buffer_ptr = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_RIGHT_SQUARE_CHAR,
|
||||
buffer_ptr,
|
||||
(lit_utf8_size_t) ((str_buffer + buffer_size) - buffer_ptr));
|
||||
|
||||
JERRY_ASSERT (buffer_ptr <= str_buffer + buffer_size);
|
||||
@@ -167,14 +170,10 @@ ecma_builtin_helper_object_to_string (const ecma_value_t this_arg) /**< this arg
|
||||
ecma_deref_object (obj_p);
|
||||
return ecma_builtin_helper_object_to_string_tag_helper (tag);
|
||||
}
|
||||
else if (builtin_tag != LIT_MAGIC_STRING_ARGUMENTS_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_FUNCTION_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_ERROR_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_BOOLEAN_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_NUMBER_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_STRING_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_DATE_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_REGEXP_UL
|
||||
else if (builtin_tag != LIT_MAGIC_STRING_ARGUMENTS_UL && builtin_tag != LIT_MAGIC_STRING_FUNCTION_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_ERROR_UL && builtin_tag != LIT_MAGIC_STRING_BOOLEAN_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_NUMBER_UL && builtin_tag != LIT_MAGIC_STRING_STRING_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_DATE_UL && builtin_tag != LIT_MAGIC_STRING_REGEXP_UL
|
||||
&& builtin_tag != LIT_MAGIC_STRING_ARRAY_UL)
|
||||
{
|
||||
builtin_tag = LIT_MAGIC_STRING_OBJECT_UL;
|
||||
@@ -393,10 +392,8 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *array_obj_p, /**< array *
|
||||
|
||||
/* 5.b.iii.3.b */
|
||||
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (array_obj_p,
|
||||
*length_p + array_index,
|
||||
get_value,
|
||||
prop_flags);
|
||||
ecma_value_t put_comp =
|
||||
ecma_builtin_helper_def_prop_by_index (array_obj_p, *length_p + array_index, get_value, prop_flags);
|
||||
ecma_free_value (get_value);
|
||||
#if JERRY_ESNEXT
|
||||
if (ECMA_IS_VALUE_ERROR (put_comp))
|
||||
@@ -414,10 +411,7 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *array_obj_p, /**< array *
|
||||
|
||||
/* 5.c.i */
|
||||
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (array_obj_p,
|
||||
(*length_p)++,
|
||||
value,
|
||||
prop_flags);
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (array_obj_p, (*length_p)++, value, prop_flags);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (ECMA_IS_VALUE_ERROR (put_comp))
|
||||
@@ -686,10 +680,8 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_string_t *original_st
|
||||
{
|
||||
break;
|
||||
}
|
||||
uint32_t index = ecma_builtin_helper_string_find_index (original_str_p,
|
||||
search_str_p,
|
||||
(uint32_t) start_ends_with);
|
||||
ret_value = ecma_make_boolean_value (index == (uint32_t) start_ends_with);
|
||||
uint32_t index = ecma_builtin_helper_string_find_index (original_str_p, search_str_p, (uint32_t) start_ends_with);
|
||||
ret_value = ecma_make_boolean_value (index == (uint32_t) start_ends_with);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
@@ -772,7 +764,7 @@ ecma_builtin_helper_string_find_index (ecma_string_t *original_str_p, /**< index
|
||||
|
||||
while (!((size_t) (original_end_p - str_current_p) < search_str_size))
|
||||
{
|
||||
if (memcmp (str_current_p , search_str_utf8_p, search_str_size) == 0)
|
||||
if (memcmp (str_current_p, search_str_utf8_p, search_str_size) == 0)
|
||||
{
|
||||
match_found = start_pos;
|
||||
break;
|
||||
@@ -804,10 +796,7 @@ ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
return ecma_builtin_helper_def_prop (obj_p,
|
||||
ECMA_CREATE_DIRECT_UINT32_STRING (index),
|
||||
value,
|
||||
opts);
|
||||
return ecma_builtin_helper_def_prop (obj_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), value, opts);
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_length (index);
|
||||
@@ -842,7 +831,7 @@ ecma_builtin_helper_calculate_index (ecma_value_t index, /**< relative index arg
|
||||
ecma_number_t relative_index;
|
||||
ecma_value_t conversion_result = ecma_op_to_integer (index, &relative_index);
|
||||
|
||||
/* 4. */
|
||||
/* 4. */
|
||||
if (ECMA_IS_VALUE_ERROR (conversion_result))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
@@ -893,9 +882,7 @@ ecma_builtin_helper_def_prop (ecma_object_t *obj_p, /**< object */
|
||||
|
||||
prop_desc.value = value;
|
||||
|
||||
return ecma_op_object_define_own_property (obj_p,
|
||||
name_p,
|
||||
&prop_desc);
|
||||
return ecma_op_object_define_own_property (obj_p, name_p, &prop_desc);
|
||||
} /* ecma_builtin_helper_def_prop */
|
||||
|
||||
/**
|
||||
@@ -909,16 +896,12 @@ ecma_builtin_replace_substitute (ecma_replace_context_t *ctx_p) /**< replace con
|
||||
{
|
||||
JERRY_ASSERT (ctx_p->string_p != NULL);
|
||||
JERRY_ASSERT (ctx_p->matched_p == NULL
|
||||
|| (ctx_p->matched_p >= ctx_p->string_p
|
||||
&& ctx_p->matched_p <= ctx_p->string_p + ctx_p->string_size));
|
||||
|| (ctx_p->matched_p >= ctx_p->string_p && ctx_p->matched_p <= ctx_p->string_p + ctx_p->string_size));
|
||||
|
||||
lit_utf8_size_t replace_size;
|
||||
uint8_t replace_flags = ECMA_STRING_FLAG_IS_ASCII;
|
||||
const lit_utf8_byte_t *replace_buf_p = ecma_string_get_chars (ctx_p->replace_str_p,
|
||||
&replace_size,
|
||||
NULL,
|
||||
NULL,
|
||||
&replace_flags);
|
||||
const lit_utf8_byte_t *replace_buf_p =
|
||||
ecma_string_get_chars (ctx_p->replace_str_p, &replace_size, NULL, NULL, &replace_flags);
|
||||
|
||||
const lit_utf8_byte_t *const replace_end_p = replace_buf_p + replace_size;
|
||||
const lit_utf8_byte_t *curr_p = replace_buf_p;
|
||||
@@ -1016,7 +999,7 @@ ecma_builtin_replace_substitute (ecma_replace_context_t *ctx_p) /**< replace con
|
||||
uint8_t idx = (uint8_t) (c - LIT_CHAR_0);
|
||||
if (curr_p < replace_end_p && lit_char_is_decimal_digit (*(curr_p)))
|
||||
{
|
||||
uint8_t two_digit_index = (uint8_t) (idx * 10 + (uint8_t) (*(curr_p) - LIT_CHAR_0));
|
||||
uint8_t two_digit_index = (uint8_t) (idx * 10 + (uint8_t) (*(curr_p) -LIT_CHAR_0));
|
||||
if (two_digit_index < capture_count)
|
||||
{
|
||||
idx = two_digit_index;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user