ToPropertyDesciptor() static private method

8.10.5
static private ToPropertyDesciptor ( IGlobal global, JsDictionaryObject owner, string name, JsInstance jsInstance ) : Descriptor
global IGlobal
owner JsDictionaryObject
name string
jsInstance JsInstance
return Descriptor
コード例 #1
0
        /// <summary>
        /// 15.2.3.6
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="p"></param>
        /// <param name="currentDescriptor"></param>
        public JsInstance DefineProperty(JsInstance[] parameters)
        {
            JsInstance instance = parameters[0];

            if (!(instance is JsDictionaryObject))
            {
                throw new JsException(Global.TypeErrorClass.New());
            }

            string     name = parameters[1].ToString();
            Descriptor desc = Descriptor.ToPropertyDesciptor(Global, (JsDictionaryObject)instance, name, parameters[2]);

            if (desc.DescriptorType == DescriptorType.Accessor)
            {
                if (((PropertyDescriptor)desc).GetFunction != null)
                {
                    ((PropertyDescriptor)desc).GetFunction.Scope[JsInstance.THIS] = instance;
                }
                if (((PropertyDescriptor)desc).SetFunction != null)
                {
                    ((PropertyDescriptor)desc).SetFunction.Scope[JsInstance.THIS] = instance;
                }
            }
            ((JsDictionaryObject)instance).DefineOwnProperty(name, desc);

            return(instance);
        }
コード例 #2
0
        public JsInstance DefineProperty(JsInstance[] parameters)
        {
            JsInstance parameter = parameters[0];

            if (!(parameter is JsDictionaryObject))
            {
                throw new JsException((JsInstance)this.Global.TypeErrorClass.New());
            }
            string     name = parameters[1].ToString();
            Descriptor propertyDesciptor = Descriptor.ToPropertyDesciptor(this.Global, (JsDictionaryObject)parameter, name, parameters[2]);

            ((JsDictionaryObject)parameter).DefineOwnProperty(propertyDesciptor);
            return(parameter);
        }
コード例 #3
0
        /// <summary>
        /// 15.2.3.6
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="p"></param>
        /// <param name="currentDescriptor"></param>
        public JsInstance DefineProperty(JsInstance[] parameters)
        {
            JsInstance instance = parameters[0];

            if (!(instance is JsDictionaryObject))
            {
                throw new JsException(Global.TypeErrorClass.New());
            }

            string     name = parameters[1].ToString();
            Descriptor desc = Descriptor.ToPropertyDesciptor(Global, (JsDictionaryObject)instance, name, parameters[2]);

            ((JsDictionaryObject)instance).DefineOwnProperty(desc);

            return(instance);
        }