Add ES2015 feature: ArrayBuffer (#1467)
This patch implements ArrayBuffer and ArrayBuffer.prototype built-in objects. JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
This commit is contained in:
committed by
Zoltan Herczeg
parent
eccfc1849e
commit
29d058cec4
@@ -424,14 +424,14 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
||||
case LIT_MAGIC_STRING_STRING_UL:
|
||||
case LIT_MAGIC_STRING_NUMBER_UL:
|
||||
{
|
||||
ecma_free_value (ext_object_p->u.class_prop.value);
|
||||
ecma_free_value (ext_object_p->u.class_prop.u.value);
|
||||
break;
|
||||
}
|
||||
|
||||
case LIT_MAGIC_STRING_DATE_UL:
|
||||
{
|
||||
ecma_number_t *num_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t,
|
||||
ext_object_p->u.class_prop.value);
|
||||
ext_object_p->u.class_prop.u.value);
|
||||
ecma_dealloc_number (num_p);
|
||||
break;
|
||||
}
|
||||
@@ -439,14 +439,22 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
||||
case LIT_MAGIC_STRING_REGEXP_UL:
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.class_prop.value);
|
||||
ext_object_p->u.class_prop.u.value);
|
||||
if (bytecode_p != NULL)
|
||||
{
|
||||
ecma_bytecode_deref (bytecode_p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_DISABLE_ARRAYBUFFER_BUILTIN
|
||||
case LIT_MAGIC_STRING_ARRAY_BUFFER_UL:
|
||||
{
|
||||
ecma_length_t arraybuffer_length = ext_object_p->u.class_prop.u.length;
|
||||
size_t size = sizeof (ecma_extended_object_t) + arraybuffer_length;
|
||||
ecma_dealloc_extended_object ((ecma_extended_object_t *) object_p, size);
|
||||
return;
|
||||
}
|
||||
#endif /* CONFIG_DISABLE_ARRAYBUFFER_BUILTIN */
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
|
||||
@@ -626,7 +626,14 @@ typedef struct
|
||||
struct
|
||||
{
|
||||
uint16_t class_id; /**< class id of the object */
|
||||
ecma_value_t value; /**< value of the object (e.g. boolean, number, string, etc.) */
|
||||
/*
|
||||
* Description of extra fields. These extra fields depends on the class_id.
|
||||
*/
|
||||
union
|
||||
{
|
||||
ecma_value_t value; /**< value of the object (e.g. boolean, number, string, etc.) */
|
||||
uint32_t length; /**< length related property (e.g. length of ArrayBuffer) */
|
||||
} u;
|
||||
} class_prop;
|
||||
|
||||
/*
|
||||
|
||||
@@ -630,7 +630,9 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
ecma_object_t *get_p, /**< getter */
|
||||
ecma_object_t *set_p, /**< setter */
|
||||
uint8_t prop_attributes) /**< property attributes */
|
||||
uint8_t prop_attributes, /**< property attributes */
|
||||
ecma_property_t **out_prop_p) /**< [out] the property is also returned
|
||||
* if this field is non-NULL */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
@@ -650,7 +652,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_POINTER (value.getter_setter_pair.setter_p, set_p);
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
|
||||
return ecma_create_property (object_p, name_p, type_and_flags, value, NULL);
|
||||
return ecma_create_property (object_p, name_p, type_and_flags, value, out_prop_p);
|
||||
} /* ecma_create_named_accessor_property */
|
||||
|
||||
/**
|
||||
|
||||
@@ -282,7 +282,8 @@ extern ecma_value_t *ecma_get_internal_property (ecma_object_t *, ecma_internal_
|
||||
extern ecma_property_value_t *
|
||||
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, uint8_t, ecma_property_t **);
|
||||
extern ecma_property_value_t *
|
||||
ecma_create_named_accessor_property (ecma_object_t *, ecma_string_t *, ecma_object_t *, ecma_object_t *, uint8_t);
|
||||
ecma_create_named_accessor_property (ecma_object_t *, ecma_string_t *, ecma_object_t *,
|
||||
ecma_object_t *, uint8_t, ecma_property_t **);
|
||||
extern ecma_property_t *
|
||||
ecma_find_named_property (ecma_object_t *, ecma_string_t *);
|
||||
extern ecma_property_value_t *
|
||||
|
||||
Reference in New Issue
Block a user