/// <summary> /// 以名称获取字段,没有就返回nil /// </summary> /// <param name="name"></param> /// <returns></returns> public ScriptObject GetFileld(string filed) { Contract.Assert(Type == ValueType.TABLE); TablePart tablePart = Value.RefPartHandle.ConverToTablePart(); ScriptObject s = tablePart.TryGetValue(filed); if (s != null) { return(s); } ScriptObject metaTable = tablePart.MetaTable; if (metaTable != null) { s = metaTable.GetFileld("_index"); if (s.Type == ValueType.TABLE) { return(s.GetFileld(filed)); } else if (s.Type == ValueType.FUNCTION) { //多一次拷贝(实际上) //RunEnvironment.Instance.LocalStack.InvokeFunction(s, this, ScriptObject.CreateString(filed)); StackState state = RunEnvironment.Instance.LocalStack; state.PushFunction(s); state.Push(this); state.Push(filed); return(state.InvokeFunction()); } } return(RunEnvironment.Nil); }
public static ScriptObject GetThisValue() { StackState stack = RunEnvironment.Instance.LocalStack; return(stack.This); }
public static void SetThisValue(ScriptObject own) { StackState stack = RunEnvironment.Instance.LocalStack; Instructor.AssignVar(stack.This, own); }
public static void SetReturn(ScriptObject res) { StackState stack = RunEnvironment.Instance.LocalStack; stack.SetReturn(res); }
/// <summary> /// 设置返回值为空 /// </summary> public static void SetReturnVoid() { StackState stack = RunEnvironment.Instance.LocalStack; stack.SetReturnVoid(); }
/// <summary> /// 调用栈中的函数 /// </summary> public static ScriptObject InvokeFuncInStack() { StackState stack = RunEnvironment.Instance.LocalStack; return(stack.InvokeFunction()); }
/// <summary> /// 函数参数压栈 /// </summary> /// <param name="parameter"></param> public static void PushParameter(ScriptObject parameter) { StackState stack = RunEnvironment.Instance.LocalStack; stack.PushFuncParameter(parameter); }
/// <summary> /// 函数压栈 /// </summary> /// <param name="func"></param> /// <returns>返回栈中的位置下表</returns> public static void PushFunction(ScriptObject func) { StackState stack = RunEnvironment.Instance.LocalStack; stack.PushFunction(func); }
/// <summary> /// 将局部变量压栈 /// </summary> /// <param name="obj"></param> public static void StackPush(ScriptObject obj) { StackState stack = RunEnvironment.Instance.LocalStack; stack.Push(obj); }
public static void StackPop(int count) { StackState stack = RunEnvironment.Instance.LocalStack; stack.Pop(count); }