private object GetNamedPropertyValue(object key, ObjectInstance thisValue)
{
ObjectInstance prototypeObject = this;
do
{
// Retrieve information about the property.
var property = prototypeObject.schema.GetPropertyIndexAndAttributes(key);
if (property.Exists == true)
{
// The property was found!
object value = prototypeObject.propertyValues[property.Index];
if ((property.Attributes & (PropertyAttributes.IsAccessorProperty | PropertyAttributes.IsLengthProperty)) == 0)
return value;
// Call the getter if there is one.
if (property.IsAccessor == true)
return ((PropertyAccessorValue)value).GetValue(thisValue);
// Otherwise, the property is the "magic" length property.
return ((ArrayInstance)prototypeObject).Length;
}
// Traverse the prototype chain.
prototypeObject = prototypeObject.prototype;
} while (prototypeObject != null);
// The property doesn't exist.
return thisValue.GetMissingPropertyValue(key);
}