Browse Source

Fix: wrong operation

Akeit0 1 year ago
parent
commit
82266bd3d2
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/Lua/Runtime/LuaVirtualMachine.cs

+ 4 - 4
src/Lua/Runtime/LuaVirtualMachine.cs

@@ -502,7 +502,7 @@ public static partial class LuaVirtualMachine
                             
                             if (vb.TryReadDouble(out numB) && vc.TryReadDouble(out var numC))
                             {
-                                Unsafe.Add(ref stackHead, iA) = numB - numC;
+                                Unsafe.Add(ref stackHead, iA) = numB + numC;
                                 stack.NotifyTop(ra1);
                                 continue;
                             }
@@ -947,11 +947,11 @@ public static partial class LuaVirtualMachine
                                 : instruction.B - 1;
                             var ra = ra1 - 1;
                             stack.EnsureCapacity(ra + count);
-                            stackHead = ref stack.Get(frameBase);
+                            stackHead = ref stack.Get(0);
                             for (int i = 0; i < count; i++)
                             {
-                                stack.Get(ra + i) = frameVariableArgumentCount > i
-                                    ? stack.Get(frameBase - (frameVariableArgumentCount - i))
+                                Unsafe.Add(ref stackHead,ra + i) = frameVariableArgumentCount > i
+                                    ? Unsafe.Add(ref stackHead,frameBase - (frameVariableArgumentCount - i))
                                     : default;
                             }