修复文档

This commit is contained in:
Luke 2025-05-07 20:30:52 +08:00
parent d4c8aea05f
commit c0691369bd
2 changed files with 71 additions and 53 deletions

View File

@ -1,7 +1,7 @@
package org.jcnc.snow.vm.engine; package org.jcnc.snow.vm.engine;
import org.jcnc.snow.vm.commands.arithmetic.byte8.*; import org.jcnc.snow.vm.commands.arithmetic.byte8.*;
import org.jcnc.snow.vm.commands.arithmetic.conversion.I2LCommand; import org.jcnc.snow.vm.commands.arithmetic.conversion.*;
import org.jcnc.snow.vm.commands.arithmetic.double64.*; import org.jcnc.snow.vm.commands.arithmetic.double64.*;
import org.jcnc.snow.vm.commands.arithmetic.float32.*; import org.jcnc.snow.vm.commands.arithmetic.float32.*;
import org.jcnc.snow.vm.commands.arithmetic.int32.*; import org.jcnc.snow.vm.commands.arithmetic.int32.*;
@ -18,7 +18,18 @@ import org.jcnc.snow.vm.commands.control.int32.*;
import org.jcnc.snow.vm.commands.function.CallCommand; import org.jcnc.snow.vm.commands.function.CallCommand;
import org.jcnc.snow.vm.commands.function.RetCommand; import org.jcnc.snow.vm.commands.function.RetCommand;
import org.jcnc.snow.vm.commands.memory.all.MovCommand; import org.jcnc.snow.vm.commands.memory.all.MovCommand;
import org.jcnc.snow.vm.commands.memory.byte8.BLoadCommand;
import org.jcnc.snow.vm.commands.memory.byte8.BStoreCommand;
import org.jcnc.snow.vm.commands.memory.double64.DLoadCommand;
import org.jcnc.snow.vm.commands.memory.double64.DStoreCommand;
import org.jcnc.snow.vm.commands.memory.float32.FLoadCommand;
import org.jcnc.snow.vm.commands.memory.float32.FStoreCommand;
import org.jcnc.snow.vm.commands.memory.int32.ILoadCommand; import org.jcnc.snow.vm.commands.memory.int32.ILoadCommand;
import org.jcnc.snow.vm.commands.memory.int32.IStoreCommand;
import org.jcnc.snow.vm.commands.memory.long64.LLoadCommand;
import org.jcnc.snow.vm.commands.memory.long64.LStoreCommand;
import org.jcnc.snow.vm.commands.memory.short16.SLoadCommand;
import org.jcnc.snow.vm.commands.memory.short16.SStoreCommand;
import org.jcnc.snow.vm.commands.stack.all.DupCommand; import org.jcnc.snow.vm.commands.stack.all.DupCommand;
import org.jcnc.snow.vm.commands.stack.all.PopCommand; import org.jcnc.snow.vm.commands.stack.all.PopCommand;
import org.jcnc.snow.vm.commands.stack.all.SwapCommand; import org.jcnc.snow.vm.commands.stack.all.SwapCommand;
@ -507,7 +518,7 @@ public class VMOpCode {
* </ol> * </ol>
* *
* <p>This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, * <p>This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic double precision floating-point addition tasks.</p> * primarily used to handle basic double64 precision floating-point addition tasks.</p>
*/ */
public static final int D_ADD = 41; public static final int D_ADD = 41;
@ -517,13 +528,13 @@ public class VMOpCode {
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
* <li>Pops the top two double values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).</li> * <li>Pops the top two double64 values from the operand stack (the first value popped is the subtrahend, and the second value popped is the minuend).</li>
* <li>Performs the double precision floating-point subtraction operation by subtracting the subtrahend from the minuend (i.e., <code>minuend - subtrahend</code>).</li> * <li>Performs the double64 precision floating-point subtraction operation by subtracting the subtrahend from the minuend (i.e., <code>minuend - subtrahend</code>).</li>
* <li>Pushes the result of the subtraction back onto the operand stack for later instructions to use.</li> * <li>Pushes the result of the subtraction back onto the operand stack for later instructions to use.</li>
* </ol> * </ol>
* *
* <p>This opcode is a fundamental arithmetic operation within the virtual machine's instruction set, * <p>This opcode is a fundamental arithmetic operation within the virtual machine's instruction set,
* primarily used to handle basic double precision floating-point subtraction tasks.</p> * primarily used to handle basic double64 precision floating-point subtraction tasks.</p>
*/ */
public static final int D_SUB = 42; public static final int D_SUB = 42;
@ -1412,126 +1423,132 @@ public class VMOpCode {
// 5. Memory Operations (151) // 5. Memory Operations (151)
/** /**
* I_STORE Opcode: Represents a load operation that retrieves an int32 value from the local variable store and pushes it onto the operand stack. * I_STORE Opcode: Represents a store operation that saves an int32 value from the operand stack into the local variable store.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> *
* <p>This opcode is implemented by the {@link IStoreCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
* <li>Retrieves the index for the local variable from the instruction parameters.</li> * <li>Retrieves the index for the local variable from the instruction parameters.</li>
* <li>Retrieves the corresponding value from the local variable store of the current method frame.</li> * <li>Pops the int32 value from the operand stack.</li>
* <li>Pushes the retrieved value onto the operand stack for later operations.</li> * <li>Stores the value into the local variable store at the specified index of the current method frame.</li>
* <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li> * <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li>
* </ol> * </ol>
* *
* <p>This opcode is commonly used for:</p> * <p>This opcode is commonly used for:</p>
* <ul> * <ul>
* <li>Loading local variables onto the operand stack for further operations or computations.</li> * <li>Storing results of computations or intermediate values into local variables.</li>
* <li>Retrieving stored values that are needed for later instructions, such as arithmetic or logic operations.</li> * <li>Preserving state across instructions or method calls by saving values to the local frame.</li>
* <li>Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.</li> * <li>Transferring values from the operand stack to the method-local scope.</li>
* </ul> * </ul>
*/ */
public static final int I_STORE = 151; public static final int I_STORE = 151;
/** /**
* L_STORE Opcode: Represents a load operation that retrieves a long64 value from the local variable store and pushes it onto the operand stack. * L_STORE Opcode: Represents a store operation that stores a long64 value from the operand stack into the local variable store.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link LStoreCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
* <li>Retrieves the index for the local variable from the instruction parameters.</li> * <li>Retrieves the index for the local variable from the instruction parameters.</li>
* <li>Retrieves the corresponding value from the local variable store of the current method frame.</li> * <li>Pops a long64 value from the operand stack.</li>
* <li>Pushes the retrieved value onto the operand stack for later operations.</li> * <li>Stores the value into the local variable store at the specified index of the current method frame.</li>
* <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li> * <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li>
* </ol> * </ol>
* *
* <p>This opcode is commonly used for:</p> * <p>This opcode is commonly used for:</p>
* <ul> * <ul>
* <li>Loading local variables onto the operand stack for further operations or computations.</li> * <li>Storing computed long64 values into local variables for reuse.</li>
* <li>Retrieving stored values that are needed for later instructions, such as arithmetic or logic operations.</li> * <li>Preserving long-type data across multiple instructions or calls.</li>
* <li>Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.</li> * <li>Moving data from the operand stack to a persistent method-local context.</li>
* </ul> * </ul>
*/ */
public static final int L_STORE = 152; public static final int L_STORE = 152;
/** /**
* S_LOAD Opcode: Represents a load operation that retrieves a short16 value from the local variable store and pushes it onto the operand stack. * S_STORE Opcode: Represents a store operation that stores a short16 value from the operand stack into the local variable store.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link SStoreCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
* <li>Retrieves the index for the local variable from the instruction parameters.</li> * <li>Retrieves the index for the local variable from the instruction parameters.</li>
* <li>Retrieves the corresponding value from the local variable store of the current method frame.</li> * <li>Pops a short16 value from the operand stack.</li>
* <li>Pushes the retrieved value onto the operand stack for later operations.</li> * <li>Stores the value into the local variable store at the specified index of the current method frame.</li>
* <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li> * <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li>
* </ol> * </ol>
* *
* <p>This opcode is commonly used for:</p> * <p>This opcode is commonly used for:</p>
* <ul> * <ul>
* <li>Loading local variables onto the operand stack for further operations or computations.</li> * <li>Storing short16 values resulting from calculations or conversions.</li>
* <li>Retrieving stored values that are needed for later instructions, such as arithmetic or logic operations.</li> * <li>Temporarily saving data in local variables for later instructions.</li>
* <li>Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.</li> * <li>Supporting typed local variable storage for short values.</li>
* </ul> * </ul>
*/ */
public static final int S_STORE = 153; public static final int S_STORE = 153;
/** /**
* B_STORE Opcode: Represents a load operation that retrieves a byte8 value from the local variable store and pushes it onto the operand stack. * B_STORE Opcode: Represents a store operation that stores a byte8 value from the operand stack into the local variable store.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link BStoreCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
* <li>Retrieves the index for the local variable from the instruction parameters.</li> * <li>Retrieves the index for the local variable from the instruction parameters.</li>
* <li>Retrieves the corresponding value from the local variable store of the current method frame.</li> * <li>Pops a byte8 value from the operand stack.</li>
* <li>Pushes the retrieved value onto the operand stack for later operations.</li> * <li>Stores the value into the local variable store at the specified index of the current method frame.</li>
* <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li> * <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li>
* </ol> * </ol>
* *
* <p>This opcode is commonly used for:</p> * <p>This opcode is commonly used for:</p>
* <ul> * <ul>
* <li>Loading local variables onto the operand stack for further operations or computations.</li> * <li>Saving byte8 results or constants into method-local variables.</li>
* <li>Retrieving stored values that are needed for later instructions, such as arithmetic or logic operations.</li> * <li>Enabling byte-level operations and temporary storage.</li>
* <li>Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.</li> * <li>Transferring values from the stack to local scope in compact form.</li>
* </ul> * </ul>
*/ */
public static final int B_STORE = 154; public static final int B_STORE = 154;
/** /**
* D_STORE Opcode: Represents a load operation that retrieves a double64 value from the local variable store and pushes it onto the operand stack. * D_STORE Opcode: Represents a store operation that stores a double64 value from the operand stack into the local variable store.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link DStoreCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
* <li>Retrieves the index for the local variable from the instruction parameters.</li> * <li>Retrieves the index for the local variable from the instruction parameters.</li>
* <li>Retrieves the corresponding value from the local variable store of the current method frame.</li> * <li>Pops a double64 value from the operand stack.</li>
* <li>Pushes the retrieved value onto the operand stack for later operations.</li> * <li>Stores the value into the local variable store at the specified index of the current method frame.</li>
* <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li> * <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li>
* </ol> * </ol>
* *
* <p>This opcode is commonly used for:</p> * <p>This opcode is commonly used for:</p>
* <ul> * <ul>
* <li>Loading local variables onto the operand stack for further operations or computations.</li> * <li>Saving double64-precision results after arithmetic or conversion operations.</li>
* <li>Retrieving stored values that are needed for later instructions, such as arithmetic or logic operations.</li> * <li>Ensuring floating-point values persist in method-local storage.</li>
* <li>Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.</li> * <li>Managing precision-critical calculations across instruction sequences.</li>
* </ul> * </ul>
*/ */
public static final int D_STORE = 155; public static final int D_STORE = 155;
/** /**
* F_STORE Opcode: Represents a load operation that retrieves a float32 value from the local variable store and pushes it onto the operand stack. * F_STORE Opcode: Represents a store operation that stores a float32 value from the operand stack into the local variable store.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link FStoreCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
* <li>Retrieves the index for the local variable from the instruction parameters.</li> * <li>Retrieves the index for the local variable from the instruction parameters.</li>
* <li>Retrieves the corresponding value from the local variable store of the current method frame.</li> * <li>Pops a float32 value from the operand stack.</li>
* <li>Pushes the retrieved value onto the operand stack for later operations.</li> * <li>Stores the value into the local variable store at the specified index of the current method frame.</li>
* <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li> * <li>Increments the program counter (PC) to proceed with the next sequential instruction.</li>
* </ol> * </ol>
* *
* <p>This opcode is commonly used for:</p> * <p>This opcode is commonly used for:</p>
* <ul> * <ul>
* <li>Loading local variables onto the operand stack for further operations or computations.</li> * <li>Saving float32 results into method-local variables.</li>
* <li>Retrieving stored values that are needed for later instructions, such as arithmetic or logic operations.</li> * <li>Supporting floating-point local variable operations.</li>
* <li>Preserving the necessary method-local state by pushing relevant values from the local variable store to the operand stack.</li> * <li>Preserving floating-point values between instructions or calls.</li>
* </ul> * </ul>
*/ */
public static final int F_STORE = 156; public static final int F_STORE = 156;
@ -1559,7 +1576,7 @@ public class VMOpCode {
public static final int I_LOAD = 161; public static final int I_LOAD = 161;
/** /**
* L_LOAD Opcode: Represents a load operation that retrieves a long64 value from the local variable store and pushes it onto the operand stack. * L_LOAD Opcode: Represents a load operation that retrieves a long64 value from the local variable store and pushes it onto the operand stack.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link LLoadCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
@ -1579,7 +1596,7 @@ public class VMOpCode {
public static final int L_LOAD = 162; public static final int L_LOAD = 162;
/** /**
* S_LOAD Opcode: Represents a load operation that retrieves a short16 value from the local variable store and pushes it onto the operand stack. * S_LOAD Opcode: Represents a load operation that retrieves a short16 value from the local variable store and pushes it onto the operand stack.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link SLoadCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
@ -1599,7 +1616,7 @@ public class VMOpCode {
public static final int S_LOAD = 163; public static final int S_LOAD = 163;
/** /**
* B_LOAD Opcode: Represents a load operation that retrieves a byte8 value from the local variable store and pushes it onto the operand stack. * B_LOAD Opcode: Represents a load operation that retrieves a byte8 value from the local variable store and pushes it onto the operand stack.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link BLoadCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
@ -1619,7 +1636,7 @@ public class VMOpCode {
public static final int B_LOAD = 164; public static final int B_LOAD = 164;
/** /**
* D_LOAD Opcode: Represents a load operation that retrieves a double64 value from the local variable store and pushes it onto the operand stack. * D_LOAD Opcode: Represents a load operation that retrieves a double64 value from the local variable store and pushes it onto the operand stack.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link DLoadCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>
@ -1639,7 +1656,7 @@ public class VMOpCode {
public static final int D_LOAD = 165; public static final int D_LOAD = 165;
/** /**
* F_LOAD Opcode: Represents a load operation that retrieves a float32 value from the local variable store and pushes it onto the operand stack. * F_LOAD Opcode: Represents a load operation that retrieves a float32 value from the local variable store and pushes it onto the operand stack.
* <p>This opcode is implemented by the {@link ILoadCommand} class, which defines its specific execution logic.</p> * <p>This opcode is implemented by the {@link FLoadCommand} class, which defines its specific execution logic.</p>
* *
* <p>Execution Steps:</p> * <p>Execution Steps:</p>
* <ol> * <ol>

3
test
View File

@ -3,10 +3,11 @@ module: CommonTasks
parameter: parameter:
declare num1: int declare num1: int
declare num2: int declare num2: int
return_type:void return_type:int
body: body:
num1 = 10 num1 = 10
return num1
end body end body
end function end function
end module end module