Пример #1
0
        public void GetMapsPDsIndices(ref mdr.PropertyMap[] maps, ref mdr.PropertyDescriptor[] pds, ref int[] indices)
        {
            var length = MapProfileData.Count;

            maps    = new mdr.PropertyMap[length];
            pds     = new mdr.PropertyDescriptor[length];
            indices = new int[length];

            for (var i = 0; i < length; ++i)
            {
                maps[i]    = MapProfileData[i] == null ? null : MapProfileData[i].Map;
                pds[i]     = MapProfileData[i] == null ? null : MapProfileData[i].PD;
                indices[i] = MapProfileData[i] == null ? -1 : MapProfileData[i].index;
            }
        }
Пример #2
0
 protected JSBuiltinConstructor(mdr.DObject prototype, string Class)
     : base(null, null)
 {
     TargetPrototype           = prototype;
     TargetDType               = mdr.Runtime.Instance.GetRootMapOfPrototype(TargetPrototype);
     TargetDType.Metadata.Name = Class;
     //var protoPD = PrototypePropertyDescriptor;
     //protoPD.SetAttributes(mdr.PropertyDescriptor.Attributes.NotConfigurable | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable, true);
     //protoPD.Set(this, prototype);
     SetField("prototype", prototype);
     prototype.DefineOwnProperty(
         "constructor"
         , this
         , mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotEnumerable
         );
     //prototype.SetField("constructor", this);
 }
Пример #3
0
        public void CreateNewProfile(ReadIndexerExpression node, mdr.PropertyMap map, mdr.PropertyDescriptor pd)
        {
            MapNodeProfile prof = new MapNodeProfile(map, pd);

            if (node.ProfileIndex == -1)
            {
                node.ProfileIndex = MapProfileData.Count;
                MapProfileData.Add(prof);
                jsMD.MapProfileSize++;
            }
            else
            {
                _resizeProfileData <MapNodeProfile>(MapProfileData, node.ProfileIndex + 1, null);
                MapProfileData[node.ProfileIndex] = prof;
            }
            HasMaps = true;
        }
Пример #4
0
 protected JSBuiltinConstructor(mdr.DObject prototype, string Class)
     : base(null, null)
 {
     TargetPrototype = prototype;
     TargetDType = mdr.Runtime.Instance.GetRootMapOfPrototype(TargetPrototype);
     TargetDType.Metadata.Name = Class;
     //var protoPD = PrototypePropertyDescriptor;
     //protoPD.SetAttributes(mdr.PropertyDescriptor.Attributes.NotConfigurable | mdr.PropertyDescriptor.Attributes.NotWritable | mdr.PropertyDescriptor.Attributes.NotEnumerable, true);
     //protoPD.Set(this, prototype);
     SetField("prototype", prototype);
     prototype.DefineOwnProperty(
         "constructor"
         , this
         , mdr.PropertyDescriptor.Attributes.Data | mdr.PropertyDescriptor.Attributes.NotEnumerable
     );
     //prototype.SetField("constructor", this);
 }
Пример #5
0
        //public MapNodeProfile(mdr.PropertyMap map, mdr.PropertyDescriptor pd)
        //{
        //  Map = map;
        //  PD = pd;
        //  if (pd != null)
        //  {
        //    index = PD.Index;
        //  }
        //}

        /* Updates the map, pd and index */
        public void UpdateNodeProfile(mdr.PropertyMap map, mdr.PropertyDescriptor pd)
        {
            if (!IsTooDynamic)
            {
                if (Map == null)
                {
                    Map   = map;
                    PD    = pd;
                    index = pd.Index;
                }
                else
                {
                    if (Map != map || PD != pd)
                    {
                        IsTooDynamic = true;
                        Map          = null;
                        PD           = null;
                        index        = -1;
                    }
                }
            }
        }
Пример #6
0
        public mdr.PropertyMap GetPropertyMapOfWrappedObjectType(Type wrappedObjectType)
        {
            mdr.PropertyMap pmap = null;
            if (!_propertyMaps.TryGetValue(wrappedObjectType, out pmap))
            {
                if (wrappedObjectType == typeof(DOM.WrappedObject))
                {
                    return(mdr.Runtime.Instance.DObjectMap);
                }

                var baseMap   = GetPropertyMapOfWrappedObjectType(wrappedObjectType.BaseType);
                var prototype = new mdr.DObject(baseMap);

                Debug.WriteLine("Creating PropertyMap for {0}", wrappedObjectType.FullName);

                var preparePrototypeMethod = wrappedObjectType.GetMethod("PreparePrototype");
                Debug.Assert(preparePrototypeMethod != null, "Cannot find method {0}.PreparePrototype()", wrappedObjectType.FullName);

                preparePrototypeMethod.Invoke(null, new object[] { prototype });
                pmap = GetRootMapOfPrototype(prototype);
                _propertyMaps[wrappedObjectType] = pmap;
            }
            return(pmap);
        }
Пример #7
0
        public bool MoveNext()
        {
            // Debug.WriteLine("calling PropertyNameEnumerator.MoveNext");
            while (_dobject != null)
            {
                var array = _dobject as mdr.DArray;
                if (array != null)
                {
                    while (++_elementsIndex < array.ElementsLength)
                    {
                        if (!_visiteds.Contains(-_elementsIndex))
                        {
                            _visiteds.Add(-_elementsIndex);
                            _current = _elementsIndex.ToString();
                            return(true);
                        }
                    }
                }

                /*
                 * ///Spec says the order of retreiving the properties does not matter, so the following code is faster
                 * ///However some stupid websites (e.g. BBC) count on the fact that Browsers list properties with a certain order
                 * ///So, we had to change to the slower to be browser compatible, rather than spec compatible
                 * if (_map == null)
                 *  _map = _dobject.Map;
                 *
                 * while (_map != null)
                 * {
                 *  var prop = _map.Property;
                 *  _map = _map.Parent;
                 *
                 *  if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                 *  {
                 *      _visiteds.Add(prop.NameId);
                 *      _current = prop.Name;
                 *      return true;
                 *  }
                 * }
                 * _dobject = _dobject.Prototype;
                 * _elementsIndex = -1;
                 * _current = null;
                 */
                if (_currentNode == null)
                {
                    //We may have reached to the end of collected properties, but meanwhile some new ones may have been added
                    _propNames.Clear();
                    if (_map != null && _map != _dobject.Map)
                    {
                        _map = _dobject.Map;
                    }
                    for (var m = _dobject.Map; m != _map; m = m.Parent)
                    {
                        var prop = m.Property;
                        if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                        {
                            _visiteds.Add(prop.NameId);
                            _propNames.AddFirst(prop.Name);
                        }
                    }
                    _map         = _dobject.Map;
                    _currentNode = _propNames.First;

                    if (_currentNode == null)
                    {
                        _dobject       = _dobject.Prototype;
                        _elementsIndex = -1;
                        _current       = null;
                        _map           = null;
                        continue; //Jump to begining of the loop!
                    }
                }
                _current     = _currentNode.Value;
                _currentNode = _currentNode.Next;
                return(true);
            }
            return(false);
        }
Пример #8
0
        public bool MoveNext()
        {
            // Debug.WriteLine("calling PropertyNameEnumerator.MoveNext");
            while (_dobject != null)
            {
                var array = _dobject as mdr.DArray;
                if (array != null)
                {
                    while (++_elementsIndex < array.ElementsLength)
                    {
                        if (!_visiteds.Contains(-_elementsIndex))
                        {
                            _visiteds.Add(-_elementsIndex);
                            _current = _elementsIndex.ToString();
                            return true;
                        }
                    }
                }

                /*
                ///Spec says the order of retreiving the properties does not matter, so the following code is faster
                ///However some stupid websites (e.g. BBC) count on the fact that Browsers list properties with a certain order
                ///So, we had to change to the slower to be browser compatible, rather than spec compatible
                if (_map == null)
                    _map = _dobject.Map;

                while (_map != null)
                {
                    var prop = _map.Property;
                    _map = _map.Parent;

                    if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                    {
                        _visiteds.Add(prop.NameId);
                        _current = prop.Name;
                        return true;
                    }
                }
                _dobject = _dobject.Prototype;
                _elementsIndex = -1;
                _current = null;
                 */
                if (_currentNode == null)
                {
                    //We may have reached to the end of collected properties, but meanwhile some new ones may have been added
                    _propNames.Clear();
                    if (_map != null && _map != _dobject.Map)
                      _map = _dobject.Map;
                    for (var m = _dobject.Map; m != _map; m = m.Parent)
                    {
                        var prop = m.Property;
                        if (!prop.IsNotEnumerable && !_visiteds.Contains(prop.NameId))
                        {
                          _visiteds.Add(prop.NameId);
                          _propNames.AddFirst(prop.Name);
                        }
                    }
                    _map = _dobject.Map;
                    _currentNode = _propNames.First;

                    if (_currentNode == null)
                    {
                        _dobject = _dobject.Prototype;
                        _elementsIndex = -1;
                        _current = null;
                        _map = null;
                        continue; //Jump to begining of the loop!
                    }
                }
                _current = _currentNode.Value;
                _currentNode = _currentNode.Next;
                return true;
            }
            return false;
        }