From 4395da05d37d5667268c42f1a509f820147d8ef9 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Tue, 15 Jul 2014 19:26:42 +0400 Subject: [PATCH] Renaming ecma_Object_t::u_Attributes to u. Renaming ecma_CompletionValue_t:: completion_type to type, completion_value to value. Introducing ECMA_TARGET_ID_RESERVED value of ecma_CompletionValue_t::target when it is unused. Adding ecma_Reference_t type for ECMA-reference. Introducing some constructors and helpers for ecma-values. Introducing ecma_FindNamedProperty helper. Removing ecma_SyntacticReference_t type. Implementing ecma operation GetIdentifierReference. Stubs and partial implementation for GetValue, SetValue, lexical environment operations (HasBinding, etc.). --- src/libecmaobjects/ecma-gc.c | 4 +- src/libecmaobjects/ecma-globals.h | 36 ++++- src/libecmaobjects/ecma-helpers-value.c | 120 ++++++++++++++++ src/libecmaobjects/ecma-helpers.c | 55 ++++++-- src/libecmaobjects/ecma-helpers.h | 13 +- src/libecmaobjects/ecma-reference.h | 29 +--- src/libecmaoperations/ecma-get-put-value.c | 101 ++++++++++++++ src/libecmaoperations/ecma-lex-env.c | 153 +++++++++++++++++++++ src/libecmaoperations/ecma-lex-env.h | 48 +++++++ src/libecmaoperations/ecma-operations.h | 6 +- 10 files changed, 520 insertions(+), 45 deletions(-) create mode 100644 src/libecmaobjects/ecma-helpers-value.c create mode 100644 src/libecmaoperations/ecma-get-put-value.c create mode 100644 src/libecmaoperations/ecma-lex-env.c create mode 100644 src/libecmaoperations/ecma-lex-env.h diff --git a/src/libecmaobjects/ecma-gc.c b/src/libecmaobjects/ecma-gc.c index 69128e454..4ced0032a 100644 --- a/src/libecmaobjects/ecma-gc.c +++ b/src/libecmaobjects/ecma-gc.c @@ -258,7 +258,7 @@ ecma_GCRun( void) if ( pObject->m_IsLexicalEnvironment ) { - ecma_Object_t *pOuterLexicalEnvironment = ecma_GetPointer( pObject->u_Attributes.m_LexicalEnvironment.m_pOuterReference); + ecma_Object_t *pOuterLexicalEnvironment = ecma_GetPointer( pObject->u.m_LexicalEnvironment.m_pOuterReference); if ( pOuterLexicalEnvironment != NULL ) { @@ -266,7 +266,7 @@ ecma_GCRun( void) } } else { - ecma_Object_t *pPrototypeObject = ecma_GetPointer( pObject->u_Attributes.m_Object.m_pPrototypeObject); + ecma_Object_t *pPrototypeObject = ecma_GetPointer( pObject->u.m_Object.m_pPrototypeObject); if ( pPrototypeObject != NULL ) { diff --git a/src/libecmaobjects/ecma-globals.h b/src/libecmaobjects/ecma-globals.h index 21d1cdf46..b8a302fb8 100644 --- a/src/libecmaobjects/ecma-globals.h +++ b/src/libecmaobjects/ecma-globals.h @@ -116,15 +116,21 @@ typedef struct { */ typedef struct { /** Type (ecma_CompletionType_t) */ - unsigned int completion_type : 3; + unsigned int type : 3; /** Value */ - ecma_Value_t completion_value; + ecma_Value_t value; /** Target */ unsigned int target : 8; } __packed ecma_CompletionValue_t; +/** + * Target value indicating that target field + * of ecma_CompletionValue_t defines no target. + */ +#define ECMA_TARGET_ID_RESERVED 255 + /** * Internal properties' identifiers. */ @@ -283,7 +289,7 @@ typedef struct ecma_Object_t { unsigned int m_pOuterReference : ECMA_POINTER_FIELD_WIDTH; } __packed m_LexicalEnvironment; - } __packed u_Attributes; + } __packed u; /** GC's information */ ecma_GCInfo_t m_GCInfo; @@ -342,6 +348,30 @@ typedef struct { uint8_t m_Elements[ ECMA_ARRAY_CHUNK_SIZE_IN_BYTES - sizeof (uint16_t) ]; } ecma_ArrayNonFirstChunk_t; +/** + * \addtogroup reference ECMA-reference + * @{ + */ + +/** + * ECMA-reference (see also: ECMA-262 v5, 8.7). + */ +typedef struct +{ + /** base value */ + ecma_Value_t base; + + /** referenced name value pointer */ + ecma_Char_t *referenced_name_p; + + /** strict reference flag */ + bool is_strict; +} ecma_Reference_t; + +/** + * @} + */ + #endif /* JERRY_ECMA_GLOBALS_H */ /** diff --git a/src/libecmaobjects/ecma-helpers-value.c b/src/libecmaobjects/ecma-helpers-value.c new file mode 100644 index 000000000..ad8d6bc9e --- /dev/null +++ b/src/libecmaobjects/ecma-helpers-value.c @@ -0,0 +1,120 @@ +/* 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. + */ + +/** \addtogroup ecma ---TODO--- + * @{ + * + * \addtogroup ecmahelpers Helpers for operations with ECMA data types + * @{ + */ + +#include "ecma-globals.h" +#include "ecma-helpers.h" +#include "globals.h" + +/** + * Check if the value is undefined. + * + * @return true - if the value contains ecma-undefined simple value, + * false - otherwise. + */ +bool +ecma_IsUndefinedValue( ecma_Value_t value) /**< ecma-value */ +{ + return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_UNDEFINED ); +} /* ecma_IsUndefinedValue */ + +/** + * Check if the value is null. + * + * @return true - if the value contains ecma-null simple value, + * false - otherwise. + */ +bool +ecma_IsNullValue( ecma_Value_t value) /**< ecma-value */ +{ + return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_NULL ); +} /* ecma_IsNullValue */ + +/** + * Check if the value is boolean. + * + * @return true - if the value contains ecma-true or ecma-false simple values, + * false - otherwise. + */ +bool +ecma_IsBooleanValue( ecma_Value_t value) /**< ecma-value */ +{ + return ( ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_FALSE ) + || ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_TRUE ) ); +} /* ecma_IsBooleanValue */ + +/** + * Check if the value is true. + * + * Warning: + * value must be boolean + * + * @return true - if the value contains ecma-true simple value, + * false - otherwise. + */ +bool +ecma_IsValueTrue( ecma_Value_t value) /**< ecma-value */ +{ + JERRY_ASSERT( ecma_IsBooleanValue( value) ); + + return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_TRUE ); +} /* ecma_IsValueTrue */ + +/** + * Simple value constructor + */ +ecma_Value_t +ecma_MakeSimpleValue( ecma_SimpleValue_t value) /**< simple value */ +{ + return (ecma_Value_t) { .m_ValueType = ECMA_TYPE_SIMPLE, .m_Value = value }; +} /* ecma_MakeSimpleValue */ + +/** + * Object value constructor + */ +ecma_Value_t +ecma_MakeObjectValue( ecma_Object_t* object_p) /**< object to reference in value */ +{ + JERRY_ASSERT( object_p != NULL ); + + ecma_Value_t object_value; + + object_value.m_ValueType = ECMA_TYPE_OBJECT; + ecma_SetPointer( object_value.m_Value, object_p); + + return object_value; +} /* ecma_MakeObjectValue */ + +/** + * Completion value constructor + */ +ecma_CompletionValue_t +ecma_MakeCompletionValue(ecma_CompletionType_t type, /**< type */ + ecma_Value_t value, /**< value */ + uint8_t target) /**< target */ +{ + return (ecma_CompletionValue_t) { .type = type, .value = value, .target = target }; +} /* ecma_MakeCompletionValue */ + +/** + * @} + * @} + */ diff --git a/src/libecmaobjects/ecma-helpers.c b/src/libecmaobjects/ecma-helpers.c index 65a9497ce..4ae5be949 100644 --- a/src/libecmaobjects/ecma-helpers.c +++ b/src/libecmaobjects/ecma-helpers.c @@ -20,10 +20,6 @@ * @{ */ -/** - * Implementation of helpers for operations with ECMA data types - */ - #include "ecma-alloc.h" #include "ecma-globals.h" #include "ecma-helpers.h" @@ -94,8 +90,8 @@ ecma_CreateObject( ecma_Object_t *pPrototypeObject, /**< pointer to prototybe of * (at least with the ctx_GlobalObject variable) */ pObject->m_GCInfo.u.m_Refs = 1; - pObject->u_Attributes.m_Object.m_Extensible = isExtensible; - ecma_SetPointer( pObject->u_Attributes.m_Object.m_pPrototypeObject, pPrototypeObject); + pObject->u.m_Object.m_Extensible = isExtensible; + ecma_SetPointer( pObject->u.m_Object.m_pPrototypeObject, pPrototypeObject); return pObject; } /* ecma_CreateObject */ @@ -119,14 +115,14 @@ ecma_CreateLexicalEnvironment(ecma_Object_t *pOuterLexicalEnvironment, /**< oute ecma_Object_t *pNewLexicalEnvironment = ecma_AllocObject(); pNewLexicalEnvironment->m_IsLexicalEnvironment = true; - pNewLexicalEnvironment->u_Attributes.m_LexicalEnvironment.m_Type = type; + pNewLexicalEnvironment->u.m_LexicalEnvironment.m_Type = type; pNewLexicalEnvironment->m_pProperties = ECMA_NULL_POINTER; pNewLexicalEnvironment->m_GCInfo.m_IsObjectValid = true; pNewLexicalEnvironment->m_GCInfo.u.m_Refs = 1; - ecma_SetPointer( pNewLexicalEnvironment->u_Attributes.m_LexicalEnvironment.m_pOuterReference, pOuterLexicalEnvironment); + ecma_SetPointer( pNewLexicalEnvironment->u.m_LexicalEnvironment.m_pOuterReference, pOuterLexicalEnvironment); return pNewLexicalEnvironment; } /* ecma_CreateLexicalEnvironment */ @@ -157,7 +153,7 @@ ecma_CreateInternalProperty(ecma_Object_t *pObject, /**< the object */ /** * Find internal property in the object's property set. * - * @return pointer to the property's descriptor, if it is found, + * @return pointer to the property, if it is found, * NULL - otherwise. */ ecma_Property_t* @@ -204,6 +200,47 @@ ecma_GetInternalProperty(ecma_Object_t *pObject, /**< object descriptor */ return pProperty; } /* ecma_GetInternalProperty */ +/** + * Find named data property or named access property in specified object. + * + * @return pointer to the property, if it is found, + * NULL - otherwise. + */ +ecma_Property_t* +ecma_FindNamedProperty(ecma_Object_t *obj_p, /**< object to find property in */ + ecma_Char_t *string_p) /**< property's name */ +{ + JERRY_ASSERT( obj_p != NULL ); + JERRY_ASSERT( string_p != NULL ); + + for ( ecma_Property_t *property_p = ecma_GetPointer( obj_p->m_pProperties); + property_p != NULL; + property_p = ecma_GetPointer( property_p->m_pNextProperty) ) + { + ecma_ArrayFirstChunk_t *property_name_p; + + if ( property_p->m_Type == ECMA_PROPERTY_NAMEDDATA ) + { + property_name_p = ecma_GetPointer( property_p->u.m_NamedDataProperty.m_pName); + } else if ( property_p->m_Type == ECMA_PROPERTY_NAMEDACCESSOR ) + { + property_name_p = ecma_GetPointer( property_p->u.m_NamedAccessorProperty.m_pName); + } else + { + continue; + } + + JERRY_ASSERT( property_name_p != NULL ); + + if ( ecma_CompareCharBufferToEcmaString( string_p, property_name_p) ) + { + return property_p; + } + } + + return NULL; +} /* ecma_FindNamedProperty */ + /** * Allocate new ecma-string and fill it with characters from specified buffer * diff --git a/src/libecmaobjects/ecma-helpers.h b/src/libecmaobjects/ecma-helpers.h index fe13dda2d..21e438a59 100644 --- a/src/libecmaobjects/ecma-helpers.h +++ b/src/libecmaobjects/ecma-helpers.h @@ -41,6 +41,15 @@ extern void* ecma_DecompressPointer(uintptr_t compressedPointer); #define ecma_SetPointer( field, nonCompressedPointer) \ (field) = ecma_CompressPointer( nonCompressedPointer) & ( ( 1u << ECMA_POINTER_FIELD_WIDTH ) - 1) +extern ecma_Value_t ecma_MakeSimpleValue( ecma_SimpleValue_t value); +extern ecma_Value_t ecma_MakeObjectValue( ecma_Object_t* object_p); +extern ecma_CompletionValue_t ecma_MakeCompletionValue( ecma_CompletionType_t type, ecma_Value_t value, uint8_t target); + +extern bool ecma_IsUndefinedValue( ecma_Value_t value); +extern bool ecma_IsNullValue( ecma_Value_t value); +extern bool ecma_IsBooleanValue( ecma_Value_t value); +extern bool ecma_IsValueTrue( ecma_Value_t value); + extern ecma_Object_t* ecma_CreateObject( ecma_Object_t *pPrototypeObject, bool isExtensible); extern ecma_Object_t* ecma_CreateLexicalEnvironment( ecma_Object_t *pOuterLexicalEnvironment, ecma_LexicalEnvironmentType_t type); @@ -49,6 +58,8 @@ extern ecma_Property_t* ecma_FindInternalProperty(ecma_Object_t *pObject, ecma_I extern ecma_Property_t* ecma_GetInternalProperty(ecma_Object_t *pObject, ecma_InternalPropertyId_t propertyId); extern ecma_Property_t* ecma_SetInternalProperty(ecma_Object_t *pObject, ecma_InternalPropertyId_t propertyId); +extern ecma_Property_t *ecma_FindNamedProperty(ecma_Object_t *obj_p, ecma_Char_t *string_p); + extern ecma_ArrayFirstChunk_t* ecma_NewEcmaString( const ecma_Char_t *pString, ecma_Length_t length); extern ssize_t ecma_CopyEcmaStringCharsToBuffer( ecma_ArrayFirstChunk_t *pFirstChunk, uint8_t *pBuffer, size_t bufferSize); extern ecma_ArrayFirstChunk_t* ecma_DuplicateEcmaString( ecma_ArrayFirstChunk_t *pFirstChunk); @@ -61,4 +72,4 @@ extern void ecma_FreeArray( ecma_ArrayFirstChunk_t *pFirstChunk); /** * @} * @} - */ \ No newline at end of file + */ diff --git a/src/libecmaobjects/ecma-reference.h b/src/libecmaobjects/ecma-reference.h index 89c4f8035..28efde2dd 100644 --- a/src/libecmaobjects/ecma-reference.h +++ b/src/libecmaobjects/ecma-reference.h @@ -21,37 +21,10 @@ */ /** - * \addtogroup syntacticreference Textual reference to variable/property + * \addtogroup reference ECMA-reference * @{ */ -/** - * Syntactic (textual/unresolved) reference to a variable/object's property. - */ -typedef struct { - /** - * Flag indicating that this is reference to a property. - * - * Note: - * m_PropertyName is valid only if m_IsPropertyReference is true. - */ - unsigned int m_IsPropertyReference : 1; - - /** - * Flag indicating that this reference is strict (see also: ECMA-262 v5, 8.7). - */ - unsigned int m_StrictReference : 1; - - /** - * Name of variable (Null-terminated string). - */ - ecma_Char_t* m_Name; - - /** - * Name of object's property (Null-terminated string). - */ - ecma_Char_t* m_PropertyName; -} ecma_SyntacticReference_t; /** * @} diff --git a/src/libecmaoperations/ecma-get-put-value.c b/src/libecmaoperations/ecma-get-put-value.c new file mode 100644 index 000000000..15ff799cb --- /dev/null +++ b/src/libecmaoperations/ecma-get-put-value.c @@ -0,0 +1,101 @@ +/* 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. + */ + +/** + * Implementation of ECMA GetValue and PutValue + */ + +#include "ecma-gc.h" +#include "ecma-helpers.h" +#include "ecma-lex-env.h" +#include "ecma-operations.h" + +/** \addtogroup ecma ---TODO--- + * @{ + * + * \addtogroup ecmaoperations ECMA-defined operations + * @{ + */ + +/** + * Resolve syntactic reference to ECMA-reference. + * + * Warning: string pointed by name_p + * must not be freed or reused + * until the reference is freed. + * + * @return ECMA-reference (if base value is an object, upon return + * it's reference counter is increased by one). + */ +ecma_Reference_t +ecma_OpGetIdentifierReference(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p, /**< identifier's name */ + bool is_strict) /**< strict reference flag */ +{ + JERRY_ASSERT( lex_env_p != NULL ); + + ecma_Object_t *lex_env_iter_p = lex_env_p; + + while ( lex_env_iter_p != NULL ) + { + ecma_CompletionValue_t completion_value; + completion_value = ecma_OpHasBinding( lex_env_iter_p, name_p); + + JERRY_ASSERT( completion_value.type == ECMA_COMPLETION_TYPE_NORMAL ); + + if ( ecma_IsValueTrue( completion_value.value) ) + { + ecma_RefObject( lex_env_iter_p); + + return (ecma_Reference_t) { .base = ecma_MakeObjectValue( lex_env_iter_p), + .referenced_name_p = name_p, + .is_strict = is_strict }; + } + + lex_env_iter_p = ecma_GetPointer( lex_env_iter_p->u.m_LexicalEnvironment.m_pOuterReference); + } + + return (ecma_Reference_t) { .base = ecma_MakeObjectValue( NULL), + .referenced_name_p = NULL, + .is_strict = is_strict }; +} /* ecma_OpGetIdentifierReference */ + +/** + * GetValue operation. + * + * See also: ECMA-262 v5, 8.7.1 + */ +ecma_CompletionValue_t +ecma_OpGetValue( ecma_Reference_t *ref_p) /**< ECMA-reference */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( ref_p); +} /* ecma_OpGetValue */ + +/** + * SetValue operation. + * + * See also: ECMA-262 v5, 8.7.1 + */ +ecma_CompletionValue_t +ecma_OpSetValue(ecma_Reference_t *ref_p, /**< ECMA-reference */ + ecma_Value_t value) /**< ECMA-value */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( ref_p, value); +} /* ecma_OpSetValue */ + +/** + * @} + * @} + */ diff --git a/src/libecmaoperations/ecma-lex-env.c b/src/libecmaoperations/ecma-lex-env.c new file mode 100644 index 000000000..be79fcbe5 --- /dev/null +++ b/src/libecmaoperations/ecma-lex-env.c @@ -0,0 +1,153 @@ +/* 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-helpers.h" +#include "ecma-lex-env.h" +#include "globals.h" + +/** \addtogroup ecma ---TODO--- + * @{ + */ + +/** + * \addtogroup lexicalenvironment Lexical environment + * @{ + */ + +/** + * HasBinding operation. + * + * See also: ECMA-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpHasBinding(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p) /**< argument N */ +{ + JERRY_ASSERT( lex_env_p != NULL && lex_env_p->m_IsLexicalEnvironment ); + + ecma_SimpleValue_t has_binding = ECMA_SIMPLE_VALUE_UNDEFINED; + + switch ( (ecma_LexicalEnvironmentType_t) lex_env_p->u.m_LexicalEnvironment.m_Type ) + { + case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE: + { + ecma_Property_t *property_p = ecma_FindNamedProperty( lex_env_p, name_p); + + has_binding = ( property_p != NULL ) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE; + } + case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND: + { + JERRY_UNIMPLEMENTED(); + } + } + + return ecma_MakeCompletionValue(ECMA_COMPLETION_TYPE_NORMAL, + ecma_MakeSimpleValue( has_binding), + ECMA_TARGET_ID_RESERVED); +} /* ecma_OpHasBinding */ + +/** + * CreateMutableBinding operation. + * + * see also: ecma-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpCreateMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p, /**< argument N */ + bool is_deletable) /**< argument D */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, is_deletable); +} /* ecma_OpCreateMutableBinding */ + +/** + * SetMutableBinding operation. + * + * See also: ECMA-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpSetMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p, /**< argument N */ + ecma_Value_t value, /**< argument V */ + bool is_strict) /**< argument S */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, value, is_strict); +} /* ecma_OpSetMutableBinding */ + +/** + * GetBindingValue operation. + * + * See also: ECMA-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpGetBindingValue(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p, /**< argument N */ + bool is_strict) /**< argument S */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, is_strict); +} /* ecma_OpGetBindingValue */ + +/** + * DeleteBinding operation. + * + * See also: ECMA-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpDeleteBinding(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p) /**< argument N */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p); +} /* ecma_OpDeleteBinding */ + +/** + * ImplicitThisValue operation. + * + * See also: ECMA-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p) /**< lexical environment */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p); +} /* ecma_OpImplicitThisValue */ + +/** + * CreateImmutableBinding operation. + * + * See also: ECMA-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpCreateImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p) /**< argument N */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p); +} /* ecma_OpCreateImmutableBinding */ + +/** + * InitializeImmutableBinding operation. + * + * See also: ECMA-262 v5, 10.2.1 + */ +ecma_CompletionValue_t +ecma_OpInitializeImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */ + ecma_Char_t *name_p, /**< argument N */ + ecma_Value_t value) /**< argument V */ +{ + JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, value); +} /* ecma_OpInitializeImmutableBinding */ + +/** + * @} + * @} + */ diff --git a/src/libecmaoperations/ecma-lex-env.h b/src/libecmaoperations/ecma-lex-env.h new file mode 100644 index 000000000..c1768bfe6 --- /dev/null +++ b/src/libecmaoperations/ecma-lex-env.h @@ -0,0 +1,48 @@ +/* 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_LEX_ENV_H +#define ECMA_LEX_ENV_H + +#include "ecma-globals.h" +#include "globals.h" + +/** \addtogroup ecma ---TODO--- + * @{ + */ + +/** + * \addtogroup lexicalenvironment Lexical environment + * @{ + */ + +/* ECMA-262 v5, Table 17. Abstract methods of Environment Records */ +extern ecma_CompletionValue_t ecma_OpHasBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p); +extern ecma_CompletionValue_t ecma_OpCreateMutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_deletable); +extern ecma_CompletionValue_t ecma_OpSetMutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, ecma_Value_t value, bool is_strict); +extern ecma_CompletionValue_t ecma_OpGetBindingValue( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_strict); +extern ecma_CompletionValue_t ecma_OpDeleteBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p); +extern ecma_CompletionValue_t ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p); + +/* ECMA-262 v5, Table 18. Additional methods of Declarative Environment Records */ +extern ecma_CompletionValue_t ecma_OpCreateImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p); +extern ecma_CompletionValue_t ecma_OpInitializeImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, ecma_Value_t value); + +/** + * @} + * @} + */ + +#endif /* !ECMA_LEX_ENV_H */ diff --git a/src/libecmaoperations/ecma-operations.h b/src/libecmaoperations/ecma-operations.h index 5600335e6..56b7c7c27 100644 --- a/src/libecmaoperations/ecma-operations.h +++ b/src/libecmaoperations/ecma-operations.h @@ -26,8 +26,10 @@ #include "ecma-globals.h" #include "ecma-reference.h" -extern ecma_CompletionValue_t ecma_GetValue( ecma_SyntacticReference_t *ref_p); -extern ecma_CompletionValue_t ecma_SetValue( ecma_SyntacticReference_t *ref_p, ecma_Value_t value); +extern ecma_Reference_t ecma_OpGetIdentifierReference( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_strict); + +extern ecma_CompletionValue_t ecma_OpGetValue( ecma_Reference_t *ref_p); +extern ecma_CompletionValue_t ecma_OpSetValue( ecma_Reference_t *ref_p, ecma_Value_t value); /** * @}