Array_index_for() static private method

static private Array_index_for ( Object index ) : long
index Object
return long
コード例 #1
0
        public static bool hasOwnProperty(object thisob, object name)
        {
            string str = Microsoft.JScript.Convert.ToString(name);

            if (thisob is ArrayObject)
            {
                long num = ArrayObject.Array_index_for(str);
                if (num >= 0L)
                {
                    object valueAtIndex = ((ArrayObject)thisob).GetValueAtIndex((uint)num);
                    return((valueAtIndex != null) && (valueAtIndex != Microsoft.JScript.Missing.Value));
                }
            }
            if (!(thisob is JSObject))
            {
                return(!(LateBinding.GetMemberValue(thisob, str) is Microsoft.JScript.Missing));
            }
            MemberInfo[] member = ((JSObject)thisob).GetMember(str, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            int          length = member.Length;

            if (length <= 1)
            {
                if (length < 1)
                {
                    return(false);
                }
                if (member[0] is JSPrototypeField)
                {
                    return(!(((JSPrototypeField)member[0]).value is Microsoft.JScript.Missing));
                }
            }
            return(true);
        }
コード例 #2
0
        private void DeleteRange(uint start, uint end)
        {
            uint denseEnd = this.denseArrayLength;

            if (denseEnd > end)
            {
                denseEnd = end;
            }
            for (; start < denseEnd; start++)
            {
                denseArray[(int)start] = Missing.Value;
            }
            if (denseEnd == end)
            {
                return;
            }
            //Go through the field table entries, deleting those with names that are indices between start and end
            IDictionaryEnumerator e   = this.NameTable.GetEnumerator();
            ArrayList             arr = new ArrayList(this.name_table.count);

            while (e.MoveNext())
            {
                long i = ArrayObject.Array_index_for(e.Key.ToString());
                if (i >= start && i <= end)
                {
                    arr.Add(e.Key);
                }
            }
            IEnumerator ae = arr.GetEnumerator();

            while (ae.MoveNext())
            {
                this.DeleteMember((String)ae.Current);
            }
        }
コード例 #3
0
        public static bool hasOwnProperty(Object thisob, Object name)
        {
            String nameStr = Convert.ToString(name);

            if (thisob is ArrayObject)
            {
                long index = ArrayObject.Array_index_for(nameStr);
                if (index >= 0)
                {
                    Object ob = ((ArrayObject)thisob).GetValueAtIndex((uint)index);
                    return(ob != null && ob != Missing.Value);
                }
            }
            if (thisob is JSObject)
            {
                MemberInfo[] members = ((JSObject)thisob).GetMember(nameStr, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly);
                int          n       = members.Length;
                if (n > 1)
                {
                    return(true);
                }
                if (n < 1)
                {
                    return(false);
                }
                if (members[0] is JSPrototypeField)
                {
                    //Do not count it as an "own" property unless it has been written to
                    return(!(((JSPrototypeField)members[0]).value is Missing));
                }
                return(true);
            }
            return(!(LateBinding.GetMemberValue(thisob, nameStr) is Missing));
        }
コード例 #4
0
        internal override object GetMemberValue(string name)
        {
            long num = ArrayObject.Array_index_for(name);

            if (num < 0L)
            {
                return(base.GetMemberValue(name));
            }
            return(this.GetValueAtIndex((uint)num));
        }
コード例 #5
0
ファイル: regexpmatch.cs プロジェクト: SSCLI/sscli_20021101
 internal override Object GetMemberValue(String name)
 {
     if (!this.hydrated)
     {
         long index = ArrayObject.Array_index_for(name);
         if (index >= 0)
         {
             return(this.GetValueAtIndex((uint)index));
         }
     }
     return(base.GetMemberValue(name));
 }
コード例 #6
0
        internal override bool DeleteMember(String name)
        {
            long i = ArrayObject.Array_index_for(name);

            if (i >= 0)
            {
                return(this.DeleteValueAtIndex((uint)i));
            }
            else
            {
                return(base.DeleteMember(name));
            }
        }
コード例 #7
0
        internal override void SetMemberValue(String name, Object val)
        {
            if (name.Equals("length"))
            {
                throw new JScriptException(JSError.AssignmentToReadOnly);
            }
            long index = ArrayObject.Array_index_for(name);

            if (index < 0)
            {
                base.SetMemberValue(name, val);
            }
            else
            {
                this.value.SetValue(val, (int)index);
            }
        }
コード例 #8
0
        internal override void SetMemberValue(String name, Object value)
        {
            if (name.Equals("length"))
            {
                this.length = value;
                return;
            }
            long index = ArrayObject.Array_index_for(name);

            if (index < 0)
            {
                base.SetMemberValue(name, value);
            }
            else
            {
                this.SetValueAtIndex((uint)index, value);
            }
        }
コード例 #9
0
        public static bool propertyIsEnumerable(Object thisob, Object name)
        {
            String nameStr = Convert.ToString(name);

            if (thisob is ArrayObject)
            {
                long index = ArrayObject.Array_index_for(nameStr);
                if (index >= 0)
                {
                    Object ob = ((ArrayObject)thisob).GetValueAtIndex((uint)index);
                    return(ob != null && ob != Missing.Value);
                }
            }
            if (thisob is JSObject)
            {
                FieldInfo f = ((JSObject)thisob).GetField(nameStr, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly);
                return(f != null && f is JSExpandoField);
            }
            return(false);
        }
コード例 #10
0
        public static bool propertyIsEnumerable(object thisob, object name)
        {
            string str = Microsoft.JScript.Convert.ToString(name);

            if (thisob is ArrayObject)
            {
                long num = ArrayObject.Array_index_for(str);
                if (num >= 0L)
                {
                    object valueAtIndex = ((ArrayObject)thisob).GetValueAtIndex((uint)num);
                    return((valueAtIndex != null) && (valueAtIndex != Microsoft.JScript.Missing.Value));
                }
            }
            if (!(thisob is JSObject))
            {
                return(false);
            }
            FieldInfo field = ((JSObject)thisob).GetField(str, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            return((field != null) && (field is JSExpandoField));
        }
コード例 #11
0
        internal virtual void Concat(ArrayObject source)
        {
            uint sourceLength = source.len;

            if (sourceLength == 0)
            {
                return;
            }
            uint oldLength = this.len;

            this.SetLength(oldLength + (ulong)sourceLength);
            uint slen = sourceLength;

            if (!(source is ArrayWrapper) && sourceLength > source.denseArrayLength)
            {
                slen = source.denseArrayLength;
            }
            uint j = oldLength;

            for (uint i = 0; i < slen; i++)
            {
                this.SetValueAtIndex(j++, source.GetValueAtIndex(i));
            }
            if (slen == sourceLength)
            {
                return;
            }
            //Iterate over the sparse indices of source
            IDictionaryEnumerator e = source.NameTable.GetEnumerator();

            while (e.MoveNext())
            {
                long i = ArrayObject.Array_index_for(e.Key.ToString());
                if (i >= 0)
                {
                    this.SetValueAtIndex(oldLength + (uint)i, ((JSField)e.Value).GetValue(null));
                }
            }
        }