mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Merge branch 'master' of git-server:jerry
This commit is contained in:
commit
cfcdc72dc9
@ -191,9 +191,13 @@ opfunc_jmp (OPCODE opdata, struct __int_data *int_data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Variable declaration.
|
||||
* Variable declaration opcode handler.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.5 - Declaration binding instantiation (block 8).
|
||||
*
|
||||
* @return completion value
|
||||
* Returned value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
opfunc_var_decl(OPCODE opdata, /**< operation data */
|
||||
@ -235,6 +239,10 @@ opfunc_var_decl(OPCODE opdata, /**< operation data */
|
||||
* Note: this is not ECMA specification-defined, but internal
|
||||
* implementation-defined opcode for end of script
|
||||
* and assertions inside of unit tests.
|
||||
*
|
||||
* @return completion value
|
||||
* Returned value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
opfunc_exitval(OPCODE opdata, /**< operation data */
|
||||
|
||||
@ -121,6 +121,9 @@ ecma_MakeObjectValue( ecma_Object_t* object_p) /**< object to reference in value
|
||||
* increase reference counter of the object
|
||||
* and return the value as it was passed.
|
||||
*
|
||||
* TODO:
|
||||
* reference counter in strings
|
||||
*
|
||||
* @return See note.
|
||||
*/
|
||||
ecma_Value_t
|
||||
@ -133,6 +136,8 @@ ecma_CopyValue( const ecma_Value_t value) /**< ecma-value */
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
value_copy = value;
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
@ -144,6 +149,8 @@ ecma_CopyValue( const ecma_Value_t value) /**< ecma-value */
|
||||
|
||||
value_copy = (ecma_Value_t) { .m_ValueType = ECMA_TYPE_NUMBER };
|
||||
ecma_SetPointer( value_copy.m_Value, number_copy_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
@ -154,6 +161,8 @@ ecma_CopyValue( const ecma_Value_t value) /**< ecma-value */
|
||||
|
||||
value_copy = (ecma_Value_t) { .m_ValueType = ECMA_TYPE_STRING };
|
||||
ecma_SetPointer( value_copy.m_Value, string_copy_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
@ -163,6 +172,8 @@ ecma_CopyValue( const ecma_Value_t value) /**< ecma-value */
|
||||
ecma_RefObject( obj_p);
|
||||
|
||||
value_copy = value;
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE__COUNT:
|
||||
{
|
||||
@ -174,7 +185,7 @@ ecma_CopyValue( const ecma_Value_t value) /**< ecma-value */
|
||||
} /* ecma_CopyValue */
|
||||
|
||||
/**
|
||||
* Free memory used for the value
|
||||
* Free the ecma-value
|
||||
*/
|
||||
void
|
||||
ecma_FreeValue( ecma_Value_t value) /**< value description */
|
||||
@ -216,6 +227,8 @@ ecma_FreeValue( ecma_Value_t value) /**< value description */
|
||||
|
||||
/**
|
||||
* Completion value constructor
|
||||
*
|
||||
* @return completion value
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_MakeCompletionValue(ecma_CompletionType_t type, /**< type */
|
||||
@ -227,21 +240,42 @@ ecma_MakeCompletionValue(ecma_CompletionType_t type, /**< type */
|
||||
|
||||
/**
|
||||
* Throw completion value constructor.
|
||||
*
|
||||
* @return 'throw' completion value
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_MakeThrowValue( ecma_Object_t *exception_p) /**< an object */
|
||||
{
|
||||
JERRY_ASSERT( exception_p != NULL && !exception_p->m_IsLexicalEnvironment );
|
||||
|
||||
ecma_Value_t exception;
|
||||
exception.m_ValueType = ECMA_TYPE_OBJECT;
|
||||
ecma_SetPointer( exception.m_Value, exception_p);
|
||||
ecma_Value_t exception = ecma_MakeObjectValue( exception_p);
|
||||
|
||||
return ecma_MakeCompletionValue(ECMA_COMPLETION_TYPE_THROW,
|
||||
exception,
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} /* ecma_MakeThrowValue */
|
||||
|
||||
/**
|
||||
* Free the completion value.
|
||||
*/
|
||||
void
|
||||
ecma_free_completion_value( ecma_CompletionValue_t completion_value) /**< completion value */
|
||||
{
|
||||
switch ( completion_value.type )
|
||||
{
|
||||
case ECMA_COMPLETION_TYPE_NORMAL:
|
||||
case ECMA_COMPLETION_TYPE_THROW:
|
||||
case ECMA_COMPLETION_TYPE_RETURN:
|
||||
ecma_FreeValue( completion_value.value);
|
||||
break;
|
||||
case ECMA_COMPLETION_TYPE_CONTINUE:
|
||||
case ECMA_COMPLETION_TYPE_BREAK:
|
||||
case ECMA_COMPLETION_TYPE_EXIT:
|
||||
JERRY_ASSERT( completion_value.value.m_ValueType == ECMA_TYPE_SIMPLE );
|
||||
break;
|
||||
}
|
||||
} /* ecma_free_completion_value */
|
||||
|
||||
/**
|
||||
* Check if the completion value is specified normal simple value.
|
||||
*
|
||||
|
||||
@ -54,6 +54,7 @@ extern void ecma_FreeValue( const ecma_Value_t value);
|
||||
|
||||
extern ecma_CompletionValue_t ecma_MakeCompletionValue( ecma_CompletionType_t type, ecma_Value_t value, uint8_t target);
|
||||
extern ecma_CompletionValue_t ecma_MakeThrowValue( ecma_Object_t *exception_p);
|
||||
extern void ecma_free_completion_value( ecma_CompletionValue_t completion_value);
|
||||
|
||||
extern bool ecma_is_completion_value_normal_simple_value( ecma_CompletionValue_t value, ecma_SimpleValue_t simple_value);
|
||||
extern bool ecma_IsCompletionValueNormalFalse( ecma_CompletionValue_t value);
|
||||
|
||||
@ -33,16 +33,21 @@
|
||||
* GetValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.7.1
|
||||
*
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpGetValue( ecma_Reference_t *ref_p) /**< ECMA-reference */
|
||||
ecma_op_get_value( ecma_Reference_t *ref_p) /**< ECMA-reference */
|
||||
{
|
||||
const ecma_Value_t base = ref_p->base;
|
||||
const bool is_unresolvable_reference = ecma_IsValueUndefined( base);
|
||||
const bool has_primitive_base = ( ecma_IsValueBoolean( base)
|
||||
|| base.m_ValueType == ECMA_TYPE_NUMBER
|
||||
|| base.m_ValueType == ECMA_TYPE_STRING );
|
||||
const bool is_property_reference = has_primitive_base || ( base.m_ValueType == ECMA_TYPE_OBJECT );
|
||||
const bool has_object_base = ( base.m_ValueType == ECMA_TYPE_OBJECT
|
||||
&& !((ecma_Object_t*)ecma_GetPointer(base.m_Value))->m_IsLexicalEnvironment );
|
||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||
|
||||
// GetValue_3
|
||||
if ( is_unresolvable_reference )
|
||||
@ -70,7 +75,7 @@ ecma_OpGetValue( ecma_Reference_t *ref_p) /**< ECMA-reference */
|
||||
if ( property->m_Type == ECMA_PROPERTY_NAMEDDATA )
|
||||
{
|
||||
return ecma_MakeCompletionValue( ECMA_COMPLETION_TYPE_NORMAL,
|
||||
property->u.m_NamedDataProperty.m_Value,
|
||||
ecma_CopyValue( property->u.m_NamedDataProperty.m_Value),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} else
|
||||
{
|
||||
@ -100,23 +105,28 @@ ecma_OpGetValue( ecma_Reference_t *ref_p) /**< ECMA-reference */
|
||||
|
||||
return ecma_OpGetBindingValue( lex_env_p, ref_p->referenced_name_p, ref_p->is_strict);
|
||||
}
|
||||
} /* ecma_OpGetValue */
|
||||
} /* ecma_op_get_value */
|
||||
|
||||
/**
|
||||
* SetValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.7.1
|
||||
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpSetValue(ecma_Reference_t *ref_p, /**< ECMA-reference */
|
||||
ecma_Value_t value) /**< ECMA-value */
|
||||
ecma_op_put_value(ecma_Reference_t *ref_p, /**< ECMA-reference */
|
||||
ecma_Value_t value) /**< ECMA-value */
|
||||
{
|
||||
const ecma_Value_t base = ref_p->base;
|
||||
const bool is_unresolvable_reference = ecma_IsValueUndefined( base);
|
||||
const bool has_primitive_base = ( ecma_IsValueBoolean( base)
|
||||
|| base.m_ValueType == ECMA_TYPE_NUMBER
|
||||
|| base.m_ValueType == ECMA_TYPE_STRING );
|
||||
const bool is_property_reference = has_primitive_base || ( base.m_ValueType == ECMA_TYPE_OBJECT );
|
||||
const bool has_object_base = ( base.m_ValueType == ECMA_TYPE_OBJECT
|
||||
&& !((ecma_Object_t*)ecma_GetPointer(base.m_Value))->m_IsLexicalEnvironment );
|
||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||
|
||||
if ( is_unresolvable_reference ) // PutValue_3
|
||||
{
|
||||
@ -221,7 +231,7 @@ ecma_OpSetValue(ecma_Reference_t *ref_p, /**< ECMA-reference */
|
||||
|
||||
return ecma_OpSetMutableBinding( lex_env_p, ref_p->referenced_name_p, value, ref_p->is_strict);
|
||||
}
|
||||
} /* ecma_OpSetValue */
|
||||
} /* ecma_op_put_value */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@ -32,6 +32,10 @@
|
||||
* HasBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*
|
||||
* @return completion value
|
||||
* Return value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpHasBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
@ -67,6 +71,10 @@ ecma_OpHasBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
* CreateMutableBinding operation.
|
||||
*
|
||||
* see also: ecma-262 v5, 10.2.1
|
||||
*
|
||||
* @return completion value
|
||||
* Return value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpCreateMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
@ -107,6 +115,9 @@ ecma_OpCreateMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment *
|
||||
* SetMutableBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpSetMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
@ -127,7 +138,8 @@ ecma_OpSetMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
|
||||
if ( property_p->u.m_NamedDataProperty.m_Writable == ECMA_PROPERTY_WRITABLE )
|
||||
{
|
||||
property_p->u.m_NamedDataProperty.m_Value = value;
|
||||
ecma_FreeValue( property_p->u.m_NamedDataProperty.m_Value);
|
||||
property_p->u.m_NamedDataProperty.m_Value = ecma_CopyValue( value);
|
||||
} else if ( is_strict )
|
||||
{
|
||||
return ecma_MakeThrowValue( ecma_NewStandardError( ECMA_ERROR_TYPE));
|
||||
@ -150,6 +162,9 @@ ecma_OpSetMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
* GetBindingValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpGetBindingValue(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
@ -173,7 +188,7 @@ ecma_OpGetBindingValue(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
if ( property_p->u.m_NamedDataProperty.m_Writable == ECMA_PROPERTY_WRITABLE )
|
||||
{
|
||||
return ecma_MakeCompletionValue( ECMA_COMPLETION_TYPE_NORMAL,
|
||||
prop_value,
|
||||
ecma_CopyValue( prop_value),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} else if ( prop_value.m_ValueType == ECMA_TYPE_SIMPLE
|
||||
&& prop_value.m_Value == ECMA_SIMPLE_VALUE_EMPTY )
|
||||
@ -205,6 +220,10 @@ ecma_OpGetBindingValue(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
* DeleteBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*
|
||||
* @return completion value
|
||||
* Return value is simple and so need not be freed.
|
||||
* However, ecma_free_completion_value may be called for it, but it is a no-op.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpDeleteBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
@ -255,6 +274,9 @@ ecma_OpDeleteBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
* ImplicitThisValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*
|
||||
* @return completion value
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p) /**< lexical environment */
|
||||
@ -283,7 +305,7 @@ ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p) /**< lexical environment */
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
void
|
||||
ecma_OpCreateImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p) /**< argument N */
|
||||
{
|
||||
@ -323,7 +345,7 @@ ecma_OpCreateImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
void
|
||||
ecma_OpInitializeImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
ecma_Value_t value) /**< argument V */
|
||||
@ -343,7 +365,7 @@ ecma_OpInitializeImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environ
|
||||
&& prop_p->u.m_NamedDataProperty.m_Value.m_ValueType == ECMA_TYPE_SIMPLE
|
||||
&& prop_p->u.m_NamedDataProperty.m_Value.m_Value == ECMA_SIMPLE_VALUE_EMPTY );
|
||||
|
||||
prop_p->u.m_NamedDataProperty.m_Value = value;
|
||||
prop_p->u.m_NamedDataProperty.m_Value = ecma_CopyValue( value);
|
||||
}
|
||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||
{
|
||||
|
||||
@ -37,8 +37,8 @@ extern ecma_CompletionValue_t ecma_OpDeleteBinding( ecma_Object_t *lex_env_p, ec
|
||||
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);
|
||||
extern void ecma_OpCreateImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p);
|
||||
extern void ecma_OpInitializeImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, ecma_Value_t value);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
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);
|
||||
extern ecma_CompletionValue_t ecma_op_get_value( ecma_Reference_t *ref_p);
|
||||
extern ecma_CompletionValue_t ecma_op_put_value( ecma_Reference_t *ref_p, ecma_Value_t value);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@ -36,8 +36,8 @@
|
||||
* 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).
|
||||
* @return ECMA-reference
|
||||
* Returned value must be freed through ecma_FreeReference.
|
||||
*/
|
||||
ecma_Reference_t
|
||||
ecma_OpGetIdentifierReference(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
@ -78,8 +78,8 @@ ecma_OpGetIdentifierReference(ecma_Object_t *lex_env_p, /**< lexical environment
|
||||
* must not be freed or reused
|
||||
* until the reference is freed.
|
||||
*
|
||||
* @return ECMA-reference (if base_p it not NULL, then upon return
|
||||
* corresponding object's reference counter is increased by one).
|
||||
* @return ECMA-reference
|
||||
* Returned value must be freed through ecma_FreeReference.
|
||||
*/
|
||||
ecma_Reference_t
|
||||
ecma_MakeReference(ecma_Value_t base, /**< base value */
|
||||
@ -95,7 +95,7 @@ ecma_MakeReference(ecma_Value_t base, /**< base value */
|
||||
* Free specified ECMA-reference.
|
||||
*
|
||||
* Warning:
|
||||
* after freeing all copy of the reference become invalid.
|
||||
* freeing invalidates all copies of the reference.
|
||||
*/
|
||||
void
|
||||
ecma_FreeReference( const ecma_Reference_t ref) /**< reference */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user