private static Table GetStringTable() { Table stringTable = new Table(); stringTable.RawPut("len", new State.NativeFuncDelegate(StrLen)); stringTable.RawPut("gsub", new State.NativeFuncDelegate(StrGSub)); stringTable.RawPut("format", new State.NativeFuncDelegate(StrFmt)); return stringTable; }
private static Table GetMathTable() { Table mathTable = new Table(); mathTable.RawPut("sin", new State.NativeFuncDelegate(Sin)); mathTable.RawPut("fmod", new State.NativeFuncDelegate(FMod)); mathTable.RawPut("floor", new State.NativeFuncDelegate(Floor)); return mathTable; }
private static Table GetCoroutineTable() { Table coroutineTable = new Table(); coroutineTable.RawPut("create", new State.NativeFuncDelegate(CoroutineCreate)); coroutineTable.RawPut("resume", new State.NativeCoreFuncDelegate(CoroutineResume)); coroutineTable.RawPut("yield", new State.NativeCoreFuncDelegate(CoroutineYield)); return coroutineTable; }
private static Table GetDebugTable() { Table debugTable = new Table(); debugTable.RawPut ("getinfo", new State.NativeFuncDelegate(DebugGetInfo)); return debugTable; }
private static VarArgs DebugGetInfo(VarArgs args, LamnEngine s) { VarArgs retArgs = new VarArgs(); List<ReturnPoint> stack = s.LamnState.GetStackTrace(); int func = (int)((double)args.PopArg() - 1); String spec = (String)args.PopArg(); if (spec.Equals("n") && func < stack.Count) { Table t = new Table(); ReturnPoint retPoint = stack[func]; t.RawPut("name", retPoint.instructionPointer.CurrentFunction.Name); retArgs.PushArg(t); } return retArgs; }