コード例 #1
0
        public static Task <LuaArguments> Pairs(Engine engine, LuaArguments args, CancellationToken token = default)
        {
            var handler = args[0].GetMetaMethod(engine, "__pairs");

            return(!handler.IsNil()
                ? handler.CallAsync(engine, args, token)
                : Lua.ArgsAsync(LuaObject.FromFunction(Next), args[0], LuaNil.Instance));
        }
コード例 #2
0
        public Task <LuaArguments> EvaluateVarargs(LuaState state)
        {
            var current = state.Context;

            while (!(current is LuaTableFunction))
            {
                if (current.Parent.IsNil())
                {
                    return(Lua.ArgsAsync());
                }

                current = (LuaTable)current.Parent;
            }

            return(Lua.ArgsAsync(((LuaTableFunction)current).Varargs));
        }
コード例 #3
0
        public static Task <LuaArguments> Ipairs(Engine engine, LuaArguments args, CancellationToken token = default)
        {
            var handler = args[0].GetMetaMethod(engine, "__ipairs");

            if (!handler.IsNil())
            {
                return(handler.CallAsync(engine, args, token));
            }

            if (!args[0].IsTable())
            {
                throw new LuaException("t must be a table");
            }

            return(Lua.ArgsAsync(LuaObject.FromFunction(GetNext), args[0], 0));
        }
コード例 #4
0
ファイル: AssertLibrary.cs プロジェクト: GerardSmit/Yali
        public Task <LuaArguments> CallAsync(LuaArguments args, CancellationToken token = default)
        {
            Assert.True(args[0].ToBoolean());

            return(Lua.ArgsAsync());
        }
コード例 #5
0
 public Task <LuaArguments> EvaluateFunctionDefinition(FunctionDefinition definition, LuaState state, CancellationToken token = default)
 {
     return(Lua.ArgsAsync(new LuaInterpreterFunction(_engine, definition, state.Context, false)));
 }
コード例 #6
0
 public static Task <LuaArguments> ToString(LuaArguments args, CancellationToken token = default)
 {
     return(Lua.ArgsAsync(args[0].AsString()));
 }