Inheritance: JsInstance
示例#1
0
 public Jint.Native.Descriptor Get(string name)
 {
     if (lastAccessed != null && lastAccessed.Name == name)
         return lastAccessed;
     Descriptor descriptor = bag.Get(name);
     if (descriptor != null)
         lastAccessed = descriptor;
     return descriptor;
 }
示例#2
0
 public Descriptor Put(string name, Descriptor descriptor)
 {
     lock (keys)
     {
         keys.Add(name);
         values.Add(descriptor);
     }
     return descriptor;
 }
示例#3
0
 /// <summary>
 /// Constructs new descriptor
 /// </summary>
 /// <param name="owner">An owner of the new descriptor</param>
 /// <param name="name">A name of the new descriptor</param>
 /// <param name="source">A property descriptor of the target object to which we should link to</param>
 /// <param name="that">A target object to whose property we are linking. This parameter will be
 /// used in the calls to a 'Get' and 'Set' properties of the source descriptor.</param>
 public LinkedDescriptor(JsDictionaryObject owner, string name, Descriptor source, JsDictionaryObject that)
     : base(owner, name)
 {
     d = source;
     Enumerable = true;
     Writable = true;
     Configurable = true;
     m_that = that;
 }
        public bool TryGet(string name, out Jint.Native.Descriptor descriptor)
        {
            int index = keys.IndexOf(name);

            if (index < 0)
            {
                descriptor = null;
                return(false);
            }
            descriptor = values[index];
            return(true);
        }
示例#5
0
 public bool TryGet(string name, out Jint.Native.Descriptor descriptor)
 {
     if (lastAccessed != null && lastAccessed.Name == name)
     {
         descriptor = lastAccessed;
         return true;
     }
     bool result = bag.TryGet(name, out descriptor);
     if (result)
         lastAccessed = descriptor;
     return result;
 }
示例#6
0
 /// <summary>
 /// Constructs new descriptor
 /// </summary>
 /// <param name="owner">An owner of the new descriptor</param>
 /// <param name="name">A name of the new descriptor</param>
 /// <param name="source">A property descriptor of the target object to which we should link to</param>
 /// <param name="that">A target object to whose property we are linking. This parameter will be
 /// used in the calls to a 'Get' and 'Set' properties of the source descriptor.</param>
 public LinkedDescriptor(JsDictionaryObject owner, string name, Descriptor source, JsDictionaryObject that)
     : base(owner, name) {
     if (source.isReference) {
         LinkedDescriptor sourceLink = source as LinkedDescriptor;
         d = sourceLink.d;
         m_that = sourceLink.m_that;
     } else
         d = source;
     Enumerable = true;
     Writable = true;
     Configurable = true;
     m_that = that;
 }
示例#7
0
        public Jint.Native.Descriptor Put(string name, Jint.Native.Descriptor descriptor)
        {
            Stack <Descriptor> stack;

            if (!bag.TryGetValue(name, out stack))
            {
                stack = new Stack <Descriptor>();
                bag.Add(name, stack);
            }
            stack.Push(descriptor);
            currentScope.Add(stack);
            return(descriptor);
        }
示例#8
0
        public bool TryGet(string name, out Jint.Native.Descriptor descriptor)
        {
            if (lastAccessed != null && lastAccessed.Name == name)
            {
                descriptor = lastAccessed;
                return(true);
            }
            bool result = bag.TryGet(name, out descriptor);

            if (result)
            {
                lastAccessed = descriptor;
            }
            return(result);
        }
示例#9
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;
                }
            }
        }
示例#10
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]; // 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);
             }
         }
     }
 }
示例#11
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]; // 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);
             }
         }
     }
 }
 public bool TryGet(string name, out Jint.Native.Descriptor descriptor)
 {
     return(bag.TryGetValue(name, out descriptor));
 }
示例#13
0
 public override void DefineOwnProperty(Descriptor currentDescriptor)
 {
     if (bag != null) {
         bag.DefineOwnProperty(currentDescriptor);
     }
     else {
         base.DefineOwnProperty(currentDescriptor);
     }
 }
示例#14
0
 public Jint.Native.Descriptor Put(string name, Jint.Native.Descriptor descriptor)
 {
     bag.Put(name, descriptor);
     return(lastAccessed = descriptor);
 }
示例#15
0
 public override void DefineOwnProperty(string key, Descriptor value)
 {
 }
示例#16
0
 public override void DefineOwnProperty(Descriptor currentDescriptor)
 {
     // Do nothing, you should not be able to define new properties
     // on literals
 }
示例#17
0
 public override void DefineOwnProperty(string key, Descriptor d)
 {
     try {
         put(Convert.ToInt32(key), d.Get(this));
     }
     catch (FormatException) {
         base.DefineOwnProperty(key, d);
     }
 }
示例#18
0
 public void Delete(string name)
 {
     bag.Delete(name);
     if (lastAccessed != null && lastAccessed.Name == name)
         lastAccessed = null;
 }
示例#19
0
 public Jint.Native.Descriptor Put(string name, Jint.Native.Descriptor descriptor)
 {
     bag.Put(name, descriptor);
     return lastAccessed = descriptor;
 }
示例#20
0
 public Descriptor Put(string name, Descriptor descriptor)
 {
     // replace existing without any exception
     bag[name] = descriptor;
     return descriptor;
 }
 public bool TryGet(string name, out Jint.Native.Descriptor descriptor)
 {
     descriptor = Get(name);
     return(descriptor != null);
 }
示例#22
0
 public Descriptor Put(string name, Descriptor descriptor)
 {
     bag.Add(name, descriptor);
     return descriptor;
 }
示例#23
0
文件: JsNull.cs 项目: rexwhitten/jint
 public override void DefineOwnProperty(Descriptor value)
 {
 }
示例#24
0
 public virtual bool TryGetDescriptor(JsInstance index, out Descriptor result)
 {
     return(TryGetDescriptor(index.ToString(), out result));
 }
 public Jint.Native.Descriptor Put(string name, Jint.Native.Descriptor descriptor)
 {
     keys.Add(name, descriptor);
     return(descriptor);
 }
示例#26
0
 public virtual bool TryGetDescriptor(string index, out Descriptor result)
 {
     result = GetDescriptor(index);
     return(result != null);
 }
示例#27
0
文件: JsArray.cs 项目: cosh/Jint
 public override void DefineOwnProperty(Descriptor d)
 {
     int index;
     if(int.TryParse(d.Name, out index))
         put(index, d.Get(this));
     else
         base.DefineOwnProperty(d);
 }
示例#28
0
 public override void DefineOwnProperty(Descriptor value)
 {
 }