Renaming ecma_GC*Property to ecma_Free*Property and moving them to ecma-helpers.c; introducing ecma_CreateNamedProperty, ecma_GetNamedProperty, ecma_GetNamedDataProperty, ecma_FreeProperty (extracted from ecma_GCRun), ecma_DeleteProperty; removing length argument of ecma_NewEcmaString helper.

This commit is contained in:
Ruben Ayrapetyan
2014-07-16 21:36:59 +04:00
parent 8d07e2b239
commit c8605bb4d1
3 changed files with 256 additions and 108 deletions
+2 -98
View File
@@ -97,79 +97,6 @@ ecma_GCInit( void)
ecma_GC_Queue = NULL;
} /* ecma_GCInit */
/**
* Garbage collect a named data property
*/
static void
ecma_GCNamedDataProperty( ecma_Property_t *pProperty) /**< the property */
{
JERRY_ASSERT( pProperty->m_Type == ECMA_PROPERTY_NAMEDDATA );
ecma_FreeArray( ecma_GetPointer( pProperty->u.m_NamedDataProperty.m_pName));
ecma_FreeValue( pProperty->u.m_NamedDataProperty.m_Value);
} /* ecma_GCNamedDataProperty */
/**
* Garbage collect a named accessor property
*/
static void
ecma_GCNamedAccessorProperty( ecma_Property_t *pProperty) /**< the property */
{
JERRY_ASSERT( pProperty->m_Type == ECMA_PROPERTY_NAMEDACCESSOR );
ecma_FreeArray( ecma_GetPointer( pProperty->u.m_NamedAccessorProperty.m_pName));
ecma_Object_t *pGet = ecma_GetPointer(pProperty->u.m_NamedAccessorProperty.m_pGet);
ecma_Object_t *pSet = ecma_GetPointer(pProperty->u.m_NamedAccessorProperty.m_pSet);
if ( pGet != NULL )
{
ecma_DerefObject( pGet);
}
if ( pSet != NULL )
{
ecma_DerefObject( pSet);
}
} /* ecma_GCNamedAccessorProperty */
/**
* Garbage collect an internal property
*/
static void
ecma_GCInternalProperty( ecma_Property_t *pProperty) /**< the property */
{
JERRY_ASSERT( pProperty->m_Type == ECMA_PROPERTY_INTERNAL );
ecma_InternalPropertyId_t propertyId = pProperty->u.m_InternalProperty.m_InternalPropertyType;
uint32_t propertyValue = pProperty->u.m_InternalProperty.m_Value;
switch ( propertyId )
{
case ECMA_INTERNAL_PROPERTY_CLASS: /* a string */
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
{
ecma_FreeArray( ecma_GetPointer( propertyValue));
break;
}
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
{
ecma_DerefObject( ecma_GetPointer( propertyValue));
break;
}
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 flag */
{
break;
}
}
} /* ecma_GCInternalProperty */
/**
* Run garbage collecting
*/
@@ -187,32 +114,9 @@ ecma_GCRun( void)
property != NULL;
property = pNextProperty )
{
switch ( (ecma_PropertyType_t) property->m_Type )
{
case ECMA_PROPERTY_NAMEDDATA:
{
ecma_GCNamedDataProperty( property);
break;
}
case ECMA_PROPERTY_NAMEDACCESSOR:
{
ecma_GCNamedAccessorProperty( property);
break;
}
case ECMA_PROPERTY_INTERNAL:
{
ecma_GCInternalProperty( property);
break;
}
}
pNextProperty = ecma_GetPointer( property->m_pNextProperty);
ecma_DeallocProperty( property);
ecma_FreeProperty( property);
}
if ( pObject->m_IsLexicalEnvironment )