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; }
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)); } }
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); } }
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; }
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); }
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); } }
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))); }
public abstract ScriptObject AssignCompute(TokenType type, ScriptNumber obj); //位运算或者运算符复制运算 += -= *= /= %= |= &= ^= >>= <<= public int ToInt32() { return(Util.ToInt32(ObjectValue)); }
public virtual int ToInt32() { return(Util.ToInt32(this.ObjectValue)); }