From 4f63f88b400de03baf0e47f09e5fb608960068dc Mon Sep 17 00:00:00 2001 From: zhangxun <1958638841@qq.com> Date: Tue, 8 Jul 2025 20:19:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A5=E5=85=85=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E6=95=B0=E5=80=BC=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E6=8C=87?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jcnc/snow/vm/engine/VMOpCode.java | 200 ++++++++++-------- .../snow/vm/factories/CommandFactory.java | 29 ++- 2 files changed, 135 insertions(+), 94 deletions(-) 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 c53f511..8b634ca 100644 --- a/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java +++ b/src/main/java/org/jcnc/snow/vm/engine/VMOpCode.java @@ -2043,34 +2043,33 @@ public class VMOpCode { // endregion // region Type Conversion (0x00C0-0x00DF) - /** - * I2L Opcode: Represents the type conversion operation from int32 to long64 in the virtual machine. - *
This opcode is implemented by the {@link I2LCommand} class, which defines its specific execution logic.
- * - *Execution Steps:
- *This opcode is commonly used to widen an int32 value to a long64 type to accommodate larger numeric ranges.
- */ - public static final int I2L = 0x00C0; - /** - * I2S Opcode: Represents the type conversion operation from int32 to short16 in the virtual machine. - *This opcode is implemented by the {@link I2SCommand} class, which defines its specific execution logic.
- * - *Execution Steps:
- *This opcode is typically used to narrow an int32 value to a short16 type when a smaller data representation is needed.
- */ - public static final int I2S = 0x00C1; + // region Byte8 (0x00C0-0xC4) + + public static final int B2S = 0x00C0; + + public static final int B2I = 0x00C1; + + public static final int B2L = 0x00C2; + + public static final int B2F = 0x00C3; + + public static final int B2D = 0x00C4; + // endregion Byte8 + + // region Short16 (0x00C5-0xC9) + + public static final int S2B = 0x00C5; + + public static final int S2I = 0x00C6; + + public static final int S2L = 0x00C7; + + public static final int S2F = 0x00C8; + + public static final int S2D = 0x00C9; + // endregion Short16 + + // region Int32 (0x00CA-0xCE) /** * I2B Opcode: Represents the type conversion operation from int32 to byte8 in the virtual machine. *This opcode is implemented by the {@link I2BCommand} class, which defines its specific execution logic.
@@ -2084,21 +2083,37 @@ public class VMOpCode { * *This opcode is used to narrow an int32 value to a byte8 type, suitable when a smaller numeric type is required.
*/ - public static final int I2B = 0x00C2; + public static final int I2B = 0x00CA; + /** - * I2D Opcode: Represents the type conversion operation from int32 to double64 in the virtual machine. - *This opcode is implemented by the {@link I2DCommand} class, which defines its specific execution logic.
+ * I2S Opcode: Represents the type conversion operation from int32 to short16 in the virtual machine. + *This opcode is implemented by the {@link I2SCommand} class, which defines its specific execution logic.
* *Execution Steps:
*This opcode is used to widen an int32 value to a double64 type, providing high-precision floating-point calculations.
+ *This opcode is typically used to narrow an int32 value to a short16 type when a smaller data representation is needed.
*/ - public static final int I2D = 0x00C3; + public static final int I2S = 0x00CB; + + /** + * I2L Opcode: Represents the type conversion operation from int32 to long64 in the virtual machine. + *This opcode is implemented by the {@link I2LCommand} class, which defines its specific execution logic.
+ * + *Execution Steps:
+ *This opcode is commonly used to widen an int32 value to a long64 type to accommodate larger numeric ranges.
+ */ + public static final int I2L = 0x00CC; /** * I2F Opcode: Represents the type conversion operation from int32 to float32 in the virtual machine. *This opcode is implemented by the {@link I2FCommand} class, which defines its specific execution logic.
@@ -2112,7 +2127,29 @@ public class VMOpCode { * *This opcode is used to convert an int32 value to a float32 type when floating-point arithmetic is required.
*/ - public static final int I2F = 0x00C4; + public static final int I2F = 0x00CD; + /** + * I2D Opcode: Represents the type conversion operation from int32 to double64 in the virtual machine. + *This opcode is implemented by the {@link I2DCommand} class, which defines its specific execution logic.
+ * + *Execution Steps:
+ *This opcode is used to widen an int32 value to a double64 type, providing high-precision floating-point calculations.
+ */ + public static final int I2D = 0x00CE; + // endregion Int32 + + // region Long64 (0x00CF-0xD3) + + public static final int L2B = 0x00CF; + + public static final int L2S = 0x00D0; + /** * L2I Opcode: Represents the type conversion operation from long64 to int32 in the virtual machine. *This opcode is implemented by the {@link L2ICommand} class, which defines its specific execution logic.
@@ -2126,21 +2163,7 @@ public class VMOpCode { * *This opcode is typically used to narrow a long64 value to an int32 type for further integer operations.
*/ - public static final int L2I = 0x00C5; - /** - * L2D Opcode: Represents the type conversion operation from long64 to double64 in the virtual machine. - *This opcode is implemented by the {@link L2DCommand} class, which defines its specific execution logic.
- * - *Execution Steps:
- *This opcode is used to widen a long64 value to a double64 type for high-precision floating-point computations.
- */ - public static final int L2D = 0x00C6; + public static final int L2I = 0x00D1; /** * L2F Opcode: Represents the type conversion operation from long64 to float32 in the virtual machine. *This opcode is implemented by the {@link L2FCommand} class, which defines its specific execution logic.
@@ -2154,7 +2177,29 @@ public class VMOpCode { * *This opcode is used to convert a long64 value to a float32 type, typically for floating-point arithmetic involving long values.
*/ - public static final int L2F = 0x00C7; + public static final int L2F = 0x00D2; + /** + * L2D Opcode: Represents the type conversion operation from long64 to double64 in the virtual machine. + *This opcode is implemented by the {@link L2DCommand} class, which defines its specific execution logic.
+ * + *Execution Steps:
+ *This opcode is used to widen a long64 value to a double64 type for high-precision floating-point computations.
+ */ + public static final int L2D = 0x00D3; + // endregion Long64 + + // region Float32 (0x00D4-0xD8) + + public static final int F2B = 0x00D4; + + public static final int F2S = 0x00D5; + /** * F2I Opcode: Represents the type conversion operation from float32 to int32 in the virtual machine. *This opcode is implemented by the {@link F2ICommand} class, which defines its specific execution logic.
@@ -2168,7 +2213,7 @@ public class VMOpCode { * *This opcode is used to convert a float32 value to an int32 type for further integer-based operations or comparisons.
*/ - public static final int F2I = 0x00C8; + public static final int F2I = 0x00D6; /** * F2L Opcode: Represents the type conversion operation from float32 to long64 in the virtual machine. *This opcode is implemented by the {@link F2LCommand} class, which defines its specific execution logic.
@@ -2182,7 +2227,7 @@ public class VMOpCode { * *This opcode is used to widen a float32 value to a long64 type, which is useful when operations require a larger numeric range.
*/ - public static final int F2L = 0x00C9; + public static final int F2L = 0x00D7; /** * F2D Opcode: Represents the type conversion operation from float32 to double64 in the virtual machine. *This opcode is implemented by the {@link F2DCommand} class, which defines its specific execution logic.
@@ -2196,7 +2241,15 @@ public class VMOpCode { * *This opcode is used to promote a float32 value to a double64 type, thereby increasing precision for floating-point computations.
*/ - public static final int F2D = 0x00CA; + public static final int F2D = 0x00D8; + // endregion Float32 + + // region Double64 (0x00D9-0xDD) + + public static final int D2B = 0x00D9; + + public static final int D2S = 0x00DA; + /** * D2I Opcode: Represents the type conversion operation from double64 to int32 in the virtual machine. *This opcode is implemented by the {@link D2ICommand} class, which defines its specific execution logic.
@@ -2210,7 +2263,7 @@ public class VMOpCode { * *This opcode is used to narrow a double64 value to an int32 type for further integer-based processing.
*/ - public static final int D2I = 0x00CB; + public static final int D2I = 0x00DB; /** * D2L Opcode: Represents the type conversion operation from double64 to long64 in the virtual machine. *This opcode is implemented by the {@link D2LCommand} class, which defines its specific execution logic.
@@ -2224,7 +2277,7 @@ public class VMOpCode { * *This opcode is used to narrow a double64 value to a long64 type, which can then be used for integer operations.
*/ - public static final int D2L = 0x00CC; + public static final int D2L = 0x00DC; /** * D2F Opcode: Represents the type conversion operation from double64 to float32 in the virtual machine. *This opcode is implemented by the {@link D2FCommand} class, which defines its specific execution logic.
@@ -2238,36 +2291,9 @@ public class VMOpCode { * *This opcode is used to narrow a double64 value to a float32 type when lower precision floating-point arithmetic is acceptable.
*/ - public static final int D2F = 0x00CD; - /** - * S2I Opcode: Represents the type conversion operation from short16 to int32 in the virtual machine. - *This opcode is implemented by the {@link S2ICommand} class, which defines its specific execution logic.
- * - *Execution Steps:
- *This opcode is used to widen a short16 value to an int32 type, facilitating subsequent integer arithmetic or comparison operations.
- */ - public static final int S2I = 0x00CE; - /** - * B2I Opcode: Represents the type conversion operation from byte8 to int32 in the virtual machine. - *This opcode is implemented by the {@link B2ICommand} class, which defines its specific execution logic.
- * - *Execution Steps:
- *This opcode is used to widen a byte8 value to an int32 type to ensure compatibility with integer-based operations.
- */ - public static final int B2I = 0x00CF; - // endregion + public static final int D2F = 0x00DD; + // endregion Double64 + // endregion Conversion // region Stack Control (0x0100-0x01FF) /** diff --git a/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java b/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java index a5af00b..4054a11 100644 --- a/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java +++ b/src/main/java/org/jcnc/snow/vm/factories/CommandFactory.java @@ -207,26 +207,41 @@ public class CommandFactory { // endregion // region Type Conversion (0x00C0-0x00DF) - COMMANDS[VMOpCode.I2L] = new I2LCommand(); - COMMANDS[VMOpCode.I2S] = new I2SCommand(); + COMMANDS[VMOpCode.B2S] = new B2SCommand(); + COMMANDS[VMOpCode.B2I] = new B2ICommand(); + COMMANDS[VMOpCode.B2L] = new B2LCommand(); + COMMANDS[VMOpCode.B2F] = new B2FCommand(); + COMMANDS[VMOpCode.B2D] = new B2DCommand(); + + COMMANDS[VMOpCode.S2B] = new S2BCommand(); + COMMANDS[VMOpCode.S2I] = new S2ICommand(); + COMMANDS[VMOpCode.S2L] = new S2LCommand(); + COMMANDS[VMOpCode.S2F] = new S2FCommand(); + COMMANDS[VMOpCode.S2D] = new S2DCommand(); + COMMANDS[VMOpCode.I2B] = new I2BCommand(); - COMMANDS[VMOpCode.I2D] = new I2DCommand(); + COMMANDS[VMOpCode.I2S] = new I2SCommand(); + COMMANDS[VMOpCode.I2L] = new I2LCommand(); COMMANDS[VMOpCode.I2F] = new I2FCommand(); + COMMANDS[VMOpCode.I2D] = new I2DCommand(); + COMMANDS[VMOpCode.L2B] = new L2BCommand(); + COMMANDS[VMOpCode.L2S] = new L2SCommand(); COMMANDS[VMOpCode.L2I] = new L2ICommand(); - COMMANDS[VMOpCode.L2D] = new L2DCommand(); COMMANDS[VMOpCode.L2F] = new L2FCommand(); + COMMANDS[VMOpCode.L2D] = new L2DCommand(); + COMMANDS[VMOpCode.F2B] = new F2BCommand(); + COMMANDS[VMOpCode.F2S] = new F2SCommand(); COMMANDS[VMOpCode.F2I] = new F2ICommand(); COMMANDS[VMOpCode.F2L] = new F2LCommand(); COMMANDS[VMOpCode.F2D] = new F2DCommand(); + COMMANDS[VMOpCode.D2B] = new D2BCommand(); + COMMANDS[VMOpCode.D2S] = new D2SCommand(); COMMANDS[VMOpCode.D2I] = new D2ICommand(); COMMANDS[VMOpCode.D2L] = new D2LCommand(); COMMANDS[VMOpCode.D2F] = new D2FCommand(); - - COMMANDS[VMOpCode.S2I] = new S2ICommand(); - COMMANDS[VMOpCode.B2I] = new B2ICommand(); // endregion // region Stack Control (0x0100-0x01FF)