diff --git a/src/libecmaobjects/ecma-globals.h b/src/libecmaobjects/ecma-globals.h index 82c361bff..b1d98b3c6 100644 --- a/src/libecmaobjects/ecma-globals.h +++ b/src/libecmaobjects/ecma-globals.h @@ -269,7 +269,7 @@ typedef struct { /** Compressed pointer to next object in the list of objects, queued for GC (if !is_object_valid) */ unsigned int next_queued_for_gc : ECMA_POINTER_FIELD_WIDTH; } __packed u; -} ecma_gc_info_t; +} __packed ecma_gc_info_t; /** * Types of lexical environments @@ -279,6 +279,20 @@ typedef enum { ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */ } ecma_lexical_environment_type_t; +/** + * Internal object types + */ +typedef enum { + ECMA_GENERAL_OBJECT, /**< all objects that are not String (15.5), Function (15.3), + Arguments (10.6), Array (15.4) specification-defined objects + and not host objects */ + ECMA_STRING_OBJECT, /**< String objects (15.5) */ + ECMA_FUNCTION_OBJECT, /**< Function objects (15.3) */ + ECMA_ARGUMENTS_OBJECT, /**< Arguments object (10.6) */ + ECMA_ARRAY_OBJECT, /**< Array object (15.4) */ + ECMA_HOST_OBJECT /**< Host object */ +} ecma_object_type_t; + /** * Description of ECMA-object or lexical environment * (depending on is_lexical_environment). @@ -303,6 +317,9 @@ typedef struct ecma_object_t { /** Attribute 'Extensible' */ unsigned int extensible : 1; + /** Implementation internal object type (ecma_object_type_t) */ + unsigned int object_type : 3; + /** Compressed pointer to prototype object (ecma_object_t) */ unsigned int prototype_object_p : ECMA_POINTER_FIELD_WIDTH; } __packed object; @@ -324,7 +341,7 @@ typedef struct ecma_object_t { /** GC's information */ ecma_gc_info_t GCInfo; -} ecma_object_t; +} __packed ecma_object_t; /** * Description of an ecma-character diff --git a/src/libecmaoperations/ecma-conversion.c b/src/libecmaoperations/ecma-conversion.c index b42a90f0b..6ddcd6b6f 100644 --- a/src/libecmaoperations/ecma-conversion.c +++ b/src/libecmaoperations/ecma-conversion.c @@ -92,7 +92,7 @@ ecma_op_check_object_coercible( ecma_value_t value) /**< ecma-value */ */ ecma_completion_value_t ecma_op_to_primitive( ecma_value_t value, /**< ecma-value */ - ecma_preferred_type_hint preferred_type) /**< preferred type hint */ + ecma_preferred_type_hint_t preferred_type) /**< preferred type hint */ { switch ( (ecma_type_t)value.value_type ) { diff --git a/src/libecmaoperations/ecma-conversion.h b/src/libecmaoperations/ecma-conversion.h index 1fbc67b01..6a85163fd 100644 --- a/src/libecmaoperations/ecma-conversion.h +++ b/src/libecmaoperations/ecma-conversion.h @@ -38,10 +38,10 @@ typedef enum ECMA_PREFERRED_TYPE_BOOLEAN, /**< Boolean */ ECMA_PREFERRED_TYPE_NUMBER, /**< Number */ ECMA_PREFERRED_TYPE_STRING /**< String */ -} ecma_preferred_type_hint; +} ecma_preferred_type_hint_t; extern ecma_completion_value_t ecma_op_check_object_coercible( ecma_value_t value); -extern ecma_completion_value_t ecma_op_to_primitive( ecma_value_t value, ecma_preferred_type_hint preferred_type); +extern ecma_completion_value_t ecma_op_to_primitive( ecma_value_t value, ecma_preferred_type_hint_t preferred_type); extern ecma_completion_value_t ecma_op_to_boolean( ecma_value_t value); extern ecma_completion_value_t ecma_op_to_number( ecma_value_t value); extern ecma_completion_value_t ecma_op_to_object( ecma_value_t value); diff --git a/src/libecmaoperations/ecma-objects-properties.c b/src/libecmaoperations/ecma-objects-properties.c new file mode 100644 index 000000000..21b17175c --- /dev/null +++ b/src/libecmaoperations/ecma-objects-properties.c @@ -0,0 +1,178 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ecma-globals.h" +#include "ecma-objects-properties.h" + +/** \addtogroup ecma ---TODO--- + * @{ + * + * \addtogroup ecmaobjectsinternalops ECMA objects' operations + * @{ + */ + +/** + * [[Get]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return completion value + * Returned value must be freed with ecma_free_completion_value + */ +ecma_completion_value_t +ecma_op_object_get( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p) /**< property name */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p); +} /* ecma_op_object_get */ + +/** + * [[GetOwnProperty]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return pointer to a property - if it exists, + * NULL - otherwise. + */ +ecma_property_t* +ecma_op_object_get_own_property( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p) /**< property name */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p); +} /* ecma_op_object_get_own_property */ + +/** + * [[GetProperty]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return pointer to a property - if it exists, + * NULL - otherwise. + */ +ecma_property_t* +ecma_op_object_get_property( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p) /**< property name */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p); +} /* ecma_op_object_get_property */ + +/** + * [[Put]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return completion value + * Returned value must be freed with ecma_free_completion_value + */ +ecma_completion_value_t +ecma_op_object_put( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p, /**< property name */ + ecma_value_t value, /**< ecma-value */ + bool is_throw) /**< flag that controls failure handling */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p, value, is_throw); +} /* ecma_op_object_put */ + +/** + * [[CanPut]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return true - if [[Put]] with the given property name can be performed; + * false - otherwise. + */ +bool +ecma_op_object_can_put( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p) /**< property name */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p); +} /* ecma_op_object_can_put */ + +/** + * [[HasProperty]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return true - if the object already has a property with the given property name; + * false - otherwise. + */ +bool +ecma_op_object_has_property( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p) /**< property name */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p); +} /* ecma_op_object_has_property */ + +/** + * [[Delete]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return completion value + * Returned value must be freed with ecma_free_completion_value + */ +ecma_completion_value_t +ecma_op_object_delete( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p, /**< property name */ + bool is_throw) /**< flag that controls failure handling */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p, is_throw); +} /* ecma_op_object_delete */ + +/** + * [[DefaultValue]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return completion value + * Returned value must be freed with ecma_free_completion_value + */ +ecma_completion_value_t +ecma_op_object_default_value( ecma_object_t *obj_p, /**< the object */ + ecma_preferred_type_hint_t hint) /**< hint on preferred result type */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, hint); +} /* ecma_op_object_default_value */ + +/** + * [[DefineOwnProperty]] ecma object's operation + * + * See also: + * ECMA-262 v5, 8.6.2; ECMA-262 v5, Table 8 + * + * @return completion value + * Returned value must be freed with ecma_free_completion_value + */ +ecma_completion_value_t +ecma_op_object_define_own_property( ecma_object_t *obj_p, /**< the object */ + ecma_array_first_chunk_t *property_name_p, /**< property name */ + ecma_property_t property_desc, /**< property descriptor */ + bool is_throw) /**< flag that controls failure handling */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( obj_p, property_name_p, property_desc, is_throw); +} /* ecma_op_object_define_own_property */ + +/** + * @} + * @} + */ diff --git a/src/libecmaoperations/ecma-objects-properties.h b/src/libecmaoperations/ecma-objects-properties.h new file mode 100644 index 000000000..ad31a42c9 --- /dev/null +++ b/src/libecmaoperations/ecma-objects-properties.h @@ -0,0 +1,52 @@ +/* Copyright 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ECMA_OBJECTS_PROPERTIES_H +#define ECMA_OBJECTS_PROPERTIES_H + +#include "ecma-conversion.h" +#include "ecma-globals.h" + +/** \addtogroup ecma ---TODO--- + * @{ + * + * \addtogroup ecmaobjectsinternalops ECMA objects' operations + * @{ + */ + +extern ecma_completion_value_t ecma_op_object_get( ecma_object_t *obj_p, ecma_array_first_chunk_t *property_name_p); +extern ecma_property_t *ecma_op_object_get_own_property( ecma_object_t *obj_p, ecma_array_first_chunk_t *property_name_p); +extern ecma_property_t *ecma_op_object_get_property( ecma_object_t *obj_p, ecma_array_first_chunk_t *property_name_p); +extern ecma_completion_value_t ecma_op_object_put( ecma_object_t *obj_p, + ecma_array_first_chunk_t *property_name_p, + ecma_value_t value, + bool is_throw); +extern bool ecma_op_object_can_put( ecma_object_t *obj_p, ecma_array_first_chunk_t *property_name_p); +extern bool ecma_op_object_has_property( ecma_object_t *obj_p, ecma_array_first_chunk_t *property_name_p); +extern ecma_completion_value_t ecma_op_object_delete( ecma_object_t *obj_p, + ecma_array_first_chunk_t *property_name_p, + bool is_throw); +extern ecma_completion_value_t ecma_op_object_default_value( ecma_object_t *obj_p, ecma_preferred_type_hint_t hint); +extern ecma_completion_value_t ecma_op_object_define_own_property( ecma_object_t *obj_p, + ecma_array_first_chunk_t *property_name_p, + ecma_property_t property_desc, + bool is_throw); + +/** + * @} + * @} + */ + +#endif /* !ECMA_OBJECTS_PROPERTIES_H */