SetMemberValue() private method

private SetMemberValue ( Object obj, String name, Object value ) : void
obj Object
name String
value Object
return void
コード例 #1
0
        public static Object unshift(Object thisob, params Object[] args)
        {
            if (args == null || args.Length == 0)
            {
                return(thisob);
            }
            if (thisob is ArrayObject)
            {
                return(((ArrayObject)thisob).Unshift(args));
            }
            uint oldLength = Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));
            long newLength = oldLength + args.Length;

            LateBinding.SetMemberValue(thisob, "length", newLength);
            // shift the array
            for (long i = oldLength - 1; i >= 0; i--)
            {
                Object val = LateBinding.GetValueAtIndex(thisob, (ulong)i);
                if (val is Missing)
                {
                    LateBinding.DeleteValueAtIndex(thisob, (ulong)(i + args.Length));
                }
                else
                {
                    LateBinding.SetValueAtIndex(thisob, (ulong)(i + args.Length), val);
                }
            }
            // copy the input args
            for (uint i = 0; i < args.Length; i++)
            {
                LateBinding.SetValueAtIndex(thisob, i, args[i]);
            }
            return(thisob);
        }
コード例 #2
0
        public static Object shift(Object thisob)
        {
            Object res = null;

            if (thisob is ArrayObject)
            {
                return(((ArrayObject)thisob).Shift());
            }
            uint length = Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            if (length == 0)
            {
                LateBinding.SetMemberValue(thisob, "length", 0);
                return(res);
            }
            res = LateBinding.GetValueAtIndex(thisob, 0);
            for (uint i = 1; i < length; i++)
            {
                Object val = LateBinding.GetValueAtIndex(thisob, i);
                if (val is Missing)
                {
                    LateBinding.DeleteValueAtIndex(thisob, i - 1);
                }
                else
                {
                    LateBinding.SetValueAtIndex(thisob, i - 1, val);
                }
            }
            LateBinding.DeleteValueAtIndex(thisob, length - 1);
            LateBinding.SetMemberValue(thisob, "length", length - 1);
            return(res);
        }
コード例 #3
0
 internal override void SetMemberValue(string name, object value)
 {
     MemberInfo[] member = this.GetMember(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
     if (member.Length == 0)
     {
         if (VsaEngine.executeForJSEE)
         {
             throw new JScriptException(JSError.UndefinedIdentifier, new Context(new DocumentContext("", null), name));
         }
         FieldInfo info = this.AddField(name);
         if (info != null)
         {
             info.SetValue(this, value);
         }
     }
     else
     {
         MemberInfo info2 = LateBinding.SelectMember(member);
         if (info2 == null)
         {
             throw new JScriptException(JSError.AssignmentToReadOnly);
         }
         LateBinding.SetMemberValue(this, name, value, info2, member);
     }
 }
コード例 #4
0
        internal override void SetMemberValue(String name, Object value)
        {
            MemberInfo[] members = this.GetMember(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
            if (members.Length == 0)
            {
                // We do not want to create expando fields on the global object when assigning to an undefined
                // variable in the debugger.
                if (VsaEngine.executeForJSEE)
                {
                    throw new JScriptException(JSError.UndefinedIdentifier, new Context(new DocumentContext("", null), name));
                }
                FieldInfo field = this.AddField(name);
                if (field != null)
                {
                    field.SetValue(this, value);
                }
                return;
            }
            MemberInfo m = LateBinding.SelectMember(members);

            if (m == null)
            {
                throw new JScriptException(JSError.AssignmentToReadOnly);
            }
            LateBinding.SetMemberValue(this, name, value, m, members);
        }
コード例 #5
0
 public static object unshift(object thisob, params object[] args)
 {
     if ((args != null) && (args.Length != 0))
     {
         if (thisob is ArrayObject)
         {
             return(((ArrayObject)thisob).Unshift(args));
         }
         uint num  = Microsoft.JScript.Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));
         long num2 = num + args.Length;
         LateBinding.SetMemberValue(thisob, "length", num2);
         for (long i = num - 1; i >= 0L; i -= 1L)
         {
             object valueAtIndex = LateBinding.GetValueAtIndex(thisob, (ulong)i);
             if (valueAtIndex is Missing)
             {
                 LateBinding.DeleteValueAtIndex(thisob, (ulong)(i + args.Length));
             }
             else
             {
                 LateBinding.SetValueAtIndex(thisob, (ulong)(i + args.Length), valueAtIndex);
             }
         }
         for (uint j = 0; j < args.Length; j++)
         {
             LateBinding.SetValueAtIndex(thisob, (ulong)j, args[j]);
         }
     }
     return(thisob);
 }
コード例 #6
0
        public static object shift(object thisob)
        {
            object valueAtIndex = null;

            if (thisob is ArrayObject)
            {
                return(((ArrayObject)thisob).Shift());
            }
            uint num = Microsoft.JScript.Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            if (num == 0)
            {
                LateBinding.SetMemberValue(thisob, "length", 0);
                return(valueAtIndex);
            }
            valueAtIndex = LateBinding.GetValueAtIndex(thisob, 0L);
            for (uint i = 1; i < num; i++)
            {
                object obj3 = LateBinding.GetValueAtIndex(thisob, (ulong)i);
                if (obj3 is Missing)
                {
                    LateBinding.DeleteValueAtIndex(thisob, (ulong)(i - 1));
                }
                else
                {
                    LateBinding.SetValueAtIndex(thisob, (ulong)(i - 1), obj3);
                }
            }
            LateBinding.DeleteValueAtIndex(thisob, (ulong)(num - 1));
            LateBinding.SetMemberValue(thisob, "length", num - 1);
            return(valueAtIndex);
        }
コード例 #7
0
 internal override void SetMemberValue(String name, Object value)
 {
     if (LateBinding.GetMemberValue2(this.contained_object, name) is Missing)
     {
         ((ScriptObject)this.parent).SetMemberValue(name, value);
     }
     else
     {
         LateBinding.SetMemberValue(this.contained_object, name, value);
     }
 }
コード例 #8
0
 internal override void SetMemberValue(string name, object value)
 {
     if (LateBinding.GetMemberValue2(this.contained_object, name) is Microsoft.JScript.Missing)
     {
         base.parent.SetMemberValue(name, value);
     }
     else
     {
         LateBinding.SetMemberValue(this.contained_object, name, value);
     }
 }
コード例 #9
0
        public static long push(Object thisob, params Object[] args)
        {
            uint length = Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            for (uint i = 0; i < args.Length; i++)
            {
                LateBinding.SetValueAtIndex(thisob, i + (ulong)length, args[i]);
            }
            long newLength = length + args.Length;

            LateBinding.SetMemberValue(thisob, "length", newLength);
            return(newLength);
        }
コード例 #10
0
        public static long push(object thisob, params object[] args)
        {
            uint num = Microsoft.JScript.Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            for (uint i = 0; i < args.Length; i++)
            {
                LateBinding.SetValueAtIndex(thisob, i + num, args[i]);
            }
            long num3 = num + args.Length;

            LateBinding.SetMemberValue(thisob, "length", num3);
            return(num3);
        }
コード例 #11
0
        public static Object pop(Object thisob)
        {
            uint thisLength = Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            if (thisLength == 0)
            {
                LateBinding.SetMemberValue(thisob, "length", 0);
                return(null);
            }
            Object result = LateBinding.GetValueAtIndex(thisob, thisLength - 1);

            LateBinding.DeleteValueAtIndex(thisob, thisLength - 1);
            LateBinding.SetMemberValue(thisob, "length", thisLength - 1);
            return(result);
        }
コード例 #12
0
        public static object pop(object thisob)
        {
            uint num = Microsoft.JScript.Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));

            if (num == 0)
            {
                LateBinding.SetMemberValue(thisob, "length", 0);
                return(null);
            }
            object valueAtIndex = LateBinding.GetValueAtIndex(thisob, (ulong)(num - 1));

            LateBinding.DeleteValueAtIndex(thisob, (ulong)(num - 1));
            LateBinding.SetMemberValue(thisob, "length", num - 1);
            return(valueAtIndex);
        }
コード例 #13
0
        public static ArrayObject splice(Object thisob, VsaEngine engine, double start, double deleteCnt, params Object[] args)
        {
            uint oldLength = Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));
            // compute the start index
            long startIndex = Runtime.DoubleToInt64(Convert.ToInteger(start));

            if (startIndex < 0)
            {
                startIndex = oldLength + startIndex;
                if (startIndex < 0)
                {
                    startIndex = 0;
                }
            }
            else if (startIndex > oldLength)
            {
                startIndex = oldLength;
            }

            // compute the number of items to delete
            long deleteCount = Runtime.DoubleToInt64(Convert.ToInteger(deleteCnt));

            if (deleteCount < 0)
            {
                deleteCount = 0;
            }
            else if (deleteCount > oldLength - startIndex)
            {
                deleteCount = oldLength - startIndex;
            }
            long newLength = oldLength + args.Length - deleteCount;

            // create an array for the result
            ArrayObject result = engine.GetOriginalArrayConstructor().Construct();

            result.length = deleteCount;

            // special case array objects (nice speedup if dense)
            if (thisob is ArrayObject)
            {
                ((ArrayObject)thisob).Splice((uint)startIndex, (uint)deleteCount, args, result, (uint)oldLength, (uint)newLength);
                return(result);
            }

            // copy the deleted items to the result array
            for (ulong i = 0; i < (ulong)deleteCount; i++)
            {
                result.SetValueAtIndex((uint)i, LateBinding.GetValueAtIndex(thisob, i + (ulong)startIndex));
            }

            // shift the remaining elements left or right
            long n = oldLength - startIndex - deleteCount;

            if (newLength < oldLength)
            {
                for (long i = 0; i < n; i++)
                {
                    LateBinding.SetValueAtIndex(thisob, (ulong)(i + startIndex + args.Length), LateBinding.GetValueAtIndex(thisob, (ulong)(i + startIndex + deleteCount)));
                }
                LateBinding.SetMemberValue(thisob, "length", newLength);
            }
            else
            {
                LateBinding.SetMemberValue(thisob, "length", newLength);
                for (long i = n - 1; i >= 0; i--)
                {
                    LateBinding.SetValueAtIndex(thisob, (ulong)(i + startIndex + args.Length), LateBinding.GetValueAtIndex(thisob, (ulong)(i + startIndex + deleteCount)));
                }
            }

            // splice in the arguments
            int m = args == null ? 0 : args.Length;

            for (uint i = 0; i < m; i++)
            {
                LateBinding.SetValueAtIndex(thisob, i + (ulong)startIndex, args[i]);
            }

            return(result);
        }
コード例 #14
0
ファイル: scriptobject.cs プロジェクト: SSCLI/sscli_20021101
 //This routine combines a GetField/GetProperty (with expando) and a subsequent SetValue operation.
 //It is used when the Field/Property cannot be cached. It is overridden by JSObject and GlobalScope to provide expando
 internal virtual void SetMemberValue(String name, Object value)
 {
     MemberInfo[] members = this.GetMember(name, BindingFlags.Instance | BindingFlags.Public);
     LateBinding.SetMemberValue(this, name, value, LateBinding.SelectMember(members), members);
 }
コード例 #15
0
        public static ArrayObject splice(object thisob, VsaEngine engine, double start, double deleteCnt, params object[] args)
        {
            uint oldLength = Microsoft.JScript.Convert.ToUint32(LateBinding.GetMemberValue(thisob, "length"));
            long num2      = Runtime.DoubleToInt64(Microsoft.JScript.Convert.ToInteger(start));

            if (num2 < 0L)
            {
                num2 = oldLength + num2;
                if (num2 < 0L)
                {
                    num2 = 0L;
                }
            }
            else if (num2 > oldLength)
            {
                num2 = oldLength;
            }
            long num3 = Runtime.DoubleToInt64(Microsoft.JScript.Convert.ToInteger(deleteCnt));

            if (num3 < 0L)
            {
                num3 = 0L;
            }
            else if (num3 > (oldLength - num2))
            {
                num3 = oldLength - num2;
            }
            long        num4     = (oldLength + args.Length) - num3;
            ArrayObject outArray = engine.GetOriginalArrayConstructor().Construct();

            outArray.length = num3;
            if (thisob is ArrayObject)
            {
                ((ArrayObject)thisob).Splice((uint)num2, (uint)num3, args, outArray, oldLength, (uint)num4);
                return(outArray);
            }
            for (ulong i = 0L; i < num3; i += (ulong)1L)
            {
                outArray.SetValueAtIndex((uint)i, LateBinding.GetValueAtIndex(thisob, i + ((ulong)num2)));
            }
            long num6 = (oldLength - num2) - num3;

            if (num4 < oldLength)
            {
                for (long k = 0L; k < num6; k += 1L)
                {
                    LateBinding.SetValueAtIndex(thisob, (ulong)((k + num2) + args.Length), LateBinding.GetValueAtIndex(thisob, (ulong)((k + num2) + num3)));
                }
                LateBinding.SetMemberValue(thisob, "length", num4);
            }
            else
            {
                LateBinding.SetMemberValue(thisob, "length", num4);
                for (long m = num6 - 1L; m >= 0L; m -= 1L)
                {
                    LateBinding.SetValueAtIndex(thisob, (ulong)((m + num2) + args.Length), LateBinding.GetValueAtIndex(thisob, (ulong)((m + num2) + num3)));
                }
            }
            int num9 = (args == null) ? 0 : args.Length;

            for (uint j = 0; j < num9; j++)
            {
                LateBinding.SetValueAtIndex(thisob, (ulong)(j + num2), args[j]);
            }
            return(outArray);
        }
コード例 #16
0
 internal virtual void SetMemberValue(string name, object value)
 {
     MemberInfo[] member = this.GetMember(name, BindingFlags.Public | BindingFlags.Instance);
     LateBinding.SetMemberValue(this, name, value, LateBinding.SelectMember(member), member);
 }