Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        public static ScriptObject GetThisValue()
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            return(stack.This);
        }
Esempio n. 3
0
        public static void SetThisValue(ScriptObject own)
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            Instructor.AssignVar(stack.This, own);
        }
Esempio n. 4
0
        public static void SetReturn(ScriptObject res)
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            stack.SetReturn(res);
        }
Esempio n. 5
0
        /// <summary>
        ///   设置返回值为空
        /// </summary>
        public static void SetReturnVoid()
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            stack.SetReturnVoid();
        }
Esempio n. 6
0
        /// <summary>
        ///   调用栈中的函数
        /// </summary>
        public static ScriptObject InvokeFuncInStack()
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            return(stack.InvokeFunction());
        }
Esempio n. 7
0
        /// <summary>
        ///    函数参数压栈
        /// </summary>
        /// <param name="parameter"></param>
        public static void PushParameter(ScriptObject parameter)
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            stack.PushFuncParameter(parameter);
        }
Esempio n. 8
0
        /// <summary>
        ///    函数压栈
        /// </summary>
        /// <param name="func"></param>
        /// <returns>返回栈中的位置下表</returns>
        public static void PushFunction(ScriptObject func)
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            stack.PushFunction(func);
        }
Esempio n. 9
0
        /// <summary>
        ///    将局部变量压栈
        /// </summary>
        /// <param name="obj"></param>
        public static void StackPush(ScriptObject obj)
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            stack.Push(obj);
        }
Esempio n. 10
0
        public static void StackPop(int count)
        {
            StackState stack = RunEnvironment.Instance.LocalStack;

            stack.Pop(count);
        }