mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Replacing const ecma_char_t* with ecma_string_t*; supporting number-represented string in ecma_string_t.
This commit is contained in:
parent
15b65a27fb
commit
8bc41358ec
@ -137,16 +137,22 @@ free_string_literal_copy (string_literal_copy *str_lit_descr_p) /**< string lite
|
||||
static bool
|
||||
do_strict_eval_arguments_check (ecma_reference_t ref) /**< ECMA-reference */
|
||||
{
|
||||
const ecma_char_t* magic_string_eval = ecma_get_magic_string (ECMA_MAGIC_STRING_EVAL);
|
||||
const ecma_char_t* magic_string_arguments = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
|
||||
return (ref.is_strict
|
||||
&& (ecma_compare_zt_string_to_zt_string (ref.referenced_name_p,
|
||||
magic_string_eval) == 0
|
||||
|| ecma_compare_zt_string_to_zt_string (ref.referenced_name_p,
|
||||
magic_string_arguments) == 0)
|
||||
&& (ref.base.value_type == ECMA_TYPE_OBJECT)
|
||||
&& (ECMA_GET_POINTER (ref.base.value) != NULL)
|
||||
&& (((ecma_object_t*) ECMA_GET_POINTER (ref.base.value))->is_lexical_environment));
|
||||
ecma_string_t* magic_string_eval = ecma_get_magic_string (ECMA_MAGIC_STRING_EVAL);
|
||||
ecma_string_t* magic_string_arguments = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
|
||||
|
||||
bool ret = (ref.is_strict
|
||||
&& (ecma_compare_ecma_string_to_ecma_string (ref.referenced_name_p,
|
||||
magic_string_eval) == 0
|
||||
|| ecma_compare_ecma_string_to_ecma_string (ref.referenced_name_p,
|
||||
magic_string_arguments) == 0)
|
||||
&& (ref.base.value_type == ECMA_TYPE_OBJECT)
|
||||
&& (ECMA_GET_POINTER (ref.base.value) != NULL)
|
||||
&& (((ecma_object_t*) ECMA_GET_POINTER (ref.base.value))->is_lexical_environment));
|
||||
|
||||
ecma_deref_ecma_string (magic_string_eval);
|
||||
ecma_deref_ecma_string (magic_string_arguments);
|
||||
|
||||
return ret;
|
||||
} /* do_strict_eval_arguments_check */
|
||||
|
||||
/**
|
||||
@ -180,8 +186,11 @@ get_variable_value (struct __int_data *int_data, /**< interpreter context */
|
||||
ecma_reference_t ref;
|
||||
|
||||
init_string_literal_copy (var_idx, &var_name);
|
||||
ecma_string_t *var_name_string_p = ecma_new_ecma_string (var_name.str_p);
|
||||
free_string_literal_copy (&var_name);
|
||||
|
||||
ref = ecma_op_get_identifier_reference (int_data->lex_env_p,
|
||||
var_name.str_p,
|
||||
var_name_string_p,
|
||||
int_data->is_strict);
|
||||
|
||||
if (unlikely (do_eval_or_arguments_check
|
||||
@ -194,8 +203,8 @@ get_variable_value (struct __int_data *int_data, /**< interpreter context */
|
||||
ret_value = ecma_op_get_value (ref);
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (var_name_string_p);
|
||||
ecma_free_reference (ref);
|
||||
free_string_literal_copy (&var_name);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
@ -234,8 +243,11 @@ set_variable_value (struct __int_data *int_data, /**< interpreter context */
|
||||
ecma_reference_t ref;
|
||||
|
||||
init_string_literal_copy (var_idx, &var_name);
|
||||
ecma_string_t *var_name_string_p = ecma_new_ecma_string (var_name.str_p);
|
||||
free_string_literal_copy (&var_name);
|
||||
|
||||
ref = ecma_op_get_identifier_reference (int_data->lex_env_p,
|
||||
var_name.str_p,
|
||||
var_name_string_p,
|
||||
int_data->is_strict);
|
||||
|
||||
if (unlikely (do_strict_eval_arguments_check (ref)))
|
||||
@ -247,8 +259,8 @@ set_variable_value (struct __int_data *int_data, /**< interpreter context */
|
||||
ret_value = ecma_op_put_value (ref, value);
|
||||
}
|
||||
|
||||
ecma_deref_ecma_string (var_name_string_p);
|
||||
ecma_free_reference (ref);
|
||||
free_string_literal_copy (&var_name);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
@ -1696,14 +1708,16 @@ opfunc_var_decl (OPCODE opdata, /**< operation data */
|
||||
{
|
||||
string_literal_copy variable_name;
|
||||
init_string_literal_copy (opdata.data.var_decl.variable_name, &variable_name);
|
||||
ecma_string_t *var_name_string_p = ecma_new_ecma_string (variable_name.str_p);
|
||||
free_string_literal_copy (&variable_name);
|
||||
|
||||
if (ecma_is_completion_value_normal_false (ecma_op_has_binding (int_data->lex_env_p,
|
||||
variable_name.str_p)))
|
||||
var_name_string_p)))
|
||||
{
|
||||
FIXME ("Pass configurableBindings that is true if and only if current code is eval code");
|
||||
|
||||
ecma_completion_value_t completion = ecma_op_create_mutable_binding (int_data->lex_env_p,
|
||||
variable_name.str_p,
|
||||
var_name_string_p,
|
||||
false);
|
||||
|
||||
JERRY_ASSERT (ecma_is_empty_completion_value (completion));
|
||||
@ -1712,12 +1726,12 @@ opfunc_var_decl (OPCODE opdata, /**< operation data */
|
||||
* any binding with specified name in current lexical environment
|
||||
* and CreateMutableBinding sets the created binding's value to undefined */
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_simple_value (ecma_op_get_binding_value (int_data->lex_env_p,
|
||||
variable_name.str_p,
|
||||
var_name_string_p,
|
||||
true),
|
||||
ECMA_SIMPLE_VALUE_UNDEFINED));
|
||||
}
|
||||
|
||||
free_string_literal_copy (&variable_name);
|
||||
ecma_deref_ecma_string (var_name_string_p);
|
||||
|
||||
int_data->pos++;
|
||||
|
||||
@ -1750,16 +1764,17 @@ function_declaration (struct __int_data *int_data, /**< interpreter context */
|
||||
|
||||
string_literal_copy function_name;
|
||||
init_string_literal_copy (function_name_lit_idx, &function_name);
|
||||
ecma_string_t *function_name_string_p = ecma_new_ecma_string (function_name.str_p);
|
||||
free_string_literal_copy (&function_name);
|
||||
|
||||
ecma_completion_value_t ret_value = ecma_op_function_declaration (int_data->lex_env_p,
|
||||
function_name.str_p,
|
||||
function_name_string_p,
|
||||
function_code_opcode_idx,
|
||||
args_names,
|
||||
args_number,
|
||||
is_strict,
|
||||
is_configurable_bindings);
|
||||
|
||||
free_string_literal_copy (&function_name);
|
||||
ecma_deref_ecma_string (function_name_string_p);
|
||||
|
||||
return ret_value;
|
||||
} /* function_declaration */
|
||||
|
||||
@ -579,8 +579,8 @@ typedef struct
|
||||
/** base value */
|
||||
ecma_value_t base;
|
||||
|
||||
/** referenced name value pointer */
|
||||
const ecma_char_t *referenced_name_p;
|
||||
/** referenced name */
|
||||
ecma_string_t *referenced_name_p;
|
||||
|
||||
/** strict reference flag */
|
||||
bool is_strict;
|
||||
|
||||
@ -91,6 +91,27 @@ ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string *
|
||||
return string_desc_p;
|
||||
} /* ecma_new_ecma_string */
|
||||
|
||||
/**
|
||||
* Allocate new ecma-string and fill it with ecma-number
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
ecma_string_t*
|
||||
ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
ecma_string_t* string_desc_p = ecma_alloc_string ();
|
||||
string_desc_p->refs = 1;
|
||||
string_desc_p->length = 0;
|
||||
string_desc_p->is_length_valid = false;
|
||||
string_desc_p->container = ECMA_STRING_CONTAINER_HEAP_NUMBER;
|
||||
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = num;
|
||||
ECMA_SET_POINTER (string_desc_p->u.number_cp, num_p);
|
||||
|
||||
return string_desc_p;
|
||||
} /* ecma_new_ecma_string_from_number */
|
||||
|
||||
/**
|
||||
* Increase reference counter of ecma-string.
|
||||
*
|
||||
@ -187,6 +208,35 @@ ecma_get_ecma_string_length (ecma_string_t *string_desc_p) /**< ecma-string desc
|
||||
JERRY_UNREACHABLE();
|
||||
} /* ecma_get_ecma_string_length */
|
||||
|
||||
/**
|
||||
* Convert ecma-string to number
|
||||
*/
|
||||
ecma_number_t
|
||||
ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */
|
||||
{
|
||||
JERRY_ASSERT (str_p != NULL);
|
||||
|
||||
if (str_p->container == ECMA_STRING_CONTAINER_HEAP_NUMBER)
|
||||
{
|
||||
ecma_number_t *num_p = ECMA_GET_POINTER (str_p->u.number_cp);
|
||||
|
||||
return *num_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (str_p->is_length_valid);
|
||||
|
||||
ecma_char_t zt_string_buffer [str_p->length + 1];
|
||||
|
||||
ssize_t bytes_copied = ecma_string_to_zt_string (str_p,
|
||||
zt_string_buffer,
|
||||
sizeof (zt_string_buffer));
|
||||
JERRY_ASSERT (bytes_copied > 0);
|
||||
|
||||
return ecma_zt_string_to_number (zt_string_buffer);
|
||||
}
|
||||
} /* ecma_string_to_number */
|
||||
|
||||
/**
|
||||
* Copy ecma-string's contents to a buffer.
|
||||
*
|
||||
@ -197,7 +247,7 @@ ecma_get_ecma_string_length (ecma_string_t *string_desc_p) /**< ecma-string desc
|
||||
* as negation of buffer size, that is required to hold the string's content.
|
||||
*/
|
||||
ssize_t
|
||||
ecma_string_to_zt_string (ecma_string_t *string_desc_p, /**< ecma-string descriptor */
|
||||
ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string descriptor */
|
||||
ecma_char_t *buffer_p, /**< destination buffer */
|
||||
size_t buffer_size) /**< size of buffer */
|
||||
{
|
||||
@ -275,6 +325,12 @@ ecma_compare_ecma_string_to_ecma_string (const ecma_string_t *string1_p, /* ecma
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string1_p->container == ECMA_STRING_CONTAINER_HEAP_NUMBER
|
||||
|| string2_p->container == ECMA_STRING_CONTAINER_HEAP_NUMBER)
|
||||
{
|
||||
JERRY_UNIMPLEMENTED ();
|
||||
}
|
||||
|
||||
if (string1_p->length != string2_p->length)
|
||||
{
|
||||
return false;
|
||||
@ -285,13 +341,18 @@ ecma_compare_ecma_string_to_ecma_string (const ecma_string_t *string1_p, /* ecma
|
||||
if (string1_p->container == ECMA_STRING_CONTAINER_IN_DESCRIPTOR
|
||||
&& string2_p->container == ECMA_STRING_CONTAINER_IN_DESCRIPTOR)
|
||||
{
|
||||
return __memcmp (string1_p->u.chars, string2_p->u.chars, chars_left * sizeof (ecma_char_t));
|
||||
return (__memcmp (string1_p->u.chars, string2_p->u.chars, chars_left * sizeof (ecma_char_t)) == 0);
|
||||
}
|
||||
|
||||
if (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE
|
||||
|| string2_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
|
||||
&& string2_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
return (string1_p->u.lit_index == string2_p->u.lit_index);
|
||||
}
|
||||
else if (string1_p->container == ECMA_STRING_CONTAINER_LIT_TABLE
|
||||
|| string2_p->container == ECMA_STRING_CONTAINER_LIT_TABLE)
|
||||
{
|
||||
JERRY_UNIMPLEMENTED ();
|
||||
}
|
||||
|
||||
if (string1_p->container == ECMA_STRING_CONTAINER_HEAP_CHUNKS
|
||||
@ -387,83 +448,6 @@ ecma_compare_zt_string_to_zt_string (const ecma_char_t *string1_p, /**< zero-ter
|
||||
return __strcmp ( (char*)string1_p, (char*)string2_p);
|
||||
} /* ecma_compare_zt_string_to_zt_string */
|
||||
|
||||
/**
|
||||
* Compare zero-terminated string to ecma-string
|
||||
*
|
||||
* @return true - if strings are equal;
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-terminated string */
|
||||
const ecma_string_t *ecma_string_p) /* ecma-string */
|
||||
{
|
||||
JERRY_ASSERT(string_p != NULL);
|
||||
JERRY_ASSERT(ecma_string_p != NULL);
|
||||
|
||||
const ecma_char_t *str_iter_p = string_p;
|
||||
ecma_length_t ecma_str_len = ecma_string_p->length;
|
||||
const ecma_char_t *current_chunk_chars_cur;
|
||||
const ecma_char_t *current_chunk_chars_end;
|
||||
ecma_collection_chunk_t *string_chunk_p = NULL;
|
||||
|
||||
if (ecma_string_p->container == ECMA_STRING_CONTAINER_IN_DESCRIPTOR)
|
||||
{
|
||||
current_chunk_chars_cur = ecma_string_p->u.chars;
|
||||
current_chunk_chars_end = current_chunk_chars_cur + sizeof (ecma_string_p->u.chars) / sizeof (ecma_char_t);
|
||||
}
|
||||
else if (ecma_string_p->container == ECMA_STRING_CONTAINER_HEAP_CHUNKS)
|
||||
{
|
||||
string_chunk_p = ECMA_GET_POINTER (ecma_string_p->u.chunk_cp);
|
||||
current_chunk_chars_cur = string_chunk_p->data;
|
||||
current_chunk_chars_end = current_chunk_chars_cur + sizeof (string_chunk_p->data) / sizeof (ecma_char_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_string_p->container == ECMA_STRING_CONTAINER_LIT_TABLE);
|
||||
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
for (ecma_length_t str_index = 0;
|
||||
str_index < ecma_str_len;
|
||||
str_index++, str_iter_p++, current_chunk_chars_cur++)
|
||||
{
|
||||
JERRY_ASSERT(current_chunk_chars_cur <= current_chunk_chars_end);
|
||||
|
||||
if (current_chunk_chars_cur == current_chunk_chars_end)
|
||||
{
|
||||
JERRY_ASSERT (ecma_string_p->container == ECMA_STRING_CONTAINER_HEAP_CHUNKS);
|
||||
|
||||
/* switching to next chunk */
|
||||
string_chunk_p = ECMA_GET_POINTER (string_chunk_p->next_chunk_cp);
|
||||
|
||||
JERRY_ASSERT(string_chunk_p != NULL);
|
||||
|
||||
current_chunk_chars_cur = string_chunk_p->data;
|
||||
current_chunk_chars_end = current_chunk_chars_cur + sizeof (string_chunk_p->data) / sizeof (ecma_char_t);
|
||||
}
|
||||
|
||||
if (*str_iter_p != *current_chunk_chars_cur)
|
||||
{
|
||||
/*
|
||||
* Either *str_iter_p is 0 (zero-terminated string is shorter),
|
||||
* or the character is just different.
|
||||
*
|
||||
* In both cases strings are not equal.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now, we have reached end of ecma-string.
|
||||
*
|
||||
* If we have also reached end of zero-terminated string, than strings are equal.
|
||||
* Otherwise zero-terminated string is longer.
|
||||
*/
|
||||
return (*str_iter_p == '\0');
|
||||
} /* ecma_compare_zt_string_to_ecma_string */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@ -200,7 +200,7 @@ ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
||||
const ecma_char_t *name_p, /**< property name */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
ecma_property_writable_value_t writable, /**< 'writable' attribute */
|
||||
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
|
||||
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
|
||||
@ -211,7 +211,8 @@ ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
||||
|
||||
prop_p->type = ECMA_PROPERTY_NAMEDDATA;
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_data_property.name_p, ecma_new_ecma_string (name_p));
|
||||
ecma_ref_ecma_string (name_p);
|
||||
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_data_property.name_p, name_p);
|
||||
|
||||
prop_p->u.named_data_property.writable = writable;
|
||||
prop_p->u.named_data_property.enumerable = enumerable;
|
||||
@ -234,7 +235,7 @@ ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
||||
const ecma_char_t *name_p, /**< property name */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
ecma_object_t *get_p, /**< getter */
|
||||
ecma_object_t *set_p, /**< setter */
|
||||
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
|
||||
@ -246,7 +247,8 @@ ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
||||
|
||||
prop_p->type = ECMA_PROPERTY_NAMEDACCESSOR;
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_accessor_property.name_p, ecma_new_ecma_string (name_p));
|
||||
ecma_ref_ecma_string (name_p);
|
||||
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_accessor_property.name_p, name_p);
|
||||
|
||||
ECMA_SET_POINTER(prop_p->u.named_accessor_property.get_p, get_p);
|
||||
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, get_p);
|
||||
@ -272,7 +274,7 @@ ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||
const ecma_char_t *name_p) /**< property's name */
|
||||
ecma_string_t *name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
@ -298,7 +300,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
|
||||
if (ecma_compare_zt_string_to_ecma_string (name_p, property_name_p))
|
||||
if (ecma_compare_ecma_string_to_ecma_string (name_p, property_name_p))
|
||||
{
|
||||
return property_p;
|
||||
}
|
||||
@ -318,7 +320,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||
const ecma_char_t *name_p) /**< property's name */
|
||||
ecma_string_t *name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
@ -341,7 +343,7 @@ ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in *
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||
const ecma_char_t *name_p) /**< property's name */
|
||||
ecma_string_t *name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL);
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
|
||||
@ -87,15 +87,15 @@ extern bool ecma_is_empty_completion_value (ecma_completion_value_t value);
|
||||
|
||||
/* ecma-helpers-string.c */
|
||||
extern ecma_string_t* ecma_new_ecma_string (const ecma_char_t *string_p);
|
||||
extern ecma_string_t* ecma_new_ecma_string_from_number (ecma_number_t number);
|
||||
extern void ecma_ref_ecma_string (ecma_string_t *string_desc_p);
|
||||
extern void ecma_deref_ecma_string (ecma_string_t *string_p);
|
||||
extern ecma_length_t ecma_get_ecma_string_length (ecma_string_t *string_desc_p);
|
||||
extern ssize_t ecma_string_to_zt_string (ecma_string_t *string_desc_p,
|
||||
extern ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
|
||||
extern ssize_t ecma_string_to_zt_string (const ecma_string_t *string_desc_p,
|
||||
ecma_char_t *buffer_p,
|
||||
size_t buffer_size);
|
||||
extern int32_t ecma_compare_zt_string_to_zt_string (const ecma_char_t *string1_p, const ecma_char_t *string2_p);
|
||||
extern bool ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p,
|
||||
const ecma_string_t *ecma_string_p);
|
||||
extern bool ecma_compare_ecma_string_to_ecma_string (const ecma_string_t *string1_p,
|
||||
const ecma_string_t *string2_p);
|
||||
|
||||
@ -144,22 +144,22 @@ extern ecma_property_t* ecma_get_internal_property (ecma_object_t *object_p,
|
||||
ecma_internal_property_id_t property_id);
|
||||
|
||||
extern ecma_property_t *ecma_create_named_data_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_property_writable_value_t writable,
|
||||
ecma_property_enumerable_value_t enumerable,
|
||||
ecma_property_configurable_value_t configurable);
|
||||
extern ecma_property_t *ecma_create_named_accessor_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_object_t *get_p,
|
||||
ecma_object_t *set_p,
|
||||
ecma_property_enumerable_value_t enumerable,
|
||||
ecma_property_configurable_value_t configurable);
|
||||
extern ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *name_p);
|
||||
ecma_string_t *name_p);
|
||||
extern ecma_property_t *ecma_get_named_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *name_p);
|
||||
ecma_string_t *name_p);
|
||||
extern ecma_property_t *ecma_get_named_data_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *name_p);
|
||||
ecma_string_t *name_p);
|
||||
|
||||
extern void ecma_free_internal_property (ecma_property_t *prop_p);
|
||||
extern void ecma_free_named_data_property (ecma_property_t *prop_p);
|
||||
|
||||
@ -77,12 +77,11 @@ ecma_array_object_reduce_length (ecma_object_t *obj_p, /**< the array object */
|
||||
old_length--;
|
||||
|
||||
// ii.
|
||||
ecma_char_t uint32_str_buf[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
ecma_uint32_to_string (old_length, uint32_str_buf, sizeof (uint32_str_buf));
|
||||
|
||||
ecma_string_t *old_length_string_p = ecma_new_ecma_string_from_number (ecma_uint32_to_number (old_length));
|
||||
ecma_completion_value_t delete_succeeded = ecma_op_object_delete (obj_p,
|
||||
uint32_str_buf,
|
||||
old_length_string_p,
|
||||
false);
|
||||
ecma_deref_ecma_string (old_length_string_p);
|
||||
|
||||
// iii.
|
||||
if (ecma_is_completion_value_normal_false (delete_succeeded))
|
||||
@ -99,11 +98,13 @@ ecma_array_object_reduce_length (ecma_object_t *obj_p, /**< the array object */
|
||||
&& new_len_desc.writable == ECMA_PROPERTY_NOT_WRITABLE);
|
||||
|
||||
// 3.
|
||||
const ecma_char_t *magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_string_t *magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_completion_value_t completion = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
new_len_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
|| ecma_is_completion_value_normal_false (completion));
|
||||
|
||||
@ -130,15 +131,15 @@ ecma_array_object_reduce_length (ecma_object_t *obj_p, /**< the array object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array object */
|
||||
const ecma_char_t *property_name_p, /**< property name */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
ecma_property_descriptor_t property_desc, /**< property descriptor */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
JERRY_ASSERT (obj_p->u.object.type == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
const ecma_char_t* magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
|
||||
// 1.
|
||||
ecma_string_t* magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_property_t *len_prop_p = ecma_op_object_get_own_property (obj_p, magic_string_length_p);
|
||||
JERRY_ASSERT (len_prop_p != NULL && len_prop_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||
|
||||
@ -151,7 +152,12 @@ ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array o
|
||||
uint32_t old_len_uint32 = ecma_number_to_uint32 (*num_p);
|
||||
|
||||
// 3.
|
||||
if (ecma_compare_zt_string_to_zt_string (property_name_p, magic_string_length_p) == 0)
|
||||
bool is_property_name_equal_length = (ecma_compare_ecma_string_to_ecma_string (property_name_p,
|
||||
magic_string_length_p) == 0);
|
||||
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
if (is_property_name_equal_length)
|
||||
{
|
||||
// a.
|
||||
if (!property_desc.is_value_defined)
|
||||
@ -198,10 +204,12 @@ ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array o
|
||||
if (new_len_uint32 >= old_len_uint32)
|
||||
{
|
||||
// i.
|
||||
magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ret_value = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
new_len_property_desc,
|
||||
is_throw);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -230,10 +238,12 @@ ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array o
|
||||
}
|
||||
|
||||
// j.
|
||||
magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_completion_value_t succeeded = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
new_len_property_desc,
|
||||
is_throw);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
/* Handling normal false and throw values */
|
||||
if (!ecma_is_completion_value_normal_true (succeeded))
|
||||
@ -272,10 +282,12 @@ ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array o
|
||||
prop_desc_not_writable.writable = ECMA_PROPERTY_NOT_WRITABLE;
|
||||
|
||||
ecma_completion_value_t completion_set_not_writable;
|
||||
magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
completion_set_not_writable = ecma_op_general_object_define_own_property (obj_p,
|
||||
magic_string_length_p,
|
||||
prop_desc_not_writable,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion_set_not_writable));
|
||||
}
|
||||
|
||||
@ -295,7 +307,7 @@ ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array o
|
||||
else
|
||||
{
|
||||
// 4.a.
|
||||
ecma_number_t number = ecma_zt_string_to_number (property_name_p);
|
||||
ecma_number_t number = ecma_string_to_number (property_name_p);
|
||||
uint32_t index = ecma_number_to_uint32 (number);
|
||||
|
||||
TODO (Check if array index recognition is done according to ECMA);
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_array_object_define_own_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p,
|
||||
ecma_string_t *property_name_p,
|
||||
ecma_property_descriptor_t property_desc,
|
||||
bool is_throw);
|
||||
|
||||
|
||||
@ -173,11 +173,13 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f
|
||||
length_prop_desc.is_configurable_defined = false;
|
||||
length_prop_desc.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE;
|
||||
|
||||
const ecma_char_t* magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_string_t* magic_string_length_p = ecma_get_magic_string (ECMA_MAGIC_STRING_LENGTH);
|
||||
ecma_completion_value_t completion = ecma_op_object_define_own_property (f,
|
||||
magic_string_length_p,
|
||||
length_prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_length_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion)
|
||||
|| ecma_is_completion_value_normal_false (completion));
|
||||
|
||||
@ -204,18 +206,22 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f
|
||||
prop_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
|
||||
}
|
||||
|
||||
ecma_string_t *magic_string_constructor_p = ecma_get_magic_string (ECMA_MAGIC_STRING_CONSTRUCTOR);
|
||||
ecma_op_object_define_own_property (proto_p,
|
||||
ecma_get_magic_string (ECMA_MAGIC_STRING_CONSTRUCTOR),
|
||||
magic_string_constructor_p,
|
||||
prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_constructor_p);
|
||||
|
||||
// 18.
|
||||
prop_desc.value = ecma_make_object_value (proto_p);
|
||||
prop_desc.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE;
|
||||
ecma_string_t *magic_string_prototype_p = ecma_get_magic_string (ECMA_MAGIC_STRING_PROTOTYPE);
|
||||
ecma_op_object_define_own_property (f,
|
||||
ecma_get_magic_string (ECMA_MAGIC_STRING_PROTOTYPE),
|
||||
magic_string_prototype_p,
|
||||
prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_prototype_p);
|
||||
|
||||
ecma_deref_object (proto_p);
|
||||
|
||||
@ -239,15 +245,19 @@ ecma_op_create_function_object (ecma_string_t* formal_parameter_list_p[], /**< f
|
||||
prop_desc.set_p = thrower_p;
|
||||
}
|
||||
|
||||
ecma_string_t *magic_string_caller_p =ecma_get_magic_string (ECMA_MAGIC_STRING_CALLER) ;
|
||||
ecma_op_object_define_own_property (f,
|
||||
ecma_get_magic_string (ECMA_MAGIC_STRING_CALLER),
|
||||
magic_string_caller_p,
|
||||
prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_caller_p);
|
||||
|
||||
ecma_string_t *magic_string_arguments_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
|
||||
ecma_op_object_define_own_property (f,
|
||||
ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS),
|
||||
magic_string_arguments_p,
|
||||
prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (magic_string_arguments_p);
|
||||
|
||||
ecma_deref_object (thrower_p);
|
||||
}
|
||||
@ -307,19 +317,12 @@ ecma_function_call_setup_args_variables (ecma_object_t *func_obj_p, /**< Functio
|
||||
JERRY_ASSERT (formal_parameter_name_value.value_type == ECMA_TYPE_STRING);
|
||||
ecma_string_t *formal_parameter_name_string_p = ECMA_GET_POINTER (formal_parameter_name_value.value);
|
||||
|
||||
ecma_char_t formal_parameter_name_zt_string[formal_parameter_name_string_p->length + 1];
|
||||
ssize_t bytes_copied = ecma_string_to_zt_string (formal_parameter_name_string_p,
|
||||
formal_parameter_name_zt_string,
|
||||
sizeof (formal_parameter_name_zt_string));
|
||||
JERRY_ASSERT (bytes_copied > 0
|
||||
&& (size_t) bytes_copied == sizeof (formal_parameter_name_zt_string));
|
||||
|
||||
ecma_completion_value_t arg_already_declared = ecma_op_has_binding (env_p,
|
||||
formal_parameter_name_zt_string);
|
||||
formal_parameter_name_string_p);
|
||||
if (!ecma_is_completion_value_normal_true (arg_already_declared))
|
||||
{
|
||||
ecma_completion_value_t completion = ecma_op_create_mutable_binding (env_p,
|
||||
formal_parameter_name_zt_string,
|
||||
formal_parameter_name_string_p,
|
||||
false);
|
||||
if (ecma_is_completion_value_throw (completion))
|
||||
{
|
||||
@ -329,7 +332,7 @@ ecma_function_call_setup_args_variables (ecma_object_t *func_obj_p, /**< Functio
|
||||
JERRY_ASSERT (ecma_is_empty_completion_value (completion));
|
||||
|
||||
completion = ecma_op_set_mutable_binding (env_p,
|
||||
formal_parameter_name_zt_string,
|
||||
formal_parameter_name_string_p,
|
||||
v,
|
||||
is_strict);
|
||||
|
||||
@ -453,7 +456,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_function_declaration (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_char_t *function_name_p, /**< function name */
|
||||
ecma_string_t *function_name_p, /**< function name */
|
||||
opcode_counter_t function_code_opcode_idx, /**< index of first opcode of function code */
|
||||
ecma_string_t* formal_parameter_list_p[], /**< formal parameters list */
|
||||
ecma_length_t formal_parameter_list_length, /**< length of formal parameters list */
|
||||
|
||||
@ -42,7 +42,7 @@ extern ecma_completion_value_t ecma_op_function_call (ecma_object_t *func_obj_p,
|
||||
|
||||
extern ecma_completion_value_t
|
||||
ecma_op_function_declaration (ecma_object_t *lex_env_p,
|
||||
ecma_char_t *function_name_p,
|
||||
ecma_string_t *function_name_p,
|
||||
opcode_counter_t function_code_opcode_idx,
|
||||
ecma_string_t* formal_parameter_list_p[],
|
||||
ecma_length_t formal_parameter_list_length,
|
||||
|
||||
@ -62,12 +62,13 @@ ecma_op_create_global_object (void)
|
||||
|
||||
ecma_object_t *glob_obj_p = ecma_create_object (NULL, true, ECMA_OBJECT_TYPE_GENERAL);
|
||||
|
||||
const ecma_char_t* undefined_identifier_p = ecma_get_magic_string (ECMA_MAGIC_STRING_UNDEFINED);
|
||||
ecma_string_t* undefined_identifier_p = ecma_get_magic_string (ECMA_MAGIC_STRING_UNDEFINED);
|
||||
ecma_property_t *undefined_prop_p = ecma_create_named_data_property (glob_obj_p,
|
||||
undefined_identifier_p,
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
ecma_deref_ecma_string (undefined_identifier_p);
|
||||
JERRY_ASSERT(ecma_is_value_undefined (undefined_prop_p->u.named_data_property.value));
|
||||
|
||||
TODO(/* Define NaN, Infinity, eval, parseInt, parseFloat, isNaN, isFinite properties */);
|
||||
|
||||
@ -61,7 +61,7 @@ ecma_get_lex_env_binding_object (ecma_object_t* obj_lex_env_p) /**< object lexic
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p) /**< argument N */
|
||||
ecma_string_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||
|
||||
@ -109,7 +109,7 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p, /**< argument N */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
bool is_deletable) /**< argument D */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||
@ -180,7 +180,7 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p, /**< argument N */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
ecma_value_t value, /**< argument V */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
@ -242,7 +242,7 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p, /**< argument N */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||
@ -316,7 +316,7 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p) /**< argument N */
|
||||
ecma_string_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||
JERRY_ASSERT(name_p != NULL);
|
||||
@ -415,7 +415,7 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
|
||||
*/
|
||||
void
|
||||
ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p) /**< argument N */
|
||||
ecma_string_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||
|
||||
@ -458,7 +458,7 @@ ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environ
|
||||
*/
|
||||
void
|
||||
ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p, /**< argument N */
|
||||
ecma_string_t *name_p, /**< argument N */
|
||||
ecma_value_t value) /**< argument V */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||
|
||||
@ -30,26 +30,26 @@
|
||||
|
||||
/* ECMA-262 v5, Table 17. Abstract methods of Environment Records */
|
||||
extern ecma_completion_value_t ecma_op_has_binding (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p);
|
||||
ecma_string_t *name_p);
|
||||
extern ecma_completion_value_t ecma_op_create_mutable_binding (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
bool is_deletable);
|
||||
extern ecma_completion_value_t ecma_op_set_mutable_binding (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_value_t value,
|
||||
bool is_strict);
|
||||
extern ecma_completion_value_t ecma_op_get_binding_value (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
bool is_strict);
|
||||
extern ecma_completion_value_t ecma_op_delete_binding (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p);
|
||||
ecma_string_t *name_p);
|
||||
extern ecma_completion_value_t ecma_op_implicit_this_value (ecma_object_t *lex_env_p);
|
||||
|
||||
/* ECMA-262 v5, Table 18. Additional methods of Declarative Environment Records */
|
||||
extern void ecma_op_create_immutable_binding (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p);
|
||||
ecma_string_t *name_p);
|
||||
extern void ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_value_t value);
|
||||
|
||||
extern ecma_object_t* ecma_op_create_global_environment (void);
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-magic-strings.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
@ -27,20 +29,20 @@
|
||||
*
|
||||
* @return pointer to magic string contant
|
||||
*/
|
||||
const ecma_char_t*
|
||||
ecma_string_t*
|
||||
ecma_get_magic_string (ecma_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
TODO(Support UTF-16);
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case ECMA_MAGIC_STRING_ARGUMENTS: return (ecma_char_t*) "arguments";
|
||||
case ECMA_MAGIC_STRING_EVAL: return (ecma_char_t*) "eval";
|
||||
case ECMA_MAGIC_STRING_PROTOTYPE: return (ecma_char_t*) "prototype";
|
||||
case ECMA_MAGIC_STRING_CONSTRUCTOR: return (ecma_char_t*) "constructor";
|
||||
case ECMA_MAGIC_STRING_CALLER: return (ecma_char_t*) "caller";
|
||||
case ECMA_MAGIC_STRING_UNDEFINED: return (ecma_char_t*) "undefined";
|
||||
case ECMA_MAGIC_STRING_LENGTH: return (ecma_char_t*) "length";
|
||||
case ECMA_MAGIC_STRING_ARGUMENTS: return ecma_new_ecma_string ((ecma_char_t*) "arguments");
|
||||
case ECMA_MAGIC_STRING_EVAL: return ecma_new_ecma_string ((ecma_char_t*) "eval");
|
||||
case ECMA_MAGIC_STRING_PROTOTYPE: return ecma_new_ecma_string ((ecma_char_t*) "prototype");
|
||||
case ECMA_MAGIC_STRING_CONSTRUCTOR: return ecma_new_ecma_string ((ecma_char_t*) "constructor");
|
||||
case ECMA_MAGIC_STRING_CALLER: return ecma_new_ecma_string ((ecma_char_t*) "caller");
|
||||
case ECMA_MAGIC_STRING_UNDEFINED: return ecma_new_ecma_string ((ecma_char_t*) "undefined");
|
||||
case ECMA_MAGIC_STRING_LENGTH: return ecma_new_ecma_string ((ecma_char_t*) "length");
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE();
|
||||
|
||||
@ -39,7 +39,7 @@ typedef enum
|
||||
ECMA_MAGIC_STRING_LENGTH /**< length */
|
||||
} ecma_magic_string_id_t;
|
||||
|
||||
extern const ecma_char_t* ecma_get_magic_string (ecma_magic_string_id_t id);
|
||||
extern ecma_string_t* ecma_get_magic_string (ecma_magic_string_id_t id);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@ -58,7 +58,7 @@ ecma_reject (bool is_throw) /**< Throw flag */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -113,7 +113,7 @@ ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_op_general_object_get_own_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -133,7 +133,7 @@ ecma_op_general_object_get_own_property (ecma_object_t *obj_p, /**< the object *
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_op_general_object_get_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -173,7 +173,7 @@ ecma_op_general_object_get_property (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_general_object_put (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p, /**< property name */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
ecma_value_t value, /**< ecma-value */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
@ -276,7 +276,7 @@ ecma_op_general_object_put (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
bool
|
||||
ecma_op_general_object_can_put (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -375,7 +375,7 @@ ecma_op_general_object_can_put (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
bool
|
||||
ecma_op_general_object_has_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -397,7 +397,7 @@ ecma_op_general_object_has_property (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_general_object_delete (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p, /**< property name */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
@ -478,7 +478,7 @@ ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p, /**< property name */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
ecma_property_descriptor_t property_desc, /**< property descriptor */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
|
||||
@ -27,26 +27,26 @@
|
||||
*/
|
||||
|
||||
extern ecma_completion_value_t ecma_op_general_object_get (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p);
|
||||
ecma_string_t *property_name_p);
|
||||
extern ecma_property_t *ecma_op_general_object_get_own_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p);
|
||||
ecma_string_t *property_name_p);
|
||||
extern ecma_property_t *ecma_op_general_object_get_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p);
|
||||
ecma_string_t *property_name_p);
|
||||
extern ecma_completion_value_t ecma_op_general_object_put (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p,
|
||||
ecma_string_t *property_name_p,
|
||||
ecma_value_t value,
|
||||
bool is_throw);
|
||||
extern bool ecma_op_general_object_can_put (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p);
|
||||
ecma_string_t *property_name_p);
|
||||
extern bool ecma_op_general_object_has_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p);
|
||||
ecma_string_t *property_name_p);
|
||||
extern ecma_completion_value_t ecma_op_general_object_delete (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p,
|
||||
ecma_string_t *property_name_p,
|
||||
bool is_throw);
|
||||
extern ecma_completion_value_t ecma_op_general_object_default_value (ecma_object_t *obj_p,
|
||||
ecma_preferred_type_hint_t hint);
|
||||
extern ecma_completion_value_t ecma_op_general_object_define_own_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p,
|
||||
ecma_string_t *property_name_p,
|
||||
ecma_property_descriptor_t property_desc,
|
||||
bool is_throw);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -74,7 +74,7 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_op_object_get_own_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -113,7 +113,7 @@ ecma_op_object_get_own_property (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_op_object_get_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -152,7 +152,7 @@ ecma_op_object_get_property (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_object_put (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p, /**< property name */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
ecma_value_t value, /**< ecma-value */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
@ -193,7 +193,7 @@ ecma_op_object_put (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
bool
|
||||
ecma_op_object_can_put (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -232,7 +232,7 @@ ecma_op_object_can_put (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
bool
|
||||
ecma_op_object_has_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p) /**< property name */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
JERRY_ASSERT(property_name_p != NULL);
|
||||
@ -271,7 +271,7 @@ ecma_op_object_has_property (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p, /**< property name */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||
@ -349,7 +349,7 @@ ecma_op_object_default_value (ecma_object_t *obj_p, /**< the object */
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
|
||||
const ecma_char_t *property_name_p, /**< property name */
|
||||
ecma_string_t *property_name_p, /**< property name */
|
||||
ecma_property_descriptor_t property_desc, /**< property descriptor */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
|
||||
@ -26,21 +26,21 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern ecma_completion_value_t ecma_op_object_get (ecma_object_t *obj_p, const ecma_char_t *property_name_p);
|
||||
extern ecma_property_t *ecma_op_object_get_own_property (ecma_object_t *obj_p, const ecma_char_t *property_name_p);
|
||||
extern ecma_property_t *ecma_op_object_get_property (ecma_object_t *obj_p, const ecma_char_t *property_name_p);
|
||||
extern ecma_completion_value_t ecma_op_object_get (ecma_object_t *obj_p, ecma_string_t *property_name_p);
|
||||
extern ecma_property_t *ecma_op_object_get_own_property (ecma_object_t *obj_p, ecma_string_t *property_name_p);
|
||||
extern ecma_property_t *ecma_op_object_get_property (ecma_object_t *obj_p, ecma_string_t *property_name_p);
|
||||
extern ecma_completion_value_t ecma_op_object_put (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p,
|
||||
ecma_string_t *property_name_p,
|
||||
ecma_value_t value,
|
||||
bool is_throw);
|
||||
extern bool ecma_op_object_can_put (ecma_object_t *obj_p, const ecma_char_t *property_name_p);
|
||||
extern bool ecma_op_object_has_property (ecma_object_t *obj_p, const ecma_char_t *property_name_p);
|
||||
extern bool ecma_op_object_can_put (ecma_object_t *obj_p, ecma_string_t *property_name_p);
|
||||
extern bool ecma_op_object_has_property (ecma_object_t *obj_p, ecma_string_t *property_name_p);
|
||||
extern ecma_completion_value_t ecma_op_object_delete (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p,
|
||||
ecma_string_t *property_name_p,
|
||||
bool is_throw);
|
||||
extern ecma_completion_value_t ecma_op_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint);
|
||||
extern ecma_completion_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p,
|
||||
const ecma_char_t *property_name_p,
|
||||
ecma_string_t *property_name_p,
|
||||
ecma_property_descriptor_t property_desc,
|
||||
bool is_throw);
|
||||
|
||||
|
||||
@ -27,10 +27,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern ecma_reference_t ecma_op_get_identifier_reference (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p,
|
||||
bool is_strict);
|
||||
|
||||
extern ecma_completion_value_t ecma_op_get_value (ecma_reference_t ref);
|
||||
extern ecma_completion_value_t ecma_op_put_value (ecma_reference_t ref,
|
||||
ecma_value_t value);
|
||||
|
||||
@ -32,16 +32,12 @@
|
||||
/**
|
||||
* Resolve syntactic reference to ECMA-reference.
|
||||
*
|
||||
* Warning: string pointed by name_p
|
||||
* must not be freed or reused
|
||||
* until the reference is freed.
|
||||
*
|
||||
* @return ECMA-reference
|
||||
* Returned value must be freed through ecma_free_reference.
|
||||
*/
|
||||
ecma_reference_t
|
||||
ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
const ecma_char_t *name_p, /**< identifier's name */
|
||||
ecma_string_t *name_p, /**< identifier's name */
|
||||
bool is_strict) /**< strict reference flag */
|
||||
{
|
||||
JERRY_ASSERT(lex_env_p != NULL);
|
||||
@ -75,18 +71,16 @@ ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environ
|
||||
/**
|
||||
* ECMA-reference constructor.
|
||||
*
|
||||
* Warning: string pointed by name_p
|
||||
* must not be freed or reused
|
||||
* until the reference is freed.
|
||||
*
|
||||
* @return ECMA-reference
|
||||
* Returned value must be freed through ecma_free_reference.
|
||||
*/
|
||||
ecma_reference_t
|
||||
ecma_make_reference (ecma_value_t base, /**< base value */
|
||||
const ecma_char_t *name_p, /**< referenced name */
|
||||
ecma_string_t *name_p, /**< referenced name */
|
||||
bool is_strict) /**< strict reference flag */
|
||||
{
|
||||
ecma_ref_ecma_string (name_p);
|
||||
|
||||
ecma_reference_t ref = (ecma_reference_t)
|
||||
{
|
||||
.base = ecma_copy_value (base, true),
|
||||
@ -107,6 +101,7 @@ void
|
||||
ecma_free_reference (const ecma_reference_t ref) /**< reference */
|
||||
{
|
||||
ecma_free_value (ref.base, true);
|
||||
ecma_deref_ecma_string (ref.referenced_name_p);
|
||||
} /* ecma_free_reference */
|
||||
|
||||
/**
|
||||
|
||||
@ -29,10 +29,10 @@
|
||||
*/
|
||||
|
||||
extern ecma_reference_t ecma_op_get_identifier_reference (ecma_object_t *lex_env_p,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
bool is_strict);
|
||||
extern ecma_reference_t ecma_make_reference (ecma_value_t base,
|
||||
const ecma_char_t *name_p,
|
||||
ecma_string_t *name_p,
|
||||
bool is_strict);
|
||||
extern void ecma_free_reference (const ecma_reference_t ref);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user