Jurassic.Library.ObjectInstance.GetNamedPropertyValue C# (CSharp) Method

GetNamedPropertyValue() private method

Gets the value of the property with the given name. The name cannot be an array index.
The prototype chain is searched if the property does not exist directly on this object.
private GetNamedPropertyValue ( object key, ObjectInstance thisValue ) : object
key object The property key (either a string or a Symbol). Cannot be an array index.
thisValue ObjectInstance The value of the "this" keyword inside a getter.
return object
        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);
        }