public ScriptObject CreateObject(object value) { if (value == null) { return(m_Null); } else if (value is bool) { return(CreateBool((bool)value)); } else if (value is string) { return(new ScriptString(this, (string)value)); } else if (value is long) { return(new ScriptNumberLong(this, (long)value)); } else if (value is sbyte || value is byte || value is short || value is ushort || value is int || value is uint || value is float || value is double || value is decimal) { return(new ScriptNumberDouble(this, Util.ToDouble(value))); } else if (value is ScriptObject) { return((ScriptObject)value); } else if (value is ScorpioFunction) { return(new ScriptDelegateFunction(this, (ScorpioFunction)value)); } else if (value is ScorpioHandle) { return(new ScriptHandleFunction(this, (ScorpioHandle)value)); } else if (value is ScorpioMethod) { return(new ScriptMethodFunction(this, (ScorpioMethod)value)); } else if (value.GetType().GetTypeInfo().IsEnum) { return(new ScriptEnum(this, value)); } return(CreateUserdata(value)); }
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 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 ScriptNumber CreateNumber(object value) { return(Util.IsLongObject(value) ? CreateLong((long)value) : CreateDouble(Util.ToDouble(value))); }
public virtual double ToDouble() { return(Util.ToDouble(ObjectValue)); }