ToInt32() 공개 정적인 메소드

public static ToInt32 ( object value ) : int
value object
리턴 int
예제 #1
0
        public override void SetValue(object index, ScriptObject obj)
        {
            if (!(index is double || index is int || index is long))
            {
                throw new ExecutionException(Script, "Array SetValue只支持Number类型 name = " + Name + " index = " + index);
            }
            int i = Util.ToInt32(index);

            if (i < 0 || i >= m_listObject.Count)
            {
                throw new ExecutionException(Script, "Array SetValue索引小于0或者超过最大值 name = " + Name + " index = " + index);
            }
            m_listObject[i] = obj;
        }
예제 #2
0
 public ScriptObject GetValueInternal(object key)
 {
     if (key is string)
     {
         return(GetValue((string)key));
     }
     else if (key is int || key is double)
     {
         return(GetValue(Util.ToInt32(key)));
     }
     else
     {
         return(GetValue(key));
     }
 }
예제 #3
0
 public void SetValueInternal(object key, ScriptObject value)
 {
     if (key is string)
     {
         SetValue((string)key, value);
     }
     else if (key is int || key is double)
     {
         SetValue(Util.ToInt32(key), value);
     }
     else
     {
         SetValue(key, value);
     }
 }
예제 #4
0
        public override void SetValue(object index, ScriptObject obj)
        {
            if ((!(index is double) && !(index is int)) && !(index is long))
            {
                throw new ExecutionException(base.m_Script, this, "Array SetValue只支持Number类型 index值为:" + index);
            }
            int num = Util.ToInt32(index);

            if (num < 0)
            {
                throw new ExecutionException(base.m_Script, this, "Array SetValue索引小于0 index值为:" + index);
            }
            if (num >= this.m_size)
            {
                this.EnsureCapacity(num + 1);
                this.m_size = num + 1;
            }
            this.m_listObject[num] = obj;
        }
예제 #5
0
 public override ScriptObject GetValue(object index)
 {
     if (index is double || index is int || index is long)
     {
         int i = Util.ToInt32(index);
         if (i < 0)
         {
             throw new ExecutionException(m_Script, this, "Array GetValue索引小于0 index值为:" + index);
         }
         if (i >= m_size)
         {
             return(m_null);
         }
         return(m_listObject[i] ?? m_null);
     }
     else if (index is string && index.Equals("length"))
     {
         return(m_Script.CreateDouble(Util.ToDouble(m_size)));
     }
     throw new ExecutionException(m_Script, this, "Array GetValue只支持Number类型 index值为:" + index);
 }
예제 #6
0
 public override void SetValue(object index, ScriptObject obj)
 {
     if (index is double || index is int || index is long)
     {
         int i = Util.ToInt32(index);
         if (i < 0)
         {
             throw new ExecutionException(m_Script, this, "Array SetValue索引小于0 index值为:" + index);
         }
         if (i >= m_size)
         {
             EnsureCapacity(i + 1);
             m_size = i + 1;
         }
         m_listObject[i] = obj;
     }
     else
     {
         throw new ExecutionException(m_Script, this, "Array SetValue只支持Number类型 index值为:" + index);
     }
 }
예제 #7
0
 public override ScriptObject GetValue(object index)
 {
     if (((index is double) || (index is int)) || (index is long))
     {
         int num = Util.ToInt32(index);
         if (num < 0)
         {
             throw new ExecutionException(base.m_Script, this, "Array GetValue索引小于0 index值为:" + index);
         }
         if (num >= this.m_size)
         {
             return(this.m_null);
         }
         return(this.m_listObject[num] ?? this.m_null);
     }
     if (!(index is string) || !index.Equals("length"))
     {
         throw new ExecutionException(base.m_Script, this, "Array GetValue只支持Number类型 index值为:" + index);
     }
     return(base.m_Script.CreateDouble(Util.ToDouble(this.m_size)));
 }
예제 #8
0
        public abstract ScriptObject AssignCompute(TokenType type, ScriptNumber obj);   //位运算或者运算符复制运算 += -= *= /= %= |= &= ^= >>= <<=

        public int ToInt32()
        {
            return(Util.ToInt32(ObjectValue));
        }
예제 #9
0
 public virtual int ToInt32()
 {
     return(Util.ToInt32(this.ObjectValue));
 }