상속: 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;
 }
예제 #4
0
        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
파일: JsScope.cs 프로젝트: pusp/o2platform
        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
파일: JsScope.cs 프로젝트: 925coder/ravendb
 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
파일: JsScope.cs 프로젝트: nate-yocom/jint
 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;
 }
예제 #21
0
 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));
 }
예제 #25
0
 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)
 {
 }