diff --git a/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTable.cs b/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTable.cs
index f61487b..d33be41 100644
--- a/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTable.cs
+++ b/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTable.cs
@@ -3,7 +3,7 @@
///
/// Represents a get table instruction.
///
- public class GetTable(uint value) : Instruction(value)
+ public class GetTable(uint value) : InstructionABC(value)
{
///
public override void Accept(Visitor visitor)
diff --git a/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTableKS.cs b/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTableKS.cs
new file mode 100644
index 0000000..2d0b631
--- /dev/null
+++ b/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTableKS.cs
@@ -0,0 +1,14 @@
+namespace Unluau.Common.IR.ProtoTypes.Instructions
+{
+ ///
+ /// Represents a get table instruction with a constant key.
+ ///
+ public class GetTableKS(ulong value) : InstructionABC(value)
+ {
+ ///
+ public override void Accept(Visitor visitor)
+ {
+ visitor.Visit(this);
+ }
+ }
+}
diff --git a/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTableN.cs b/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTableN.cs
new file mode 100644
index 0000000..b94c4bb
--- /dev/null
+++ b/src/Unluau.Common/IR/ProtoTypes/Instructions/GetTableN.cs
@@ -0,0 +1,11 @@
+namespace Unluau.Common.IR.ProtoTypes.Instructions
+{
+ public class GetTableN(uint value) : InstructionABC(value)
+ {
+ ///
+ public override void Accept(Visitor visitor)
+ {
+ visitor.Visit(this);
+ }
+ }
+}
diff --git a/src/Unluau.Common/IR/ProtoTypes/Instructions/Instruction.cs b/src/Unluau.Common/IR/ProtoTypes/Instructions/Instruction.cs
index 541de6d..4160991 100644
--- a/src/Unluau.Common/IR/ProtoTypes/Instructions/Instruction.cs
+++ b/src/Unluau.Common/IR/ProtoTypes/Instructions/Instruction.cs
@@ -124,6 +124,104 @@ public enum OpCode
/// C: index register.
///
GetTable,
+
+ ///
+ /// Store source register into table using key from register
+ ///
+ ///
+ /// A: source register.
+ /// B: table register.
+ /// C: index register.
+ ///
+ SetTable,
+
+ ///
+ /// Load value from table into target register using constant string as a key
+ ///
+ ///
+ /// A: target register.
+ /// B: table register.
+ /// C: predicted slot index (based on hash).
+ /// AUX: constant table index.
+ ///
+ GetTableKS,
+
+ ///
+ /// Store source register into table using constant string as a key
+ ///
+ ///
+ /// A: source register.
+ /// B: table register.
+ /// C: predicted slot index (based on hash).
+ /// AUX: constant table index.
+ ///
+ SetTableKS,
+
+ ///
+ /// Load value from table into target register using small integer index as a key
+ ///
+ ///
+ /// A: target register.
+ /// B: table register.
+ /// C: index-1 (index is 1..256).
+ ///
+ GetTableN,
+
+ NewClosure,
+ NameCall,
+ Call,
+ Return,
+ Jump,
+ JumpBack,
+ JumpIf,
+ JumpIfNot,
+ JumpIfEq,
+ JumpIfLe,
+ JumpIfLt,
+ JumpIfNotEq,
+ JumpIfNotLe,
+ JumpIfNotLt,
+
+ Add,
+ Sub,
+ Mul,
+ Div,
+ Mod,
+ Pow,
+
+ AddK,
+ SubK,
+ MulK,
+ DivK,
+ ModK,
+ PowK,
+
+ And,
+ Or,
+
+ AndK,
+ OrK,
+
+ Concat,
+
+ Not,
+ Minus,
+ Len,
+
+ NewTable,
+ DupTable,
+ SetList,
+ ForNPrep,
+ ForNLoop,
+ ForGPrep,
+ ForGLoop,
+
+ ForGPrepINext,
+
+ // Deprecated, removed in v3
+ _ForGLoopINext,
+
+ ForGPrepNext,
}
///
diff --git a/src/Unluau.Common/IR/ProtoTypes/Instructions/SetTable.cs b/src/Unluau.Common/IR/ProtoTypes/Instructions/SetTable.cs
new file mode 100644
index 0000000..50e3265
--- /dev/null
+++ b/src/Unluau.Common/IR/ProtoTypes/Instructions/SetTable.cs
@@ -0,0 +1,14 @@
+namespace Unluau.Common.IR.ProtoTypes.Instructions
+{
+ ///
+ /// Represents the `settable` instruction.
+ ///
+ public class SetTable(uint value) : InstructionABC(value)
+ {
+ ///
+ public override void Accept(Visitor visitor)
+ {
+ visitor.Visit(this);
+ }
+ }
+}
diff --git a/src/Unluau.Common/IR/ProtoTypes/Instructions/SetTableKS.cs b/src/Unluau.Common/IR/ProtoTypes/Instructions/SetTableKS.cs
new file mode 100644
index 0000000..3e4fda2
--- /dev/null
+++ b/src/Unluau.Common/IR/ProtoTypes/Instructions/SetTableKS.cs
@@ -0,0 +1,14 @@
+namespace Unluau.Common.IR.ProtoTypes.Instructions
+{
+ ///
+ /// Represents a set table instruction with a constant key.
+ ///
+ public class SetTableKS(ulong value) : InstructionABC(value)
+ {
+ ///
+ public override void Accept(Visitor visitor)
+ {
+ visitor.Visit(this);
+ }
+ }
+}
diff --git a/src/Unluau.Common/IR/Reader.cs b/src/Unluau.Common/IR/Reader.cs
index a743855..a554e55 100644
--- a/src/Unluau.Common/IR/Reader.cs
+++ b/src/Unluau.Common/IR/Reader.cs
@@ -135,6 +135,10 @@ public Instruction ReadInstruction()
OpCode.CloseUpvalues => new CloseUpvalues(ReadUInt32()),
OpCode.GetImport => new GetImport(ReadUInt64()),
OpCode.GetTable => new GetTable(ReadUInt32()),
+ OpCode.SetTable => new SetTable(ReadUInt32()),
+ OpCode.GetTableKS => new GetTableKS(ReadUInt64()),
+ OpCode.SetTableKS => new SetTableKS(ReadUInt64()),
+ OpCode.GetTableN => new GetTableN(ReadUInt32()),
_ => throw new Exception($"invalid opcode {code}")
};
}
diff --git a/src/Unluau.Common/IR/Visitor.cs b/src/Unluau.Common/IR/Visitor.cs
index c3128e4..57c1489 100644
--- a/src/Unluau.Common/IR/Visitor.cs
+++ b/src/Unluau.Common/IR/Visitor.cs
@@ -141,5 +141,30 @@ public abstract class Visitor
/// The visitor for the class.
///
public virtual bool Visit(GetImport instruction) => Visit(instruction as InstructionAD);
+
+ ///
+ /// The visitor for the class.
+ ///
+ public virtual bool Visit(GetTable instruction) => Visit(instruction as InstructionABC);
+
+ ///
+ /// The visitor for the class.
+ ///
+ public virtual bool Visit(SetTable instruction) => Visit(instruction as InstructionABC);
+
+ ///
+ /// The visitor for the class.
+ ///
+ public virtual bool Visit(GetTableKS instruction) => Visit(instruction as InstructionABC);
+
+ ///
+ /// The visitor for the class.
+ ///
+ public virtual bool Visit(SetTableKS instruction) => Visit(instruction as InstructionABC);
+
+ ///
+ /// The visitor for the class.
+ ///
+ public virtual bool Visit(GetTableN instruction) => Visit(instruction as InstructionABC);
}
}