Beispiel #1
0
        static void Main(string[] args)
        {
            ILuaState ls = new LuaStateImplement();

            ls.PushBoolean(true);
            printStack(ls);
            ls.PushInteger(1024);
            printStack(ls);
            ls.PushString("Wocao");
            printStack(ls);
            ls.PushNumber(233.444);
            printStack(ls);
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     if (args.Length > 0)
     {
         string path = Path.GetFullPath(args[0]);
         Console.WriteLine($"path {path}");
         byte[]    data = File.ReadAllBytes(Path.GetFullPath(args[0]));
         ILuaState ls   = new LuaStateImplement();
         ls.Load(data, args[0], "b");
         ls.Call(0, 0);
         //Prototype proto = BinaryChunk.Undump(data);
     }
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            ILuaState ls = new LuaStateImplement();

            ls.PushInteger(2);
            ls.PushString("2.0");
            ls.PushString("3.0");
            ls.PushNumber(4.0);
            printStack(ls);

            ls.Arith(ArithOpEnum.LUA_OPADD);
            printStack(ls);
            ls.Arith(ArithOpEnum.LUA_OPSUB);
            printStack(ls);
        }
Beispiel #4
0
        private static void luaMain(Prototype proto)
        {
            ILuaVM vm = new LuaStateImplement();

            vm.SetTop(proto.MaxStackSize);
            for (; ;)
            {
                int    pc     = vm.GetPC();
                int    i      = vm.Fetch();
                OpCode opCode = Instruction.GetOpCode(i);
                if (opCode.NotEqual(OpCodeEnum.OP_RETURN))
                {
                    opCode.Action(i, vm);
                    System.Console.WriteLine($"Pc {pc + 1} ,OpcodeName {opCode.Name}");
                    printStack(vm);
                }
                else
                {
                }
            }
        }
Beispiel #5
0
        public static void luaMain(Prototype proto)
        {
            ILuaVM vm = new LuaStateImplement(proto);

            vm.SetTop(proto.MaxStackSize);
            for (; ;)
            {
                int    pc     = vm.GetPC();
                int    i      = vm.Fetch();
                OpCode opCode = Instruction.GetOpCode(i);
                if (opCode.NotEqual(OpCodeEnum.OP_RETURN))
                {
                    opCode.Action(i, vm);
                    Console.WriteLine(string.Format("[{0}] {1}", pc + 1, opCode.ToString()));
                    printStack(vm);
                }
                else
                {
                    break;
                }
            }
        }