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)); }
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)); }
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)); }
public Task <LuaArguments> CallAsync(LuaArguments args, CancellationToken token = default) { Assert.True(args[0].ToBoolean()); return(Lua.ArgsAsync()); }
public Task <LuaArguments> EvaluateFunctionDefinition(FunctionDefinition definition, LuaState state, CancellationToken token = default) { return(Lua.ArgsAsync(new LuaInterpreterFunction(_engine, definition, state.Context, false))); }
public static Task <LuaArguments> ToString(LuaArguments args, CancellationToken token = default) { return(Lua.ArgsAsync(args[0].AsString())); }