Set() public abstract method

Sets a value.
public abstract Set ( JsDictionaryObject that, JsInstance value ) : void
that JsDictionaryObject A target object. This has a meaning in case of descriptors which helds an accessors, /// in value descriptors this parameter is ignored.
value JsInstance A new value which should be stored in the descriptor.
return void
コード例 #1
0
 public override JsInstance this[string index]
 {
     get
     {
         if (index == JsScope.THIS && this.thisDescriptor != null)
         {
             return(this.thisDescriptor.Get((JsDictionaryObject)this));
         }
         if (index == JsScope.ARGUMENTS && this.argumentsDescriptor != null)
         {
             return(this.argumentsDescriptor.Get((JsDictionaryObject)this));
         }
         return(base[index]);
     }
     set
     {
         if (index == JsScope.THIS)
         {
             if (this.thisDescriptor != null)
             {
                 this.thisDescriptor.Set((JsDictionaryObject)this, value);
             }
             else
             {
                 this.DefineOwnProperty(this.thisDescriptor = (Descriptor) new ValueDescriptor((JsDictionaryObject)this, index, value));
             }
         }
         else if (index == JsScope.ARGUMENTS)
         {
             if (this.argumentsDescriptor != null)
             {
                 this.argumentsDescriptor.Set((JsDictionaryObject)this, value);
             }
             else
             {
                 this.DefineOwnProperty(this.argumentsDescriptor = (Descriptor) new ValueDescriptor((JsDictionaryObject)this, index, value));
             }
         }
         else
         {
             Descriptor descriptor = this.GetDescriptor(index);
             if (descriptor != null)
             {
                 descriptor.Set((JsDictionaryObject)this, value);
             }
             else if (this.globalScope != null)
             {
                 this.globalScope.DefineOwnProperty(index, value);
             }
             else
             {
                 this.DefineOwnProperty(index, value);
             }
         }
     }
 }
コード例 #2
0
ファイル: JsScope.cs プロジェクト: lorinbeer/Jint.Phone
 public override JsInstance this[string index] {
     get {
         if (index == THIS && thisDescriptor != null)
         {
             return(thisDescriptor.Get(this));
         }
         if (index == ARGUMENTS && argumentsDescriptor != null)
         {
             return(argumentsDescriptor.Get(this));
         }
         return(base[index]); // will use overriden GetDescriptor
     }
     set {
         if (index == THIS)
         {
             if (thisDescriptor != null)
             {
                 thisDescriptor.Set(this, value);
             }
             else
             {
                 DefineOwnProperty(thisDescriptor = new ValueDescriptor(this, index, value));
             }
         }
         else if (index == ARGUMENTS)
         {
             if (argumentsDescriptor != null)
             {
                 argumentsDescriptor.Set(this, value);
             }
             else
             {
                 DefineOwnProperty(argumentsDescriptor = new ValueDescriptor(this, index, value));
             }
         }
         else
         {
             Descriptor d = GetDescriptor(index);
             if (d != null)
             {
                 d.Set(this, value);
             }
             else if (globalScope != null)
             {
                 // TODO: move to Execution visitor
                 // define missing property in the global scope
                 globalScope.DefineOwnProperty(index, value);
             }
             else
             {
                 // this scope is a global scope
                 DefineOwnProperty(index, value);
             }
         }
     }
 }
コード例 #3
0
        public virtual JsInstance this[string index]
        {
            get
            {
                Descriptor d = GetDescriptor(index);
                return(d != null?d.Get(this) : JsUndefined.Instance);
            }
            set
            {
                Descriptor d = GetDescriptor(index);
                if (d == null || (d.DescriptorType == DescriptorType.Value && d.Owner != this))
                {
                    bool enumerable = index != PROTOTYPE;

                    if (index == PROTOTYPE)
                    {
                        prototypeDescriptor.Set(this, value);
                    }
                    else
                    {
                        if (d == null)
                        {
                            properties.Put(index, new ValueDescriptor(this, index, value)
                            {
                                Enumerable = enumerable
                            });
                        }
                        else
                        {
                            d.Set(this, value);
                        }
                    }
                }
                else
                {
                    d.Set(this, value);
                }
            }
        }
コード例 #4
0
        public override JsInstance this[string index]
        {
            get
            {
                if (index == THIS && thisDescriptor != null)
                {
                    return(thisDescriptor.Get(this));
                }
                if (index == ARGUMENTS && argumentsDescriptor != null)
                {
                    return(argumentsDescriptor.Get(this));
                }
                return(base[index]);
            }
            set
            {
                if (Extensible)
                {
                    if (index == THIS)
                    {
                        if (thisDescriptor != null)
                        {
                            thisDescriptor.Set(this, value);
                        }
                        else
                        {
                            DefineOwnProperty(index, thisDescriptor = new ValueDescriptor(this, index, value));
                        }
                    }
                    if (index == ARGUMENTS)
                    {
                        if (argumentsDescriptor != null)
                        {
                            argumentsDescriptor.Set(this, value);
                        }
                        else
                        {
                            DefineOwnProperty(index, argumentsDescriptor = new ValueDescriptor(this, index, value));
                        }
                    }

                    base[index] = value;
                }
                else
                {
                    Prototype[index] = value;
                }
            }
        }
コード例 #5
0
 public virtual JsInstance this[string index] {
     get {
         Descriptor d = GetDescriptor(index);
         return(d != null?d.Get(this) : JsUndefined.Instance);
     }
     set {
         Descriptor d = GetDescriptor(index);
         if (d == null || (d.Owner != this && d.DescriptorType == DescriptorType.Value))
         {
             DefineOwnProperty(new ValueDescriptor(this, index, value));
         }
         else
         {
             d.Set(this, value);
         }
     }
 }
コード例 #6
0
 public virtual JsInstance this[string index]
 {
     get
     {
         Descriptor descriptor = this.GetDescriptor(index);
         return(descriptor != null?descriptor.Get(this) : (JsInstance)JsUndefined.Instance);
     }
     set
     {
         Descriptor descriptor = this.GetDescriptor(index);
         if (descriptor == null || descriptor.Owner != this && descriptor.DescriptorType == DescriptorType.Value)
         {
             this.DefineOwnProperty((Descriptor) new ValueDescriptor(this, index, value));
         }
         else
         {
             descriptor.Set(this, value);
         }
     }
 }
コード例 #7
0
 public override void Set(JsDictionaryObject that, JsInstance value)
 {
     d.Set(that, value);
 }
コード例 #8
0
ファイル: JsScope.cs プロジェクト: lhamed/unity-jint
 public override JsInstance this[string index] {
     get {
         if (index == THIS && thisDescriptor != null)
         {
             return(thisDescriptor.Get(this));
         }
         if (index == ARGUMENTS && argumentsDescriptor != null)
         {
             return(argumentsDescriptor.Get(this));
         }
         return(base[index]); // will use overriden GetDescriptor
     }
     set {
         if (index == THIS)
         {
             if (thisDescriptor != null)
             {
                 thisDescriptor.Set(this, value);
             }
             else
             {
                 DefineOwnProperty(index, thisDescriptor = new ValueDescriptor(this, index, value));
             }
         }
         else if (index == ARGUMENTS)
         {
             if (argumentsDescriptor != null)
             {
                 argumentsDescriptor.Set(this, value);
             }
             else
             {
                 DefineOwnProperty(index, argumentsDescriptor = new ValueDescriptor(this, index, value));
             }
         }
         else
         {
             Descriptor d = GetDescriptor(index);
             if (d != null)
             {
                 // we have a property in the scopes hierarchy or in the bag
                 if (d.Owner == bag || d.Owner == this || d.Owner.IsPrototypeOf(this))
                 {
                     // if this is an own property of the bag or in scopes
                     d.Set(d.Owner, value);
                 }
                 else
                 {
                     // this property should be from one of prototypes of the bag
                     if (bag != null)
                     {
                         bag[index] = value;
                     }
                 }
             }
             else if (globalScope != null)
             {
                 // define missing property in the global scope
                 globalScope.DefineOwnProperty(index, value);
             }
             else
             {
                 // this scope is a global scope
                 DefineOwnProperty(index, value);
             }
         }
     }
 }