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; }
public Descriptor Put(string name, Descriptor descriptor) { lock (keys) { keys.Add(name); values.Add(descriptor); } return descriptor; }
/// <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); }
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; }
/// <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; }
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); }
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); }
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; } } }
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); } } } }
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)); }
public override void DefineOwnProperty(Descriptor currentDescriptor) { if (bag != null) { bag.DefineOwnProperty(currentDescriptor); } else { base.DefineOwnProperty(currentDescriptor); } }
public Jint.Native.Descriptor Put(string name, Jint.Native.Descriptor descriptor) { bag.Put(name, descriptor); return(lastAccessed = descriptor); }
public override void DefineOwnProperty(string key, Descriptor value) { }
public override void DefineOwnProperty(Descriptor currentDescriptor) { // Do nothing, you should not be able to define new properties // on literals }
public override void DefineOwnProperty(string key, Descriptor d) { try { put(Convert.ToInt32(key), d.Get(this)); } catch (FormatException) { base.DefineOwnProperty(key, d); } }
public void Delete(string name) { bag.Delete(name); if (lastAccessed != null && lastAccessed.Name == name) lastAccessed = null; }
public Jint.Native.Descriptor Put(string name, Jint.Native.Descriptor descriptor) { bag.Put(name, descriptor); return lastAccessed = descriptor; }
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); }
public Descriptor Put(string name, Descriptor descriptor) { bag.Add(name, descriptor); return descriptor; }
public override void DefineOwnProperty(Descriptor value) { }
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); }
public virtual bool TryGetDescriptor(string index, out Descriptor result) { result = GetDescriptor(index); return(result != null); }
public override void DefineOwnProperty(Descriptor d) { int index; if(int.TryParse(d.Name, out index)) put(index, d.Get(this)); else base.DefineOwnProperty(d); }