From c03761ed610fa6df9502091b08ce0a2f87102224 Mon Sep 17 00:00:00 2001 From: zhangxun <1958638841@qq.com> Date: Thu, 26 Jun 2025 20:39:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20byte=E3=80=81short=20=E8=BF=90=E7=AE=97?= =?UTF-8?q?=E5=90=8E=E4=BC=9A=E5=8F=98=E4=B8=BA=20int=20=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java | 2 +- .../jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java | 2 +- .../jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java | 2 +- .../jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java | 2 +- .../jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java | 2 +- .../snow/vm/commands/arithmetic/short16/SAddCommand.java | 6 +++--- .../snow/vm/commands/arithmetic/short16/SDivCommand.java | 2 +- .../snow/vm/commands/arithmetic/short16/SModCommand.java | 2 +- .../snow/vm/commands/arithmetic/short16/SMulCommand.java | 2 +- .../snow/vm/commands/arithmetic/short16/SSubCommand.java | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java index b05f809..f2a42ca 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BAddCommand.java @@ -50,7 +50,7 @@ public class BAddCommand implements Command { byte a = (byte) operandStack.pop(); // Perform the addition and push the result back onto the stack - operandStack.push(a + b); + operandStack.push((byte)(a + b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java index ad24912..582951b 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BDivCommand.java @@ -56,7 +56,7 @@ public class BDivCommand implements Command { } // Perform the division and push the result back onto the stack - operandStack.push(a / b); + operandStack.push((byte)(a / b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java index 88b12bd..dd5892f 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BModCommand.java @@ -50,7 +50,7 @@ public class BModCommand implements Command { byte a = (byte) operandStack.pop(); // Perform the modulus operation and push the result back onto the stack - operandStack.push(a % b); + operandStack.push((byte)(a % b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java index e5de63a..0c6d9c3 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BMulCommand.java @@ -50,7 +50,7 @@ public class BMulCommand implements Command { byte a = (byte) operandStack.pop(); // Perform the multiplication and push the result back onto the stack - operandStack.push(a * b); + operandStack.push((byte)(a * b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java index 091cafd..4c7957e 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/byte8/BSubCommand.java @@ -50,7 +50,7 @@ public class BSubCommand implements Command { byte a = (byte) operandStack.pop(); // Perform the subtraction and push the result back onto the stack - operandStack.push(a - b); + operandStack.push((byte)(a - b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java index 4137a01..b4b1290 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SAddCommand.java @@ -46,11 +46,11 @@ public class SAddCommand implements Command { @Override public int execute(String[] parts, int currentPC, OperandStack operandStack, LocalVariableStore localVariableStore, CallStack callStack) { // Pop the top two operands from the stack - Short b = (Short) operandStack.pop(); - Short a = (Short) operandStack.pop(); + short b = (short) operandStack.pop(); + short a = (short) operandStack.pop(); // Perform the addition and push the result back onto the stack - operandStack.push(a + b); + operandStack.push((short)(a + b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java index f14cefa..9c71b8c 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SDivCommand.java @@ -56,7 +56,7 @@ public class SDivCommand implements Command { } // Perform the division and push the result back onto the stack - operandStack.push(a / b); + operandStack.push((short)(a / b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java index 0047449..105b5bc 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SModCommand.java @@ -50,7 +50,7 @@ public class SModCommand implements Command { short a = (short) operandStack.pop(); // Perform the modulus operation and push the result back onto the stack - operandStack.push(a % b); + operandStack.push((short)(a % b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java index 1a2ac4e..f6c022d 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SMulCommand.java @@ -50,7 +50,7 @@ public class SMulCommand implements Command { short a = (short) operandStack.pop(); // Perform the multiplication and push the result back onto the stack - operandStack.push(a * b); + operandStack.push((short)(a * b)); // Return the updated program counter (next instruction) return currentPC + 1; diff --git a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java index 66c3295..53953b3 100644 --- a/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java +++ b/src/main/java/org/jcnc/snow/vm/commands/arithmetic/short16/SSubCommand.java @@ -50,7 +50,7 @@ public class SSubCommand implements Command { short a = (short) operandStack.pop(); // Perform the subtraction and push the result back onto the stack - operandStack.push(a - b); + operandStack.push((short)(a - b)); // Return the updated program counter (next instruction) return currentPC + 1;