AnnulusGames 1 year ago
parent
commit
24b2bdca53
2 changed files with 560 additions and 508 deletions
  1. 2 2
      src/Lua/CodeAnalysis/Compilation/LuaCompiler.cs
  2. 558 506
      src/Lua/Runtime/LuaVirtualMachine.cs

+ 2 - 2
src/Lua/CodeAnalysis/Compilation/LuaCompiler.cs

@@ -841,9 +841,9 @@ public sealed class LuaCompiler : ISyntaxNodeVisitor<ScopeCompilationContext, bo
         context.Function.LoopLevel--;
         context.Function.LoopLevel--;
 
 
         // set JMP sBx
         // set JMP sBx
-        context.Function.Instructions[conditionIndex].SBx = context.Function.Instructions.Length - 1 - conditionIndex;
+        scopeContext.Function.Instructions[conditionIndex].SBx = scopeContext.Function.Instructions.Length - 1 - conditionIndex;
 
 
-        CompileConditionNode(node.ConditionNode, context, false);
+        CompileConditionNode(node.ConditionNode, scopeContext, false);
         var a = scopeContext.HasCapturedLocalVariables ? scopeContext.StackPosition : (byte)0;
         var a = scopeContext.HasCapturedLocalVariables ? scopeContext.StackPosition : (byte)0;
         scopeContext.PushInstruction(Instruction.Jmp(a, conditionIndex - context.Function.Instructions.Length), node.Position);
         scopeContext.PushInstruction(Instruction.Jmp(a, conditionIndex - context.Function.Instructions.Length), node.Position);
         scopeContext.TryPushCloseUpValue(scopeContext.StackPosition, node.Position);
         scopeContext.TryPushCloseUpValue(scopeContext.StackPosition, node.Position);

File diff suppressed because it is too large
+ 558 - 506
src/Lua/Runtime/LuaVirtualMachine.cs


Some files were not shown because too many files changed in this diff