diff --git a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java index 8e1a880..c333e34 100644 --- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java +++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java @@ -1,5 +1,8 @@ package org.jcnc.snow.vm.engine; +import org.jcnc.snow.vm.commands.ref.control.RLoadCommand; +import org.jcnc.snow.vm.commands.ref.control.RPushCommand; +import org.jcnc.snow.vm.commands.ref.control.RStoreCommand; import org.jcnc.snow.vm.commands.system.control.SyscallCommand; import org.jcnc.snow.vm.commands.type.control.byte8.*; import org.jcnc.snow.vm.commands.type.control.double64.*; @@ -2483,6 +2486,74 @@ public class VMOpCode { // endregion Double64 // endregion Conversion + // region Reference Control (0x00E0-0x00EF) + /** + * R_PUSH Opcode: Represents an operation that pushes an object reference (such as a String or any reference type) + * onto the operand stack. + *

This opcode is implemented by the {@link RPushCommand} class, which defines its specific execution logic.

+ * + *

Execution Steps:

+ *
    + *
  1. Parses the object reference literal (e.g., a string) from the instruction parameters.
  2. + *
  3. Creates or interprets the reference as an object instance if necessary.
  4. + *
  5. Pushes the reference object onto the operand stack.
  6. + *
  7. Increments the program counter (PC) to proceed with the next sequential instruction.
  8. + *
+ * + *

This opcode is commonly used for:

+ * + */ + public static final int R_PUSH = 0x00E0; + /** + * R_LOAD Opcode: Represents an operation that loads an object reference from the local variable table + * and pushes it onto the operand stack. + *

This opcode is implemented by the {@link RLoadCommand} class, which defines its specific execution logic.

+ * + *

Execution Steps:

+ *
    + *
  1. Parses the target slot index from the instruction parameters.
  2. + *
  3. Retrieves the reference object stored at the specified slot in the local variable table + * of the current stack frame.
  4. + *
  5. Pushes the retrieved reference onto the operand stack.
  6. + *
  7. Increments the program counter (PC) to proceed with the next sequential instruction.
  8. + *
+ * + *

This opcode is commonly used for:

+ * + */ + public static final int R_LOAD = 0x00E1; + /** + * R_STORE Opcode: Represents an operation that pops an object reference from the top of the operand stack + * and stores it into the local variable table at the specified slot index. + *

This opcode is implemented by the {@link RStoreCommand} class, which defines its specific execution logic.

+ * + *

Execution Steps:

+ *
    + *
  1. Parses the target slot index from the instruction parameters.
  2. + *
  3. Pops the top reference object from the operand stack.
  4. + *
  5. Stores the popped reference object into the specified slot in the local variable table + * of the current stack frame.
  6. + *
  7. Increments the program counter (PC) to proceed with the next sequential instruction.
  8. + *
+ * + *

This opcode is commonly used for:

+ * + */ + public static final int R_STORE = 0x00E2; + // endregion + // region Stack Control (0x0100-0x01FF) /** * POP Opcode: Represents a stack operation that removes the top element from the operand stack.