Styles fixes in libecmaobjects, libecmaoperations: indentation and braces rules.
This commit is contained in:
@@ -55,30 +55,30 @@ JERRY_STATIC_ASSERT(sizeof (ecma_completion_value_t) == sizeof (uint32_t));
|
|||||||
* FIXME: Run GC only if allocation failed.
|
* FIXME: Run GC only if allocation failed.
|
||||||
*/
|
*/
|
||||||
#define ALLOC(ecma_type) ecma_ ## ecma_type ## _t * \
|
#define ALLOC(ecma_type) ecma_ ## ecma_type ## _t * \
|
||||||
ecma_alloc_ ## ecma_type (void) \
|
ecma_alloc_ ## ecma_type (void) \
|
||||||
{ \
|
{ \
|
||||||
ecma_ ## ecma_type ## _t *p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
|
ecma_ ## ecma_type ## _t *p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
|
||||||
mem_pools_alloc (); \
|
mem_pools_alloc (); \
|
||||||
\
|
\
|
||||||
if (likely (p ## ecma_type != NULL)) \
|
if (likely (p ## ecma_type != NULL)) \
|
||||||
|
{ \
|
||||||
|
return p ## ecma_type; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \
|
||||||
|
gen_id < ECMA_GC_GEN_COUNT; \
|
||||||
|
gen_id++) \
|
||||||
|
{ \
|
||||||
|
ecma_gc_run (gen_id); \
|
||||||
|
\
|
||||||
|
p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
|
||||||
|
mem_pools_alloc (); \
|
||||||
|
\
|
||||||
|
if (likely (p ## ecma_type != NULL)) \
|
||||||
{ \
|
{ \
|
||||||
return p ## ecma_type; \
|
return p ## ecma_type; \
|
||||||
} \
|
} \
|
||||||
\
|
} \
|
||||||
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \
|
|
||||||
gen_id < ECMA_GC_GEN_COUNT; \
|
|
||||||
gen_id++) \
|
|
||||||
{ \
|
|
||||||
ecma_gc_run (gen_id); \
|
|
||||||
\
|
|
||||||
p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
|
|
||||||
mem_pools_alloc (); \
|
|
||||||
\
|
|
||||||
if (likely (p ## ecma_type != NULL)) \
|
|
||||||
{ \
|
|
||||||
return p ## ecma_type; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
JERRY_UNREACHABLE(); \
|
JERRY_UNREACHABLE(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,17 +86,17 @@ ecma_alloc_ ## ecma_type (void) \
|
|||||||
* Deallocation routine template
|
* Deallocation routine template
|
||||||
*/
|
*/
|
||||||
#define DEALLOC(ecma_type) void \
|
#define DEALLOC(ecma_type) void \
|
||||||
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _t *p ## ecma_type) \
|
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _t *p ## ecma_type) \
|
||||||
{ \
|
{ \
|
||||||
mem_pools_free ((uint8_t*) p ## ecma_type); \
|
mem_pools_free ((uint8_t*) p ## ecma_type); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declaration of alloc/free routine for specified ecma-type.
|
* Declaration of alloc/free routine for specified ecma-type.
|
||||||
*/
|
*/
|
||||||
#define DECLARE_ROUTINES_FOR(ecma_type) \
|
#define DECLARE_ROUTINES_FOR(ecma_type) \
|
||||||
ALLOC(ecma_type) \
|
ALLOC(ecma_type) \
|
||||||
DEALLOC(ecma_type)
|
DEALLOC(ecma_type)
|
||||||
|
|
||||||
DECLARE_ROUTINES_FOR (object)
|
DECLARE_ROUTINES_FOR (object)
|
||||||
DECLARE_ROUTINES_FOR (property)
|
DECLARE_ROUTINES_FOR (property)
|
||||||
|
|||||||
+220
-220
@@ -72,9 +72,9 @@ ecma_ref_object (ecma_object_t *object_p) /**< object */
|
|||||||
JERRY_ASSERT(object_p->gc_info.refs > 0);
|
JERRY_ASSERT(object_p->gc_info.refs > 0);
|
||||||
|
|
||||||
if (unlikely (object_p->gc_info.refs == 0))
|
if (unlikely (object_p->gc_info.refs == 0))
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
}
|
}
|
||||||
} /* ecma_ref_object */
|
} /* ecma_ref_object */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +99,9 @@ ecma_gc_update_may_ref_younger_object_flag_by_value (ecma_object_t *obj_p, /**<
|
|||||||
ecma_value_t value) /**< value */
|
ecma_value_t value) /**< value */
|
||||||
{
|
{
|
||||||
if (value.value_type != ECMA_TYPE_OBJECT)
|
if (value.value_type != ECMA_TYPE_OBJECT)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_object_t *ref_obj_p = ECMA_GET_POINTER(value.value);
|
ecma_object_t *ref_obj_p = ECMA_GET_POINTER(value.value);
|
||||||
JERRY_ASSERT(ref_obj_p != NULL);
|
JERRY_ASSERT(ref_obj_p != NULL);
|
||||||
@@ -115,14 +115,14 @@ ecma_gc_update_may_ref_younger_object_flag_by_object (ecma_object_t *obj_p, /**<
|
|||||||
or NULL */
|
or NULL */
|
||||||
{
|
{
|
||||||
if (ref_obj_p == NULL)
|
if (ref_obj_p == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref_obj_p->gc_info.generation < obj_p->gc_info.generation)
|
if (ref_obj_p->gc_info.generation < obj_p->gc_info.generation)
|
||||||
{
|
{
|
||||||
obj_p->gc_info.may_ref_younger_objects = true;
|
obj_p->gc_info.may_ref_younger_objects = true;
|
||||||
}
|
}
|
||||||
} /* ecma_gc_update_may_ref_younger_object_flag_by_object */
|
} /* ecma_gc_update_may_ref_younger_object_flag_by_object */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,145 +151,145 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
|
|||||||
bool does_reference_object_to_traverse = false;
|
bool does_reference_object_to_traverse = false;
|
||||||
|
|
||||||
if (object_p->is_lexical_environment)
|
if (object_p->is_lexical_environment)
|
||||||
|
{
|
||||||
|
ecma_object_t *lex_env_p = ECMA_GET_POINTER(object_p->u.lexical_environment.outer_reference_p);
|
||||||
|
if (lex_env_p != NULL
|
||||||
|
&& lex_env_p->gc_info.generation <= maximum_gen_to_traverse)
|
||||||
{
|
{
|
||||||
ecma_object_t *lex_env_p = ECMA_GET_POINTER(object_p->u.lexical_environment.outer_reference_p);
|
if (!lex_env_p->gc_info.visited)
|
||||||
if (lex_env_p != NULL
|
{
|
||||||
&& lex_env_p->gc_info.generation <= maximum_gen_to_traverse)
|
ecma_gc_mark (lex_env_p, ECMA_GC_GEN_COUNT);
|
||||||
{
|
}
|
||||||
if (!lex_env_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (lex_env_p, ECMA_GC_GEN_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
does_reference_object_to_traverse = true;
|
does_reference_object_to_traverse = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ecma_object_t *proto_p = ECMA_GET_POINTER(object_p->u.object.prototype_object_p);
|
||||||
|
if (proto_p != NULL
|
||||||
|
&& proto_p->gc_info.generation <= maximum_gen_to_traverse)
|
||||||
{
|
{
|
||||||
ecma_object_t *proto_p = ECMA_GET_POINTER(object_p->u.object.prototype_object_p);
|
if (!proto_p->gc_info.visited)
|
||||||
if (proto_p != NULL
|
{
|
||||||
&& proto_p->gc_info.generation <= maximum_gen_to_traverse)
|
ecma_gc_mark (proto_p, ECMA_GC_GEN_COUNT);
|
||||||
{
|
}
|
||||||
if (!proto_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (proto_p, ECMA_GC_GEN_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
does_reference_object_to_traverse = true;
|
does_reference_object_to_traverse = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (ecma_property_t *property_p = ECMA_GET_POINTER(object_p->properties_p), *next_property_p;
|
for (ecma_property_t *property_p = ECMA_GET_POINTER(object_p->properties_p), *next_property_p;
|
||||||
property_p != NULL;
|
property_p != NULL;
|
||||||
property_p = next_property_p)
|
property_p = next_property_p)
|
||||||
|
{
|
||||||
|
next_property_p = ECMA_GET_POINTER(property_p->next_property_p);
|
||||||
|
|
||||||
|
switch ((ecma_property_type_t) property_p->type)
|
||||||
{
|
{
|
||||||
next_property_p = ECMA_GET_POINTER(property_p->next_property_p);
|
case ECMA_PROPERTY_NAMEDDATA:
|
||||||
|
{
|
||||||
|
ecma_value_t value = property_p->u.named_data_property.value;
|
||||||
|
|
||||||
switch ((ecma_property_type_t) property_p->type)
|
if (value.value_type == ECMA_TYPE_OBJECT)
|
||||||
{
|
{
|
||||||
case ECMA_PROPERTY_NAMEDDATA:
|
ecma_object_t *value_obj_p = ECMA_GET_POINTER(value.value);
|
||||||
|
|
||||||
|
if (value_obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
||||||
|
{
|
||||||
|
if (!value_obj_p->gc_info.visited)
|
||||||
{
|
{
|
||||||
ecma_value_t value = property_p->u.named_data_property.value;
|
ecma_gc_mark (value_obj_p, ECMA_GC_GEN_COUNT);
|
||||||
|
|
||||||
if (value.value_type == ECMA_TYPE_OBJECT)
|
|
||||||
{
|
|
||||||
ecma_object_t *value_obj_p = ECMA_GET_POINTER(value.value);
|
|
||||||
|
|
||||||
if (value_obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
|
||||||
{
|
|
||||||
if (!value_obj_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (value_obj_p, ECMA_GC_GEN_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
does_reference_object_to_traverse = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_PROPERTY_NAMEDACCESSOR:
|
does_reference_object_to_traverse = true;
|
||||||
{
|
}
|
||||||
ecma_object_t *getter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.get_p);
|
|
||||||
ecma_object_t *setter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.set_p);
|
|
||||||
|
|
||||||
if (getter_obj_p != NULL)
|
|
||||||
{
|
|
||||||
if (getter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
|
||||||
{
|
|
||||||
if (!getter_obj_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (getter_obj_p, ECMA_GC_GEN_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
does_reference_object_to_traverse = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setter_obj_p != NULL)
|
|
||||||
{
|
|
||||||
if (setter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
|
||||||
{
|
|
||||||
if (!setter_obj_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (setter_obj_p, ECMA_GC_GEN_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
does_reference_object_to_traverse = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ECMA_PROPERTY_INTERNAL:
|
|
||||||
{
|
|
||||||
ecma_internal_property_id_t property_id = property_p->u.internal_property.type;
|
|
||||||
uint32_t property_value = property_p->u.internal_property.value;
|
|
||||||
|
|
||||||
switch (property_id)
|
|
||||||
{
|
|
||||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_PROTOTYPE: /* the property's value is located in ecma_object_t */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_EXTENSIBLE: /* the property's value is located in ecma_object_t */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
|
||||||
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
|
|
||||||
{
|
|
||||||
ecma_object_t *obj_p = ECMA_GET_POINTER(property_value);
|
|
||||||
|
|
||||||
if (obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
|
||||||
{
|
|
||||||
if (!obj_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (obj_p, ECMA_GC_GEN_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
does_reference_object_to_traverse = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECMA_PROPERTY_NAMEDACCESSOR:
|
||||||
|
{
|
||||||
|
ecma_object_t *getter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.get_p);
|
||||||
|
ecma_object_t *setter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.set_p);
|
||||||
|
|
||||||
|
if (getter_obj_p != NULL)
|
||||||
|
{
|
||||||
|
if (getter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
||||||
|
{
|
||||||
|
if (!getter_obj_p->gc_info.visited)
|
||||||
|
{
|
||||||
|
ecma_gc_mark (getter_obj_p, ECMA_GC_GEN_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
does_reference_object_to_traverse = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setter_obj_p != NULL)
|
||||||
|
{
|
||||||
|
if (setter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
||||||
|
{
|
||||||
|
if (!setter_obj_p->gc_info.visited)
|
||||||
|
{
|
||||||
|
ecma_gc_mark (setter_obj_p, ECMA_GC_GEN_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
does_reference_object_to_traverse = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECMA_PROPERTY_INTERNAL:
|
||||||
|
{
|
||||||
|
ecma_internal_property_id_t property_id = property_p->u.internal_property.type;
|
||||||
|
uint32_t property_value = property_p->u.internal_property.value;
|
||||||
|
|
||||||
|
switch (property_id)
|
||||||
|
{
|
||||||
|
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_PROTOTYPE: /* the property's value is located in ecma_object_t */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_EXTENSIBLE: /* the property's value is located in ecma_object_t */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
||||||
|
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
|
||||||
|
{
|
||||||
|
ecma_object_t *obj_p = ECMA_GET_POINTER(property_value);
|
||||||
|
|
||||||
|
if (obj_p->gc_info.generation <= maximum_gen_to_traverse)
|
||||||
|
{
|
||||||
|
if (!obj_p->gc_info.visited)
|
||||||
|
{
|
||||||
|
ecma_gc_mark (obj_p, ECMA_GC_GEN_COUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
does_reference_object_to_traverse = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!does_reference_object_to_traverse)
|
if (!does_reference_object_to_traverse)
|
||||||
{
|
{
|
||||||
object_p->gc_info.may_ref_younger_objects = false;
|
object_p->gc_info.may_ref_younger_objects = false;
|
||||||
}
|
}
|
||||||
} /* ecma_gc_mark */
|
} /* ecma_gc_mark */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,18 +299,18 @@ void
|
|||||||
ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(object_p != NULL
|
JERRY_ASSERT(object_p != NULL
|
||||||
&& !object_p->gc_info.visited
|
&& !object_p->gc_info.visited
|
||||||
&& object_p->gc_info.refs == 0);
|
&& object_p->gc_info.refs == 0);
|
||||||
|
|
||||||
for (ecma_property_t *property = ECMA_GET_POINTER(object_p->properties_p),
|
for (ecma_property_t *property = ECMA_GET_POINTER(object_p->properties_p),
|
||||||
*next_property_p;
|
*next_property_p;
|
||||||
property != NULL;
|
property != NULL;
|
||||||
property = next_property_p)
|
property = next_property_p)
|
||||||
{
|
{
|
||||||
next_property_p = ECMA_GET_POINTER(property->next_property_p);
|
next_property_p = ECMA_GET_POINTER(property->next_property_p);
|
||||||
|
|
||||||
ecma_free_property (property);
|
ecma_free_property (property);
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_dealloc_object (object_p);
|
ecma_dealloc_object (object_p);
|
||||||
} /* ecma_gc_sweep */
|
} /* ecma_gc_sweep */
|
||||||
@@ -325,46 +325,46 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
|||||||
|
|
||||||
/* clearing visited flags for all objects of generations to be processed */
|
/* clearing visited flags for all objects of generations to be processed */
|
||||||
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
|
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
|
||||||
|
{
|
||||||
|
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||||
|
obj_iter_p != NULL;
|
||||||
|
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
||||||
{
|
{
|
||||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
obj_iter_p->gc_info.visited = false;
|
||||||
obj_iter_p != NULL;
|
|
||||||
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
|
||||||
{
|
|
||||||
obj_iter_p->gc_info.visited = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if some object is referenced from stack or globals (i.e. it is root),
|
/* if some object is referenced from stack or globals (i.e. it is root),
|
||||||
* start recursive marking traverse from the object */
|
* start recursive marking traverse from the object */
|
||||||
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
|
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
|
||||||
|
{
|
||||||
|
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||||
|
obj_iter_p != NULL;
|
||||||
|
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
||||||
{
|
{
|
||||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
if (obj_iter_p->gc_info.refs > 0
|
||||||
obj_iter_p != NULL;
|
&& !obj_iter_p->gc_info.visited)
|
||||||
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
{
|
||||||
{
|
ecma_gc_mark (obj_iter_p, ECMA_GC_GEN_COUNT);
|
||||||
if (obj_iter_p->gc_info.refs > 0
|
}
|
||||||
&& !obj_iter_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (obj_iter_p, ECMA_GC_GEN_COUNT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if some object from generations that are not processed during current session may reference
|
/* if some object from generations that are not processed during current session may reference
|
||||||
* younger generations, start recursive marking traverse from the object, but one the first level
|
* younger generations, start recursive marking traverse from the object, but one the first level
|
||||||
* consider only references to object of at most max_gen_to_collect generation */
|
* consider only references to object of at most max_gen_to_collect generation */
|
||||||
for (ecma_gc_gen_t gen_id = max_gen_to_collect + 1; gen_id < ECMA_GC_GEN_COUNT; gen_id++)
|
for (ecma_gc_gen_t gen_id = max_gen_to_collect + 1; gen_id < ECMA_GC_GEN_COUNT; gen_id++)
|
||||||
|
{
|
||||||
|
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||||
|
obj_iter_p != NULL;
|
||||||
|
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
||||||
{
|
{
|
||||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
if (obj_iter_p->gc_info.may_ref_younger_objects > 0)
|
||||||
obj_iter_p != NULL;
|
{
|
||||||
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
ecma_gc_mark (obj_iter_p, max_gen_to_collect);
|
||||||
{
|
}
|
||||||
if (obj_iter_p->gc_info.may_ref_younger_objects > 0)
|
|
||||||
{
|
|
||||||
ecma_gc_mark (obj_iter_p, max_gen_to_collect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ecma_object_t *gen_last_obj_p[ max_gen_to_collect + 1 ];
|
ecma_object_t *gen_last_obj_p[ max_gen_to_collect + 1 ];
|
||||||
#ifndef JERRY_NDEBUG
|
#ifndef JERRY_NDEBUG
|
||||||
@@ -372,79 +372,79 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
|
|||||||
#endif /* !JERRY_NDEBUG */
|
#endif /* !JERRY_NDEBUG */
|
||||||
|
|
||||||
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
|
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
|
||||||
|
{
|
||||||
|
ecma_object_t *obj_prev_p = NULL;
|
||||||
|
|
||||||
|
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ],
|
||||||
|
*obj_next_p;
|
||||||
|
obj_iter_p != NULL;
|
||||||
|
obj_iter_p = obj_next_p)
|
||||||
{
|
{
|
||||||
ecma_object_t *obj_prev_p = NULL;
|
obj_next_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next);
|
||||||
|
|
||||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ],
|
if (!obj_iter_p->gc_info.visited)
|
||||||
*obj_next_p;
|
{
|
||||||
obj_iter_p != NULL;
|
ecma_gc_sweep (obj_iter_p);
|
||||||
obj_iter_p = obj_next_p)
|
|
||||||
|
if (likely (obj_prev_p != NULL))
|
||||||
{
|
{
|
||||||
obj_next_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next);
|
ECMA_SET_POINTER(obj_prev_p->gc_info.next, obj_next_p);
|
||||||
|
|
||||||
if (!obj_iter_p->gc_info.visited)
|
|
||||||
{
|
|
||||||
ecma_gc_sweep (obj_iter_p);
|
|
||||||
|
|
||||||
if (likely (obj_prev_p != NULL))
|
|
||||||
{
|
|
||||||
ECMA_SET_POINTER(obj_prev_p->gc_info.next, obj_next_p);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ecma_gc_objects_lists[ gen_id ] = obj_next_p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
obj_prev_p = obj_iter_p;
|
|
||||||
|
|
||||||
if (obj_iter_p->gc_info.generation != ECMA_GC_GEN_COUNT - 1)
|
|
||||||
{
|
|
||||||
/* the object will be promoted to next generation */
|
|
||||||
obj_iter_p->gc_info.generation++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ecma_gc_objects_lists[ gen_id ] = obj_next_p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
obj_prev_p = obj_iter_p;
|
||||||
|
|
||||||
gen_last_obj_p[ gen_id ] = obj_prev_p;
|
if (obj_iter_p->gc_info.generation != ECMA_GC_GEN_COUNT - 1)
|
||||||
|
{
|
||||||
|
/* the object will be promoted to next generation */
|
||||||
|
obj_iter_p->gc_info.generation++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gen_last_obj_p[ gen_id ] = obj_prev_p;
|
||||||
|
}
|
||||||
|
|
||||||
ecma_gc_gen_t gen_to_promote = max_gen_to_collect;
|
ecma_gc_gen_t gen_to_promote = max_gen_to_collect;
|
||||||
if (unlikely (gen_to_promote == ECMA_GC_GEN_COUNT - 1))
|
if (unlikely (gen_to_promote == ECMA_GC_GEN_COUNT - 1))
|
||||||
{
|
{
|
||||||
/* not promoting last generation */
|
/* not promoting last generation */
|
||||||
gen_to_promote--;
|
gen_to_promote--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* promoting to next generation */
|
/* promoting to next generation */
|
||||||
if (gen_last_obj_p[ gen_to_promote ] != NULL)
|
if (gen_last_obj_p[ gen_to_promote ] != NULL)
|
||||||
{
|
{
|
||||||
ECMA_SET_POINTER(gen_last_obj_p[ gen_to_promote ]->gc_info.next, ecma_gc_objects_lists[ gen_to_promote + 1 ]);
|
ECMA_SET_POINTER(gen_last_obj_p[ gen_to_promote ]->gc_info.next, ecma_gc_objects_lists[ gen_to_promote + 1 ]);
|
||||||
ecma_gc_objects_lists[ gen_to_promote + 1 ] = ecma_gc_objects_lists[ gen_to_promote ];
|
ecma_gc_objects_lists[ gen_to_promote + 1 ] = ecma_gc_objects_lists[ gen_to_promote ];
|
||||||
ecma_gc_objects_lists[ gen_to_promote ] = NULL;
|
ecma_gc_objects_lists[ gen_to_promote ] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t gen_id = (int32_t)gen_to_promote - 1;
|
for (int32_t gen_id = (int32_t)gen_to_promote - 1;
|
||||||
gen_id >= 0;
|
gen_id >= 0;
|
||||||
gen_id--)
|
gen_id--)
|
||||||
{
|
{
|
||||||
ecma_gc_objects_lists[ gen_id + 1 ] = ecma_gc_objects_lists[ gen_id ];
|
ecma_gc_objects_lists[ gen_id + 1 ] = ecma_gc_objects_lists[ gen_id ];
|
||||||
ecma_gc_objects_lists[ gen_id ] = NULL;
|
ecma_gc_objects_lists[ gen_id ] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef JERRY_NDEBUG
|
#ifndef JERRY_NDEBUG
|
||||||
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0;
|
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0;
|
||||||
gen_id < ECMA_GC_GEN_COUNT;
|
gen_id < ECMA_GC_GEN_COUNT;
|
||||||
gen_id++)
|
gen_id++)
|
||||||
|
{
|
||||||
|
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
||||||
|
obj_iter_p != NULL;
|
||||||
|
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
||||||
{
|
{
|
||||||
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
|
JERRY_ASSERT(obj_iter_p->gc_info.generation == gen_id);
|
||||||
obj_iter_p != NULL;
|
|
||||||
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
|
|
||||||
{
|
|
||||||
JERRY_ASSERT(obj_iter_p->gc_info.generation == gen_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif /* !JERRY_NDEBUG */
|
#endif /* !JERRY_NDEBUG */
|
||||||
} /* ecma_gc_run */
|
} /* ecma_gc_run */
|
||||||
|
|
||||||
|
|||||||
+229
-207
@@ -51,42 +51,45 @@
|
|||||||
/**
|
/**
|
||||||
* Type of ecma-value
|
* Type of ecma-value
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
ECMA_TYPE_SIMPLE, /**< simple value */
|
{
|
||||||
ECMA_TYPE_NUMBER, /**< 64-bit integer */
|
ECMA_TYPE_SIMPLE, /**< simple value */
|
||||||
ECMA_TYPE_STRING, /**< pointer to description of a string */
|
ECMA_TYPE_NUMBER, /**< 64-bit integer */
|
||||||
ECMA_TYPE_OBJECT, /**< pointer to description of an object */
|
ECMA_TYPE_STRING, /**< pointer to description of a string */
|
||||||
ECMA_TYPE__COUNT /**< count of types */
|
ECMA_TYPE_OBJECT, /**< pointer to description of an object */
|
||||||
|
ECMA_TYPE__COUNT /**< count of types */
|
||||||
} ecma_type_t;
|
} ecma_type_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple ecma-values
|
* Simple ecma-values
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
/**
|
{
|
||||||
* Empty value is implementation defined value, used for:
|
/**
|
||||||
* - representing empty value in completion values (see also: ECMA-262 v5, 8.9 Completion specification type);
|
* Empty value is implementation defined value, used for:
|
||||||
* - values of uninitialized immutable bindings;
|
* - representing empty value in completion values (see also: ECMA-262 v5, 8.9 Completion specification type);
|
||||||
* - values of empty register variables.
|
* - values of uninitialized immutable bindings;
|
||||||
*/
|
* - values of empty register variables.
|
||||||
ECMA_SIMPLE_VALUE_EMPTY,
|
*/
|
||||||
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
|
ECMA_SIMPLE_VALUE_EMPTY,
|
||||||
ECMA_SIMPLE_VALUE_NULL, /**< null value */
|
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
|
||||||
ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */
|
ECMA_SIMPLE_VALUE_NULL, /**< null value */
|
||||||
ECMA_SIMPLE_VALUE_TRUE, /**< boolean true */
|
ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */
|
||||||
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< implementation defined value for an array's elements that exists,
|
ECMA_SIMPLE_VALUE_TRUE, /**< boolean true */
|
||||||
but is stored directly in the array's property list
|
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< implementation defined value for an array's elements that exists,
|
||||||
(used for array elements with non-default attribute values) */
|
but is stored directly in the array's property list
|
||||||
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma-values */
|
(used for array elements with non-default attribute values) */
|
||||||
|
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma-values */
|
||||||
} ecma_simple_value_t;
|
} ecma_simple_value_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of ecma-property
|
* Type of ecma-property
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
ECMA_PROPERTY_NAMEDDATA, /**< named data property */
|
{
|
||||||
ECMA_PROPERTY_NAMEDACCESSOR, /**< named accessor property */
|
ECMA_PROPERTY_NAMEDDATA, /**< named data property */
|
||||||
ECMA_PROPERTY_INTERNAL /**< internal property */
|
ECMA_PROPERTY_NAMEDACCESSOR, /**< named accessor property */
|
||||||
|
ECMA_PROPERTY_INTERNAL /**< internal property */
|
||||||
} ecma_property_type_t;
|
} ecma_property_type_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,27 +97,29 @@ typedef enum {
|
|||||||
*
|
*
|
||||||
* See also: ECMA-262 v5, 8.9.
|
* See also: ECMA-262 v5, 8.9.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
ECMA_COMPLETION_TYPE_NORMAL, /**< default block completion */
|
{
|
||||||
ECMA_COMPLETION_TYPE_RETURN, /**< block completed with return */
|
ECMA_COMPLETION_TYPE_NORMAL, /**< default block completion */
|
||||||
ECMA_COMPLETION_TYPE_BREAK, /**< block completed with break */
|
ECMA_COMPLETION_TYPE_RETURN, /**< block completed with return */
|
||||||
ECMA_COMPLETION_TYPE_CONTINUE, /**< block completed with continue */
|
ECMA_COMPLETION_TYPE_BREAK, /**< block completed with break */
|
||||||
ECMA_COMPLETION_TYPE_THROW, /**< block completed with throw */
|
ECMA_COMPLETION_TYPE_CONTINUE, /**< block completed with continue */
|
||||||
ECMA_COMPLETION_TYPE_EXIT /**< implementation-defined completion type
|
ECMA_COMPLETION_TYPE_THROW, /**< block completed with throw */
|
||||||
for finishing script execution */
|
ECMA_COMPLETION_TYPE_EXIT /**< implementation-defined completion type
|
||||||
|
for finishing script execution */
|
||||||
} ecma_completion_type_t;
|
} ecma_completion_type_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of an ecma-value
|
* Description of an ecma-value
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
/** Value type (ecma_type_t) */
|
{
|
||||||
unsigned int value_type : 2;
|
/** Value type (ecma_type_t) */
|
||||||
|
unsigned int value_type : 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple value (ecma_simple_value_t) or compressed pointer to value (depending on value_type)
|
* Simple value (ecma_simple_value_t) or compressed pointer to value (depending on value_type)
|
||||||
*/
|
*/
|
||||||
unsigned int value : ECMA_POINTER_FIELD_WIDTH;
|
unsigned int value : ECMA_POINTER_FIELD_WIDTH;
|
||||||
} __packed ecma_value_t;
|
} __packed ecma_value_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,15 +127,16 @@ typedef struct {
|
|||||||
*
|
*
|
||||||
* See also: ECMA-262 v5, 8.9.
|
* See also: ECMA-262 v5, 8.9.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
/** Type (ecma_completion_type_t) */
|
{
|
||||||
unsigned int type : 3;
|
/** Type (ecma_completion_type_t) */
|
||||||
|
unsigned int type : 3;
|
||||||
|
|
||||||
/** Value */
|
/** Value */
|
||||||
ecma_value_t value;
|
ecma_value_t value;
|
||||||
|
|
||||||
/** Target */
|
/** Target */
|
||||||
unsigned int target : 8;
|
unsigned int target : 8;
|
||||||
} __packed ecma_completion_value_t;
|
} __packed ecma_completion_value_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,25 +148,26 @@ typedef struct {
|
|||||||
/**
|
/**
|
||||||
* Internal properties' identifiers.
|
* Internal properties' identifiers.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
ECMA_INTERNAL_PROPERTY_CLASS, /**< [[Class]] */
|
{
|
||||||
ECMA_INTERNAL_PROPERTY_PROTOTYPE, /**< [[Prototype]] */
|
ECMA_INTERNAL_PROPERTY_CLASS, /**< [[Class]] */
|
||||||
ECMA_INTERNAL_PROPERTY_EXTENSIBLE, /**< [[Extensible]] */
|
ECMA_INTERNAL_PROPERTY_PROTOTYPE, /**< [[Prototype]] */
|
||||||
ECMA_INTERNAL_PROPERTY_SCOPE, /**< [[Scope]] */
|
ECMA_INTERNAL_PROPERTY_EXTENSIBLE, /**< [[Extensible]] */
|
||||||
ECMA_INTERNAL_PROPERTY_CODE, /**< [[Code]] */
|
ECMA_INTERNAL_PROPERTY_SCOPE, /**< [[Scope]] */
|
||||||
ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS, /**< [[FormalParameters]] */
|
ECMA_INTERNAL_PROPERTY_CODE, /**< [[Code]] */
|
||||||
|
ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS, /**< [[FormalParameters]] */
|
||||||
|
|
||||||
/** provideThis property of lexical environment */
|
/** provideThis property of lexical environment */
|
||||||
ECMA_INTERNAL_PROPERTY_PROVIDE_THIS,
|
ECMA_INTERNAL_PROPERTY_PROVIDE_THIS,
|
||||||
|
|
||||||
/** binding object of lexical environment */
|
/** binding object of lexical environment */
|
||||||
ECMA_INTERNAL_PROPERTY_BINDING_OBJECT,
|
ECMA_INTERNAL_PROPERTY_BINDING_OBJECT,
|
||||||
|
|
||||||
/** Part of an array, that is indexed by numbers */
|
/** Part of an array, that is indexed by numbers */
|
||||||
ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES,
|
ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES,
|
||||||
|
|
||||||
/** Part of an array, that is indexed by strings */
|
/** Part of an array, that is indexed by strings */
|
||||||
ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES
|
ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES
|
||||||
} ecma_internal_property_id_t;
|
} ecma_internal_property_id_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,186 +200,198 @@ typedef enum
|
|||||||
/**
|
/**
|
||||||
* Description of ecma-property
|
* Description of ecma-property
|
||||||
*/
|
*/
|
||||||
typedef struct ecma_property_t {
|
typedef struct ecma_property_t
|
||||||
/** Property's type (ecma_property_type_t) */
|
{
|
||||||
unsigned int type : 2;
|
/** Property's type (ecma_property_type_t) */
|
||||||
|
unsigned int type : 2;
|
||||||
|
|
||||||
/** Compressed pointer to next property */
|
/** Compressed pointer to next property */
|
||||||
unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH;
|
unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
|
||||||
/** Property's details (depending on Type) */
|
/** Property's details (depending on Type) */
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
|
/** Description of named data property */
|
||||||
|
struct __packed ecma_named_data_property_t
|
||||||
|
{
|
||||||
|
/** Compressed pointer to property's name (pointer to String) */
|
||||||
|
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
|
||||||
/** Description of named data property */
|
/** Attribute 'Writable' (ecma_property_writable_value_t) */
|
||||||
struct __packed ecma_named_data_property_t {
|
unsigned int writable : 1;
|
||||||
/** Compressed pointer to property's name (pointer to String) */
|
|
||||||
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
|
||||||
|
|
||||||
/** Attribute 'Writable' (ecma_property_writable_value_t) */
|
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
|
||||||
unsigned int writable : 1;
|
unsigned int enumerable : 1;
|
||||||
|
|
||||||
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
|
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
|
||||||
unsigned int enumerable : 1;
|
unsigned int configurable : 1;
|
||||||
|
|
||||||
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
|
/** Value */
|
||||||
unsigned int configurable : 1;
|
ecma_value_t value;
|
||||||
|
} named_data_property;
|
||||||
|
|
||||||
/** Value */
|
/** Description of named accessor property */
|
||||||
ecma_value_t value;
|
struct __packed ecma_named_accessor_property_t
|
||||||
} named_data_property;
|
{
|
||||||
|
/** Compressed pointer to property's name (pointer to String) */
|
||||||
|
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
|
||||||
/** Description of named accessor property */
|
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
|
||||||
struct __packed ecma_named_accessor_property_t {
|
unsigned int enumerable : 1;
|
||||||
/** Compressed pointer to property's name (pointer to String) */
|
|
||||||
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
|
||||||
|
|
||||||
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
|
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
|
||||||
unsigned int enumerable : 1;
|
unsigned int configurable : 1;
|
||||||
|
|
||||||
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
|
/** Compressed pointer to property's getter */
|
||||||
unsigned int configurable : 1;
|
unsigned int get_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
|
||||||
/** Compressed pointer to property's getter */
|
/** Compressed pointer to property's setter */
|
||||||
unsigned int get_p : ECMA_POINTER_FIELD_WIDTH;
|
unsigned int set_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
} named_accessor_property;
|
||||||
|
|
||||||
/** Compressed pointer to property's setter */
|
/** Description of internal property */
|
||||||
unsigned int set_p : ECMA_POINTER_FIELD_WIDTH;
|
struct __packed ecma_internal_property_t
|
||||||
} named_accessor_property;
|
{
|
||||||
|
/** Internal property's type */
|
||||||
|
unsigned int type : 4;
|
||||||
|
|
||||||
/** Description of internal property */
|
/** Value (may be a compressed pointer) */
|
||||||
struct __packed ecma_internal_property_t {
|
uint32_t value;
|
||||||
/** Internal property's type */
|
} internal_property;
|
||||||
unsigned int type : 4;
|
} u;
|
||||||
|
|
||||||
/** Value (may be a compressed pointer) */
|
|
||||||
uint32_t value;
|
|
||||||
} internal_property;
|
|
||||||
} u;
|
|
||||||
} ecma_property_t;
|
} ecma_property_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of GC's information layout
|
* Description of GC's information layout
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
/**
|
{
|
||||||
* Reference counter of the object.
|
/**
|
||||||
*
|
* Reference counter of the object.
|
||||||
* Number of references to the object from stack variables.
|
*
|
||||||
*/
|
* Number of references to the object from stack variables.
|
||||||
unsigned int refs : CONFIG_ECMA_REFERENCE_COUNTER_WIDTH;
|
*/
|
||||||
|
unsigned int refs : CONFIG_ECMA_REFERENCE_COUNTER_WIDTH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifier of GC generation.
|
* Identifier of GC generation.
|
||||||
*/
|
*/
|
||||||
unsigned int generation : 2;
|
unsigned int generation : 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compressed pointer to next object in the global list of objects with same generation.
|
* Compressed pointer to next object in the global list of objects with same generation.
|
||||||
*/
|
*/
|
||||||
unsigned int next : ECMA_POINTER_FIELD_WIDTH;
|
unsigned int next : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marker that is set if the object was visited during graph traverse.
|
* Marker that is set if the object was visited during graph traverse.
|
||||||
*/
|
*/
|
||||||
unsigned int visited : 1;
|
unsigned int visited : 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag indicating that the object may reference objects of younger generations in its properties.
|
* Flag indicating that the object may reference objects of younger generations in its properties.
|
||||||
*/
|
*/
|
||||||
unsigned int may_ref_younger_objects : 1;
|
unsigned int may_ref_younger_objects : 1;
|
||||||
} __packed ecma_gc_info_t;
|
} __packed ecma_gc_info_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types of lexical environments
|
* Types of lexical environments
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< declarative lexical environment */
|
{
|
||||||
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */
|
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< declarative lexical environment */
|
||||||
|
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */
|
||||||
} ecma_lexical_environment_type_t;
|
} ecma_lexical_environment_type_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal object types
|
* Internal object types
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
ECMA_OBJECT_TYPE_GENERAL, /**< all objects that are not String (15.5), Function (15.3),
|
{
|
||||||
Arguments (10.6), Array (15.4) specification-defined objects
|
ECMA_OBJECT_TYPE_GENERAL, /**< all objects that are not String (15.5), Function (15.3),
|
||||||
and not host objects */
|
Arguments (10.6), Array (15.4) specification-defined objects
|
||||||
ECMA_OBJECT_TYPE_STRING, /**< String objects (15.5) */
|
and not host objects */
|
||||||
ECMA_OBJECT_TYPE_FUNCTION, /**< Function objects (15.3), created through 13.2 routine */
|
ECMA_OBJECT_TYPE_STRING, /**< String objects (15.5) */
|
||||||
ECMA_OBJECT_TYPE_BOUND_FUNCTION, /**< Function objects (15.3), created through 15.3.4.5 routine */
|
ECMA_OBJECT_TYPE_FUNCTION, /**< Function objects (15.3), created through 13.2 routine */
|
||||||
ECMA_OBJECT_TYPE_ARGUMENTS, /**< Arguments object (10.6) */
|
ECMA_OBJECT_TYPE_BOUND_FUNCTION, /**< Function objects (15.3), created through 15.3.4.5 routine */
|
||||||
ECMA_OBJECT_TYPE_ARRAY, /**< Array object (15.4) */
|
ECMA_OBJECT_TYPE_ARGUMENTS, /**< Arguments object (10.6) */
|
||||||
ECMA_OBJECT_TYPE_HOST /**< Host object */
|
ECMA_OBJECT_TYPE_ARRAY, /**< Array object (15.4) */
|
||||||
|
ECMA_OBJECT_TYPE_HOST /**< Host object */
|
||||||
} ecma_object_type_t;
|
} ecma_object_type_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ECMA-defined object classes
|
* ECMA-defined object classes
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum
|
||||||
ECMA_OBJECT_CLASS_OBJECT, /**< "Object" */
|
{
|
||||||
ECMA_OBJECT_CLASS_FUNCTION, /**< "Function" */
|
ECMA_OBJECT_CLASS_OBJECT, /**< "Object" */
|
||||||
ECMA_OBJECT_CLASS_ARGUMENTS, /**< "Arguments" */
|
ECMA_OBJECT_CLASS_FUNCTION, /**< "Function" */
|
||||||
ECMA_OBJECT_CLASS_ARRAY, /**< "Array" */
|
ECMA_OBJECT_CLASS_ARGUMENTS, /**< "Arguments" */
|
||||||
ECMA_OBJECT_CLASS_BOOLEAN, /**< "Boolean" */
|
ECMA_OBJECT_CLASS_ARRAY, /**< "Array" */
|
||||||
ECMA_OBJECT_CLASS_DATE, /**< "Date" */
|
ECMA_OBJECT_CLASS_BOOLEAN, /**< "Boolean" */
|
||||||
ECMA_OBJECT_CLASS_ERROR, /**< "Error" */
|
ECMA_OBJECT_CLASS_DATE, /**< "Date" */
|
||||||
ECMA_OBJECT_CLASS_JSON, /**< "JSON" */
|
ECMA_OBJECT_CLASS_ERROR, /**< "Error" */
|
||||||
ECMA_OBJECT_CLASS_MATH, /**< "Math" */
|
ECMA_OBJECT_CLASS_JSON, /**< "JSON" */
|
||||||
ECMA_OBJECT_CLASS_NUMBER, /**< "Number" */
|
ECMA_OBJECT_CLASS_MATH, /**< "Math" */
|
||||||
ECMA_OBJECT_CLASS_REGEXP, /**< "RegExp" */
|
ECMA_OBJECT_CLASS_NUMBER, /**< "Number" */
|
||||||
ECMA_OBJECT_CLASS_STRING /**< "String" */
|
ECMA_OBJECT_CLASS_REGEXP, /**< "RegExp" */
|
||||||
|
ECMA_OBJECT_CLASS_STRING /**< "String" */
|
||||||
} ecma_object_class_t;
|
} ecma_object_class_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of ECMA-object or lexical environment
|
* Description of ECMA-object or lexical environment
|
||||||
* (depending on is_lexical_environment).
|
* (depending on is_lexical_environment).
|
||||||
*/
|
*/
|
||||||
typedef struct ecma_object_t {
|
typedef struct ecma_object_t
|
||||||
/** Compressed pointer to property list */
|
{
|
||||||
unsigned int properties_p : ECMA_POINTER_FIELD_WIDTH;
|
/** Compressed pointer to property list */
|
||||||
|
unsigned int properties_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
|
||||||
/** Flag indicating whether it is a general object (false)
|
/** Flag indicating whether it is a general object (false)
|
||||||
or a lexical environment (true) */
|
or a lexical environment (true) */
|
||||||
unsigned int is_lexical_environment : 1;
|
unsigned int is_lexical_environment : 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attributes of either general object or lexical environment
|
||||||
|
* (depending on is_lexical_environment)
|
||||||
|
*/
|
||||||
|
union
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A general object's attributes (if !is_lexical_environment)
|
||||||
|
*/
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
/** Attribute 'Extensible' */
|
||||||
|
unsigned int extensible : 1;
|
||||||
|
|
||||||
|
/** Implementation internal object type (ecma_object_type_t) */
|
||||||
|
unsigned int type : 3;
|
||||||
|
|
||||||
|
/** Compressed pointer to prototype object (ecma_object_t) */
|
||||||
|
unsigned int prototype_object_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
} __packed object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes of either general object or lexical environment
|
* A lexical environment's attribute (if is_lexical_environment)
|
||||||
* (depending on is_lexical_environment)
|
|
||||||
*/
|
*/
|
||||||
union {
|
struct
|
||||||
/**
|
{
|
||||||
* A general object's attributes (if !is_lexical_environment)
|
/**
|
||||||
*/
|
* Type of lexical environment (ecma_lexical_environment_type_t).
|
||||||
struct {
|
*/
|
||||||
/** Attribute 'Extensible' */
|
unsigned int type : 1;
|
||||||
unsigned int extensible : 1;
|
|
||||||
|
|
||||||
/** Implementation internal object type (ecma_object_type_t) */
|
/** Compressed pointer to outer lexical environment */
|
||||||
unsigned int type : 3;
|
unsigned int outer_reference_p : ECMA_POINTER_FIELD_WIDTH;
|
||||||
|
} __packed lexical_environment;
|
||||||
|
|
||||||
/** Compressed pointer to prototype object (ecma_object_t) */
|
} __packed u;
|
||||||
unsigned int prototype_object_p : ECMA_POINTER_FIELD_WIDTH;
|
|
||||||
} __packed object;
|
|
||||||
|
|
||||||
/**
|
/** GC's information */
|
||||||
* A lexical environment's attribute (if is_lexical_environment)
|
ecma_gc_info_t gc_info;
|
||||||
*/
|
|
||||||
struct {
|
|
||||||
/**
|
|
||||||
* Type of lexical environment (ecma_lexical_environment_type_t).
|
|
||||||
*/
|
|
||||||
unsigned int type : 1;
|
|
||||||
|
|
||||||
/** Compressed pointer to outer lexical environment */
|
FIXME(Remove aligned attribute after packing the struct)
|
||||||
unsigned int outer_reference_p : ECMA_POINTER_FIELD_WIDTH;
|
|
||||||
} __packed lexical_environment;
|
|
||||||
|
|
||||||
} __packed u;
|
|
||||||
|
|
||||||
/** GC's information */
|
|
||||||
ecma_gc_info_t gc_info;
|
|
||||||
|
|
||||||
FIXME(Remove aligned attribute after packing the struct)
|
|
||||||
} __packed __attribute__ ((aligned (16))) ecma_object_t;
|
} __packed __attribute__ ((aligned (16))) ecma_object_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -451,34 +470,37 @@ typedef uint16_t ecma_length_t;
|
|||||||
/**
|
/**
|
||||||
* Description of an Array's header
|
* Description of an Array's header
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
/** Compressed pointer to next chunk */
|
{
|
||||||
uint16_t next_chunk_p;
|
/** Compressed pointer to next chunk */
|
||||||
|
uint16_t next_chunk_p;
|
||||||
|
|
||||||
/** Number of elements in the Array */
|
/** Number of elements in the Array */
|
||||||
ecma_length_t unit_number;
|
ecma_length_t unit_number;
|
||||||
} ecma_array_header_t;
|
} ecma_array_header_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of first chunk in a chain of chunks that contains an Array.
|
* Description of first chunk in a chain of chunks that contains an Array.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
/** Array's header */
|
{
|
||||||
ecma_array_header_t header;
|
/** Array's header */
|
||||||
|
ecma_array_header_t header;
|
||||||
|
|
||||||
/** Elements */
|
/** Elements */
|
||||||
uint8_t data[ sizeof (uint64_t) - sizeof (ecma_array_header_t) ];
|
uint8_t data[ sizeof (uint64_t) - sizeof (ecma_array_header_t) ];
|
||||||
} ecma_array_first_chunk_t;
|
} ecma_array_first_chunk_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of non-first chunk in a chain of chunks that contains an Array
|
* Description of non-first chunk in a chain of chunks that contains an Array
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct
|
||||||
/** Compressed pointer to next chunk */
|
{
|
||||||
uint16_t next_chunk_p;
|
/** Compressed pointer to next chunk */
|
||||||
|
uint16_t next_chunk_p;
|
||||||
|
|
||||||
/** Characters */
|
/** Characters */
|
||||||
uint8_t data[ sizeof (uint64_t) - sizeof (uint16_t) ];
|
uint8_t data[ sizeof (uint64_t) - sizeof (uint16_t) ];
|
||||||
} ecma_array_non_first_chunk_t;
|
} ecma_array_non_first_chunk_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ bool
|
|||||||
ecma_is_value_boolean (ecma_value_t value) /**< ecma-value */
|
ecma_is_value_boolean (ecma_value_t value) /**< ecma-value */
|
||||||
{
|
{
|
||||||
return ((value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_FALSE)
|
return ((value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_FALSE)
|
||||||
|| (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE));
|
|| (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE));
|
||||||
} /* ecma_is_value_boolean */
|
} /* ecma_is_value_boolean */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,11 @@ ecma_is_value_true (ecma_value_t value) /**< ecma-value */
|
|||||||
ecma_value_t
|
ecma_value_t
|
||||||
ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
|
ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
|
||||||
{
|
{
|
||||||
return (ecma_value_t) { .value_type = ECMA_TYPE_SIMPLE, .value = value };
|
return (ecma_value_t)
|
||||||
|
{
|
||||||
|
.value_type = ECMA_TYPE_SIMPLE,
|
||||||
|
.value = value
|
||||||
|
};
|
||||||
} /* ecma_make_simple_value */
|
} /* ecma_make_simple_value */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,54 +184,60 @@ ecma_copy_value (const ecma_value_t value, /**< ecma-value */
|
|||||||
switch ((ecma_type_t)value.value_type)
|
switch ((ecma_type_t)value.value_type)
|
||||||
{
|
{
|
||||||
case ECMA_TYPE_SIMPLE:
|
case ECMA_TYPE_SIMPLE:
|
||||||
{
|
{
|
||||||
value_copy = value;
|
value_copy = value;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ECMA_TYPE_NUMBER:
|
case ECMA_TYPE_NUMBER:
|
||||||
|
{
|
||||||
|
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
|
||||||
|
JERRY_ASSERT(num_p != NULL);
|
||||||
|
|
||||||
|
ecma_number_t *number_copy_p = ecma_alloc_number ();
|
||||||
|
*number_copy_p = *num_p;
|
||||||
|
|
||||||
|
value_copy = (ecma_value_t)
|
||||||
{
|
{
|
||||||
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
|
.value_type = ECMA_TYPE_NUMBER
|
||||||
JERRY_ASSERT(num_p != NULL);
|
};
|
||||||
|
ECMA_SET_NON_NULL_POINTER(value_copy.value, number_copy_p);
|
||||||
|
|
||||||
ecma_number_t *number_copy_p = ecma_alloc_number ();
|
break;
|
||||||
*number_copy_p = *num_p;
|
}
|
||||||
|
|
||||||
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_NUMBER };
|
|
||||||
ECMA_SET_NON_NULL_POINTER(value_copy.value, number_copy_p);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ECMA_TYPE_STRING:
|
case ECMA_TYPE_STRING:
|
||||||
|
{
|
||||||
|
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
|
||||||
|
JERRY_ASSERT(string_p != NULL);
|
||||||
|
|
||||||
|
ecma_array_first_chunk_t *string_copy_p = ecma_duplicate_ecma_string (string_p);
|
||||||
|
|
||||||
|
value_copy = (ecma_value_t)
|
||||||
{
|
{
|
||||||
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
|
.value_type = ECMA_TYPE_STRING
|
||||||
JERRY_ASSERT(string_p != NULL);
|
};
|
||||||
|
ECMA_SET_POINTER(value_copy.value, string_copy_p);
|
||||||
|
|
||||||
ecma_array_first_chunk_t *string_copy_p = ecma_duplicate_ecma_string (string_p);
|
break;
|
||||||
|
}
|
||||||
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_STRING };
|
|
||||||
ECMA_SET_POINTER(value_copy.value, string_copy_p);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ECMA_TYPE_OBJECT:
|
case ECMA_TYPE_OBJECT:
|
||||||
|
{
|
||||||
|
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
|
||||||
|
JERRY_ASSERT(obj_p != NULL);
|
||||||
|
|
||||||
|
if (do_ref_if_object)
|
||||||
{
|
{
|
||||||
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
|
ecma_ref_object (obj_p);
|
||||||
JERRY_ASSERT(obj_p != NULL);
|
|
||||||
|
|
||||||
if (do_ref_if_object)
|
|
||||||
{
|
|
||||||
ecma_ref_object (obj_p);
|
|
||||||
}
|
|
||||||
|
|
||||||
value_copy = value;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value_copy = value;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ECMA_TYPE__COUNT:
|
case ECMA_TYPE__COUNT:
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return value_copy;
|
return value_copy;
|
||||||
@@ -244,38 +254,38 @@ ecma_free_value (ecma_value_t value, /**< value description */
|
|||||||
switch ((ecma_type_t) value.value_type)
|
switch ((ecma_type_t) value.value_type)
|
||||||
{
|
{
|
||||||
case ECMA_TYPE_SIMPLE:
|
case ECMA_TYPE_SIMPLE:
|
||||||
{
|
{
|
||||||
/* doesn't hold additional memory */
|
/* doesn't hold additional memory */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_TYPE_NUMBER:
|
case ECMA_TYPE_NUMBER:
|
||||||
{
|
{
|
||||||
ecma_number_t *number_p = ECMA_GET_POINTER(value.value);
|
ecma_number_t *number_p = ECMA_GET_POINTER(value.value);
|
||||||
ecma_dealloc_number (number_p);
|
ecma_dealloc_number (number_p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_TYPE_STRING:
|
case ECMA_TYPE_STRING:
|
||||||
{
|
{
|
||||||
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
|
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
|
||||||
ecma_free_array (string_p);
|
ecma_free_array (string_p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_TYPE_OBJECT:
|
case ECMA_TYPE_OBJECT:
|
||||||
|
{
|
||||||
|
if (do_deref_if_object)
|
||||||
{
|
{
|
||||||
if (do_deref_if_object)
|
ecma_deref_object (ECMA_GET_POINTER(value.value));
|
||||||
{
|
|
||||||
ecma_deref_object (ECMA_GET_POINTER(value.value));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ECMA_TYPE__COUNT:
|
case ECMA_TYPE__COUNT:
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* ecma_free_value */
|
} /* ecma_free_value */
|
||||||
|
|
||||||
@@ -286,10 +296,15 @@ ecma_free_value (ecma_value_t value, /**< value description */
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_make_completion_value (ecma_completion_type_t type, /**< type */
|
ecma_make_completion_value (ecma_completion_type_t type, /**< type */
|
||||||
ecma_value_t value, /**< value */
|
ecma_value_t value, /**< value */
|
||||||
uint8_t target) /**< target */
|
uint8_t target) /**< target */
|
||||||
{
|
{
|
||||||
return (ecma_completion_value_t) { .type = type, .value = value, .target = target };
|
return (ecma_completion_value_t)
|
||||||
|
{
|
||||||
|
.type = type,
|
||||||
|
.value = value,
|
||||||
|
.target = target
|
||||||
|
};
|
||||||
} /* ecma_make_completion_value */
|
} /* ecma_make_completion_value */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -301,9 +316,9 @@ ecma_completion_value_t
|
|||||||
ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma-value */
|
ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma-value */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
|
JERRY_ASSERT(simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
|
||||||
|| simple_value == ECMA_SIMPLE_VALUE_NULL
|
|| simple_value == ECMA_SIMPLE_VALUE_NULL
|
||||||
|| simple_value == ECMA_SIMPLE_VALUE_FALSE
|
|| simple_value == ECMA_SIMPLE_VALUE_FALSE
|
||||||
|| simple_value == ECMA_SIMPLE_VALUE_TRUE);
|
|| simple_value == ECMA_SIMPLE_VALUE_TRUE);
|
||||||
|
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_simple_value (simple_value),
|
ecma_make_simple_value (simple_value),
|
||||||
@@ -323,8 +338,8 @@ ecma_make_throw_value (ecma_object_t *exception_p) /**< an object */
|
|||||||
ecma_value_t exception = ecma_make_object_value (exception_p);
|
ecma_value_t exception = ecma_make_object_value (exception_p);
|
||||||
|
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW,
|
||||||
exception,
|
exception,
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
} /* ecma_make_throw_value */
|
} /* ecma_make_throw_value */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -360,18 +375,18 @@ void
|
|||||||
ecma_free_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
ecma_free_completion_value (ecma_completion_value_t completion_value) /**< completion value */
|
||||||
{
|
{
|
||||||
switch (completion_value.type)
|
switch (completion_value.type)
|
||||||
{
|
{
|
||||||
case ECMA_COMPLETION_TYPE_NORMAL:
|
case ECMA_COMPLETION_TYPE_NORMAL:
|
||||||
case ECMA_COMPLETION_TYPE_THROW:
|
case ECMA_COMPLETION_TYPE_THROW:
|
||||||
case ECMA_COMPLETION_TYPE_RETURN:
|
case ECMA_COMPLETION_TYPE_RETURN:
|
||||||
ecma_free_value (completion_value.value, true);
|
ecma_free_value (completion_value.value, true);
|
||||||
break;
|
break;
|
||||||
case ECMA_COMPLETION_TYPE_CONTINUE:
|
case ECMA_COMPLETION_TYPE_CONTINUE:
|
||||||
case ECMA_COMPLETION_TYPE_BREAK:
|
case ECMA_COMPLETION_TYPE_BREAK:
|
||||||
case ECMA_COMPLETION_TYPE_EXIT:
|
case ECMA_COMPLETION_TYPE_EXIT:
|
||||||
JERRY_ASSERT(completion_value.value.value_type == ECMA_TYPE_SIMPLE);
|
JERRY_ASSERT(completion_value.value.value_type == ECMA_TYPE_SIMPLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} /* ecma_free_completion_value */
|
} /* ecma_free_completion_value */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -411,8 +426,8 @@ ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /**
|
|||||||
for equality with */
|
for equality with */
|
||||||
{
|
{
|
||||||
return (value.type == ECMA_COMPLETION_TYPE_NORMAL
|
return (value.type == ECMA_COMPLETION_TYPE_NORMAL
|
||||||
&& value.value.value_type == ECMA_TYPE_SIMPLE
|
&& value.value.value_type == ECMA_TYPE_SIMPLE
|
||||||
&& value.value.value == simple_value);
|
&& value.value.value == simple_value);
|
||||||
} /* ecma_is_completion_value_normal_simple_value */
|
} /* ecma_is_completion_value_normal_simple_value */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -452,7 +467,7 @@ bool
|
|||||||
ecma_is_empty_completion_value (ecma_completion_value_t value) /**< completion value */
|
ecma_is_empty_completion_value (ecma_completion_value_t value) /**< completion value */
|
||||||
{
|
{
|
||||||
return (ecma_is_completion_value_normal (value)
|
return (ecma_is_completion_value_normal (value)
|
||||||
&& ecma_is_value_empty (value.value));
|
&& ecma_is_value_empty (value.value));
|
||||||
} /* ecma_is_empty_completion_value */
|
} /* ecma_is_empty_completion_value */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+238
-237
@@ -40,17 +40,17 @@ ecma_create_object (ecma_object_t *prototype_object_p, /**< pointer to prototybe
|
|||||||
bool is_extensible, /**< value of extensible attribute */
|
bool is_extensible, /**< value of extensible attribute */
|
||||||
ecma_object_type_t type) /**< object type */
|
ecma_object_type_t type) /**< object type */
|
||||||
{
|
{
|
||||||
ecma_object_t *object_p = ecma_alloc_object ();
|
ecma_object_t *object_p = ecma_alloc_object ();
|
||||||
ecma_init_gc_info (object_p);
|
ecma_init_gc_info (object_p);
|
||||||
|
|
||||||
object_p->properties_p = ECMA_NULL_POINTER;
|
object_p->properties_p = ECMA_NULL_POINTER;
|
||||||
object_p->is_lexical_environment = false;
|
object_p->is_lexical_environment = false;
|
||||||
|
|
||||||
object_p->u.object.extensible = is_extensible;
|
object_p->u.object.extensible = is_extensible;
|
||||||
ECMA_SET_POINTER(object_p->u.object.prototype_object_p, prototype_object_p);
|
ECMA_SET_POINTER(object_p->u.object.prototype_object_p, prototype_object_p);
|
||||||
object_p->u.object.type = type;
|
object_p->u.object.type = type;
|
||||||
|
|
||||||
return object_p;
|
return object_p;
|
||||||
} /* ecma_create_object */
|
} /* ecma_create_object */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,8 +91,8 @@ ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer
|
|||||||
*/
|
*/
|
||||||
ecma_object_t*
|
ecma_object_t*
|
||||||
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
|
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
|
||||||
ecma_object_t *binding_obj_p, /**< binding object */
|
ecma_object_t *binding_obj_p, /**< binding object */
|
||||||
bool provide_this) /**< provideThis flag */
|
bool provide_this) /**< provideThis flag */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(binding_obj_p != NULL);
|
JERRY_ASSERT(binding_obj_p != NULL);
|
||||||
|
|
||||||
@@ -127,20 +127,20 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
||||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||||
{
|
{
|
||||||
ecma_property_t *new_property_p = ecma_alloc_property ();
|
ecma_property_t *new_property_p = ecma_alloc_property ();
|
||||||
|
|
||||||
new_property_p->type = ECMA_PROPERTY_INTERNAL;
|
new_property_p->type = ECMA_PROPERTY_INTERNAL;
|
||||||
|
|
||||||
ecma_property_t *list_head_p = ECMA_GET_POINTER(object_p->properties_p);
|
ecma_property_t *list_head_p = ECMA_GET_POINTER(object_p->properties_p);
|
||||||
ECMA_SET_POINTER(new_property_p->next_property_p, list_head_p);
|
ECMA_SET_POINTER(new_property_p->next_property_p, list_head_p);
|
||||||
ECMA_SET_NON_NULL_POINTER(object_p->properties_p, new_property_p);
|
ECMA_SET_NON_NULL_POINTER(object_p->properties_p, new_property_p);
|
||||||
|
|
||||||
new_property_p->u.internal_property.type = property_id;
|
new_property_p->u.internal_property.type = property_id;
|
||||||
new_property_p->u.internal_property.value = ECMA_NULL_POINTER;
|
new_property_p->u.internal_property.value = ECMA_NULL_POINTER;
|
||||||
|
|
||||||
return new_property_p;
|
return new_property_p;
|
||||||
} /* ecma_create_internal_property */
|
} /* ecma_create_internal_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,27 +151,27 @@ ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(object_p != NULL);
|
JERRY_ASSERT(object_p != NULL);
|
||||||
|
|
||||||
JERRY_ASSERT(property_id != ECMA_INTERNAL_PROPERTY_PROTOTYPE
|
JERRY_ASSERT(property_id != ECMA_INTERNAL_PROPERTY_PROTOTYPE
|
||||||
&& property_id != ECMA_INTERNAL_PROPERTY_EXTENSIBLE);
|
&& property_id != ECMA_INTERNAL_PROPERTY_EXTENSIBLE);
|
||||||
|
|
||||||
for (ecma_property_t *property_p = ECMA_GET_POINTER(object_p->properties_p);
|
for (ecma_property_t *property_p = ECMA_GET_POINTER(object_p->properties_p);
|
||||||
property_p != NULL;
|
property_p != NULL;
|
||||||
property_p = ECMA_GET_POINTER(property_p->next_property_p))
|
property_p = ECMA_GET_POINTER(property_p->next_property_p))
|
||||||
|
{
|
||||||
|
if (property_p->type == ECMA_PROPERTY_INTERNAL)
|
||||||
{
|
{
|
||||||
if (property_p->type == ECMA_PROPERTY_INTERNAL)
|
if (property_p->u.internal_property.type == property_id)
|
||||||
{
|
{
|
||||||
if (property_p->u.internal_property.type == property_id)
|
return property_p;
|
||||||
{
|
}
|
||||||
return property_p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
} /* ecma_find_internal_property */
|
} /* ecma_find_internal_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,13 +184,13 @@ ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||||
{
|
{
|
||||||
ecma_property_t *property_p = ecma_find_internal_property (object_p, property_id);
|
ecma_property_t *property_p = ecma_find_internal_property (object_p, property_id);
|
||||||
|
|
||||||
JERRY_ASSERT(property_p != NULL);
|
JERRY_ASSERT(property_p != NULL);
|
||||||
|
|
||||||
return property_p;
|
return property_p;
|
||||||
} /* ecma_get_internal_property */
|
} /* ecma_get_internal_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,10 +201,10 @@ ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
||||||
const ecma_char_t *name_p, /**< property name */
|
const ecma_char_t *name_p, /**< property name */
|
||||||
ecma_property_writable_value_t writable, /**< 'writable' attribute */
|
ecma_property_writable_value_t writable, /**< 'writable' attribute */
|
||||||
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
|
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
|
||||||
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
|
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
|
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
|
||||||
|
|
||||||
@@ -235,11 +235,11 @@ ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
||||||
const ecma_char_t *name_p, /**< property name */
|
const ecma_char_t *name_p, /**< property name */
|
||||||
ecma_object_t *get_p, /**< getter */
|
ecma_object_t *get_p, /**< getter */
|
||||||
ecma_object_t *set_p, /**< setter */
|
ecma_object_t *set_p, /**< setter */
|
||||||
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
|
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
|
||||||
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
|
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
|
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
|
||||||
|
|
||||||
@@ -273,37 +273,37 @@ ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||||
const ecma_char_t *name_p) /**< property's name */
|
const ecma_char_t *name_p) /**< property's name */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(obj_p != NULL);
|
JERRY_ASSERT(obj_p != NULL);
|
||||||
JERRY_ASSERT(name_p != NULL);
|
JERRY_ASSERT(name_p != NULL);
|
||||||
|
|
||||||
for (ecma_property_t *property_p = ECMA_GET_POINTER(obj_p->properties_p);
|
for (ecma_property_t *property_p = ECMA_GET_POINTER(obj_p->properties_p);
|
||||||
property_p != NULL;
|
property_p != NULL;
|
||||||
property_p = ECMA_GET_POINTER(property_p->next_property_p))
|
property_p = ECMA_GET_POINTER(property_p->next_property_p))
|
||||||
|
{
|
||||||
|
ecma_array_first_chunk_t *property_name_p;
|
||||||
|
|
||||||
|
if (property_p->type == ECMA_PROPERTY_NAMEDDATA)
|
||||||
{
|
{
|
||||||
ecma_array_first_chunk_t *property_name_p;
|
property_name_p = ECMA_GET_POINTER(property_p->u.named_data_property.name_p);
|
||||||
|
} else if (property_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
||||||
if (property_p->type == ECMA_PROPERTY_NAMEDDATA)
|
{
|
||||||
{
|
property_name_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.name_p);
|
||||||
property_name_p = ECMA_GET_POINTER(property_p->u.named_data_property.name_p);
|
} else
|
||||||
} else if (property_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
{
|
||||||
{
|
continue;
|
||||||
property_name_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.name_p);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
JERRY_ASSERT(property_name_p != NULL);
|
|
||||||
|
|
||||||
if (ecma_compare_zt_string_to_ecma_string (name_p, property_name_p))
|
|
||||||
{
|
|
||||||
return property_p;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
JERRY_ASSERT(property_name_p != NULL);
|
||||||
|
|
||||||
|
if (ecma_compare_zt_string_to_ecma_string (name_p, property_name_p))
|
||||||
|
{
|
||||||
|
return property_p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
} /* ecma_find_named_property */
|
} /* ecma_find_named_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -317,16 +317,16 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||||
const ecma_char_t *name_p) /**< property's name */
|
const ecma_char_t *name_p) /**< property's name */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(obj_p != NULL);
|
JERRY_ASSERT(obj_p != NULL);
|
||||||
JERRY_ASSERT(name_p != NULL);
|
JERRY_ASSERT(name_p != NULL);
|
||||||
|
|
||||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||||
|
|
||||||
JERRY_ASSERT(property_p != NULL);
|
JERRY_ASSERT(property_p != NULL);
|
||||||
|
|
||||||
return property_p;
|
return property_p;
|
||||||
} /* ecma_get_named_property */
|
} /* ecma_get_named_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,16 +340,16 @@ ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in *
|
|||||||
*/
|
*/
|
||||||
ecma_property_t*
|
ecma_property_t*
|
||||||
ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property in */
|
ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property in */
|
||||||
const ecma_char_t *name_p) /**< property's name */
|
const ecma_char_t *name_p) /**< property's name */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(obj_p != NULL);
|
JERRY_ASSERT(obj_p != NULL);
|
||||||
JERRY_ASSERT(name_p != NULL);
|
JERRY_ASSERT(name_p != NULL);
|
||||||
|
|
||||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||||
|
|
||||||
JERRY_ASSERT(property_p != NULL && property_p->type == ECMA_PROPERTY_NAMEDDATA);
|
JERRY_ASSERT(property_p != NULL && property_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||||
|
|
||||||
return property_p;
|
return property_p;
|
||||||
} /* ecma_get_named_data_property */
|
} /* ecma_get_named_data_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,10 +395,10 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
|||||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
|
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
|
||||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
|
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
|
||||||
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
|
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
|
||||||
{
|
{
|
||||||
ecma_free_array (ECMA_GET_POINTER(property_value));
|
ecma_free_array (ECMA_GET_POINTER(property_value));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
||||||
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
|
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
|
||||||
@@ -407,9 +407,9 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
|||||||
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
|
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
|
||||||
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
|
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
|
||||||
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
|
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_dealloc_property (property_p);
|
ecma_dealloc_property (property_p);
|
||||||
@@ -424,25 +424,25 @@ ecma_free_property (ecma_property_t *prop_p) /**< property */
|
|||||||
switch ((ecma_property_type_t) prop_p->type)
|
switch ((ecma_property_type_t) prop_p->type)
|
||||||
{
|
{
|
||||||
case ECMA_PROPERTY_NAMEDDATA:
|
case ECMA_PROPERTY_NAMEDDATA:
|
||||||
{
|
{
|
||||||
ecma_free_named_data_property (prop_p);
|
ecma_free_named_data_property (prop_p);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_PROPERTY_NAMEDACCESSOR:
|
case ECMA_PROPERTY_NAMEDACCESSOR:
|
||||||
{
|
{
|
||||||
ecma_free_named_accessor_property (prop_p);
|
ecma_free_named_accessor_property (prop_p);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_PROPERTY_INTERNAL:
|
case ECMA_PROPERTY_INTERNAL:
|
||||||
{
|
{
|
||||||
ecma_free_internal_property (prop_p);
|
ecma_free_internal_property (prop_p);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* ecma_free_property */
|
} /* ecma_free_property */
|
||||||
|
|
||||||
@@ -453,11 +453,11 @@ ecma_free_property (ecma_property_t *prop_p) /**< property */
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ecma_delete_property (ecma_object_t *obj_p, /**< object */
|
ecma_delete_property (ecma_object_t *obj_p, /**< object */
|
||||||
ecma_property_t *prop_p) /**< property */
|
ecma_property_t *prop_p) /**< property */
|
||||||
{
|
{
|
||||||
for (ecma_property_t *cur_prop_p = ECMA_GET_POINTER(obj_p->properties_p), *prev_prop_p = NULL, *next_prop_p;
|
for (ecma_property_t *cur_prop_p = ECMA_GET_POINTER(obj_p->properties_p), *prev_prop_p = NULL, *next_prop_p;
|
||||||
cur_prop_p != NULL;
|
cur_prop_p != NULL;
|
||||||
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p)
|
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p)
|
||||||
{
|
{
|
||||||
next_prop_p = ECMA_GET_POINTER(cur_prop_p->next_property_p);
|
next_prop_p = ECMA_GET_POINTER(cur_prop_p->next_property_p);
|
||||||
|
|
||||||
@@ -488,51 +488,51 @@ ecma_delete_property (ecma_object_t *obj_p, /**< object */
|
|||||||
ecma_array_first_chunk_t*
|
ecma_array_first_chunk_t*
|
||||||
ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string of ecma-characters */
|
ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string of ecma-characters */
|
||||||
{
|
{
|
||||||
ecma_length_t length = 0;
|
ecma_length_t length = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: Do not precalculate length.
|
* TODO: Do not precalculate length.
|
||||||
*/
|
*/
|
||||||
if (string_p != NULL)
|
if (string_p != NULL)
|
||||||
|
{
|
||||||
|
const ecma_char_t *iter_p = string_p;
|
||||||
|
while (*iter_p++)
|
||||||
{
|
{
|
||||||
const ecma_char_t *iter_p = string_p;
|
length++;
|
||||||
while (*iter_p++)
|
|
||||||
{
|
|
||||||
length++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ecma_array_first_chunk_t *string_first_chunk_p = ecma_alloc_array_first_chunk ();
|
ecma_array_first_chunk_t *string_first_chunk_p = ecma_alloc_array_first_chunk ();
|
||||||
|
|
||||||
string_first_chunk_p->header.unit_number = length;
|
string_first_chunk_p->header.unit_number = length;
|
||||||
uint8_t *copy_pointer = (uint8_t*) string_p;
|
uint8_t *copy_pointer = (uint8_t*) string_p;
|
||||||
size_t chars_left = length;
|
size_t chars_left = length;
|
||||||
size_t chars_to_copy = JERRY_MIN(length, sizeof (string_first_chunk_p->data) / sizeof (ecma_char_t));
|
size_t chars_to_copy = JERRY_MIN(length, sizeof (string_first_chunk_p->data) / sizeof (ecma_char_t));
|
||||||
__memcpy (string_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
|
__memcpy (string_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
|
||||||
|
chars_left -= chars_to_copy;
|
||||||
|
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
|
||||||
|
|
||||||
|
ecma_array_non_first_chunk_t *string_non_first_chunk_p;
|
||||||
|
|
||||||
|
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
|
||||||
|
uint16_t *next_chunk_compressed_pointer_p = &string_first_chunk_p->header.next_chunk_p;
|
||||||
|
|
||||||
|
while (chars_left > 0)
|
||||||
|
{
|
||||||
|
string_non_first_chunk_p = ecma_alloc_array_non_first_chunk ();
|
||||||
|
|
||||||
|
size_t chars_to_copy = JERRY_MIN(chars_left, sizeof (string_non_first_chunk_p->data) / sizeof (ecma_char_t));
|
||||||
|
__memcpy (string_non_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
|
||||||
chars_left -= chars_to_copy;
|
chars_left -= chars_to_copy;
|
||||||
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
|
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
|
||||||
|
|
||||||
ecma_array_non_first_chunk_t *string_non_first_chunk_p;
|
ECMA_SET_NON_NULL_POINTER(*next_chunk_compressed_pointer_p, string_non_first_chunk_p);
|
||||||
|
next_chunk_compressed_pointer_p = &string_non_first_chunk_p->next_chunk_p;
|
||||||
|
}
|
||||||
|
|
||||||
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
|
*next_chunk_compressed_pointer_p = ECMA_NULL_POINTER;
|
||||||
uint16_t *next_chunk_compressed_pointer_p = &string_first_chunk_p->header.next_chunk_p;
|
|
||||||
|
|
||||||
while (chars_left > 0)
|
return string_first_chunk_p;
|
||||||
{
|
|
||||||
string_non_first_chunk_p = ecma_alloc_array_non_first_chunk ();
|
|
||||||
|
|
||||||
size_t chars_to_copy = JERRY_MIN(chars_left, sizeof (string_non_first_chunk_p->data) / sizeof (ecma_char_t));
|
|
||||||
__memcpy (string_non_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
|
|
||||||
chars_left -= chars_to_copy;
|
|
||||||
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
|
|
||||||
|
|
||||||
ECMA_SET_NON_NULL_POINTER(*next_chunk_compressed_pointer_p, string_non_first_chunk_p);
|
|
||||||
next_chunk_compressed_pointer_p = &string_non_first_chunk_p->next_chunk_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
*next_chunk_compressed_pointer_p = ECMA_NULL_POINTER;
|
|
||||||
|
|
||||||
return string_first_chunk_p;
|
|
||||||
} /* ecma_new_ecma_string */
|
} /* ecma_new_ecma_string */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -546,43 +546,43 @@ ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string o
|
|||||||
*/
|
*/
|
||||||
ssize_t
|
ssize_t
|
||||||
ecma_copy_ecma_string_chars_to_buffer (ecma_array_first_chunk_t *first_chunk_p, /**< first chunk of ecma-string */
|
ecma_copy_ecma_string_chars_to_buffer (ecma_array_first_chunk_t *first_chunk_p, /**< first chunk of ecma-string */
|
||||||
uint8_t *buffer_p, /**< destination buffer */
|
uint8_t *buffer_p, /**< destination buffer */
|
||||||
size_t buffer_size) /**< size of buffer */
|
size_t buffer_size) /**< size of buffer */
|
||||||
{
|
{
|
||||||
ecma_length_t string_length = first_chunk_p->header.unit_number;
|
ecma_length_t string_length = first_chunk_p->header.unit_number;
|
||||||
size_t required_buffer_size = sizeof (ecma_length_t) + sizeof (ecma_char_t) * string_length;
|
size_t required_buffer_size = sizeof (ecma_length_t) + sizeof (ecma_char_t) * string_length;
|
||||||
|
|
||||||
if (required_buffer_size > buffer_size)
|
if (required_buffer_size > buffer_size)
|
||||||
{
|
{
|
||||||
return - (ssize_t) required_buffer_size;
|
return - (ssize_t) required_buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(ecma_length_t*) buffer_p = string_length;
|
*(ecma_length_t*) buffer_p = string_length;
|
||||||
|
|
||||||
size_t chars_left = string_length;
|
size_t chars_left = string_length;
|
||||||
uint8_t *dest_pointer = buffer_p + sizeof (ecma_length_t);
|
uint8_t *dest_pointer = buffer_p + sizeof (ecma_length_t);
|
||||||
size_t copy_chunk_chars = JERRY_MIN(sizeof (first_chunk_p->data) / sizeof (ecma_char_t),
|
size_t copy_chunk_chars = JERRY_MIN(sizeof (first_chunk_p->data) / sizeof (ecma_char_t),
|
||||||
chars_left);
|
chars_left);
|
||||||
__memcpy (dest_pointer, first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
|
__memcpy (dest_pointer, first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
|
||||||
|
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
|
||||||
|
chars_left -= copy_chunk_chars;
|
||||||
|
|
||||||
|
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
|
||||||
|
|
||||||
|
while (chars_left > 0)
|
||||||
|
{
|
||||||
|
JERRY_ASSERT(chars_left < string_length);
|
||||||
|
|
||||||
|
copy_chunk_chars = JERRY_MIN(sizeof (non_first_chunk_p->data) / sizeof (ecma_char_t),
|
||||||
|
chars_left);
|
||||||
|
__memcpy (dest_pointer, non_first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
|
||||||
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
|
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
|
||||||
chars_left -= copy_chunk_chars;
|
chars_left -= copy_chunk_chars;
|
||||||
|
|
||||||
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
|
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
|
||||||
|
}
|
||||||
|
|
||||||
while (chars_left > 0)
|
return (ssize_t) required_buffer_size;
|
||||||
{
|
|
||||||
JERRY_ASSERT(chars_left < string_length);
|
|
||||||
|
|
||||||
copy_chunk_chars = JERRY_MIN(sizeof (non_first_chunk_p->data) / sizeof (ecma_char_t),
|
|
||||||
chars_left);
|
|
||||||
__memcpy (dest_pointer, non_first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
|
|
||||||
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
|
|
||||||
chars_left -= copy_chunk_chars;
|
|
||||||
|
|
||||||
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ssize_t) required_buffer_size;
|
|
||||||
} /* ecma_copy_ecma_string_chars_to_buffer */
|
} /* ecma_copy_ecma_string_chars_to_buffer */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -593,29 +593,29 @@ ecma_copy_ecma_string_chars_to_buffer (ecma_array_first_chunk_t *first_chunk_p,
|
|||||||
ecma_array_first_chunk_t*
|
ecma_array_first_chunk_t*
|
||||||
ecma_duplicate_ecma_string (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of string to duplicate */
|
ecma_duplicate_ecma_string (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of string to duplicate */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(first_chunk_p != NULL);
|
JERRY_ASSERT(first_chunk_p != NULL);
|
||||||
|
|
||||||
ecma_array_first_chunk_t *first_chunk_copy_p = ecma_alloc_array_first_chunk ();
|
ecma_array_first_chunk_t *first_chunk_copy_p = ecma_alloc_array_first_chunk ();
|
||||||
__memcpy (first_chunk_copy_p, first_chunk_p, sizeof (ecma_array_first_chunk_t));
|
__memcpy (first_chunk_copy_p, first_chunk_p, sizeof (ecma_array_first_chunk_t));
|
||||||
|
|
||||||
ecma_array_non_first_chunk_t *non_first_chunk_p, *non_first_chunk_copy_p;
|
ecma_array_non_first_chunk_t *non_first_chunk_p, *non_first_chunk_copy_p;
|
||||||
non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
|
non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
|
||||||
uint16_t *next_pointer_p = &first_chunk_copy_p->header.next_chunk_p;
|
uint16_t *next_pointer_p = &first_chunk_copy_p->header.next_chunk_p;
|
||||||
|
|
||||||
while (non_first_chunk_p != NULL)
|
while (non_first_chunk_p != NULL)
|
||||||
{
|
{
|
||||||
non_first_chunk_copy_p = ecma_alloc_array_non_first_chunk ();
|
non_first_chunk_copy_p = ecma_alloc_array_non_first_chunk ();
|
||||||
ECMA_SET_POINTER(*next_pointer_p, non_first_chunk_copy_p);
|
ECMA_SET_POINTER(*next_pointer_p, non_first_chunk_copy_p);
|
||||||
next_pointer_p = &non_first_chunk_copy_p->next_chunk_p;
|
next_pointer_p = &non_first_chunk_copy_p->next_chunk_p;
|
||||||
|
|
||||||
__memcpy (non_first_chunk_copy_p, non_first_chunk_p, sizeof (ecma_array_non_first_chunk_t));
|
__memcpy (non_first_chunk_copy_p, non_first_chunk_p, sizeof (ecma_array_non_first_chunk_t));
|
||||||
|
|
||||||
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
|
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
*next_pointer_p = ECMA_NULL_POINTER;
|
*next_pointer_p = ECMA_NULL_POINTER;
|
||||||
|
|
||||||
return first_chunk_copy_p;
|
return first_chunk_copy_p;
|
||||||
} /* ecma_duplicate_ecma_string */
|
} /* ecma_duplicate_ecma_string */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -626,7 +626,7 @@ ecma_duplicate_ecma_string (ecma_array_first_chunk_t *first_chunk_p) /**< first
|
|||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ecma_compare_ecma_string_to_ecma_string (const ecma_array_first_chunk_t *string1_p, /* ecma-string */
|
ecma_compare_ecma_string_to_ecma_string (const ecma_array_first_chunk_t *string1_p, /* ecma-string */
|
||||||
const ecma_array_first_chunk_t *string2_p) /* ecma-string */
|
const ecma_array_first_chunk_t *string2_p) /* ecma-string */
|
||||||
{
|
{
|
||||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(string1_p, string2_p);
|
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(string1_p, string2_p);
|
||||||
} /* ecma_compare_ecma_string_to_ecma_string */
|
} /* ecma_compare_ecma_string_to_ecma_string */
|
||||||
@@ -639,51 +639,51 @@ ecma_compare_ecma_string_to_ecma_string (const ecma_array_first_chunk_t *string1
|
|||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-terminated string */
|
ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-terminated string */
|
||||||
const ecma_array_first_chunk_t *ecma_string_p) /* ecma-string */
|
const ecma_array_first_chunk_t *ecma_string_p) /* ecma-string */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(string_p != NULL);
|
JERRY_ASSERT(string_p != NULL);
|
||||||
JERRY_ASSERT(ecma_string_p != NULL);
|
JERRY_ASSERT(ecma_string_p != NULL);
|
||||||
|
|
||||||
const ecma_char_t *str_iter_p = string_p;
|
const ecma_char_t *str_iter_p = string_p;
|
||||||
ecma_length_t ecma_str_len = ecma_string_p->header.unit_number;
|
ecma_length_t ecma_str_len = ecma_string_p->header.unit_number;
|
||||||
const ecma_char_t *current_chunk_chars_cur = (const ecma_char_t*) ecma_string_p->data,
|
const ecma_char_t *current_chunk_chars_cur = (const ecma_char_t*) ecma_string_p->data;
|
||||||
*current_chunk_chars_end = (const ecma_char_t*) (ecma_string_p->data
|
const ecma_char_t *current_chunk_chars_end = (const ecma_char_t*) (ecma_string_p->data +
|
||||||
+ sizeof (ecma_string_p->data));
|
sizeof (ecma_string_p->data));
|
||||||
|
|
||||||
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
|
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
|
||||||
const uint16_t *next_chunk_compressed_pointer_p = &ecma_string_p->header.next_chunk_p;
|
const uint16_t *next_chunk_compressed_pointer_p = &ecma_string_p->header.next_chunk_p;
|
||||||
|
|
||||||
for (ecma_length_t str_index = 0;
|
for (ecma_length_t str_index = 0;
|
||||||
str_index < ecma_str_len;
|
str_index < ecma_str_len;
|
||||||
str_index++, str_iter_p++, current_chunk_chars_cur++)
|
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(current_chunk_chars_cur <= current_chunk_chars_end);
|
/* switching to next chunk */
|
||||||
|
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(*next_chunk_compressed_pointer_p);
|
||||||
|
|
||||||
if (current_chunk_chars_cur == current_chunk_chars_end)
|
JERRY_ASSERT(next_chunk_p != NULL);
|
||||||
{
|
|
||||||
/* switching to next chunk */
|
|
||||||
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(*next_chunk_compressed_pointer_p);
|
|
||||||
|
|
||||||
JERRY_ASSERT(next_chunk_p != NULL);
|
current_chunk_chars_cur = (const ecma_char_t*) next_chunk_p->data;
|
||||||
|
current_chunk_chars_end = (const ecma_char_t*) (next_chunk_p->data + sizeof (next_chunk_p->data));
|
||||||
|
|
||||||
current_chunk_chars_cur = (const ecma_char_t*) next_chunk_p->data;
|
next_chunk_compressed_pointer_p = &next_chunk_p->next_chunk_p;
|
||||||
current_chunk_chars_end = (const ecma_char_t*) (next_chunk_p->data + sizeof (next_chunk_p->data));
|
|
||||||
|
|
||||||
next_chunk_compressed_pointer_p = &next_chunk_p->next_chunk_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.
|
* Now, we have reached end of ecma-string.
|
||||||
*
|
*
|
||||||
@@ -699,20 +699,20 @@ ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-te
|
|||||||
void
|
void
|
||||||
ecma_free_array (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of the array */
|
ecma_free_array (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of the array */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(first_chunk_p != NULL);
|
JERRY_ASSERT(first_chunk_p != NULL);
|
||||||
|
|
||||||
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
|
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
|
||||||
|
|
||||||
ecma_dealloc_array_first_chunk (first_chunk_p);
|
ecma_dealloc_array_first_chunk (first_chunk_p);
|
||||||
|
|
||||||
while (non_first_chunk_p != NULL)
|
while (non_first_chunk_p != NULL)
|
||||||
{
|
{
|
||||||
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
|
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
|
||||||
|
|
||||||
ecma_dealloc_array_non_first_chunk (non_first_chunk_p);
|
ecma_dealloc_array_non_first_chunk (non_first_chunk_p);
|
||||||
|
|
||||||
non_first_chunk_p = next_chunk_p;
|
non_first_chunk_p = next_chunk_p;
|
||||||
}
|
}
|
||||||
} /* ecma_free_array */
|
} /* ecma_free_array */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -724,24 +724,25 @@ ecma_free_array (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of th
|
|||||||
ecma_property_descriptor_t
|
ecma_property_descriptor_t
|
||||||
ecma_make_empty_property_descriptor (void)
|
ecma_make_empty_property_descriptor (void)
|
||||||
{
|
{
|
||||||
ecma_property_descriptor_t prop_desc = (ecma_property_descriptor_t) {
|
ecma_property_descriptor_t prop_desc = (ecma_property_descriptor_t)
|
||||||
.is_value_defined = false,
|
{
|
||||||
.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
|
.is_value_defined = false,
|
||||||
|
.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
|
||||||
|
|
||||||
.is_writable_defined = false,
|
.is_writable_defined = false,
|
||||||
.writable = ECMA_PROPERTY_NOT_WRITABLE,
|
.writable = ECMA_PROPERTY_NOT_WRITABLE,
|
||||||
|
|
||||||
.is_enumerable_defined = false,
|
.is_enumerable_defined = false,
|
||||||
.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE,
|
.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||||
|
|
||||||
.is_configurable_defined = false,
|
.is_configurable_defined = false,
|
||||||
.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE,
|
.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE,
|
||||||
|
|
||||||
.is_get_defined = false,
|
.is_get_defined = false,
|
||||||
.get_p = NULL,
|
.get_p = NULL,
|
||||||
|
|
||||||
.is_set_defined = false,
|
.is_set_defined = false,
|
||||||
.set_p = NULL
|
.set_p = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
return prop_desc;
|
return prop_desc;
|
||||||
|
|||||||
@@ -30,28 +30,29 @@
|
|||||||
* Get value of pointer from specified compressed pointer field.
|
* Get value of pointer from specified compressed pointer field.
|
||||||
*/
|
*/
|
||||||
#define ECMA_GET_POINTER(field) \
|
#define ECMA_GET_POINTER(field) \
|
||||||
((unlikely (field == ECMA_NULL_POINTER)) ? NULL : mem_decompress_pointer (field))
|
((unlikely (field == ECMA_NULL_POINTER)) ? NULL : mem_decompress_pointer (field))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set value of compressed pointer field so that it will correspond
|
* Set value of compressed pointer field so that it will correspond
|
||||||
* to specified non_compressed_pointer.
|
* to specified non_compressed_pointer.
|
||||||
*/
|
*/
|
||||||
#define ECMA_SET_POINTER(field, non_compressed_pointer) \
|
#define ECMA_SET_POINTER(field, non_compressed_pointer) \
|
||||||
do { \
|
do \
|
||||||
void *__temp_pointer = non_compressed_pointer; \
|
{ \
|
||||||
non_compressed_pointer = __temp_pointer; \
|
void *__temp_pointer = non_compressed_pointer; \
|
||||||
} \
|
non_compressed_pointer = __temp_pointer; \
|
||||||
while (0); \
|
} while (0); \
|
||||||
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
|
\
|
||||||
: mem_compress_pointer (non_compressed_pointer) \
|
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
|
||||||
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
|
: (mem_compress_pointer (non_compressed_pointer) \
|
||||||
|
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set value of non-null compressed pointer field so that it will correspond
|
* Set value of non-null compressed pointer field so that it will correspond
|
||||||
* to specified non_compressed_pointer.
|
* to specified non_compressed_pointer.
|
||||||
*/
|
*/
|
||||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||||
(field) = (mem_compress_pointer (non_compressed_pointer) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
|
(field) = (mem_compress_pointer (non_compressed_pointer) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
|
||||||
|
|
||||||
/* ecma-helpers-value.c */
|
/* ecma-helpers-value.c */
|
||||||
extern bool ecma_is_value_empty (ecma_value_t value);
|
extern bool ecma_is_value_empty (ecma_value_t value);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
|
ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
|
||||||
ecma_value_t y) /**< second operand */
|
ecma_value_t y) /**< second operand */
|
||||||
{
|
{
|
||||||
const bool is_x_undefined = ecma_is_value_undefined (x);
|
const bool is_x_undefined = ecma_is_value_undefined (x);
|
||||||
const bool is_x_null = ecma_is_value_null (x);
|
const bool is_x_null = ecma_is_value_null (x);
|
||||||
@@ -53,18 +53,18 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
|
|||||||
const bool is_y_object = (y.value_type == ECMA_TYPE_OBJECT);
|
const bool is_y_object = (y.value_type == ECMA_TYPE_OBJECT);
|
||||||
|
|
||||||
const bool is_types_equal = ((is_x_undefined && is_y_undefined)
|
const bool is_types_equal = ((is_x_undefined && is_y_undefined)
|
||||||
|| (is_x_null && is_y_null)
|
|| (is_x_null && is_y_null)
|
||||||
|| (is_x_boolean && is_y_boolean)
|
|| (is_x_boolean && is_y_boolean)
|
||||||
|| (is_x_number && is_y_number)
|
|| (is_x_number && is_y_number)
|
||||||
|| (is_x_string && is_y_string)
|
|| (is_x_string && is_y_string)
|
||||||
|| (is_x_object && is_y_object));
|
|| (is_x_object && is_y_object));
|
||||||
|
|
||||||
if (is_types_equal)
|
if (is_types_equal)
|
||||||
{
|
{
|
||||||
// 1.
|
// 1.
|
||||||
|
|
||||||
if (is_x_undefined
|
if (is_x_undefined
|
||||||
|| is_x_null)
|
|| is_x_null)
|
||||||
{
|
{
|
||||||
// a., b.
|
// a., b.
|
||||||
return true;
|
return true;
|
||||||
@@ -92,7 +92,7 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
|
|||||||
return (x.value == y.value);
|
return (x.value == y.value);
|
||||||
}
|
}
|
||||||
} else if ((is_x_null && is_y_undefined)
|
} else if ((is_x_null && is_y_undefined)
|
||||||
|| (is_x_undefined && is_y_null))
|
|| (is_x_undefined && is_y_null))
|
||||||
{ // 2., 3.
|
{ // 2., 3.
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
@@ -111,8 +111,8 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */
|
ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */
|
||||||
ecma_value_t y, /**< second operand */
|
ecma_value_t y, /**< second operand */
|
||||||
bool left_first) /**< 'LeftFirst' flag */
|
bool left_first) /**< 'LeftFirst' flag */
|
||||||
{
|
{
|
||||||
ecma_completion_value_t ret_value, px, py;
|
ecma_completion_value_t ret_value, px, py;
|
||||||
|
|
||||||
@@ -134,38 +134,38 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */
|
|||||||
const bool is_py_string = (py.value.value_type == ECMA_TYPE_STRING);
|
const bool is_py_string = (py.value.value_type == ECMA_TYPE_STRING);
|
||||||
|
|
||||||
if (!(is_px_string && is_py_string))
|
if (!(is_px_string && is_py_string))
|
||||||
{ // 3.
|
{ // 3.
|
||||||
// a.
|
// a.
|
||||||
ECMA_TRY_CATCH(nx, ecma_op_to_number (px.value), ret_value);
|
ECMA_TRY_CATCH(nx, ecma_op_to_number (px.value), ret_value);
|
||||||
|
|
||||||
// b.
|
// b.
|
||||||
ECMA_TRY_CATCH(ny, ecma_op_to_number (py.value), ret_value);
|
ECMA_TRY_CATCH(ny, ecma_op_to_number (py.value), ret_value);
|
||||||
|
|
||||||
ecma_number_t* num_x_p = (ecma_number_t*)ECMA_GET_POINTER(nx.value.value);
|
ecma_number_t* num_x_p = (ecma_number_t*)ECMA_GET_POINTER(nx.value.value);
|
||||||
ecma_number_t* num_y_p = (ecma_number_t*)ECMA_GET_POINTER(ny.value.value);
|
ecma_number_t* num_y_p = (ecma_number_t*)ECMA_GET_POINTER(ny.value.value);
|
||||||
|
|
||||||
TODO(/* Implement according to ECMA */);
|
TODO(/* Implement according to ECMA */);
|
||||||
|
|
||||||
if (*num_x_p >= *num_y_p)
|
if (*num_x_p >= *num_y_p)
|
||||||
{
|
{
|
||||||
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE),
|
ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
|
||||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE),
|
|
||||||
ECMA_TARGET_ID_RESERVED);
|
|
||||||
}
|
|
||||||
|
|
||||||
ECMA_FINALIZE(ny);
|
|
||||||
ECMA_FINALIZE(nx);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
|
ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE),
|
||||||
|
ECMA_TARGET_ID_RESERVED);
|
||||||
|
}
|
||||||
|
|
||||||
|
ECMA_FINALIZE(ny);
|
||||||
|
ECMA_FINALIZE(nx);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ // 4.
|
{ // 4.
|
||||||
JERRY_UNIMPLEMENTED();
|
JERRY_UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
|
|
||||||
ECMA_FINALIZE(prim_second_converted_value);
|
ECMA_FINALIZE(prim_second_converted_value);
|
||||||
ECMA_FINALIZE(prim_first_converted_value);
|
ECMA_FINALIZE(prim_first_converted_value);
|
||||||
|
|||||||
@@ -43,32 +43,34 @@ ecma_op_check_object_coercible (ecma_value_t value) /**< ecma-value */
|
|||||||
switch ((ecma_type_t)value.value_type)
|
switch ((ecma_type_t)value.value_type)
|
||||||
{
|
{
|
||||||
case ECMA_TYPE_SIMPLE:
|
case ECMA_TYPE_SIMPLE:
|
||||||
|
{
|
||||||
|
if (ecma_is_value_undefined (value))
|
||||||
{
|
{
|
||||||
if (ecma_is_value_undefined (value))
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
{
|
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
|
||||||
}
|
|
||||||
else if (ecma_is_value_boolean (value))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
JERRY_UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case ECMA_TYPE_NUMBER:
|
else if (ecma_is_value_boolean (value))
|
||||||
case ECMA_TYPE_STRING:
|
|
||||||
case ECMA_TYPE_OBJECT:
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ECMA_TYPE__COUNT:
|
else
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECMA_TYPE_NUMBER:
|
||||||
|
case ECMA_TYPE_STRING:
|
||||||
|
case ECMA_TYPE_OBJECT:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ECMA_TYPE__COUNT:
|
||||||
|
{
|
||||||
|
JERRY_UNREACHABLE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ecma_make_empty_completion_value ();
|
return ecma_make_empty_completion_value ();
|
||||||
@@ -102,45 +104,45 @@ ecma_op_same_value (ecma_value_t x, /**< ecma-value */
|
|||||||
const bool is_y_object = (y.value_type == ECMA_TYPE_OBJECT);
|
const bool is_y_object = (y.value_type == ECMA_TYPE_OBJECT);
|
||||||
|
|
||||||
const bool is_types_equal = ((is_x_undefined && is_y_undefined)
|
const bool is_types_equal = ((is_x_undefined && is_y_undefined)
|
||||||
|| (is_x_null && is_y_null)
|
|| (is_x_null && is_y_null)
|
||||||
|| (is_x_boolean && is_y_boolean)
|
|| (is_x_boolean && is_y_boolean)
|
||||||
|| (is_x_number && is_y_number)
|
|| (is_x_number && is_y_number)
|
||||||
|| (is_x_string && is_y_string)
|
|| (is_x_string && is_y_string)
|
||||||
|| (is_x_object && is_y_object));
|
|| (is_x_object && is_y_object));
|
||||||
|
|
||||||
if (!is_types_equal)
|
if (!is_types_equal)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_x_undefined
|
if (is_x_undefined
|
||||||
|| is_x_null)
|
|| is_x_null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_x_number)
|
if (is_x_number)
|
||||||
{
|
{
|
||||||
TODO(Implement according to ECMA);
|
TODO(Implement according to ECMA);
|
||||||
|
|
||||||
ecma_number_t *x_num_p = (ecma_number_t*)ECMA_GET_POINTER(x.value);
|
ecma_number_t *x_num_p = (ecma_number_t*)ECMA_GET_POINTER(x.value);
|
||||||
ecma_number_t *y_num_p = (ecma_number_t*)ECMA_GET_POINTER(y.value);
|
ecma_number_t *y_num_p = (ecma_number_t*)ECMA_GET_POINTER(y.value);
|
||||||
|
|
||||||
return (*x_num_p == *y_num_p);
|
return (*x_num_p == *y_num_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_x_string)
|
if (is_x_string)
|
||||||
{
|
{
|
||||||
ecma_array_first_chunk_t* x_str_p = (ecma_array_first_chunk_t*)(ECMA_GET_POINTER(x.value));
|
ecma_array_first_chunk_t* x_str_p = (ecma_array_first_chunk_t*)(ECMA_GET_POINTER(x.value));
|
||||||
ecma_array_first_chunk_t* y_str_p = (ecma_array_first_chunk_t*)(ECMA_GET_POINTER(y.value));
|
ecma_array_first_chunk_t* y_str_p = (ecma_array_first_chunk_t*)(ECMA_GET_POINTER(y.value));
|
||||||
|
|
||||||
return ecma_compare_ecma_string_to_ecma_string (x_str_p, y_str_p);
|
return ecma_compare_ecma_string_to_ecma_string (x_str_p, y_str_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_x_boolean)
|
if (is_x_boolean)
|
||||||
{
|
{
|
||||||
return (ecma_is_value_true (x) == ecma_is_value_true (y));
|
return (ecma_is_value_true (x) == ecma_is_value_true (y));
|
||||||
}
|
}
|
||||||
|
|
||||||
JERRY_ASSERT(is_x_object);
|
JERRY_ASSERT(is_x_object);
|
||||||
|
|
||||||
@@ -165,19 +167,21 @@ ecma_op_to_primitive (ecma_value_t value, /**< ecma-value */
|
|||||||
case ECMA_TYPE_SIMPLE:
|
case ECMA_TYPE_SIMPLE:
|
||||||
case ECMA_TYPE_NUMBER:
|
case ECMA_TYPE_NUMBER:
|
||||||
case ECMA_TYPE_STRING:
|
case ECMA_TYPE_STRING:
|
||||||
{
|
{
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_copy_value (value, true),
|
ecma_copy_value (value, true),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_TYPE_OBJECT:
|
case ECMA_TYPE_OBJECT:
|
||||||
{
|
{
|
||||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(preferred_type);
|
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(preferred_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ECMA_TYPE__COUNT:
|
case ECMA_TYPE__COUNT:
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
@@ -199,51 +203,51 @@ ecma_op_to_boolean (ecma_value_t value) /**< ecma-value */
|
|||||||
switch ((ecma_type_t)value.value_type)
|
switch ((ecma_type_t)value.value_type)
|
||||||
{
|
{
|
||||||
case ECMA_TYPE_NUMBER:
|
case ECMA_TYPE_NUMBER:
|
||||||
{
|
{
|
||||||
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
|
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
|
||||||
|
|
||||||
TODO(Implement according to ECMA);
|
TODO(Implement according to ECMA);
|
||||||
|
|
||||||
return ecma_make_simple_completion_value ((*num_p == 0) ? ECMA_SIMPLE_VALUE_FALSE
|
return ecma_make_simple_completion_value ((*num_p == 0) ? ECMA_SIMPLE_VALUE_FALSE
|
||||||
: ECMA_SIMPLE_VALUE_TRUE);
|
: ECMA_SIMPLE_VALUE_TRUE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ECMA_TYPE_SIMPLE:
|
case ECMA_TYPE_SIMPLE:
|
||||||
|
{
|
||||||
|
if (ecma_is_value_boolean (value))
|
||||||
{
|
{
|
||||||
if (ecma_is_value_boolean (value))
|
return ecma_make_simple_completion_value (value.value);
|
||||||
{
|
} else if (ecma_is_value_undefined (value)
|
||||||
return ecma_make_simple_completion_value (value.value);
|
|| ecma_is_value_null (value))
|
||||||
} else if (ecma_is_value_undefined (value)
|
|
||||||
|| ecma_is_value_null (value))
|
|
||||||
{
|
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
JERRY_UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ECMA_TYPE_STRING:
|
|
||||||
{
|
{
|
||||||
ecma_array_first_chunk_t *str_p = ECMA_GET_POINTER(value.value);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||||
|
} else
|
||||||
return ecma_make_simple_completion_value ((str_p->header.unit_number == 0) ? ECMA_SIMPLE_VALUE_FALSE
|
|
||||||
: ECMA_SIMPLE_VALUE_TRUE);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ECMA_TYPE_OBJECT:
|
|
||||||
{
|
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ECMA_TYPE__COUNT:
|
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ECMA_TYPE_STRING:
|
||||||
|
{
|
||||||
|
ecma_array_first_chunk_t *str_p = ECMA_GET_POINTER(value.value);
|
||||||
|
|
||||||
|
return ecma_make_simple_completion_value ((str_p->header.unit_number == 0) ? ECMA_SIMPLE_VALUE_FALSE
|
||||||
|
: ECMA_SIMPLE_VALUE_TRUE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ECMA_TYPE_OBJECT:
|
||||||
|
{
|
||||||
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ECMA_TYPE__COUNT:
|
||||||
|
{
|
||||||
|
JERRY_UNREACHABLE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
@@ -264,30 +268,30 @@ ecma_op_to_number (ecma_value_t value) /**< ecma-value */
|
|||||||
switch ((ecma_type_t)value.value_type)
|
switch ((ecma_type_t)value.value_type)
|
||||||
{
|
{
|
||||||
case ECMA_TYPE_NUMBER:
|
case ECMA_TYPE_NUMBER:
|
||||||
{
|
{
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_copy_value (value, true),
|
ecma_copy_value (value, true),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
}
|
}
|
||||||
case ECMA_TYPE_SIMPLE:
|
case ECMA_TYPE_SIMPLE:
|
||||||
case ECMA_TYPE_STRING:
|
case ECMA_TYPE_STRING:
|
||||||
{
|
{
|
||||||
JERRY_UNIMPLEMENTED();
|
JERRY_UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
case ECMA_TYPE_OBJECT:
|
case ECMA_TYPE_OBJECT:
|
||||||
{
|
{
|
||||||
ecma_completion_value_t completion_to_primitive = ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER);
|
ecma_completion_value_t completion_to_primitive = ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER);
|
||||||
JERRY_ASSERT(ecma_is_completion_value_normal (completion_to_primitive));
|
JERRY_ASSERT(ecma_is_completion_value_normal (completion_to_primitive));
|
||||||
|
|
||||||
ecma_completion_value_t completion_to_number = ecma_op_to_number (completion_to_primitive.value);
|
ecma_completion_value_t completion_to_number = ecma_op_to_number (completion_to_primitive.value);
|
||||||
ecma_free_completion_value (completion_to_primitive);
|
ecma_free_completion_value (completion_to_primitive);
|
||||||
|
|
||||||
return completion_to_number;
|
return completion_to_number;
|
||||||
}
|
}
|
||||||
case ECMA_TYPE__COUNT:
|
case ECMA_TYPE__COUNT:
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
|
|||||||
@@ -45,9 +45,9 @@ ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */
|
|||||||
JERRY_ASSERT(((value) & (1u << is_strict_bit_offset)) == 0);
|
JERRY_ASSERT(((value) & (1u << is_strict_bit_offset)) == 0);
|
||||||
|
|
||||||
if (is_strict)
|
if (is_strict)
|
||||||
{
|
{
|
||||||
value |= (1u << is_strict_bit_offset);
|
value |= (1u << is_strict_bit_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
} /* ecma_pack_code_internal_property_value */
|
} /* ecma_pack_code_internal_property_value */
|
||||||
@@ -86,9 +86,9 @@ bool
|
|||||||
ecma_op_is_callable (ecma_value_t value) /**< ecma-value */
|
ecma_op_is_callable (ecma_value_t value) /**< ecma-value */
|
||||||
{
|
{
|
||||||
if (value.value_type != ECMA_TYPE_OBJECT)
|
if (value.value_type != ECMA_TYPE_OBJECT)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
|
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ ecma_op_is_callable (ecma_value_t value) /**< ecma-value */
|
|||||||
JERRY_ASSERT(!obj_p->is_lexical_environment);
|
JERRY_ASSERT(!obj_p->is_lexical_environment);
|
||||||
|
|
||||||
return (obj_p->u.object.type == ECMA_OBJECT_TYPE_FUNCTION
|
return (obj_p->u.object.type == ECMA_OBJECT_TYPE_FUNCTION
|
||||||
|| obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
|| obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||||
} /* ecma_op_is_callable */
|
} /* ecma_op_is_callable */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,9 +137,9 @@ ecma_op_create_function_object (const ecma_char_t* formal_parameter_list_p[], /*
|
|||||||
|
|
||||||
// 10., 11., 14., 15.
|
// 10., 11., 14., 15.
|
||||||
if (formal_parameters_number != 0)
|
if (formal_parameters_number != 0)
|
||||||
{
|
{
|
||||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(formal_parameter_list_p);
|
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(formal_parameter_list_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 12.
|
// 12.
|
||||||
ecma_property_t *code_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE);
|
ecma_property_t *code_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE);
|
||||||
@@ -152,19 +152,19 @@ ecma_op_create_function_object (const ecma_char_t* formal_parameter_list_p[], /*
|
|||||||
|
|
||||||
// 17.
|
// 17.
|
||||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||||
{
|
{
|
||||||
prop_desc.is_value_defined = true;
|
prop_desc.is_value_defined = true;
|
||||||
prop_desc.value = ecma_make_object_value (f);
|
prop_desc.value = ecma_make_object_value (f);
|
||||||
|
|
||||||
prop_desc.is_writable_defined = true;
|
prop_desc.is_writable_defined = true;
|
||||||
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
|
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
|
||||||
|
|
||||||
prop_desc.is_enumerable_defined = true;
|
prop_desc.is_enumerable_defined = true;
|
||||||
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
|
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
|
||||||
|
|
||||||
prop_desc.is_configurable_defined = true;
|
prop_desc.is_configurable_defined = true;
|
||||||
prop_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
|
prop_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_op_object_define_own_property (proto_p,
|
ecma_op_object_define_own_property (proto_p,
|
||||||
ecma_get_magic_string (ECMA_MAGIC_STRING_CONSTRUCTOR),
|
ecma_get_magic_string (ECMA_MAGIC_STRING_CONSTRUCTOR),
|
||||||
@@ -183,37 +183,37 @@ ecma_op_create_function_object (const ecma_char_t* formal_parameter_list_p[], /*
|
|||||||
|
|
||||||
// 19.
|
// 19.
|
||||||
if (is_strict)
|
if (is_strict)
|
||||||
|
{
|
||||||
|
ecma_object_t *thrower_p = ecma_op_get_throw_type_error ();
|
||||||
|
|
||||||
|
prop_desc = ecma_make_empty_property_descriptor ();
|
||||||
{
|
{
|
||||||
ecma_object_t *thrower_p = ecma_op_get_throw_type_error ();
|
prop_desc.is_enumerable_defined = true;
|
||||||
|
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
|
||||||
|
|
||||||
prop_desc = ecma_make_empty_property_descriptor ();
|
prop_desc.is_configurable_defined = true;
|
||||||
{
|
prop_desc.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE;
|
||||||
prop_desc.is_enumerable_defined = true;
|
|
||||||
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
|
|
||||||
|
|
||||||
prop_desc.is_configurable_defined = true;
|
prop_desc.is_get_defined = true;
|
||||||
prop_desc.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE;
|
prop_desc.get_p = thrower_p;
|
||||||
|
|
||||||
prop_desc.is_get_defined = true;
|
prop_desc.is_set_defined = true;
|
||||||
prop_desc.get_p = thrower_p;
|
prop_desc.set_p = thrower_p;
|
||||||
|
|
||||||
prop_desc.is_set_defined = true;
|
|
||||||
prop_desc.set_p = thrower_p;
|
|
||||||
}
|
|
||||||
|
|
||||||
ecma_op_object_define_own_property (f,
|
|
||||||
ecma_get_magic_string (ECMA_MAGIC_STRING_CALLER),
|
|
||||||
prop_desc,
|
|
||||||
false);
|
|
||||||
|
|
||||||
ecma_op_object_define_own_property (f,
|
|
||||||
ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS),
|
|
||||||
prop_desc,
|
|
||||||
false);
|
|
||||||
|
|
||||||
ecma_deref_object (thrower_p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ecma_op_object_define_own_property (f,
|
||||||
|
ecma_get_magic_string (ECMA_MAGIC_STRING_CALLER),
|
||||||
|
prop_desc,
|
||||||
|
false);
|
||||||
|
|
||||||
|
ecma_op_object_define_own_property (f,
|
||||||
|
ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS),
|
||||||
|
prop_desc,
|
||||||
|
false);
|
||||||
|
|
||||||
|
ecma_deref_object (thrower_p);
|
||||||
|
}
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
} /* ecma_op_create_function_object */
|
} /* ecma_op_create_function_object */
|
||||||
|
|
||||||
@@ -236,81 +236,81 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
|
|||||||
JERRY_ASSERT(arguments_list_len == 0 || arguments_list_p != NULL);
|
JERRY_ASSERT(arguments_list_len == 0 || arguments_list_p != NULL);
|
||||||
|
|
||||||
if (func_obj_p->u.object.type == ECMA_OBJECT_TYPE_FUNCTION)
|
if (func_obj_p->u.object.type == ECMA_OBJECT_TYPE_FUNCTION)
|
||||||
|
{
|
||||||
|
ecma_completion_value_t ret_value;
|
||||||
|
|
||||||
|
/* Entering Function Code (ECMA-262 v5, 10.4.3) */
|
||||||
|
|
||||||
|
ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
|
||||||
|
ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE);
|
||||||
|
|
||||||
|
ecma_object_t *scope_p = ECMA_GET_POINTER(scope_prop_p->u.internal_property.value);
|
||||||
|
uint32_t code_prop_value = code_prop_p->u.internal_property.value;
|
||||||
|
|
||||||
|
bool is_strict;
|
||||||
|
// 8.
|
||||||
|
opcode_counter_t code_first_opcode_idx = ecma_unpack_code_internal_property_value (code_prop_value, &is_strict);
|
||||||
|
|
||||||
|
ecma_value_t this_binding;
|
||||||
|
// 1.
|
||||||
|
if (is_strict)
|
||||||
{
|
{
|
||||||
ecma_completion_value_t ret_value;
|
this_binding = ecma_copy_value (this_arg_value, true);
|
||||||
|
|
||||||
/* Entering Function Code (ECMA-262 v5, 10.4.3) */
|
|
||||||
|
|
||||||
ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
|
|
||||||
ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE);
|
|
||||||
|
|
||||||
ecma_object_t *scope_p = ECMA_GET_POINTER(scope_prop_p->u.internal_property.value);
|
|
||||||
uint32_t code_prop_value = code_prop_p->u.internal_property.value;
|
|
||||||
|
|
||||||
bool is_strict;
|
|
||||||
// 8.
|
|
||||||
opcode_counter_t code_first_opcode_idx = ecma_unpack_code_internal_property_value (code_prop_value, &is_strict);
|
|
||||||
|
|
||||||
ecma_value_t this_binding;
|
|
||||||
// 1.
|
|
||||||
if (is_strict)
|
|
||||||
{
|
|
||||||
this_binding = ecma_copy_value (this_arg_value, true);
|
|
||||||
}
|
|
||||||
else if (ecma_is_value_undefined (this_arg_value)
|
|
||||||
|| ecma_is_value_null (this_arg_value))
|
|
||||||
{
|
|
||||||
// 2.
|
|
||||||
FIXME(Assign Global object when it will be implemented);
|
|
||||||
|
|
||||||
this_binding = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 3., 4.
|
|
||||||
ecma_completion_value_t completion = ecma_op_to_object (this_arg_value);
|
|
||||||
JERRY_ASSERT(ecma_is_completion_value_normal (completion));
|
|
||||||
|
|
||||||
this_binding = completion.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5.
|
|
||||||
ecma_object_t *local_env_p = ecma_create_decl_lex_env (scope_p);
|
|
||||||
|
|
||||||
// 9.
|
|
||||||
/* Declaration binding instantiation (ECMA-262 v5, 10.5), block 4 */
|
|
||||||
TODO(Perform declaration binding instantion when [[FormalParameters]] list will be supported);
|
|
||||||
if (arguments_list_len != 0)
|
|
||||||
{
|
|
||||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(arguments_list_p);
|
|
||||||
}
|
|
||||||
|
|
||||||
ecma_completion_value_t completion = run_int_from_pos (code_first_opcode_idx,
|
|
||||||
this_binding,
|
|
||||||
local_env_p,
|
|
||||||
is_strict);
|
|
||||||
if (ecma_is_completion_value_normal (completion))
|
|
||||||
{
|
|
||||||
JERRY_ASSERT(ecma_is_empty_completion_value (completion));
|
|
||||||
|
|
||||||
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret_value = completion;
|
|
||||||
}
|
|
||||||
|
|
||||||
ecma_deref_object (local_env_p);
|
|
||||||
ecma_free_value (this_binding, true);
|
|
||||||
|
|
||||||
return ret_value;
|
|
||||||
}
|
}
|
||||||
|
else if (ecma_is_value_undefined (this_arg_value)
|
||||||
|
|| ecma_is_value_null (this_arg_value))
|
||||||
|
{
|
||||||
|
// 2.
|
||||||
|
FIXME(Assign Global object when it will be implemented);
|
||||||
|
|
||||||
|
this_binding = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 3., 4.
|
||||||
|
ecma_completion_value_t completion = ecma_op_to_object (this_arg_value);
|
||||||
|
JERRY_ASSERT(ecma_is_completion_value_normal (completion));
|
||||||
|
|
||||||
|
this_binding = completion.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5.
|
||||||
|
ecma_object_t *local_env_p = ecma_create_decl_lex_env (scope_p);
|
||||||
|
|
||||||
|
// 9.
|
||||||
|
/* Declaration binding instantiation (ECMA-262 v5, 10.5), block 4 */
|
||||||
|
TODO(Perform declaration binding instantion when [[FormalParameters]] list will be supported);
|
||||||
|
if (arguments_list_len != 0)
|
||||||
|
{
|
||||||
|
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(arguments_list_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
ecma_completion_value_t completion = run_int_from_pos (code_first_opcode_idx,
|
||||||
|
this_binding,
|
||||||
|
local_env_p,
|
||||||
|
is_strict);
|
||||||
|
if (ecma_is_completion_value_normal (completion))
|
||||||
|
{
|
||||||
|
JERRY_ASSERT(ecma_is_empty_completion_value (completion));
|
||||||
|
|
||||||
|
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret_value = completion;
|
||||||
|
}
|
||||||
|
|
||||||
|
ecma_deref_object (local_env_p);
|
||||||
|
ecma_free_value (this_binding, true);
|
||||||
|
|
||||||
|
return ret_value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(func_obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
JERRY_ASSERT(func_obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||||
|
|
||||||
JERRY_UNIMPLEMENTED();
|
JERRY_UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
} /* ecma_op_function_call */
|
} /* ecma_op_function_call */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ ecma_op_get_value (ecma_reference_t ref) /**< ECMA-reference */
|
|||||||
const ecma_value_t base = ref.base;
|
const ecma_value_t base = ref.base;
|
||||||
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
|
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
|
||||||
const bool has_primitive_base = (ecma_is_value_boolean (base)
|
const bool has_primitive_base = (ecma_is_value_boolean (base)
|
||||||
|| base.value_type == ECMA_TYPE_NUMBER
|
|| base.value_type == ECMA_TYPE_NUMBER
|
||||||
|| base.value_type == ECMA_TYPE_STRING);
|
|| base.value_type == ECMA_TYPE_STRING);
|
||||||
const bool has_object_base = (base.value_type == ECMA_TYPE_OBJECT
|
const bool has_object_base = (base.value_type == ECMA_TYPE_OBJECT
|
||||||
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
|
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
|
||||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||||
|
|
||||||
// GetValue_3
|
// GetValue_3
|
||||||
@@ -72,31 +72,31 @@ ecma_op_get_value (ecma_reference_t ref) /**< ECMA-reference */
|
|||||||
} else
|
} else
|
||||||
{ // GetValue_4.b case 2
|
{ // GetValue_4.b case 2
|
||||||
/*
|
/*
|
||||||
ecma_object_t *obj_p = ecma_ToObject (base);
|
ecma_object_t *obj_p = ecma_ToObject (base);
|
||||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||||
ecma_property_t *property = obj_p->[[GetProperty]](ref.referenced_name_p);
|
ecma_property_t *property = obj_p->[[GetProperty]](ref.referenced_name_p);
|
||||||
if (property->Type == ECMA_PROPERTY_NAMEDDATA)
|
if (property->Type == ECMA_PROPERTY_NAMEDDATA)
|
||||||
{
|
{
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
|
||||||
ecma_copy_value (property->u.named_data_property.value),
|
|
||||||
ECMA_TARGET_ID_RESERVED);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
JERRY_ASSERT(property->Type == ECMA_PROPERTY_NAMEDACCESSOR);
|
|
||||||
|
|
||||||
ecma_object_t *getter = ECMA_GET_POINTER(property->u.named_accessor_property.get_p);
|
|
||||||
|
|
||||||
if (getter == NULL)
|
|
||||||
{
|
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
|
ecma_copy_value (property->u.named_data_property.value),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
JERRY_ASSERT(property->Type == ECMA_PROPERTY_NAMEDACCESSOR);
|
||||||
|
|
||||||
|
ecma_object_t *getter = ECMA_GET_POINTER(property->u.named_accessor_property.get_p);
|
||||||
|
|
||||||
|
if (getter == NULL)
|
||||||
|
{
|
||||||
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
|
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
|
||||||
|
ECMA_TARGET_ID_RESERVED);
|
||||||
|
} else
|
||||||
|
{
|
||||||
return [[Call]](getter, base as this);
|
return [[Call]](getter, base as this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
JERRY_UNIMPLEMENTED();
|
JERRY_UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -120,15 +120,15 @@ ecma_op_get_value (ecma_reference_t ref) /**< ECMA-reference */
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
|
ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
|
||||||
ecma_value_t value) /**< ECMA-value */
|
ecma_value_t value) /**< ECMA-value */
|
||||||
{
|
{
|
||||||
const ecma_value_t base = ref.base;
|
const ecma_value_t base = ref.base;
|
||||||
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
|
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
|
||||||
const bool has_primitive_base = (ecma_is_value_boolean (base)
|
const bool has_primitive_base = (ecma_is_value_boolean (base)
|
||||||
|| base.value_type == ECMA_TYPE_NUMBER
|
|| base.value_type == ECMA_TYPE_NUMBER
|
||||||
|| base.value_type == ECMA_TYPE_STRING);
|
|| base.value_type == ECMA_TYPE_STRING);
|
||||||
const bool has_object_base = (base.value_type == ECMA_TYPE_OBJECT
|
const bool has_object_base = (base.value_type == ECMA_TYPE_OBJECT
|
||||||
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
|
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
|
||||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||||
|
|
||||||
if (is_unresolvable_reference) // PutValue_3
|
if (is_unresolvable_reference) // PutValue_3
|
||||||
@@ -138,19 +138,19 @@ ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
|
|||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
||||||
} else // PutValue_3.b
|
} else // PutValue_3.b
|
||||||
{
|
{
|
||||||
ecma_object_t *global_object_p = ecma_get_global_object ();
|
ecma_object_t *global_object_p = ecma_get_global_object ();
|
||||||
|
|
||||||
ecma_completion_value_t completion = ecma_op_object_put (global_object_p,
|
ecma_completion_value_t completion = ecma_op_object_put (global_object_p,
|
||||||
ref.referenced_name_p,
|
ref.referenced_name_p,
|
||||||
value,
|
value,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
ecma_deref_object (global_object_p);
|
ecma_deref_object (global_object_p);
|
||||||
|
|
||||||
JERRY_ASSERT(ecma_is_completion_value_normal_true (completion)
|
JERRY_ASSERT(ecma_is_completion_value_normal_true (completion)
|
||||||
|| ecma_is_completion_value_normal_false (completion));
|
|| ecma_is_completion_value_normal_false (completion));
|
||||||
|
|
||||||
return ecma_make_empty_completion_value ();
|
return ecma_make_empty_completion_value ();
|
||||||
}
|
}
|
||||||
} else if (is_property_reference) // PutValue_4
|
} else if (is_property_reference) // PutValue_4
|
||||||
{
|
{
|
||||||
@@ -165,68 +165,68 @@ ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
|
|||||||
// PutValue_4.b case 2
|
// PutValue_4.b case 2
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// PutValue_sub_1
|
// PutValue_sub_1
|
||||||
ecma_object_t *obj_p = ecma_ToObject (base);
|
ecma_object_t *obj_p = ecma_ToObject (base);
|
||||||
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
|
||||||
|
|
||||||
// PutValue_sub_2
|
// PutValue_sub_2
|
||||||
if (!obj_p->[[CanPut]](ref.referenced_name_p))
|
if (!obj_p->[[CanPut]](ref.referenced_name_p))
|
||||||
{
|
{
|
||||||
// PutValue_sub_2.a
|
// PutValue_sub_2.a
|
||||||
if (ref.is_strict)
|
if (ref.is_strict)
|
||||||
{
|
{
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
} else
|
} else
|
||||||
{ // PutValue_sub_2.b
|
{ // PutValue_sub_2.b
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
|
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutValue_sub_3
|
// PutValue_sub_3
|
||||||
ecma_property_t *own_prop = obj_p->[[GetOwnProperty]](ref.referenced_name_p);
|
ecma_property_t *own_prop = obj_p->[[GetOwnProperty]](ref.referenced_name_p);
|
||||||
|
|
||||||
// PutValue_sub_4
|
// PutValue_sub_4
|
||||||
if (ecma_OpIsDataDescriptor (own_prop))
|
if (ecma_OpIsDataDescriptor (own_prop))
|
||||||
{
|
{
|
||||||
// PutValue_sub_4.a
|
// PutValue_sub_4.a
|
||||||
if (ref.is_strict)
|
if (ref.is_strict)
|
||||||
{
|
{
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
} else
|
} else
|
||||||
{ // PutValue_sub_4.b
|
{ // PutValue_sub_4.b
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
|
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutValue_sub_5
|
// PutValue_sub_5
|
||||||
ecma_property_t *prop = obj_p->[[GetProperty]](ref.referenced_name_p);
|
ecma_property_t *prop = obj_p->[[GetProperty]](ref.referenced_name_p);
|
||||||
|
|
||||||
// PutValue_sub_6
|
// PutValue_sub_6
|
||||||
if (ecma_OpIsAccessorDescriptor (prop))
|
if (ecma_OpIsAccessorDescriptor (prop))
|
||||||
{
|
{
|
||||||
// PutValue_sub_6.a
|
// PutValue_sub_6.a
|
||||||
ecma_object_t *setter = ECMA_GET_POINTER(property->u.named_accessor_property.set_p);
|
ecma_object_t *setter = ECMA_GET_POINTER(property->u.named_accessor_property.set_p);
|
||||||
JERRY_ASSERT(setter != NULL);
|
JERRY_ASSERT(setter != NULL);
|
||||||
|
|
||||||
// PutValue_sub_6.b
|
// PutValue_sub_6.b
|
||||||
return [[Call]](setter, base as this, value);
|
return [[Call]](setter, base as this, value);
|
||||||
} else // PutValue_sub_7
|
} else // PutValue_sub_7
|
||||||
{
|
{
|
||||||
// PutValue_sub_7.a
|
// PutValue_sub_7.a
|
||||||
if (ref.is_strict)
|
if (ref.is_strict)
|
||||||
{
|
{
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutValue_sub_8
|
// PutValue_sub_8
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
|
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
JERRY_UNIMPLEMENTED();
|
JERRY_UNIMPLEMENTED();
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ static ecma_object_t*
|
|||||||
ecma_get_lex_env_binding_object (ecma_object_t* obj_lex_env_p) /**< object lexical environment */
|
ecma_get_lex_env_binding_object (ecma_object_t* obj_lex_env_p) /**< object lexical environment */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(obj_lex_env_p != NULL
|
JERRY_ASSERT(obj_lex_env_p != NULL
|
||||||
&& obj_lex_env_p->is_lexical_environment
|
&& obj_lex_env_p->is_lexical_environment
|
||||||
&& obj_lex_env_p->u.lexical_environment.type == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
&& obj_lex_env_p->u.lexical_environment.type == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||||
|
|
||||||
ecma_property_t *binding_obj_prop_p = ECMA_GET_POINTER(obj_lex_env_p->properties_p);
|
ecma_property_t *binding_obj_prop_p = ECMA_GET_POINTER(obj_lex_env_p->properties_p);
|
||||||
JERRY_ASSERT(binding_obj_prop_p != NULL
|
JERRY_ASSERT(binding_obj_prop_p != NULL
|
||||||
&& binding_obj_prop_p->u.internal_property.type == ECMA_INTERNAL_PROPERTY_BINDING_OBJECT);
|
&& binding_obj_prop_p->u.internal_property.type == ECMA_INTERNAL_PROPERTY_BINDING_OBJECT);
|
||||||
|
|
||||||
return ECMA_GET_POINTER(binding_obj_prop_p->u.internal_property.value);
|
return ECMA_GET_POINTER(binding_obj_prop_p->u.internal_property.value);
|
||||||
} /* ecma_get_lex_env_binding_object */
|
} /* ecma_get_lex_env_binding_object */
|
||||||
@@ -61,7 +61,7 @@ ecma_get_lex_env_binding_object (ecma_object_t* obj_lex_env_p) /**< object lexic
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p) /**< argument N */
|
const ecma_char_t *name_p) /**< argument N */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||||
|
|
||||||
@@ -73,8 +73,7 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
{
|
{
|
||||||
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
|
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
|
||||||
|
|
||||||
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE
|
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
|
||||||
: ECMA_SIMPLE_VALUE_FALSE;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -82,16 +81,22 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
{
|
{
|
||||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||||
|
|
||||||
has_binding = ecma_op_object_has_property (binding_obj_p, name_p) ? ECMA_SIMPLE_VALUE_TRUE
|
if (ecma_op_object_has_property (binding_obj_p, name_p))
|
||||||
: ECMA_SIMPLE_VALUE_FALSE;
|
{
|
||||||
|
has_binding = ECMA_SIMPLE_VALUE_TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
has_binding = ECMA_SIMPLE_VALUE_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_simple_value (has_binding),
|
ecma_make_simple_value (has_binding),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
} /* ecma_op_has_binding */
|
} /* ecma_op_has_binding */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,8 +109,8 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p, /**< argument N */
|
const ecma_char_t *name_p, /**< argument N */
|
||||||
bool is_deletable) /**< argument D */
|
bool is_deletable) /**< argument D */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||||
JERRY_ASSERT(name_p != NULL);
|
JERRY_ASSERT(name_p != NULL);
|
||||||
@@ -121,7 +126,7 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
|
|||||||
ECMA_PROPERTY_WRITABLE,
|
ECMA_PROPERTY_WRITABLE,
|
||||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||||
is_deletable ? ECMA_PROPERTY_CONFIGURABLE
|
is_deletable ? ECMA_PROPERTY_CONFIGURABLE
|
||||||
: ECMA_PROPERTY_NOT_CONFIGURABLE);
|
: ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -133,20 +138,19 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
|
|||||||
JERRY_ASSERT(!ecma_op_object_has_property (binding_obj_p, name_p));
|
JERRY_ASSERT(!ecma_op_object_has_property (binding_obj_p, name_p));
|
||||||
|
|
||||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||||
{
|
{
|
||||||
prop_desc.is_value_defined = true;
|
prop_desc.is_value_defined = true;
|
||||||
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
|
|
||||||
prop_desc.is_writable_defined = true;
|
prop_desc.is_writable_defined = true;
|
||||||
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
|
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
|
||||||
|
|
||||||
prop_desc.is_enumerable_defined = true;
|
prop_desc.is_enumerable_defined = true;
|
||||||
prop_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
|
prop_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
|
||||||
|
|
||||||
prop_desc.is_configurable_defined = true;
|
prop_desc.is_configurable_defined = true;
|
||||||
prop_desc.configurable = is_deletable ? ECMA_PROPERTY_CONFIGURABLE
|
prop_desc.configurable = is_deletable ? ECMA_PROPERTY_CONFIGURABLE : ECMA_PROPERTY_NOT_CONFIGURABLE;
|
||||||
: ECMA_PROPERTY_NOT_CONFIGURABLE;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ecma_completion_value_t completion = ecma_op_object_define_own_property (binding_obj_p,
|
ecma_completion_value_t completion = ecma_op_object_define_own_property (binding_obj_p,
|
||||||
name_p,
|
name_p,
|
||||||
@@ -154,12 +158,12 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
|
|||||||
true);
|
true);
|
||||||
|
|
||||||
if (!(ecma_is_completion_value_normal_true (completion)
|
if (!(ecma_is_completion_value_normal_true (completion)
|
||||||
|| ecma_is_completion_value_normal_false (completion)))
|
|| ecma_is_completion_value_normal_false (completion)))
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
|
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
|
||||||
|
|
||||||
return completion;
|
return completion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +180,9 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p, /**< argument N */
|
const ecma_char_t *name_p, /**< argument N */
|
||||||
ecma_value_t value, /**< argument V */
|
ecma_value_t value, /**< argument V */
|
||||||
bool is_strict) /**< argument S */
|
bool is_strict) /**< argument S */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||||
JERRY_ASSERT(name_p != NULL);
|
JERRY_ASSERT(name_p != NULL);
|
||||||
@@ -192,16 +196,16 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
|
|||||||
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
|
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
|
||||||
|
|
||||||
if (property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE)
|
if (property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE)
|
||||||
{
|
{
|
||||||
ecma_free_value (property_p->u.named_data_property.value, false);
|
ecma_free_value (property_p->u.named_data_property.value, false);
|
||||||
property_p->u.named_data_property.value = ecma_copy_value (value, false);
|
property_p->u.named_data_property.value = ecma_copy_value (value, false);
|
||||||
|
|
||||||
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
|
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
|
||||||
}
|
}
|
||||||
else if (is_strict)
|
else if (is_strict)
|
||||||
{
|
{
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -214,12 +218,12 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
|
|||||||
value,
|
value,
|
||||||
is_strict);
|
is_strict);
|
||||||
if (!(ecma_is_completion_value_normal_true (completion)
|
if (!(ecma_is_completion_value_normal_true (completion)
|
||||||
|| ecma_is_completion_value_normal_false (completion)))
|
|| ecma_is_completion_value_normal_false (completion)))
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
|
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
|
||||||
|
|
||||||
return completion;
|
return completion;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -238,8 +242,8 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p, /**< argument N */
|
const ecma_char_t *name_p, /**< argument N */
|
||||||
bool is_strict) /**< argument S */
|
bool is_strict) /**< argument S */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||||
JERRY_ASSERT(name_p != NULL);
|
JERRY_ASSERT(name_p != NULL);
|
||||||
@@ -281,16 +285,16 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
bool has_prop = ecma_op_object_has_property (binding_obj_p, name_p);
|
bool has_prop = ecma_op_object_has_property (binding_obj_p, name_p);
|
||||||
|
|
||||||
if (!has_prop)
|
if (!has_prop)
|
||||||
|
{
|
||||||
|
if (is_strict)
|
||||||
{
|
{
|
||||||
if (is_strict)
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
||||||
{
|
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ecma_op_object_get (binding_obj_p, name_p);
|
return ecma_op_object_get (binding_obj_p, name_p);
|
||||||
}
|
}
|
||||||
@@ -310,7 +314,7 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
*/
|
*/
|
||||||
ecma_completion_value_t
|
ecma_completion_value_t
|
||||||
ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p) /**< argument N */
|
const ecma_char_t *name_p) /**< argument N */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||||
JERRY_ASSERT(name_p != NULL);
|
JERRY_ASSERT(name_p != NULL);
|
||||||
@@ -318,32 +322,32 @@ ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
||||||
{
|
{
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||||
{
|
{
|
||||||
ecma_property_t *prop_p = ecma_find_named_property (lex_env_p, name_p);
|
ecma_property_t *prop_p = ecma_find_named_property (lex_env_p, name_p);
|
||||||
ecma_simple_value_t ret_val;
|
ecma_simple_value_t ret_val;
|
||||||
|
|
||||||
if (prop_p == NULL)
|
if (prop_p == NULL)
|
||||||
|
{
|
||||||
|
ret_val = ECMA_SIMPLE_VALUE_TRUE;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||||
|
|
||||||
|
if (prop_p->u.named_data_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||||
{
|
{
|
||||||
ret_val = ECMA_SIMPLE_VALUE_TRUE;
|
ret_val = ECMA_SIMPLE_VALUE_FALSE;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
|
ecma_delete_property (lex_env_p, prop_p);
|
||||||
|
|
||||||
if (prop_p->u.named_data_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
ret_val = ECMA_SIMPLE_VALUE_TRUE;
|
||||||
{
|
|
||||||
ret_val = ECMA_SIMPLE_VALUE_FALSE;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
ecma_delete_property (lex_env_p, prop_p);
|
|
||||||
|
|
||||||
ret_val = ECMA_SIMPLE_VALUE_TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
|
||||||
ecma_make_simple_value (ret_val),
|
|
||||||
ECMA_TARGET_ID_RESERVED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
|
ecma_make_simple_value (ret_val),
|
||||||
|
ECMA_TARGET_ID_RESERVED);
|
||||||
|
}
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||||
{
|
{
|
||||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||||
@@ -371,9 +375,9 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
|
|||||||
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
||||||
{
|
{
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
}
|
}
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||||
{
|
{
|
||||||
ecma_property_t *provide_this_prop_p = ecma_get_internal_property (lex_env_p,
|
ecma_property_t *provide_this_prop_p = ecma_get_internal_property (lex_env_p,
|
||||||
@@ -382,18 +386,18 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
|
|||||||
bool provide_this = provide_this_prop_p->u.internal_property.value;
|
bool provide_this = provide_this_prop_p->u.internal_property.value;
|
||||||
|
|
||||||
if (provide_this)
|
if (provide_this)
|
||||||
{
|
{
|
||||||
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
|
||||||
ecma_ref_object (binding_obj_p);
|
ecma_ref_object (binding_obj_p);
|
||||||
|
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_make_object_value (binding_obj_p),
|
ecma_make_object_value (binding_obj_p),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,31 +411,31 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p) /**< argument N */
|
const ecma_char_t *name_p) /**< argument N */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||||
|
|
||||||
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
||||||
{
|
{
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(ecma_is_completion_value_normal_false (ecma_op_has_binding (lex_env_p, name_p)));
|
JERRY_ASSERT(ecma_is_completion_value_normal_false (ecma_op_has_binding (lex_env_p, name_p)));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Warning:
|
* Warning:
|
||||||
* Whether immutable bindings are deletable seems not to be defined by ECMA v5.
|
* Whether immutable bindings are deletable seems not to be defined by ECMA v5.
|
||||||
*/
|
*/
|
||||||
ecma_property_t *prop_p = ecma_create_named_data_property (lex_env_p,
|
ecma_property_t *prop_p = ecma_create_named_data_property (lex_env_p,
|
||||||
name_p,
|
name_p,
|
||||||
ECMA_PROPERTY_NOT_WRITABLE,
|
ECMA_PROPERTY_NOT_WRITABLE,
|
||||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||||
|
|
||||||
JERRY_ASSERT(ecma_is_value_undefined (prop_p->u.named_data_property.value));
|
JERRY_ASSERT(ecma_is_value_undefined (prop_p->u.named_data_property.value));
|
||||||
|
|
||||||
prop_p->u.named_data_property.value.value_type = ECMA_TYPE_SIMPLE;
|
prop_p->u.named_data_property.value.value_type = ECMA_TYPE_SIMPLE;
|
||||||
prop_p->u.named_data_property.value.value = ECMA_SIMPLE_VALUE_EMPTY;
|
prop_p->u.named_data_property.value.value = ECMA_SIMPLE_VALUE_EMPTY;
|
||||||
}
|
}
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
@@ -448,27 +452,27 @@ ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environ
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p, /**< argument N */
|
const ecma_char_t *name_p, /**< argument N */
|
||||||
ecma_value_t value) /**< argument V */
|
ecma_value_t value) /**< argument V */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
|
||||||
|
|
||||||
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
|
||||||
{
|
{
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(ecma_is_completion_value_normal_true (ecma_op_has_binding (lex_env_p, name_p)));
|
JERRY_ASSERT(ecma_is_completion_value_normal_true (ecma_op_has_binding (lex_env_p, name_p)));
|
||||||
|
|
||||||
ecma_property_t *prop_p = ecma_get_named_data_property (lex_env_p, name_p);
|
ecma_property_t *prop_p = ecma_get_named_data_property (lex_env_p, name_p);
|
||||||
|
|
||||||
/* The binding must be unitialized immutable binding */
|
/* The binding must be unitialized immutable binding */
|
||||||
JERRY_ASSERT(prop_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE
|
JERRY_ASSERT(prop_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE
|
||||||
&& ecma_is_value_empty (prop_p->u.named_data_property.value));
|
&& ecma_is_value_empty (prop_p->u.named_data_property.value));
|
||||||
|
|
||||||
prop_p->u.named_data_property.value = ecma_copy_value (value, false);
|
prop_p->u.named_data_property.value = ecma_copy_value (value, false);
|
||||||
|
|
||||||
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
|
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
|
||||||
}
|
}
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
|
|||||||
@@ -33,20 +33,14 @@ ecma_get_magic_string (ecma_magic_string_id_t id) /**< magic string id */
|
|||||||
TODO(Support UTF-16);
|
TODO(Support UTF-16);
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case ECMA_MAGIC_STRING_ARGUMENTS:
|
case ECMA_MAGIC_STRING_ARGUMENTS: return (ecma_char_t*) "arguments";
|
||||||
return (ecma_char_t*) "arguments";
|
case ECMA_MAGIC_STRING_EVAL: return (ecma_char_t*) "eval";
|
||||||
case ECMA_MAGIC_STRING_EVAL:
|
case ECMA_MAGIC_STRING_PROTOTYPE: return (ecma_char_t*) "prototype";
|
||||||
return (ecma_char_t*) "eval";
|
case ECMA_MAGIC_STRING_CONSTRUCTOR: return (ecma_char_t*) "constructor";
|
||||||
case ECMA_MAGIC_STRING_PROTOTYPE:
|
case ECMA_MAGIC_STRING_CALLER: return (ecma_char_t*) "caller";
|
||||||
return (ecma_char_t*) "prototype";
|
case ECMA_MAGIC_STRING_UNDEFINED: return (ecma_char_t*) "undefined";
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
} /* ecma_get_magic_string */
|
} /* ecma_get_magic_string */
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
ecma_number_t
|
ecma_number_t
|
||||||
ecma_op_number_add (ecma_number_t left_num, /**< left operand */
|
ecma_op_number_add (ecma_number_t left_num, /**< left operand */
|
||||||
ecma_number_t right_num) /**< right operand */
|
ecma_number_t right_num) /**< right operand */
|
||||||
{
|
{
|
||||||
TODO(Implement according to ECMA);
|
TODO(Implement according to ECMA);
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ ecma_op_number_add (ecma_number_t left_num, /**< left operand */
|
|||||||
*/
|
*/
|
||||||
ecma_number_t
|
ecma_number_t
|
||||||
ecma_op_number_substract (ecma_number_t left_num, /**< left operand */
|
ecma_op_number_substract (ecma_number_t left_num, /**< left operand */
|
||||||
ecma_number_t right_num) /**< right operand */
|
ecma_number_t right_num) /**< right operand */
|
||||||
{
|
{
|
||||||
return ecma_op_number_add (left_num, ecma_op_number_negate (right_num));
|
return ecma_op_number_add (left_num, ecma_op_number_negate (right_num));
|
||||||
} /* ecma_op_number_substract */
|
} /* ecma_op_number_substract */
|
||||||
@@ -67,7 +67,7 @@ ecma_op_number_substract (ecma_number_t left_num, /**< left operand */
|
|||||||
*/
|
*/
|
||||||
ecma_number_t
|
ecma_number_t
|
||||||
ecma_op_number_multiply (ecma_number_t left_num, /**< left operand */
|
ecma_op_number_multiply (ecma_number_t left_num, /**< left operand */
|
||||||
ecma_number_t right_num) /**< right operand */
|
ecma_number_t right_num) /**< right operand */
|
||||||
{
|
{
|
||||||
TODO(Implement according to ECMA);
|
TODO(Implement according to ECMA);
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ ecma_op_number_multiply (ecma_number_t left_num, /**< left operand */
|
|||||||
*/
|
*/
|
||||||
ecma_number_t
|
ecma_number_t
|
||||||
ecma_op_number_divide (ecma_number_t left_num, /**< left operand */
|
ecma_op_number_divide (ecma_number_t left_num, /**< left operand */
|
||||||
ecma_number_t right_num) /**< right operand */
|
ecma_number_t right_num) /**< right operand */
|
||||||
{
|
{
|
||||||
TODO(Implement according to ECMA);
|
TODO(Implement according to ECMA);
|
||||||
|
|
||||||
@@ -101,13 +101,13 @@ ecma_op_number_divide (ecma_number_t left_num, /**< left operand */
|
|||||||
*/
|
*/
|
||||||
ecma_number_t
|
ecma_number_t
|
||||||
ecma_op_number_remainder (ecma_number_t left_num, /**< left operand */
|
ecma_op_number_remainder (ecma_number_t left_num, /**< left operand */
|
||||||
ecma_number_t right_num) /**< right operand */
|
ecma_number_t right_num) /**< right operand */
|
||||||
{
|
{
|
||||||
TODO(Implement according to ECMA);
|
TODO(Implement according to ECMA);
|
||||||
|
|
||||||
ecma_number_t n = left_num, d = right_num;
|
ecma_number_t n = left_num, d = right_num;
|
||||||
|
|
||||||
return (n - d * (ecma_number_t)((int32_t)(n / d)));
|
return (n - d * (ecma_number_t) ((int32_t) (n / d)));
|
||||||
} /* ecma_op_number_remainder */
|
} /* ecma_op_number_remainder */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ static ecma_completion_value_t
|
|||||||
ecma_reject (bool is_throw) /**< Throw flag */
|
ecma_reject (bool is_throw) /**< Throw flag */
|
||||||
{
|
{
|
||||||
if (is_throw)
|
if (is_throw)
|
||||||
{
|
{
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||||
}
|
}
|
||||||
} /* ecma_reject */
|
} /* ecma_reject */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,35 +72,35 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
|
|||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if (prop_p == NULL)
|
if (prop_p == NULL)
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
if (prop_p->type == ECMA_PROPERTY_NAMEDDATA)
|
if (prop_p->type == ECMA_PROPERTY_NAMEDDATA)
|
||||||
{
|
{
|
||||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||||
ecma_copy_value (prop_p->u.named_data_property.value, true),
|
ecma_copy_value (prop_p->u.named_data_property.value, true),
|
||||||
ECMA_TARGET_ID_RESERVED);
|
ECMA_TARGET_ID_RESERVED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 4.
|
// 4.
|
||||||
ecma_object_t *getter = ECMA_GET_POINTER(prop_p->u.named_accessor_property.get_p);
|
ecma_object_t *getter = ECMA_GET_POINTER(prop_p->u.named_accessor_property.get_p);
|
||||||
|
|
||||||
// 5.
|
// 5.
|
||||||
if (getter == NULL)
|
if (getter == NULL)
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Return result of O.[[Call]];
|
|
||||||
*/
|
|
||||||
JERRY_UNIMPLEMENTED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Return result of O.[[Call]];
|
||||||
|
*/
|
||||||
|
JERRY_UNIMPLEMENTED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
} /* ecma_op_object_get */
|
} /* ecma_op_object_get */
|
||||||
@@ -157,22 +157,22 @@ ecma_op_object_get_property (ecma_object_t *obj_p, /**< the object */
|
|||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if (prop_p != NULL)
|
if (prop_p != NULL)
|
||||||
{
|
{
|
||||||
return prop_p;
|
return prop_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
ecma_object_t *prototype_p = ECMA_GET_POINTER(obj_p->u.object.prototype_object_p);
|
ecma_object_t *prototype_p = ECMA_GET_POINTER(obj_p->u.object.prototype_object_p);
|
||||||
|
|
||||||
// 4., 5.
|
// 4., 5.
|
||||||
if (prototype_p != NULL)
|
if (prototype_p != NULL)
|
||||||
{
|
{
|
||||||
return ecma_op_object_get_property (prototype_p, property_name_p);
|
return ecma_op_object_get_property (prototype_p, property_name_p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} /* ecma_op_object_get_property */
|
} /* ecma_op_object_get_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,85 +195,85 @@ ecma_op_object_put (ecma_object_t *obj_p, /**< the object */
|
|||||||
|
|
||||||
// 1.
|
// 1.
|
||||||
if (!ecma_op_object_can_put (obj_p, property_name_p))
|
if (!ecma_op_object_can_put (obj_p, property_name_p))
|
||||||
|
{
|
||||||
|
if (is_throw)
|
||||||
{
|
{
|
||||||
if (is_throw)
|
// a.
|
||||||
{
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
// a.
|
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// b.
|
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// b.
|
||||||
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
ecma_property_t *own_desc_p = ecma_op_object_get_own_property (obj_p, property_name_p);
|
ecma_property_t *own_desc_p = ecma_op_object_get_own_property (obj_p, property_name_p);
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
if (own_desc_p != NULL
|
if (own_desc_p != NULL
|
||||||
&& own_desc_p->type == ECMA_PROPERTY_NAMEDDATA)
|
&& own_desc_p->type == ECMA_PROPERTY_NAMEDDATA)
|
||||||
|
{
|
||||||
|
// a.
|
||||||
|
ecma_property_descriptor_t value_desc = ecma_make_empty_property_descriptor ();
|
||||||
{
|
{
|
||||||
// a.
|
value_desc.is_value_defined = true;
|
||||||
ecma_property_descriptor_t value_desc = ecma_make_empty_property_descriptor ();
|
value_desc.value = value;
|
||||||
{
|
|
||||||
value_desc.is_value_defined = true;
|
|
||||||
value_desc.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// b., c.
|
|
||||||
return ecma_op_object_define_own_property (obj_p,
|
|
||||||
property_name_p,
|
|
||||||
value_desc,
|
|
||||||
is_throw);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// b., c.
|
||||||
|
return ecma_op_object_define_own_property (obj_p,
|
||||||
|
property_name_p,
|
||||||
|
value_desc,
|
||||||
|
is_throw);
|
||||||
|
}
|
||||||
|
|
||||||
// 4.
|
// 4.
|
||||||
ecma_property_t *desc_p = ecma_op_object_get_property (obj_p, property_name_p);
|
ecma_property_t *desc_p = ecma_op_object_get_property (obj_p, property_name_p);
|
||||||
|
|
||||||
// 5.
|
// 5.
|
||||||
if (desc_p != NULL
|
if (desc_p != NULL
|
||||||
&& desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
&& desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
||||||
{
|
{
|
||||||
// a.
|
// a.
|
||||||
ecma_object_t *setter_p = ECMA_GET_POINTER(desc_p->u.named_accessor_property.set_p);
|
ecma_object_t *setter_p = ECMA_GET_POINTER(desc_p->u.named_accessor_property.set_p);
|
||||||
|
|
||||||
JERRY_ASSERT(setter_p != NULL);
|
JERRY_ASSERT(setter_p != NULL);
|
||||||
|
|
||||||
// b.
|
// b.
|
||||||
/*
|
/*
|
||||||
* setter_p->[[Call]](obj_p, value);
|
* setter_p->[[Call]](obj_p, value);
|
||||||
*/
|
*/
|
||||||
JERRY_UNIMPLEMENTED();
|
JERRY_UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
// 6.
|
||||||
|
|
||||||
|
// a.
|
||||||
|
ecma_property_descriptor_t new_desc = ecma_make_empty_property_descriptor ();
|
||||||
{
|
{
|
||||||
// 6.
|
new_desc.is_value_defined = true;
|
||||||
|
new_desc.value = value;
|
||||||
|
|
||||||
// a.
|
new_desc.is_writable_defined = true;
|
||||||
ecma_property_descriptor_t new_desc = ecma_make_empty_property_descriptor ();
|
new_desc.writable = ECMA_PROPERTY_WRITABLE;
|
||||||
{
|
|
||||||
new_desc.is_value_defined = true;
|
|
||||||
new_desc.value = value;
|
|
||||||
|
|
||||||
new_desc.is_writable_defined = true;
|
new_desc.is_enumerable_defined = true;
|
||||||
new_desc.writable = ECMA_PROPERTY_WRITABLE;
|
new_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
|
||||||
|
|
||||||
new_desc.is_enumerable_defined = true;
|
new_desc.is_configurable_defined = true;
|
||||||
new_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
|
new_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
|
||||||
|
|
||||||
new_desc.is_configurable_defined = true;
|
|
||||||
new_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// b.
|
|
||||||
return ecma_op_object_define_own_property (obj_p,
|
|
||||||
property_name_p,
|
|
||||||
new_desc,
|
|
||||||
is_throw);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// b.
|
||||||
|
return ecma_op_object_define_own_property (obj_p,
|
||||||
|
property_name_p,
|
||||||
|
new_desc,
|
||||||
|
is_throw);
|
||||||
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
} /* ecma_op_object_put */
|
} /* ecma_op_object_put */
|
||||||
|
|
||||||
@@ -304,79 +304,79 @@ ecma_op_object_can_put (ecma_object_t *obj_p, /**< the object */
|
|||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if (prop_p != NULL)
|
if (prop_p != NULL)
|
||||||
|
{
|
||||||
|
// a.
|
||||||
|
if (prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
||||||
{
|
{
|
||||||
// a.
|
ecma_object_t *setter_p = ECMA_GET_POINTER(prop_p->u.named_accessor_property.set_p);
|
||||||
if (prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
|
||||||
{
|
|
||||||
ecma_object_t *setter_p = ECMA_GET_POINTER(prop_p->u.named_accessor_property.set_p);
|
|
||||||
|
|
||||||
// i.
|
// i.
|
||||||
if (setter_p == NULL)
|
if (setter_p == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ii.
|
// ii.
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// b.
|
|
||||||
|
|
||||||
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
|
|
||||||
|
|
||||||
return (prop_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// b.
|
||||||
|
|
||||||
|
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||||
|
|
||||||
|
return (prop_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
ecma_object_t *proto_p = ECMA_GET_POINTER(obj_p->u.object.prototype_object_p);
|
ecma_object_t *proto_p = ECMA_GET_POINTER(obj_p->u.object.prototype_object_p);
|
||||||
|
|
||||||
// 4.
|
// 4.
|
||||||
if (proto_p == NULL)
|
if (proto_p == NULL)
|
||||||
{
|
{
|
||||||
return obj_p->u.object.extensible;
|
return obj_p->u.object.extensible;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5.
|
// 5.
|
||||||
ecma_property_t *inherited_p = ecma_op_object_get_property (proto_p, property_name_p);
|
ecma_property_t *inherited_p = ecma_op_object_get_property (proto_p, property_name_p);
|
||||||
|
|
||||||
// 6.
|
// 6.
|
||||||
if (inherited_p == NULL)
|
if (inherited_p == NULL)
|
||||||
{
|
{
|
||||||
return obj_p->u.object.extensible;
|
return obj_p->u.object.extensible;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.
|
// 7.
|
||||||
if (inherited_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
if (inherited_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
||||||
|
{
|
||||||
|
ecma_object_t *setter_p = ECMA_GET_POINTER(inherited_p->u.named_accessor_property.set_p);
|
||||||
|
|
||||||
|
// a.
|
||||||
|
if (setter_p == NULL)
|
||||||
{
|
{
|
||||||
ecma_object_t *setter_p = ECMA_GET_POINTER(inherited_p->u.named_accessor_property.set_p);
|
return false;
|
||||||
|
|
||||||
// a.
|
|
||||||
if (setter_p == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// b.
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// b.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 8.
|
// 8.
|
||||||
JERRY_ASSERT(inherited_p->type == ECMA_PROPERTY_NAMEDDATA);
|
JERRY_ASSERT(inherited_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||||
|
|
||||||
// a.
|
// a.
|
||||||
if (!obj_p->u.object.extensible)
|
if (!obj_p->u.object.extensible)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// b.
|
|
||||||
return (inherited_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// b.
|
||||||
|
return (inherited_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
} /* ecma_op_object_can_put */
|
} /* ecma_op_object_can_put */
|
||||||
@@ -436,41 +436,41 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
|
|||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
if (desc_p == NULL)
|
if (desc_p == NULL)
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
bool is_configurable;
|
bool is_configurable;
|
||||||
if (desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
if (desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
|
||||||
{
|
{
|
||||||
is_configurable = desc_p->u.named_accessor_property.configurable;
|
is_configurable = desc_p->u.named_accessor_property.configurable;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(desc_p->type == ECMA_PROPERTY_NAMEDDATA);
|
JERRY_ASSERT(desc_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||||
|
|
||||||
is_configurable = desc_p->u.named_data_property.configurable;
|
is_configurable = desc_p->u.named_data_property.configurable;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_configurable)
|
if (is_configurable)
|
||||||
{
|
{
|
||||||
// a.
|
// a.
|
||||||
ecma_delete_property (obj_p, desc_p);
|
ecma_delete_property (obj_p, desc_p);
|
||||||
|
|
||||||
// b.
|
// b.
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
}
|
}
|
||||||
else if (is_throw)
|
else if (is_throw)
|
||||||
{
|
{
|
||||||
// 4.
|
// 4.
|
||||||
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 5.
|
// 5.
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
JERRY_UNREACHABLE();
|
JERRY_UNREACHABLE();
|
||||||
} /* ecma_op_object_delete */
|
} /* ecma_op_object_delete */
|
||||||
@@ -512,13 +512,13 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
|
|||||||
JERRY_ASSERT(property_name_p != NULL);
|
JERRY_ASSERT(property_name_p != NULL);
|
||||||
|
|
||||||
const bool is_property_desc_generic_descriptor = (!property_desc.is_value_defined
|
const bool is_property_desc_generic_descriptor = (!property_desc.is_value_defined
|
||||||
&& !property_desc.is_writable_defined
|
&& !property_desc.is_writable_defined
|
||||||
&& !property_desc.is_get_defined
|
&& !property_desc.is_get_defined
|
||||||
&& !property_desc.is_set_defined);
|
&& !property_desc.is_set_defined);
|
||||||
const bool is_property_desc_data_descriptor = (property_desc.is_value_defined
|
const bool is_property_desc_data_descriptor = (property_desc.is_value_defined
|
||||||
|| property_desc.is_writable_defined);
|
|| property_desc.is_writable_defined);
|
||||||
const bool is_property_desc_accessor_descriptor = (property_desc.is_get_defined
|
const bool is_property_desc_accessor_descriptor = (property_desc.is_get_defined
|
||||||
|| property_desc.is_set_defined);
|
|| property_desc.is_set_defined);
|
||||||
|
|
||||||
// 1.
|
// 1.
|
||||||
ecma_property_t *current_p = ecma_op_object_get_own_property (obj_p, property_name_p);
|
ecma_property_t *current_p = ecma_op_object_get_own_property (obj_p, property_name_p);
|
||||||
@@ -527,55 +527,55 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
|
|||||||
bool extensible = obj_p->u.object.extensible;
|
bool extensible = obj_p->u.object.extensible;
|
||||||
|
|
||||||
if (current_p == NULL)
|
if (current_p == NULL)
|
||||||
|
{
|
||||||
|
// 3.
|
||||||
|
if (!extensible)
|
||||||
{
|
{
|
||||||
// 3.
|
return ecma_reject (is_throw);
|
||||||
if (!extensible)
|
|
||||||
{
|
|
||||||
return ecma_reject (is_throw);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 4.
|
|
||||||
|
|
||||||
// a.
|
|
||||||
if (is_property_desc_generic_descriptor
|
|
||||||
|| is_property_desc_data_descriptor)
|
|
||||||
{
|
|
||||||
ecma_property_t *new_prop_p = ecma_create_named_data_property (obj_p,
|
|
||||||
property_name_p,
|
|
||||||
property_desc.writable,
|
|
||||||
property_desc.enumerable,
|
|
||||||
property_desc.configurable);
|
|
||||||
|
|
||||||
new_prop_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
|
|
||||||
|
|
||||||
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// b.
|
|
||||||
JERRY_ASSERT(is_property_desc_accessor_descriptor);
|
|
||||||
|
|
||||||
ecma_create_named_accessor_property (obj_p,
|
|
||||||
property_name_p,
|
|
||||||
property_desc.get_p,
|
|
||||||
property_desc.set_p,
|
|
||||||
property_desc.enumerable,
|
|
||||||
property_desc.configurable);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 4.
|
||||||
|
|
||||||
|
// a.
|
||||||
|
if (is_property_desc_generic_descriptor
|
||||||
|
|| is_property_desc_data_descriptor)
|
||||||
|
{
|
||||||
|
ecma_property_t *new_prop_p = ecma_create_named_data_property (obj_p,
|
||||||
|
property_name_p,
|
||||||
|
property_desc.writable,
|
||||||
|
property_desc.enumerable,
|
||||||
|
property_desc.configurable);
|
||||||
|
|
||||||
|
new_prop_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
|
||||||
|
|
||||||
|
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// b.
|
||||||
|
JERRY_ASSERT(is_property_desc_accessor_descriptor);
|
||||||
|
|
||||||
|
ecma_create_named_accessor_property (obj_p,
|
||||||
|
property_name_p,
|
||||||
|
property_desc.get_p,
|
||||||
|
property_desc.set_p,
|
||||||
|
property_desc.enumerable,
|
||||||
|
property_desc.configurable);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 5.
|
// 5.
|
||||||
if (is_property_desc_generic_descriptor
|
if (is_property_desc_generic_descriptor
|
||||||
&& !property_desc.is_enumerable_defined
|
&& !property_desc.is_enumerable_defined
|
||||||
&& !property_desc.is_configurable_defined)
|
&& !property_desc.is_configurable_defined)
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6.
|
// 6.
|
||||||
const bool is_current_data_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDDATA);
|
const bool is_current_data_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||||
@@ -583,226 +583,226 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
|
|||||||
|
|
||||||
const ecma_property_enumerable_value_t current_enumerable =
|
const ecma_property_enumerable_value_t current_enumerable =
|
||||||
is_current_data_descriptor ? current_p->u.named_data_property.enumerable
|
is_current_data_descriptor ? current_p->u.named_data_property.enumerable
|
||||||
: current_p->u.named_accessor_property.enumerable;
|
: current_p->u.named_accessor_property.enumerable;
|
||||||
const ecma_property_configurable_value_t current_configurable =
|
const ecma_property_configurable_value_t current_configurable =
|
||||||
is_current_data_descriptor ? current_p->u.named_data_property.configurable
|
is_current_data_descriptor ? current_p->u.named_data_property.configurable
|
||||||
: current_p->u.named_accessor_property.configurable;
|
: current_p->u.named_accessor_property.configurable;
|
||||||
|
|
||||||
JERRY_ASSERT(is_current_data_descriptor || is_current_accessor_descriptor);
|
JERRY_ASSERT(is_current_data_descriptor || is_current_accessor_descriptor);
|
||||||
|
|
||||||
bool is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = true;
|
bool is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = true;
|
||||||
if (property_desc.is_value_defined)
|
if (property_desc.is_value_defined)
|
||||||
|
{
|
||||||
|
if (!is_current_data_descriptor
|
||||||
|
|| !ecma_op_same_value (property_desc.value,
|
||||||
|
current_p->u.named_data_property.value))
|
||||||
{
|
{
|
||||||
if (!is_current_data_descriptor
|
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
||||||
|| !ecma_op_same_value (property_desc.value,
|
|
||||||
current_p->u.named_data_property.value))
|
|
||||||
{
|
|
||||||
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property_desc.is_writable_defined)
|
if (property_desc.is_writable_defined)
|
||||||
|
{
|
||||||
|
if (!is_current_data_descriptor
|
||||||
|
|| property_desc.writable != current_p->u.named_data_property.writable)
|
||||||
{
|
{
|
||||||
if (!is_current_data_descriptor
|
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
||||||
|| property_desc.writable != current_p->u.named_data_property.writable)
|
|
||||||
{
|
|
||||||
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property_desc.is_get_defined)
|
if (property_desc.is_get_defined)
|
||||||
|
{
|
||||||
|
if (!is_current_accessor_descriptor
|
||||||
|
|| property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
|
||||||
{
|
{
|
||||||
if (!is_current_accessor_descriptor
|
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
||||||
|| property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
|
|
||||||
{
|
|
||||||
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property_desc.is_set_defined)
|
if (property_desc.is_set_defined)
|
||||||
|
{
|
||||||
|
if (!is_current_accessor_descriptor
|
||||||
|
|| property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p))
|
||||||
{
|
{
|
||||||
if (!is_current_accessor_descriptor
|
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
||||||
|| property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p))
|
|
||||||
{
|
|
||||||
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property_desc.is_enumerable_defined)
|
if (property_desc.is_enumerable_defined)
|
||||||
|
{
|
||||||
|
if (property_desc.enumerable != current_enumerable)
|
||||||
{
|
{
|
||||||
if (property_desc.enumerable != current_enumerable)
|
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
||||||
{
|
|
||||||
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property_desc.is_configurable_defined)
|
if (property_desc.is_configurable_defined)
|
||||||
|
{
|
||||||
|
if (property_desc.configurable != current_configurable)
|
||||||
{
|
{
|
||||||
if (property_desc.configurable != current_configurable)
|
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
||||||
{
|
|
||||||
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (is_every_field_in_desc_also_occurs_in_current_desc_with_same_value)
|
if (is_every_field_in_desc_also_occurs_in_current_desc_with_same_value)
|
||||||
{
|
{
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.
|
// 7.
|
||||||
if (current_p->u.named_accessor_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
if (current_p->u.named_accessor_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||||
|
{
|
||||||
|
if (property_desc.configurable == ECMA_PROPERTY_CONFIGURABLE
|
||||||
|
|| (property_desc.is_enumerable_defined
|
||||||
|
&& property_desc.enumerable != current_enumerable))
|
||||||
{
|
{
|
||||||
if (property_desc.configurable == ECMA_PROPERTY_CONFIGURABLE
|
// a., b.
|
||||||
|| (property_desc.is_enumerable_defined
|
return ecma_reject (is_throw);
|
||||||
&& property_desc.enumerable != current_enumerable))
|
|
||||||
{
|
|
||||||
// a., b.
|
|
||||||
return ecma_reject (is_throw);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 8.
|
// 8.
|
||||||
if (is_property_desc_generic_descriptor)
|
if (is_property_desc_generic_descriptor)
|
||||||
{
|
{
|
||||||
// no action required
|
// no action required
|
||||||
}
|
}
|
||||||
else if (is_property_desc_data_descriptor != is_current_data_descriptor)
|
else if (is_property_desc_data_descriptor != is_current_data_descriptor)
|
||||||
|
{
|
||||||
|
// 9.
|
||||||
|
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||||
{
|
{
|
||||||
// 9.
|
// a.
|
||||||
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
return ecma_reject (is_throw);
|
||||||
|
}
|
||||||
|
|
||||||
|
ecma_delete_property (obj_p, current_p);
|
||||||
|
|
||||||
|
if (is_current_data_descriptor)
|
||||||
|
{
|
||||||
|
// b.
|
||||||
|
|
||||||
|
current_p = ecma_create_named_accessor_property (obj_p,
|
||||||
|
property_name_p,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
current_enumerable,
|
||||||
|
current_configurable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// c.
|
||||||
|
|
||||||
|
current_p = ecma_create_named_data_property (obj_p,
|
||||||
|
property_name_p,
|
||||||
|
ECMA_PROPERTY_NOT_WRITABLE,
|
||||||
|
current_enumerable,
|
||||||
|
current_configurable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is_property_desc_data_descriptor && is_current_data_descriptor)
|
||||||
|
{
|
||||||
|
// 10.
|
||||||
|
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||||
|
{
|
||||||
|
// a.
|
||||||
|
if (current_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE)
|
||||||
|
{
|
||||||
|
// i.
|
||||||
|
if (property_desc.writable == ECMA_PROPERTY_WRITABLE)
|
||||||
{
|
{
|
||||||
// a.
|
|
||||||
return ecma_reject (is_throw);
|
return ecma_reject (is_throw);
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_delete_property (obj_p, current_p);
|
// ii.
|
||||||
|
if (property_desc.is_value_defined
|
||||||
if (is_current_data_descriptor)
|
&& !ecma_op_same_value (property_desc.value,
|
||||||
|
current_p->u.named_data_property.value))
|
||||||
{
|
{
|
||||||
// b.
|
return ecma_reject (is_throw);
|
||||||
|
|
||||||
current_p = ecma_create_named_accessor_property (obj_p,
|
|
||||||
property_name_p,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
current_enumerable,
|
|
||||||
current_configurable);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// c.
|
|
||||||
|
|
||||||
current_p = ecma_create_named_data_property (obj_p,
|
|
||||||
property_name_p,
|
|
||||||
ECMA_PROPERTY_NOT_WRITABLE,
|
|
||||||
current_enumerable,
|
|
||||||
current_configurable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (is_property_desc_data_descriptor && is_current_data_descriptor)
|
|
||||||
{
|
|
||||||
// 10.
|
|
||||||
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
|
||||||
{
|
|
||||||
// a.
|
|
||||||
if (current_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE)
|
|
||||||
{
|
|
||||||
// i.
|
|
||||||
if (property_desc.writable == ECMA_PROPERTY_WRITABLE)
|
|
||||||
{
|
|
||||||
return ecma_reject (is_throw);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ii.
|
|
||||||
if (property_desc.is_value_defined
|
|
||||||
&& !ecma_op_same_value (property_desc.value,
|
|
||||||
current_p->u.named_data_property.value))
|
|
||||||
{
|
|
||||||
return ecma_reject (is_throw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
JERRY_ASSERT(is_property_desc_accessor_descriptor && is_current_accessor_descriptor);
|
||||||
|
|
||||||
|
// 11.
|
||||||
|
|
||||||
|
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(is_property_desc_accessor_descriptor && is_current_accessor_descriptor);
|
// a.
|
||||||
|
|
||||||
// 11.
|
if ((property_desc.is_get_defined
|
||||||
|
&& property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
|
||||||
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
|
|| (property_desc.is_set_defined
|
||||||
{
|
&& property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p)))
|
||||||
// a.
|
{
|
||||||
|
// i., ii.
|
||||||
if ((property_desc.is_get_defined
|
return ecma_reject (is_throw);
|
||||||
&& property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
|
}
|
||||||
|| (property_desc.is_set_defined
|
|
||||||
&& property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p)))
|
|
||||||
{
|
|
||||||
// i., ii.
|
|
||||||
return ecma_reject (is_throw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 12.
|
// 12.
|
||||||
if (property_desc.is_value_defined)
|
if (property_desc.is_value_defined)
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(is_current_data_descriptor);
|
JERRY_ASSERT(is_current_data_descriptor);
|
||||||
|
|
||||||
ecma_free_value (current_p->u.named_data_property.value, false);
|
ecma_free_value (current_p->u.named_data_property.value, false);
|
||||||
current_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
|
current_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
|
||||||
|
|
||||||
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
|
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_desc.is_writable_defined)
|
if (property_desc.is_writable_defined)
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(is_current_data_descriptor);
|
JERRY_ASSERT(is_current_data_descriptor);
|
||||||
|
|
||||||
current_p->u.named_data_property.writable = property_desc.writable;
|
current_p->u.named_data_property.writable = property_desc.writable;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_desc.is_get_defined)
|
if (property_desc.is_get_defined)
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(is_current_accessor_descriptor);
|
JERRY_ASSERT(is_current_accessor_descriptor);
|
||||||
|
|
||||||
ECMA_SET_POINTER(current_p->u.named_accessor_property.get_p, property_desc.get_p);
|
ECMA_SET_POINTER(current_p->u.named_accessor_property.get_p, property_desc.get_p);
|
||||||
|
|
||||||
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.get_p);
|
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.get_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_desc.is_set_defined)
|
if (property_desc.is_set_defined)
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(is_current_accessor_descriptor);
|
JERRY_ASSERT(is_current_accessor_descriptor);
|
||||||
|
|
||||||
ECMA_SET_POINTER(current_p->u.named_accessor_property.set_p, property_desc.set_p);
|
ECMA_SET_POINTER(current_p->u.named_accessor_property.set_p, property_desc.set_p);
|
||||||
|
|
||||||
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.set_p);
|
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.set_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property_desc.is_enumerable_defined)
|
if (property_desc.is_enumerable_defined)
|
||||||
|
{
|
||||||
|
if (is_current_data_descriptor)
|
||||||
{
|
{
|
||||||
if (is_current_data_descriptor)
|
current_p->u.named_data_property.enumerable = property_desc.enumerable;
|
||||||
{
|
|
||||||
current_p->u.named_data_property.enumerable = property_desc.enumerable;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
current_p->u.named_accessor_property.enumerable = property_desc.enumerable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current_p->u.named_accessor_property.enumerable = property_desc.enumerable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (property_desc.is_configurable_defined)
|
if (property_desc.is_configurable_defined)
|
||||||
|
{
|
||||||
|
if (is_current_data_descriptor)
|
||||||
{
|
{
|
||||||
if (is_current_data_descriptor)
|
current_p->u.named_data_property.configurable = property_desc.configurable;
|
||||||
{
|
|
||||||
current_p->u.named_data_property.configurable = property_desc.configurable;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
current_p->u.named_accessor_property.configurable = property_desc.configurable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current_p->u.named_accessor_property.configurable = property_desc.configurable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
} /* ecma_op_object_define_own_property */
|
} /* ecma_op_object_define_own_property */
|
||||||
|
|||||||
@@ -41,8 +41,8 @@
|
|||||||
*/
|
*/
|
||||||
ecma_reference_t
|
ecma_reference_t
|
||||||
ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environment */
|
ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environment */
|
||||||
const ecma_char_t *name_p, /**< identifier's name */
|
const ecma_char_t *name_p, /**< identifier's name */
|
||||||
bool is_strict) /**< strict reference flag */
|
bool is_strict) /**< strict reference flag */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(lex_env_p != NULL);
|
JERRY_ASSERT(lex_env_p != NULL);
|
||||||
|
|
||||||
@@ -56,8 +56,8 @@ ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environ
|
|||||||
if (ecma_is_completion_value_normal_true (completion_value))
|
if (ecma_is_completion_value_normal_true (completion_value))
|
||||||
{
|
{
|
||||||
return ecma_make_reference (ecma_make_object_value (lex_env_iter_p),
|
return ecma_make_reference (ecma_make_object_value (lex_env_iter_p),
|
||||||
name_p,
|
name_p,
|
||||||
is_strict);
|
is_strict);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
JERRY_ASSERT(ecma_is_completion_value_normal_false (completion_value));
|
JERRY_ASSERT(ecma_is_completion_value_normal_false (completion_value));
|
||||||
@@ -67,8 +67,8 @@ ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environ
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ecma_make_reference (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
|
return ecma_make_reference (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
|
||||||
name_p,
|
name_p,
|
||||||
is_strict);
|
is_strict);
|
||||||
} /* ecma_op_get_identifier_reference */
|
} /* ecma_op_get_identifier_reference */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,12 +83,15 @@ ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environ
|
|||||||
*/
|
*/
|
||||||
ecma_reference_t
|
ecma_reference_t
|
||||||
ecma_make_reference (ecma_value_t base, /**< base value */
|
ecma_make_reference (ecma_value_t base, /**< base value */
|
||||||
const ecma_char_t *name_p, /**< referenced name */
|
const ecma_char_t *name_p, /**< referenced name */
|
||||||
bool is_strict) /**< strict reference flag */
|
bool is_strict) /**< strict reference flag */
|
||||||
{
|
{
|
||||||
ecma_reference_t ref = (ecma_reference_t) { .base = ecma_copy_value (base, true),
|
ecma_reference_t ref = (ecma_reference_t)
|
||||||
.referenced_name_p = name_p,
|
{
|
||||||
.is_strict = is_strict };
|
.base = ecma_copy_value (base, true),
|
||||||
|
.referenced_name_p = name_p,
|
||||||
|
.is_strict = is_strict
|
||||||
|
};
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
} /* ecma_make_reference */
|
} /* ecma_make_reference */
|
||||||
|
|||||||
Reference in New Issue
Block a user