public void Trace(StackFrame stackFrame, LuaObject[] args) { var sb = new StringBuilder(); sb.Append("trace:"); var currentFrame = stackFrame; while (currentFrame.module != null) { sb.Append(currentFrame.module.name); sb.Append(';'); currentFrame = currentFrame.parent; } stackFrame.Push(vm.GetString(sb.ToString())); }
public LuaLibrary(LVM vm) { this.vm = vm; stackFrame = vm.stackFrame; Add(traceFunc = new LuaNative(vm, "trace", Trace)); Add(printFunc = new LuaNative(vm, "print", Print)); Add(lenFunc = new LuaNative(vm, "len", Length)); Add(pairsFunc = new LuaNative(vm, "pairs", Pairs)); Add(nextFunc = new LuaNative(vm, "next", Next)); Add(ipairsFunc = new LuaNative(vm, "ipairs", IPairs)); Add(iterFunc = new LuaNative(vm, vm.NewUID(), Iterator)); Add(setmetaFunc = new LuaNative(vm, "setmetatable", SetMetatable)); Add(getmetaFunc = new LuaNative(vm, "getmetatable", GetMetatable)); Add("table", table = vm.GetTable()); table.Bind(vm.GetString("insert"), new LuaNative(vm, "insert", Insert)); }