private static void printOperands(Instruction i) { int a, b, c, ax, bx, sbx; switch (i.OpMode()) { case OpCodes.IABC: var abc = i.ABC(); Console.Write($"{abc.Item1:D}", abc.Item1); if (i.BMode() != OpCodes.OpArgN) { if (abc.Item2 > 0xFF) { Console.Write($" {-1 - (abc.Item2 & 0xFF):D}"); } else { Console.Write($" {abc.Item2:D}"); } } if (i.CMode() != OpCodes.OpArgN) { if (abc.Item3 > 0xFF) { Console.Write($"{-1 - (abc.Item3 & 0xFF):D}"); } else { Console.Write($" {abc.Item3:D}"); } } break; case OpCodes.IABx: var aBx = i.ABx(); Console.Write($" {aBx.Item1:D}"); if (i.BMode() == OpCodes.OpArgK) { Console.Write($"{-1 - aBx.Item2:D}"); } else if (i.BMode() == OpCodes.OpArgU) { Console.Write($" {aBx.Item2:D}"); } break; case OpCodes.IAsBx: var asBx = i.AsBx(); Console.Write($"{asBx.Item1:D} {asBx.Item2:D}"); break; case OpCodes.IAx: ax = i.Ax(); Console.Write($"{-1 - ax:D}"); break; } }
internal static void LoadK(Instruction i, ILuaVM vm) { var(a, bx) = i.ABx(); a += 1; vm.GetConst(bx); vm.Replace(a); }
internal static void Closure(Instruction i, ILuaVM vm) { var(a, bx) = i.ABx(); a += 1; vm.LoadProto(bx); vm.Replace(a); }
internal static void LoadKx(Instruction i, ILuaVM vm) { var(a, _) = i.ABx(); a += 1; int ax = ((Instruction)vm.Fetch()).Ax(); vm.GetConst(ax); vm.Replace(a); }