public IReference GetOwnReference(string name)
 {
     var index = DeclaredNames.IndexOf(name);
     if (index < 0)
     {
         return null;
     }
     if (_references == null)
     {
         _references = new IReference[DeclaredNames.Count];
     }
     return _references[index] ??
            (_references[index] =
             new ValueReference((index < ActualValues.Count ? ActualValues[index] : null) ?? JsUndefined.Value));
 }
Beispiel #2
0
        public IReference CreateReference(string name, IJsValue value)
        {
            if (_references == null)
            {
                _references = new Dictionary<string, IReference>();
            }
            IReference reference;
            if (_references.TryGetValue(name, out reference))
            {
                //throw new JsReferenceError(); // TODO: throw if strict only

                // NOTE: node.js allows redeclaration
                reference.SetValue(value);
                return reference;
            }
            return _references[name] = new ValueReference(value);
        }