Adding stubs for String.prototype routines.

This commit is contained in:
Ruben Ayrapetyan
2014-09-25 20:39:00 +04:00
parent caa2663b28
commit 5bee6cad0f
4 changed files with 727 additions and 41 deletions
@@ -34,7 +34,7 @@
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup object ECMA Object object built-in
* \addtogroup string ECMA String object built-in
* @{
*/
@@ -0,0 +1,643 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* 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-alloc.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-objects.h"
#include "ecma-string-object.h"
#include "ecma-try-catch-macro.h"
#include "globals.h"
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup ecmabuiltins
* @{
*
* \addtogroup stringprototype ECMA String.prototype object built-in
* @{
*/
/**
* List of the String.prototype object built-in object value properties in format 'macro (name, value)'.
*/
#define ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_OBJECT_VALUES_PROPERTY_LIST(macro) \
macro (ECMA_MAGIC_STRING_CONSTRUCTOR, ecma_builtin_get (ECMA_BUILTIN_ID_STRING))
/**
* List of the String.prototype object built-in routine properties in format
* 'macro (name, C function name, arguments number of the routine, length value of the routine)'.
*/
#define ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_ROUTINES_PROPERTY_LIST(macro) \
macro (ECMA_MAGIC_STRING_TO_STRING_UL, \
ecma_builtin_string_prototype_object_to_string, \
0, \
0) \
macro (ECMA_MAGIC_STRING_VALUE_OF_UL, \
ecma_builtin_string_prototype_object_value_of, \
0, \
0) \
macro (ECMA_MAGIC_STRING_CHAR_AT_UL, \
ecma_builtin_string_prototype_object_char_at, \
1, \
1) \
macro (ECMA_MAGIC_STRING_CHAR_CODE_AT_UL, \
ecma_builtin_string_prototype_object_char_code_at, \
1, \
1) \
macro (ECMA_MAGIC_STRING_CONCAT, \
ecma_builtin_string_prototype_object_concat, \
NON_FIXED, \
1) \
macro (ECMA_MAGIC_STRING_INDEX_OF_UL, \
ecma_builtin_string_prototype_object_index_of, \
2, \
1) \
macro (ECMA_MAGIC_STRING_LAST_INDEX_OF_UL, \
ecma_builtin_string_prototype_object_last_index_of, \
2, \
1) \
macro (ECMA_MAGIC_STRING_LOCALE_COMPARE_UL, \
ecma_builtin_string_prototype_object_locale_compare, \
1, \
1) \
macro (ECMA_MAGIC_STRING_MATCH, \
ecma_builtin_string_prototype_object_match, \
1, \
1) \
macro (ECMA_MAGIC_STRING_REPLACE, \
ecma_builtin_string_prototype_object_replace, \
2, \
2) \
macro (ECMA_MAGIC_STRING_SEARCH, \
ecma_builtin_string_prototype_object_search, \
1, \
1) \
macro (ECMA_MAGIC_STRING_SLICE, \
ecma_builtin_string_prototype_object_slice, \
2, \
2) \
macro (ECMA_MAGIC_STRING_SPLIT, \
ecma_builtin_string_prototype_object_split, \
2, \
2) \
macro (ECMA_MAGIC_STRING_SUBSTRING, \
ecma_builtin_string_prototype_object_substring, \
2, \
2) \
macro (ECMA_MAGIC_STRING_TO_LOWER_CASE_UL, \
ecma_builtin_string_prototype_object_to_lower_case, \
0, \
0) \
macro (ECMA_MAGIC_STRING_TO_LOCALE_LOWER_CASE_UL, \
ecma_builtin_string_prototype_object_to_locale_lower_case, \
0, \
0) \
macro (ECMA_MAGIC_STRING_TO_UPPER_CASE_UL, \
ecma_builtin_string_prototype_object_to_upper_case, \
0, \
0) \
macro (ECMA_MAGIC_STRING_TO_LOCALE_UPPER_CASE_UL, \
ecma_builtin_string_prototype_object_to_locale_upper_case, \
0, \
0) \
macro (ECMA_MAGIC_STRING_TRIM, \
ecma_builtin_string_prototype_object_trim, \
0, \
0)
/**
* List of the String.prototype object's built-in property names
*/
static const ecma_magic_string_id_t ecma_builtin_property_names[] =
{
#define VALUE_PROP_LIST(name, value) name,
#define ROUTINE_PROP_LIST(name, c_function_name, args_number, length) name,
ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_OBJECT_VALUES_PROPERTY_LIST (VALUE_PROP_LIST)
ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_ROUTINES_PROPERTY_LIST (ROUTINE_PROP_LIST)
#undef VALUE_PROP_LIST
#undef ROUTINE_PROP_LIST
};
/**
* Number of the String.prototype object's built-in properties
*/
const ecma_length_t ecma_builtin_string_prototype_property_number = (sizeof (ecma_builtin_property_names) /
sizeof (ecma_magic_string_id_t));
/**
* The String.prototype object's 'toString' routine
*
* See also:
* ECMA-262 v5, 15.5.4.2
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_string (ecma_value_t this) /**< this argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this);
} /* ecma_builtin_string_prototype_object_to_string */
/**
* The String.prototype object's 'valueOf' routine
*
* See also:
* ECMA-262 v5, 15.5.4.3
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_value_of (ecma_value_t this) /**< this argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this);
} /* ecma_builtin_string_prototype_object_value_of */
/**
* The String.prototype object's 'charAt' routine
*
* See also:
* ECMA-262 v5, 15.5.4.4
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_char_at (ecma_value_t this, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg);
} /* ecma_builtin_string_prototype_object_char_at */
/**
* The String.prototype object's 'charCodeAt' routine
*
* See also:
* ECMA-262 v5, 15.5.4.5
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_char_code_at (ecma_value_t this, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg);
} /* ecma_builtin_string_prototype_object_char_code_at */
/**
* The String.prototype object's 'concat' routine
*
* See also:
* ECMA-262 v5, 15.5.4.6
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_concat (ecma_value_t this, /**< this argument */
ecma_value_t* argument_list_p, /**< arguments list */
ecma_length_t arguments_number) /**< number of arguments */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, argument_list_p, arguments_number);
} /* ecma_builtin_string_prototype_object_concat */
/**
* The String.prototype object's 'indexOf' routine
*
* See also:
* ECMA-262 v5, 15.5.4.7
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_index_of (ecma_value_t this, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg1, arg2);
} /* ecma_builtin_string_prototype_object_index_of */
/**
* The String.prototype object's 'lastIndexOf' routine
*
* See also:
* ECMA-262 v5, 15.5.4.8
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_last_index_of (ecma_value_t this, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg1, arg2);
} /* ecma_builtin_string_prototype_object_last_index_of */
/**
* The String.prototype object's 'localeCompare' routine
*
* See also:
* ECMA-262 v5, 15.5.4.9
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_locale_compare (ecma_value_t this, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg);
} /* ecma_builtin_string_prototype_object_locale_compare */
/**
* The String.prototype object's 'match' routine
*
* See also:
* ECMA-262 v5, 15.5.4.10
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_match (ecma_value_t this, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg);
} /* ecma_builtin_string_prototype_object_match */
/**
* The String.prototype object's 'replace' routine
*
* See also:
* ECMA-262 v5, 15.5.4.11
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_replace (ecma_value_t this, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg1, arg2);
} /* ecma_builtin_string_prototype_object_replace */
/**
* The String.prototype object's 'search' routine
*
* See also:
* ECMA-262 v5, 15.5.4.12
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_search (ecma_value_t this, /**< this argument */
ecma_value_t arg) /**< routine's argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg);
} /* ecma_builtin_string_prototype_object_search */
/**
* The String.prototype object's 'slice' routine
*
* See also:
* ECMA-262 v5, 15.5.4.13
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_slice (ecma_value_t this, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg1, arg2);
} /* ecma_builtin_string_prototype_object_slice */
/**
* The String.prototype object's 'split' routine
*
* See also:
* ECMA-262 v5, 15.5.4.14
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_split (ecma_value_t this, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg1, arg2);
} /* ecma_builtin_string_prototype_object_split */
/**
* The String.prototype object's 'substring' routine
*
* See also:
* ECMA-262 v5, 15.5.4.15
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_substring (ecma_value_t this, /**< this argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this, arg1, arg2);
} /* ecma_builtin_string_prototype_object_substring */
/**
* The String.prototype object's 'toLowerCase' routine
*
* See also:
* ECMA-262 v5, 15.5.4.16
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_lower_case (ecma_value_t this) /**< this argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this);
} /* ecma_builtin_string_prototype_object_to_lower_case */
/**
* The String.prototype object's 'toLocaleLowerCase' routine
*
* See also:
* ECMA-262 v5, 15.5.4.17
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_locale_lower_case (ecma_value_t this) /**< this argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this);
} /* ecma_builtin_string_prototype_object_to_locale_lower_case */
/**
* The String.prototype object's 'toUpperCase' routine
*
* See also:
* ECMA-262 v5, 15.5.4.18
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_upper_case (ecma_value_t this) /**< this argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this);
} /* ecma_builtin_string_prototype_object_to_upper_case */
/**
* The String.prototype object's 'toLocaleUpperCase' routine
*
* See also:
* ECMA-262 v5, 15.5.4.19
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_to_locale_upper_case (ecma_value_t this) /**< this argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this);
} /* ecma_builtin_string_prototype_object_to_locale_upper_case */
/**
* The String.prototype object's 'trim' routine
*
* See also:
* ECMA-262 v5, 15.5.4.20
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_string_prototype_object_trim (ecma_value_t this) /**< this argument */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (this);
} /* ecma_builtin_string_prototype_object_trim */
/**
* If the property's name is one of built-in properties of the String.prototype object
* that is not instantiated yet, instantiate the property and
* return pointer to the instantiated property.
*
* @return pointer property, if one was instantiated,
* NULL - otherwise.
*/
ecma_property_t*
ecma_builtin_string_prototype_try_to_instantiate_property (ecma_object_t *obj_p, /**< object */
ecma_string_t *prop_name_p) /**< property's name */
{
JERRY_ASSERT (ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_STRING_PROTOTYPE));
JERRY_ASSERT (ecma_find_named_property (obj_p, prop_name_p) == NULL);
ecma_magic_string_id_t id;
if (!ecma_is_string_magic (prop_name_p, &id))
{
return NULL;
}
int32_t index = ecma_builtin_bin_search_for_magic_string_id_in_array (ecma_builtin_property_names,
ecma_builtin_string_prototype_property_number,
id);
if (index == -1)
{
return NULL;
}
JERRY_ASSERT (index >= 0 && (uint32_t) index < sizeof (uint64_t) * JERRY_BITSINBYTE);
uint32_t bit;
ecma_internal_property_id_t mask_prop_id;
if (index >= 32)
{
mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63;
bit = (uint32_t) 1u << (index - 32);
}
else
{
mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31;
bit = (uint32_t) 1u << index;
}
ecma_property_t *mask_prop_p = ecma_get_internal_property (obj_p, mask_prop_id);
uint32_t bit_mask = mask_prop_p->u.internal_property.value;
if (!(bit_mask & bit))
{
return NULL;
}
bit_mask &= ~bit;
mask_prop_p->u.internal_property.value = bit_mask;
ecma_value_t value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
ecma_property_writable_value_t writable = ECMA_PROPERTY_WRITABLE;
ecma_property_enumerable_value_t enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
ecma_property_configurable_value_t configurable = ECMA_PROPERTY_CONFIGURABLE;
switch (id)
{
#define CASE_ROUTINE_PROP_LIST(name, c_function_name, args_number, length) case name:
ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_ROUTINES_PROPERTY_LIST (CASE_ROUTINE_PROP_LIST)
#undef CASE_ROUTINE_PROP_LIST
{
ecma_object_t *func_obj_p = ecma_builtin_make_function_object_for_routine (ECMA_BUILTIN_ID_STRING, id);
value = ecma_make_object_value (func_obj_p);
break;
}
#define CASE_VALUE_PROP_LIST(name, value) case name:
ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_OBJECT_VALUES_PROPERTY_LIST (CASE_VALUE_PROP_LIST)
#undef CASE_VALUE_PROP_LIST
{
writable = ECMA_PROPERTY_NOT_WRITABLE;
enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
configurable = ECMA_PROPERTY_NOT_CONFIGURABLE;
switch (id)
{
#define CASE_OBJECT_VALUE_PROP_LIST(name, value_obj) case name: { value = ecma_make_object_value (value_obj); break; }
ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_OBJECT_VALUES_PROPERTY_LIST (CASE_OBJECT_VALUE_PROP_LIST)
#undef CASE_OBJECT_VALUE_PROP_LIST
default:
{
JERRY_UNREACHABLE ();
}
}
break;
}
default:
{
JERRY_UNREACHABLE ();
}
}
ecma_property_t *prop_p = ecma_create_named_data_property (obj_p,
prop_name_p,
writable,
enumerable,
configurable);
prop_p->u.named_data_property.value = ecma_copy_value (value, false);
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p,
prop_p->u.named_data_property.value);
ecma_free_value (value, true);
return prop_p;
} /* ecma_builtin_string_prototype_try_to_instantiate_property */
/**
* Dispatcher of the String.prototype object's built-in routines
*
* @return completion-value
* Returned value must be freed with ecma_free_completion_value.
*/
ecma_completion_value_t
ecma_builtin_string_prototype_dispatch_routine (ecma_magic_string_id_t builtin_routine_id, /**< String.prototype
object's built-in
routine's name */
ecma_value_t this_arg_value __unused, /**< 'this' argument value */
ecma_value_t arguments_list [], /**< list of arguments
passed to routine */
ecma_length_t arguments_number) /**< length of arguments' list */
{
const ecma_value_t value_undefined = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
switch (builtin_routine_id)
{
#define ROUTINE_ARG(n) (arguments_number >= n ? arguments_list[n - 1] : value_undefined)
#define ROUTINE_ARG_LIST_0
#define ROUTINE_ARG_LIST_1 , ROUTINE_ARG(1)
#define ROUTINE_ARG_LIST_2 ROUTINE_ARG_LIST_1, ROUTINE_ARG(2)
#define ROUTINE_ARG_LIST_3 ROUTINE_ARG_LIST_2, ROUTINE_ARG(3)
#define ROUTINE_ARG_LIST_NON_FIXED , arguments_list, arguments_number
#define CASE_ROUTINE_PROP_LIST(name, c_function_name, args_number, length) \
case name: \
{ \
return c_function_name (this_arg_value ROUTINE_ARG_LIST_ ## args_number); \
}
ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_ROUTINES_PROPERTY_LIST (CASE_ROUTINE_PROP_LIST)
#undef CASE_ROUTINE_PROP_LIST
#undef ROUTINE_ARG_LIST_0
#undef ROUTINE_ARG_LIST_1
#undef ROUTINE_ARG_LIST_2
#undef ROUTINE_ARG_LIST_3
#undef ROUTINE_ARG_LIST_NON_FIXED
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_string_prototype_dispatch_routine */
/**
* Get number of routine's parameters
*
* @return number of parameters
*/
ecma_length_t
ecma_builtin_string_prototype_get_routine_parameters_number (ecma_magic_string_id_t builtin_routine_id) /**< built-in
routine's
name */
{
switch (builtin_routine_id)
{
#define CASE_ROUTINE_PROP_LIST(name, c_function_name, args_number, length) case name: return length;
ECMA_BUILTIN_STRING_PROTOTYPE_OBJECT_ROUTINES_PROPERTY_LIST (CASE_ROUTINE_PROP_LIST)
#undef CASE_ROUTINE_PROP_LIST
default:
{
JERRY_UNREACHABLE ();
}
}
} /* ecma_builtin_string_prototype_get_routine_parameters_number */
/**
* @}
* @}
* @}
*/
@@ -124,6 +124,18 @@ extern ecma_completion_value_t
ecma_builtin_string_dispatch_construct (ecma_value_t *arguments_list_p,
ecma_length_t arguments_list_len);
/* ecma-builtin-string-prototype-object.c */
extern const ecma_length_t ecma_builtin_string_prototype_property_number;
extern ecma_length_t
ecma_builtin_string_prototype_get_routine_parameters_number (ecma_magic_string_id_t routine_id);
extern ecma_completion_value_t
ecma_builtin_string_prototype_dispatch_routine (ecma_magic_string_id_t builtin_routine_id,
ecma_value_t this_arg_value,
ecma_value_t arguments_list [],
ecma_length_t arguments_number);
extern ecma_property_t*
ecma_builtin_string_prototype_try_to_instantiate_property (ecma_object_t *obj_p, ecma_string_t *prop_name_p);
/* ecma-builtin-array-object.c */
extern const ecma_length_t ecma_builtin_array_property_number;
extern ecma_length_t
+71 -40
View File
@@ -86,11 +86,12 @@ ecma_builtin_get (ecma_builtin_id_t builtin_id) /**< id of built-in to check on
*/
static ecma_object_t*
ecma_builtin_init_object (ecma_builtin_id_t obj_builtin_id, /**< built-in ID */
ecma_object_t* prototype_obj_p, /**< prototype object */
ecma_object_type_t obj_type, /**< object's type */
ecma_object_class_t obj_class, /**< object's class */
ecma_length_t property_number) /**< number of the object's properties */
{
ecma_object_t *object_obj_p = ecma_create_object (NULL, true, obj_type);
ecma_object_t *object_obj_p = ecma_create_object (prototype_obj_p, true, obj_type);
ecma_property_t *class_prop_p = ecma_create_internal_property (object_obj_p,
ECMA_INTERNAL_PROPERTY_CLASS);
@@ -134,30 +135,47 @@ ecma_init_builtins (void)
ecma_builtin_objects [id] = NULL;
}
ecma_builtin_objects [ECMA_BUILTIN_ID_OBJECT] = ecma_builtin_init_object (ECMA_BUILTIN_ID_OBJECT,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_OBJECT_CLASS_OBJECT,
ecma_builtin_object_property_number);
ecma_builtin_id_t id = ECMA_BUILTIN_ID_OBJECT;
ecma_builtin_objects [id] = ecma_builtin_init_object (id,
NULL, /* FIXME */
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_OBJECT_CLASS_OBJECT,
ecma_builtin_object_property_number);
ecma_builtin_objects [ECMA_BUILTIN_ID_STRING] = ecma_builtin_init_object (ECMA_BUILTIN_ID_STRING,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_OBJECT_CLASS_STRING,
ecma_builtin_string_property_number);
id = ECMA_BUILTIN_ID_STRING_PROTOTYPE;
ecma_builtin_objects [id] = ecma_builtin_init_object (id,
NULL,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_OBJECT_CLASS_STRING,
ecma_builtin_string_prototype_property_number);
ecma_builtin_objects [ECMA_BUILTIN_ID_ARRAY] = ecma_builtin_init_object (ECMA_BUILTIN_ID_ARRAY,
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_OBJECT_CLASS_ARRAY,
ecma_builtin_array_property_number);
id = ECMA_BUILTIN_ID_STRING;
ecma_builtin_objects [id] = ecma_builtin_init_object (id,
ecma_builtin_objects [ECMA_BUILTIN_ID_STRING_PROTOTYPE],
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_OBJECT_CLASS_STRING,
ecma_builtin_string_property_number);
ecma_builtin_objects [ECMA_BUILTIN_ID_MATH] = ecma_builtin_init_object (ECMA_BUILTIN_ID_MATH,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_OBJECT_CLASS_MATH,
ecma_builtin_math_property_number);
id = ECMA_BUILTIN_ID_ARRAY;
ecma_builtin_objects [id] = ecma_builtin_init_object (id,
NULL, /* FIXME */
ECMA_OBJECT_TYPE_FUNCTION,
ECMA_OBJECT_CLASS_ARRAY,
ecma_builtin_array_property_number);
ecma_builtin_objects [ECMA_BUILTIN_ID_GLOBAL] = ecma_builtin_init_object (ECMA_BUILTIN_ID_GLOBAL,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_OBJECT_CLASS_OBJECT,
ecma_builtin_global_property_number);
id = ECMA_BUILTIN_ID_MATH;
ecma_builtin_objects [id] = ecma_builtin_init_object (id,
NULL, /* FIXME */
ECMA_OBJECT_TYPE_GENERAL,
ECMA_OBJECT_CLASS_MATH,
ecma_builtin_math_property_number);
id = ECMA_BUILTIN_ID_GLOBAL;
ecma_builtin_objects [id] = ecma_builtin_init_object (id,
NULL, /* FIXME */
ECMA_OBJECT_TYPE_GENERAL,
ECMA_OBJECT_CLASS_OBJECT,
ecma_builtin_global_property_number);
} /* ecma_init_builtins */
/**
@@ -226,11 +244,15 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
return ecma_builtin_array_try_to_instantiate_property (object_p, string_p);
}
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
{
return ecma_builtin_string_prototype_try_to_instantiate_property (object_p, string_p);
}
case ECMA_BUILTIN_ID_OBJECT_PROTOTYPE:
case ECMA_BUILTIN_ID_FUNCTION:
case ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE:
case ECMA_BUILTIN_ID_ARRAY_PROTOTYPE:
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
case ECMA_BUILTIN_ID_BOOLEAN:
case ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE:
case ECMA_BUILTIN_ID_NUMBER:
@@ -376,20 +398,12 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
return ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
}
case ECMA_BUILTIN_ID_OBJECT_PROTOTYPE:
case ECMA_BUILTIN_ID_FUNCTION:
case ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE:
case ECMA_BUILTIN_ID_ARRAY_PROTOTYPE:
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
case ECMA_BUILTIN_ID_BOOLEAN:
case ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE:
case ECMA_BUILTIN_ID_NUMBER:
case ECMA_BUILTIN_ID_NUMBER_PROTOTYPE:
case ECMA_BUILTIN_ID_DATE:
case ECMA_BUILTIN_ID_REGEXP:
case ECMA_BUILTIN_ID_REGEXP_PROTOTYPE:
case ECMA_BUILTIN_ID_ERROR:
case ECMA_BUILTIN_ID_ERROR_PROTOTYPE:
case ECMA_BUILTIN_ID_EVAL_ERROR:
case ECMA_BUILTIN_ID_RANGE_ERROR:
case ECMA_BUILTIN_ID_REFERENCE_ERROR:
@@ -403,6 +417,14 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
case ECMA_BUILTIN_ID_GLOBAL:
case ECMA_BUILTIN_ID_MATH:
case ECMA_BUILTIN_ID_JSON:
case ECMA_BUILTIN_ID_OBJECT_PROTOTYPE:
case ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE:
case ECMA_BUILTIN_ID_ARRAY_PROTOTYPE:
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
case ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE:
case ECMA_BUILTIN_ID_NUMBER_PROTOTYPE:
case ECMA_BUILTIN_ID_REGEXP_PROTOTYPE:
case ECMA_BUILTIN_ID_ERROR_PROTOTYPE:
{
JERRY_UNREACHABLE ();
}
@@ -455,20 +477,12 @@ ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
return ecma_builtin_array_dispatch_construct (arguments_list_p, arguments_list_len);
}
case ECMA_BUILTIN_ID_OBJECT_PROTOTYPE:
case ECMA_BUILTIN_ID_FUNCTION:
case ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE:
case ECMA_BUILTIN_ID_ARRAY_PROTOTYPE:
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
case ECMA_BUILTIN_ID_BOOLEAN:
case ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE:
case ECMA_BUILTIN_ID_NUMBER:
case ECMA_BUILTIN_ID_NUMBER_PROTOTYPE:
case ECMA_BUILTIN_ID_DATE:
case ECMA_BUILTIN_ID_REGEXP:
case ECMA_BUILTIN_ID_REGEXP_PROTOTYPE:
case ECMA_BUILTIN_ID_ERROR:
case ECMA_BUILTIN_ID_ERROR_PROTOTYPE:
case ECMA_BUILTIN_ID_EVAL_ERROR:
case ECMA_BUILTIN_ID_RANGE_ERROR:
case ECMA_BUILTIN_ID_REFERENCE_ERROR:
@@ -482,6 +496,14 @@ ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
case ECMA_BUILTIN_ID_GLOBAL:
case ECMA_BUILTIN_ID_MATH:
case ECMA_BUILTIN_ID_JSON:
case ECMA_BUILTIN_ID_OBJECT_PROTOTYPE:
case ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE:
case ECMA_BUILTIN_ID_ARRAY_PROTOTYPE:
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
case ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE:
case ECMA_BUILTIN_ID_NUMBER_PROTOTYPE:
case ECMA_BUILTIN_ID_REGEXP_PROTOTYPE:
case ECMA_BUILTIN_ID_ERROR_PROTOTYPE:
{
JERRY_UNREACHABLE ();
}
@@ -529,12 +551,15 @@ ecma_builtin_get_routine_parameters_number (ecma_builtin_id_t builtin_id, /**< i
{
return ecma_builtin_array_get_routine_parameters_number (routine_id);
}
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
{
return ecma_builtin_string_prototype_get_routine_parameters_number (routine_id);
}
case ECMA_BUILTIN_ID_OBJECT_PROTOTYPE:
case ECMA_BUILTIN_ID_FUNCTION:
case ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE:
case ECMA_BUILTIN_ID_ARRAY_PROTOTYPE:
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
case ECMA_BUILTIN_ID_BOOLEAN:
case ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE:
case ECMA_BUILTIN_ID_NUMBER:
@@ -615,12 +640,18 @@ ecma_builtin_dispatch_routine (ecma_builtin_id_t builtin_object_id, /**< built-i
arguments_list,
arguments_number);
}
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
{
return ecma_builtin_string_prototype_dispatch_routine (builtin_routine_id,
this_arg_value,
arguments_list,
arguments_number);
}
case ECMA_BUILTIN_ID_OBJECT_PROTOTYPE:
case ECMA_BUILTIN_ID_FUNCTION:
case ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE:
case ECMA_BUILTIN_ID_ARRAY_PROTOTYPE:
case ECMA_BUILTIN_ID_STRING_PROTOTYPE:
case ECMA_BUILTIN_ID_BOOLEAN:
case ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE:
case ECMA_BUILTIN_ID_NUMBER: