|
@@ -7,7 +7,6 @@ public partial struct Instruction(uint value)
|
|
|
public const int IAsBx = 2;
|
|
public const int IAsBx = 2;
|
|
|
public const int IAx = 3;
|
|
public const int IAx = 3;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
public uint Value = value;
|
|
public uint Value = value;
|
|
|
|
|
|
|
|
public static implicit operator Instruction(uint value)
|
|
public static implicit operator Instruction(uint value)
|
|
@@ -62,30 +61,31 @@ public partial struct Instruction(uint value)
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
-const (
|
|
|
|
|
- sizeC = 9
|
|
|
|
|
- sizeB = 9
|
|
|
|
|
- sizeBx = sizeC + sizeB
|
|
|
|
|
- sizeA = 8
|
|
|
|
|
- sizeAx = sizeC + sizeB + sizeA
|
|
|
|
|
- sizeOp = 6
|
|
|
|
|
- posOp = 0
|
|
|
|
|
- posA = posOp + sizeOp
|
|
|
|
|
- posC = posA + sizeA
|
|
|
|
|
- posB = posC + sizeC
|
|
|
|
|
- posBx = posC
|
|
|
|
|
- posAx = posA
|
|
|
|
|
- bitRK = 1 << (sizeB - 1)
|
|
|
|
|
- maxIndexRK = bitRK - 1
|
|
|
|
|
- maxArgAx = 1<<sizeAx - 1
|
|
|
|
|
- maxArgBx = 1<<sizeBx - 1
|
|
|
|
|
- maxArgSBx = maxArgBx >> 1 // sBx is signed
|
|
|
|
|
- maxArgA = 1<<sizeA - 1
|
|
|
|
|
- maxArgB = 1<<sizeB - 1
|
|
|
|
|
- maxArgC = 1<<sizeC - 1
|
|
|
|
|
- listItemsPerFlush = 50 // # list items to accumulate before a setList instruction
|
|
|
|
|
-)
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ const (
|
|
|
|
|
+ sizeC = 9
|
|
|
|
|
+ sizeB = 9
|
|
|
|
|
+ sizeBx = sizeC + sizeB
|
|
|
|
|
+ sizeA = 8
|
|
|
|
|
+ sizeAx = sizeC + sizeB + sizeA
|
|
|
|
|
+ sizeOp = 6
|
|
|
|
|
+ posOp = 0
|
|
|
|
|
+ posA = posOp + sizeOp
|
|
|
|
|
+ posC = posA + sizeA
|
|
|
|
|
+ posB = posC + sizeC
|
|
|
|
|
+ posBx = posC
|
|
|
|
|
+ posAx = posA
|
|
|
|
|
+ bitRK = 1 << (sizeB - 1)
|
|
|
|
|
+ maxIndexRK = bitRK - 1
|
|
|
|
|
+ maxArgAx = 1<<sizeAx - 1
|
|
|
|
|
+ maxArgBx = 1<<sizeBx - 1
|
|
|
|
|
+ maxArgSBx = maxArgBx >> 1 // sBx is signed
|
|
|
|
|
+ maxArgA = 1<<sizeA - 1
|
|
|
|
|
+ maxArgB = 1<<sizeB - 1
|
|
|
|
|
+ maxArgC = 1<<sizeC - 1
|
|
|
|
|
+ listItemsPerFlush = 50 // # list items to accumulate before a setList instruction
|
|
|
|
|
+ )
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
public const int SizeC = 9;
|
|
public const int SizeC = 9;
|
|
|
public const int SizeB = 9;
|
|
public const int SizeB = 9;
|
|
|
public const int SizeBx = SizeC + SizeB;
|
|
public const int SizeBx = SizeC + SizeB;
|
|
@@ -109,20 +109,21 @@ const (
|
|
|
public const int ListItemsPerFlush = 50; // # list items to accumulate before a setList instruction
|
|
public const int ListItemsPerFlush = 50; // # list items to accumulate before a setList instruction
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
-func isConstant(x int) bool { return 0 != x&bitRK }
|
|
|
|
|
-func constantIndex(r int) int { return r & ^bitRK }
|
|
|
|
|
-func asConstant(r int) int { return r | bitRK }
|
|
|
|
|
-
|
|
|
|
|
-// creates a mask with 'n' 1 bits at position 'p'
|
|
|
|
|
-func mask1(n, p uint) instruction { return ^(^instruction(0) << n) << p }
|
|
|
|
|
-// creates a mask with 'n' 0 bits at position 'p'
|
|
|
|
|
-func mask0(n, p uint) instruction { return ^mask1(n, p) }
|
|
|
|
|
-func (i instruction) opCode() opCode { return opCode(i >> posOp & (1<<sizeOp - 1)) }
|
|
|
|
|
-func (i instruction) arg(pos, size uint) int { return int(i >> pos & mask1(size, 0)) }
|
|
|
|
|
-func (i *instruction) setOpCode(op opCode) { i.setArg(posOp, sizeOp, int(op)) }
|
|
|
|
|
-func (i *instruction) setArg(pos, size uint, arg int) {
|
|
|
|
|
- *i = *i&mask0(size, pos) | instruction(arg)<<pos&mask1(size, pos)}
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ func isConstant(x int) bool { return 0 != x&bitRK }
|
|
|
|
|
+ func constantIndex(r int) int { return r & ^bitRK }
|
|
|
|
|
+ func asConstant(r int) int { return r | bitRK }
|
|
|
|
|
+
|
|
|
|
|
+ // creates a mask with 'n' 1 bits at position 'p'
|
|
|
|
|
+ func mask1(n, p uint) instruction { return ^(^instruction(0) << n) << p }
|
|
|
|
|
+ // creates a mask with 'n' 0 bits at position 'p'
|
|
|
|
|
+ func mask0(n, p uint) instruction { return ^mask1(n, p) }
|
|
|
|
|
+ func (i instruction) opCode() opCode { return opCode(i >> posOp & (1<<sizeOp - 1)) }
|
|
|
|
|
+ func (i instruction) arg(pos, size uint) int { return int(i >> pos & mask1(size, 0)) }
|
|
|
|
|
+ func (i *instruction) setOpCode(op opCode) { i.setArg(posOp, sizeOp, int(op)) }
|
|
|
|
|
+ func (i *instruction) setArg(pos, size uint, arg int) {
|
|
|
|
|
+ *i = *i&mask0(size, pos) | instruction(arg)<<pos&mask1(size, pos)}
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
public static bool IsConstant(int x)
|
|
public static bool IsConstant(int x)
|
|
|
{
|
|
{
|
|
|
return 0 != (x & BitRK);
|
|
return 0 != (x & BitRK);
|
|
@@ -166,16 +167,15 @@ func (i *instruction) setArg(pos, size uint, arg int) {
|
|
|
Value = (uint)((Value & Mask0(size, pos)) | ((arg << (int)pos) & Mask1(size, pos)));
|
|
Value = (uint)((Value & Mask0(size, pos)) | ((arg << (int)pos) & Mask1(size, pos)));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/*
|
|
/*
|
|
|
-func (i instruction) a() int { return int(i >> posA & maxArgA) }
|
|
|
|
|
-func (i instruction) b() int { return int(i >> posB & maxArgB) }
|
|
|
|
|
-func (i instruction) c() int { return int(i >> posC & maxArgC) }
|
|
|
|
|
-func (i instruction) bx() int { return int(i >> posBx & maxArgBx) }
|
|
|
|
|
-func (i instruction) ax() int { return int(i >> posAx & maxArgAx) }
|
|
|
|
|
-func (i instruction) sbx() int { return int(i>>posBx&maxArgBx) - maxArgSBx }
|
|
|
|
|
-
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ func (i instruction) a() int { return int(i >> posA & maxArgA) }
|
|
|
|
|
+ func (i instruction) b() int { return int(i >> posB & maxArgB) }
|
|
|
|
|
+ func (i instruction) c() int { return int(i >> posC & maxArgC) }
|
|
|
|
|
+ func (i instruction) bx() int { return int(i >> posBx & maxArgBx) }
|
|
|
|
|
+ func (i instruction) ax() int { return int(i >> posAx & maxArgAx) }
|
|
|
|
|
+ func (i instruction) sbx() int { return int(i>>posBx&maxArgBx) - maxArgSBx }
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
public int A
|
|
public int A
|
|
|
{
|
|
{
|
|
|
get => (int)((Value >> PosA) & MaxArgA);
|
|
get => (int)((Value >> PosA) & MaxArgA);
|
|
@@ -213,7 +213,6 @@ func (i instruction) sbx() int { return int(i>>posBx&maxArgBx) - maxArgSBx }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
-
|
|
|
|
|
func createABC(op opCode, a, b, c int) instruction {
|
|
func createABC(op opCode, a, b, c int) instruction {
|
|
|
return instruction(op)<<posOp |
|
|
return instruction(op)<<posOp |
|
|
|
instruction(a)<<posA |
|
|
instruction(a)<<posA |
|
|
@@ -228,8 +227,8 @@ func createABx(op opCode, a, bx int) instruction {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func createAx(op opCode, a int) instruction { return instruction(op)<<posOp | instruction(a)<<posAx }
|
|
func createAx(op opCode, a int) instruction { return instruction(op)<<posOp | instruction(a)<<posAx }
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
-*/
|
|
|
|
|
public static uint CreateABC(OpCode op, int a, int b, int c)
|
|
public static uint CreateABC(OpCode op, int a, int b, int c)
|
|
|
{
|
|
{
|
|
|
return (uint)(((byte)op << PosOp) | (a << PosA) | (b << PosB) | (c << PosC));
|
|
return (uint)(((byte)op << PosOp) | (a << PosA) | (b << PosB) | (c << PosC));
|
|
@@ -247,39 +246,39 @@ func createAx(op opCode, a int) instruction { return instruction(op)<<posOp | in
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
-
|
|
|
|
|
-func (i instruction) String() string {
|
|
|
|
|
- op := i.opCode()
|
|
|
|
|
- s := opNames[op]
|
|
|
|
|
- switch opMode(op) {
|
|
|
|
|
- case iABC:
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.a())
|
|
|
|
|
- if bMode(op) == opArgK && isConstant(i.b()) {
|
|
|
|
|
- s = fmt.Sprintf("%s constant %d", s, constantIndex(i.b()))
|
|
|
|
|
- } else if bMode(op) != opArgN {
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.b())
|
|
|
|
|
- }
|
|
|
|
|
- if cMode(op) == opArgK && isConstant(i.c()) {
|
|
|
|
|
- s = fmt.Sprintf("%s constant %d", s, constantIndex(i.c()))
|
|
|
|
|
- } else if cMode(op) != opArgN {
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.c())
|
|
|
|
|
- }
|
|
|
|
|
- case iAsBx:
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.a())
|
|
|
|
|
- if bMode(op) != opArgN {
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.sbx())
|
|
|
|
|
|
|
+ func (i instruction) String() string {
|
|
|
|
|
+ op := i.opCode()
|
|
|
|
|
+ s := opNames[op]
|
|
|
|
|
+ switch opMode(op) {
|
|
|
|
|
+ case iABC:
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.a())
|
|
|
|
|
+ if bMode(op) == opArgK && isConstant(i.b()) {
|
|
|
|
|
+ s = fmt.Sprintf("%s constant %d", s, constantIndex(i.b()))
|
|
|
|
|
+ } else if bMode(op) != opArgN {
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.b())
|
|
|
|
|
+ }
|
|
|
|
|
+ if cMode(op) == opArgK && isConstant(i.c()) {
|
|
|
|
|
+ s = fmt.Sprintf("%s constant %d", s, constantIndex(i.c()))
|
|
|
|
|
+ } else if cMode(op) != opArgN {
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.c())
|
|
|
|
|
+ }
|
|
|
|
|
+ case iAsBx:
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.a())
|
|
|
|
|
+ if bMode(op) != opArgN {
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.sbx())
|
|
|
|
|
+ }
|
|
|
|
|
+ case iABx:
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.a())
|
|
|
|
|
+ if bMode(op) != opArgN {
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.bx())
|
|
|
|
|
+ }
|
|
|
|
|
+ case iAx:
|
|
|
|
|
+ s = fmt.Sprintf("%s %d", s, i.ax())
|
|
|
}
|
|
}
|
|
|
- case iABx:
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.a())
|
|
|
|
|
- if bMode(op) != opArgN {
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.bx())
|
|
|
|
|
- }
|
|
|
|
|
- case iAx:
|
|
|
|
|
- s = fmt.Sprintf("%s %d", s, i.ax())
|
|
|
|
|
|
|
+ return s
|
|
|
}
|
|
}
|
|
|
- return s
|
|
|
|
|
-}
|
|
|
|
|
-*/
|
|
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
public override string ToString()
|
|
public override string ToString()
|
|
|
{
|
|
{
|
|
|
var op = OpCode;
|
|
var op = OpCode;
|
|
@@ -341,22 +340,23 @@ func (i instruction) String() string {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
|
|
+ func opmode(t, a, b, c, m int) byte { return byte(t<<7 | a<<6 | b<<4 | c<<2 | m) }
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
-func opmode(t, a, b, c, m int) byte { return byte(t<<7 | a<<6 | b<<4 | c<<2 | m) }
|
|
|
|
|
-*/
|
|
|
|
|
public static byte OpMode(int t, int a, int b, int c, int m)
|
|
public static byte OpMode(int t, int a, int b, int c, int m)
|
|
|
{
|
|
{
|
|
|
return (byte)((t << 7) | (a << 6) | (b << 4) | (c << 2) | m);
|
|
return (byte)((t << 7) | (a << 6) | (b << 4) | (c << 2) | m);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
-const (
|
|
|
|
|
- opArgN = iota // argument is not used
|
|
|
|
|
- opArgU // argument is used
|
|
|
|
|
- opArgR // argument is a register or a jump offset
|
|
|
|
|
- opArgK // argument is a constant or register/constant
|
|
|
|
|
-)
|
|
|
|
|
-*/
|
|
|
|
|
|
|
+ const (
|
|
|
|
|
+ opArgN = iota // argument is not used
|
|
|
|
|
+ opArgU // argument is used
|
|
|
|
|
+ opArgR // argument is a register or a jump offset
|
|
|
|
|
+ opArgK // argument is a constant or register/constant
|
|
|
|
|
+ )
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
public const int OpArgN = 0;
|
|
public const int OpArgN = 0;
|
|
|
public const int OpArgU = 1;
|
|
public const int OpArgU = 1;
|
|
|
public const int OpArgR = 2;
|
|
public const int OpArgR = 2;
|
|
@@ -364,13 +364,13 @@ const (
|
|
|
public const int OpArgK = 3;
|
|
public const int OpArgK = 3;
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
|
|
+ func opMode(m opCode) int { return int(opModes[m] & 3) }
|
|
|
|
|
+ func bMode(m opCode) byte { return (opModes[m] >> 4) & 3 }
|
|
|
|
|
+ func cMode(m opCode) byte { return (opModes[m] >> 2) & 3 }
|
|
|
|
|
+ func testAMode(m opCode) bool { return opModes[m]&(1<<6) != 0 }
|
|
|
|
|
+ func testTMode(m opCode) bool { return opModes[m]&(1<<7) != 0 }
|
|
|
|
|
+ */
|
|
|
|
|
|
|
|
-func opMode(m opCode) int { return int(opModes[m] & 3) }
|
|
|
|
|
-func bMode(m opCode) byte { return (opModes[m] >> 4) & 3 }
|
|
|
|
|
-func cMode(m opCode) byte { return (opModes[m] >> 2) & 3 }
|
|
|
|
|
-func testAMode(m opCode) bool { return opModes[m]&(1<<6) != 0 }
|
|
|
|
|
-func testTMode(m opCode) bool { return opModes[m]&(1<<7) != 0 }
|
|
|
|
|
-*/
|
|
|
|
|
public static int OpMode(OpCode m)
|
|
public static int OpMode(OpCode m)
|
|
|
{
|
|
{
|
|
|
return (int)(opModes[(byte)m] & 3);
|
|
return (int)(opModes[(byte)m] & 3);
|
|
@@ -397,95 +397,96 @@ func testTMode(m opCode) bool { return opModes[m]&(1<<7) != 0 }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
-var opModes []byte = []byte{
|
|
|
|
|
-// T A B C mode opcode
|
|
|
|
|
-opmode(0, 1, opArgR, opArgN, iABC), // opMove
|
|
|
|
|
-opmode(0, 1, opArgK, opArgN, iABx), // opLoadConstant
|
|
|
|
|
-opmode(0, 1, opArgN, opArgN, iABx), // opLoadConstantEx
|
|
|
|
|
-opmode(0, 1, opArgU, opArgU, iABC), // opLoadBool
|
|
|
|
|
-opmode(0, 1, opArgU, opArgN, iABC), // opLoadNil
|
|
|
|
|
-opmode(0, 1, opArgU, opArgN, iABC), // opGetUpValue
|
|
|
|
|
-opmode(0, 1, opArgU, opArgK, iABC), // opGetTableUp
|
|
|
|
|
-opmode(0, 1, opArgR, opArgK, iABC), // opGetTable
|
|
|
|
|
-opmode(0, 0, opArgK, opArgK, iABC), // opSetTableUp
|
|
|
|
|
-opmode(0, 0, opArgU, opArgN, iABC), // opSetUpValue
|
|
|
|
|
-opmode(0, 0, opArgK, opArgK, iABC), // opSetTable
|
|
|
|
|
-opmode(0, 1, opArgU, opArgU, iABC), // opNewTable
|
|
|
|
|
-opmode(0, 1, opArgR, opArgK, iABC), // opSelf
|
|
|
|
|
-opmode(0, 1, opArgK, opArgK, iABC), // opAdd
|
|
|
|
|
-opmode(0, 1, opArgK, opArgK, iABC), // opSub
|
|
|
|
|
-opmode(0, 1, opArgK, opArgK, iABC), // opMul
|
|
|
|
|
-opmode(0, 1, opArgK, opArgK, iABC), // opDiv
|
|
|
|
|
-opmode(0, 1, opArgK, opArgK, iABC), // opMod
|
|
|
|
|
-opmode(0, 1, opArgK, opArgK, iABC), // opPow
|
|
|
|
|
-opmode(0, 1, opArgR, opArgN, iABC), // opUnaryMinus
|
|
|
|
|
-opmode(0, 1, opArgR, opArgN, iABC), // opNot
|
|
|
|
|
-opmode(0, 1, opArgR, opArgN, iABC), // opLength
|
|
|
|
|
-opmode(0, 1, opArgR, opArgR, iABC), // opConcat
|
|
|
|
|
-opmode(0, 0, opArgR, opArgN, iAsBx), // opJump
|
|
|
|
|
-opmode(1, 0, opArgK, opArgK, iABC), // opEqual
|
|
|
|
|
-opmode(1, 0, opArgK, opArgK, iABC), // opLessThan
|
|
|
|
|
-opmode(1, 0, opArgK, opArgK, iABC), // opLessOrEqual
|
|
|
|
|
-opmode(1, 0, opArgN, opArgU, iABC), // opTest
|
|
|
|
|
-opmode(1, 1, opArgR, opArgU, iABC), // opTestSet
|
|
|
|
|
-opmode(0, 1, opArgU, opArgU, iABC), // opCall
|
|
|
|
|
-opmode(0, 1, opArgU, opArgU, iABC), // opTailCall
|
|
|
|
|
-opmode(0, 0, opArgU, opArgN, iABC), // opReturn
|
|
|
|
|
-opmode(0, 1, opArgR, opArgN, iAsBx), // opForLoop
|
|
|
|
|
-opmode(0, 1, opArgR, opArgN, iAsBx), // opForPrep
|
|
|
|
|
-opmode(0, 0, opArgN, opArgU, iABC), // opTForCall
|
|
|
|
|
-opmode(0, 1, opArgR, opArgN, iAsBx), // opTForLoop
|
|
|
|
|
-opmode(0, 0, opArgU, opArgU, iABC), // opSetList
|
|
|
|
|
-opmode(0, 1, opArgU, opArgN, iABx), // opClosure
|
|
|
|
|
-opmode(0, 1, opArgU, opArgN, iABC), // opVarArg
|
|
|
|
|
-opmode(0, 0, opArgU, opArgU, iAx), // opExtraArg
|
|
|
|
|
-}
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ var opModes []byte = []byte{
|
|
|
|
|
+ // T A B C mode opcode
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgN, iABC), // opMove
|
|
|
|
|
+ opmode(0, 1, opArgK, opArgN, iABx), // opLoadConstant
|
|
|
|
|
+ opmode(0, 1, opArgN, opArgN, iABx), // opLoadConstantEx
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgU, iABC), // opLoadBool
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgN, iABC), // opLoadNil
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgN, iABC), // opGetUpValue
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgK, iABC), // opGetTableUp
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgK, iABC), // opGetTable
|
|
|
|
|
+ opmode(0, 0, opArgK, opArgK, iABC), // opSetTableUp
|
|
|
|
|
+ opmode(0, 0, opArgU, opArgN, iABC), // opSetUpValue
|
|
|
|
|
+ opmode(0, 0, opArgK, opArgK, iABC), // opSetTable
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgU, iABC), // opNewTable
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgK, iABC), // opSelf
|
|
|
|
|
+ opmode(0, 1, opArgK, opArgK, iABC), // opAdd
|
|
|
|
|
+ opmode(0, 1, opArgK, opArgK, iABC), // opSub
|
|
|
|
|
+ opmode(0, 1, opArgK, opArgK, iABC), // opMul
|
|
|
|
|
+ opmode(0, 1, opArgK, opArgK, iABC), // opDiv
|
|
|
|
|
+ opmode(0, 1, opArgK, opArgK, iABC), // opMod
|
|
|
|
|
+ opmode(0, 1, opArgK, opArgK, iABC), // opPow
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgN, iABC), // opUnaryMinus
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgN, iABC), // opNot
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgN, iABC), // opLength
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgR, iABC), // opConcat
|
|
|
|
|
+ opmode(0, 0, opArgR, opArgN, iAsBx), // opJump
|
|
|
|
|
+ opmode(1, 0, opArgK, opArgK, iABC), // opEqual
|
|
|
|
|
+ opmode(1, 0, opArgK, opArgK, iABC), // opLessThan
|
|
|
|
|
+ opmode(1, 0, opArgK, opArgK, iABC), // opLessOrEqual
|
|
|
|
|
+ opmode(1, 0, opArgN, opArgU, iABC), // opTest
|
|
|
|
|
+ opmode(1, 1, opArgR, opArgU, iABC), // opTestSet
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgU, iABC), // opCall
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgU, iABC), // opTailCall
|
|
|
|
|
+ opmode(0, 0, opArgU, opArgN, iABC), // opReturn
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgN, iAsBx), // opForLoop
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgN, iAsBx), // opForPrep
|
|
|
|
|
+ opmode(0, 0, opArgN, opArgU, iABC), // opTForCall
|
|
|
|
|
+ opmode(0, 1, opArgR, opArgN, iAsBx), // opTForLoop
|
|
|
|
|
+ opmode(0, 0, opArgU, opArgU, iABC), // opSetList
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgN, iABx), // opClosure
|
|
|
|
|
+ opmode(0, 1, opArgU, opArgN, iABC), // opVarArg
|
|
|
|
|
+ opmode(0, 0, opArgU, opArgU, iAx), // opExtraArg
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
public static ReadOnlySpan<byte> OpModes => opModes;
|
|
public static ReadOnlySpan<byte> OpModes => opModes;
|
|
|
|
|
|
|
|
static readonly byte[] opModes =
|
|
static readonly byte[] opModes =
|
|
|
[
|
|
[
|
|
|
// T A B C mode opcode]
|
|
// T A B C mode opcode]
|
|
|
- OpMode(0, 1, OpArgR, OpArgN, IABC), // opMove
|
|
|
|
|
- OpMode(0, 1, OpArgK, OpArgN, IABx), // opLoadConstant
|
|
|
|
|
- OpMode(0, 1, OpArgN, OpArgN, IABx), // opLoadConstantEx
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgU, IABC), // opLoadBool
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgN, IABC), // opLoadNil
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgN, IABC), // opGetUpValue
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgK, IABC), // opGetTableUp
|
|
|
|
|
- OpMode(0, 1, OpArgR, OpArgK, IABC), // opGetTable
|
|
|
|
|
- OpMode(0, 0, OpArgK, OpArgK, IABC), // opSetTableUp
|
|
|
|
|
- OpMode(0, 0, OpArgU, OpArgN, IABC), // opSetUpValue
|
|
|
|
|
- OpMode(0, 0, OpArgK, OpArgK, IABC), // opSetTable
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgU, IABC), // opNewTable
|
|
|
|
|
- OpMode(0, 1, OpArgR, OpArgK, IABC), // opSelf
|
|
|
|
|
- OpMode(0, 1, OpArgK, OpArgK, IABC), // opAdd
|
|
|
|
|
- OpMode(0, 1, OpArgK, OpArgK, IABC), // opSub
|
|
|
|
|
- OpMode(0, 1, OpArgK, OpArgK, IABC), // opMul
|
|
|
|
|
- OpMode(0, 1, OpArgK, OpArgK, IABC), // opDiv
|
|
|
|
|
- OpMode(0, 1, OpArgK, OpArgK, IABC), // opMod
|
|
|
|
|
- OpMode(0, 1, OpArgK, OpArgK, IABC), // opPow
|
|
|
|
|
- OpMode(0, 1, OpArgR, OpArgN, IABC), // opUnaryMinus
|
|
|
|
|
- OpMode(0, 1, OpArgR, OpArgN, IABC), // opNot
|
|
|
|
|
- OpMode(0, 1, OpArgR, OpArgN, IABC), // opLength
|
|
|
|
|
- OpMode(0, 1, OpArgR, OpArgR, IABC), // opConcat
|
|
|
|
|
|
|
+ OpMode(0, 1, OpArgR, OpArgN, IABC), // opMove
|
|
|
|
|
+ OpMode(0, 1, OpArgK, OpArgN, IABx), // opLoadConstant
|
|
|
|
|
+ OpMode(0, 1, OpArgN, OpArgN, IABx), // opLoadConstantEx
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgU, IABC), // opLoadBool
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgN, IABC), // opLoadNil
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgN, IABC), // opGetUpValue
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgK, IABC), // opGetTableUp
|
|
|
|
|
+ OpMode(0, 1, OpArgR, OpArgK, IABC), // opGetTable
|
|
|
|
|
+ OpMode(0, 0, OpArgK, OpArgK, IABC), // opSetTableUp
|
|
|
|
|
+ OpMode(0, 0, OpArgU, OpArgN, IABC), // opSetUpValue
|
|
|
|
|
+ OpMode(0, 0, OpArgK, OpArgK, IABC), // opSetTable
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgU, IABC), // opNewTable
|
|
|
|
|
+ OpMode(0, 1, OpArgR, OpArgK, IABC), // opSelf
|
|
|
|
|
+ OpMode(0, 1, OpArgK, OpArgK, IABC), // opAdd
|
|
|
|
|
+ OpMode(0, 1, OpArgK, OpArgK, IABC), // opSub
|
|
|
|
|
+ OpMode(0, 1, OpArgK, OpArgK, IABC), // opMul
|
|
|
|
|
+ OpMode(0, 1, OpArgK, OpArgK, IABC), // opDiv
|
|
|
|
|
+ OpMode(0, 1, OpArgK, OpArgK, IABC), // opMod
|
|
|
|
|
+ OpMode(0, 1, OpArgK, OpArgK, IABC), // opPow
|
|
|
|
|
+ OpMode(0, 1, OpArgR, OpArgN, IABC), // opUnaryMinus
|
|
|
|
|
+ OpMode(0, 1, OpArgR, OpArgN, IABC), // opNot
|
|
|
|
|
+ OpMode(0, 1, OpArgR, OpArgN, IABC), // opLength
|
|
|
|
|
+ OpMode(0, 1, OpArgR, OpArgR, IABC), // opConcat
|
|
|
OpMode(0, 0, OpArgR, OpArgN, IAsBx), // opJump
|
|
OpMode(0, 0, OpArgR, OpArgN, IAsBx), // opJump
|
|
|
- OpMode(1, 0, OpArgK, OpArgK, IABC), // opEqual
|
|
|
|
|
- OpMode(1, 0, OpArgK, OpArgK, IABC), // opLessThan
|
|
|
|
|
- OpMode(1, 0, OpArgK, OpArgK, IABC), // opLessOrEqual
|
|
|
|
|
- OpMode(1, 0, OpArgN, OpArgU, IABC), // opTest
|
|
|
|
|
- OpMode(1, 1, OpArgR, OpArgU, IABC), // opTestSet
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgU, IABC), // opCall
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgU, IABC), // opTailCall
|
|
|
|
|
- OpMode(0, 0, OpArgU, OpArgN, IABC), // opReturn
|
|
|
|
|
|
|
+ OpMode(1, 0, OpArgK, OpArgK, IABC), // opEqual
|
|
|
|
|
+ OpMode(1, 0, OpArgK, OpArgK, IABC), // opLessThan
|
|
|
|
|
+ OpMode(1, 0, OpArgK, OpArgK, IABC), // opLessOrEqual
|
|
|
|
|
+ OpMode(1, 0, OpArgN, OpArgU, IABC), // opTest
|
|
|
|
|
+ OpMode(1, 1, OpArgR, OpArgU, IABC), // opTestSet
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgU, IABC), // opCall
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgU, IABC), // opTailCall
|
|
|
|
|
+ OpMode(0, 0, OpArgU, OpArgN, IABC), // opReturn
|
|
|
OpMode(0, 1, OpArgR, OpArgN, IAsBx), // opForLoop
|
|
OpMode(0, 1, OpArgR, OpArgN, IAsBx), // opForLoop
|
|
|
OpMode(0, 1, OpArgR, OpArgN, IAsBx), // opForPrep
|
|
OpMode(0, 1, OpArgR, OpArgN, IAsBx), // opForPrep
|
|
|
- OpMode(0, 0, OpArgN, OpArgU, IABC), // opTForCall
|
|
|
|
|
|
|
+ OpMode(0, 0, OpArgN, OpArgU, IABC), // opTForCall
|
|
|
OpMode(0, 1, OpArgR, OpArgN, IAsBx), // opTForLoop
|
|
OpMode(0, 1, OpArgR, OpArgN, IAsBx), // opTForLoop
|
|
|
- OpMode(0, 0, OpArgU, OpArgU, IABC), // opSetList
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgN, IABx), // opClosure
|
|
|
|
|
- OpMode(0, 1, OpArgU, OpArgN, IABC), // opVarArg
|
|
|
|
|
- OpMode(0, 0, OpArgU, OpArgU, IAx) // opExtraArg
|
|
|
|
|
|
|
+ OpMode(0, 0, OpArgU, OpArgU, IABC), // opSetList
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgN, IABx), // opClosure
|
|
|
|
|
+ OpMode(0, 1, OpArgU, OpArgN, IABC), // opVarArg
|
|
|
|
|
+ OpMode(0, 0, OpArgU, OpArgU, IAx) // opExtraArg
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|