|
@@ -63,21 +63,10 @@ public static partial class LuaVirtualMachine
|
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
|
var upValue = closure.UpValues[instruction.B];
|
|
var upValue = closure.UpValues[instruction.B];
|
|
|
var table = upValue.GetValue();
|
|
var table = upValue.GetValue();
|
|
|
-
|
|
|
|
|
- (var task, var funcContext) = GetTableValue(state, thread, chunk, rootChunk, pc, table, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await task;
|
|
|
|
|
- stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
|
|
- stack.NotifyTop(RA + 1);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- if (funcContext != null)
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ await GetTableValue(state, thread, chunk, rootChunk, pc, table, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
+ var value = resultBuffer[0];
|
|
|
|
|
+ stack.UnsafeGet(RA) = value;
|
|
|
|
|
+ stack.NotifyTop(RA + 1);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
case OpCode.GetTable:
|
|
case OpCode.GetTable:
|
|
@@ -85,20 +74,10 @@ public static partial class LuaVirtualMachine
|
|
|
stack.EnsureCapacity(RA + 1);
|
|
stack.EnsureCapacity(RA + 1);
|
|
|
var table = stack.UnsafeGet(RB);
|
|
var table = stack.UnsafeGet(RB);
|
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
|
- (var task, var funcContext) = GetTableValue(state, thread, chunk, rootChunk, pc, table, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await task;
|
|
|
|
|
- stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
|
|
- stack.NotifyTop(RA + 1);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- if (funcContext != null)
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ await GetTableValue(state, thread, chunk, rootChunk, pc, table, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
+ var value = resultBuffer[0];
|
|
|
|
|
+ stack.UnsafeGet(RA) = value;
|
|
|
|
|
+ stack.NotifyTop(RA + 1);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case OpCode.SetTabUp:
|
|
case OpCode.SetTabUp:
|
|
@@ -108,21 +87,9 @@ public static partial class LuaVirtualMachine
|
|
|
|
|
|
|
|
var upValue = closure.UpValues[instruction.A];
|
|
var upValue = closure.UpValues[instruction.A];
|
|
|
var table = upValue.GetValue();
|
|
var table = upValue.GetValue();
|
|
|
-
|
|
|
|
|
- (var task, var funcContext) = SetTableValue(state, thread, chunk, rootChunk, pc, table, vb, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await task;
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- if (funcContext != null)
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ await SetTableValue(state, thread, chunk, rootChunk, pc, table, vb, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
- break;
|
|
|
|
|
case OpCode.SetUpVal:
|
|
case OpCode.SetUpVal:
|
|
|
{
|
|
{
|
|
|
var upValue = closure.UpValues[instruction.B];
|
|
var upValue = closure.UpValues[instruction.B];
|
|
@@ -134,19 +101,7 @@ public static partial class LuaVirtualMachine
|
|
|
var table = stack.UnsafeGet(RA);
|
|
var table = stack.UnsafeGet(RA);
|
|
|
var vb = RK(stack, chunk, instruction.B, frame.Base);
|
|
var vb = RK(stack, chunk, instruction.B, frame.Base);
|
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
|
-
|
|
|
|
|
- (var task, var funcContext) = SetTableValue(state, thread, chunk, rootChunk, pc, table, vb, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await task;
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- if (funcContext != null)
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ await SetTableValue(state, thread, chunk, rootChunk, pc, table, vb, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case OpCode.NewTable:
|
|
case OpCode.NewTable:
|
|
@@ -160,22 +115,12 @@ public static partial class LuaVirtualMachine
|
|
|
var table = stack.UnsafeGet(RB);
|
|
var table = stack.UnsafeGet(RB);
|
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
var vc = RK(stack, chunk, instruction.C, frame.Base);
|
|
|
|
|
|
|
|
- (var task, var funcContext) = GetTableValue(state, thread, chunk, rootChunk, pc, table, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await task;
|
|
|
|
|
- var value = resultBuffer[0];
|
|
|
|
|
- stack.UnsafeGet(RA + 1) = table;
|
|
|
|
|
- stack.UnsafeGet(RA) = value;
|
|
|
|
|
- stack.NotifyTop(RA + 2);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- if (funcContext != null)
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ await GetTableValue(state, thread, chunk, rootChunk, pc, table, vc, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
+ var value = resultBuffer[0];
|
|
|
|
|
+
|
|
|
|
|
+ stack.UnsafeGet(RA + 1) = table;
|
|
|
|
|
+ stack.UnsafeGet(RA) = value;
|
|
|
|
|
+ stack.NotifyTop(RA + 2);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case OpCode.Add:
|
|
case OpCode.Add:
|
|
@@ -199,22 +144,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -247,22 +186,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -295,22 +228,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -343,22 +270,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -396,22 +317,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -444,22 +359,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -490,22 +399,16 @@ public static partial class LuaVirtualMachine
|
|
|
|
|
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 1;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 1;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 1,
|
|
|
|
|
+ FrameBase = stack.Count - 1,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -543,22 +446,16 @@ public static partial class LuaVirtualMachine
|
|
|
|
|
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 1;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 1;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 1,
|
|
|
|
|
+ FrameBase = stack.Count - 1,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -609,22 +506,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
stack.UnsafeGet(RA) = resultBuffer[0];
|
|
|
}
|
|
}
|
|
@@ -659,22 +550,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
compareResult = resultBuffer[0].ToBoolean();
|
|
compareResult = resultBuffer[0].ToBoolean();
|
|
|
}
|
|
}
|
|
@@ -709,22 +594,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
compareResult = resultBuffer[0].ToBoolean();
|
|
compareResult = resultBuffer[0].ToBoolean();
|
|
|
}
|
|
}
|
|
@@ -763,22 +642,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(vb);
|
|
stack.Push(vb);
|
|
|
stack.Push(vc);
|
|
stack.Push(vc);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
|
|
+ await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- await func.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
compareResult = resultBuffer[0].ToBoolean();
|
|
compareResult = resultBuffer[0].ToBoolean();
|
|
|
}
|
|
}
|
|
@@ -845,25 +718,18 @@ public static partial class LuaVirtualMachine
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
int rawResultCount;
|
|
int rawResultCount;
|
|
|
-
|
|
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = argumentCount;
|
|
|
|
|
- funcContext.FrameBase = newBase;
|
|
|
|
|
- funcContext.SourcePosition = callPosition;
|
|
|
|
|
- funcContext.ChunkName = chunkName;
|
|
|
|
|
- funcContext.RootChunkName = rootChunkName;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- rawResultCount = await func.InternalInvokeAsyncCore(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ rawResultCount = await func.InternalInvokeAsyncCore(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = argumentCount,
|
|
|
|
|
+ FrameBase = newBase,
|
|
|
|
|
+ SourcePosition = callPosition,
|
|
|
|
|
+ ChunkName = chunkName,
|
|
|
|
|
+ RootChunkName = rootChunkName,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
}
|
|
}
|
|
|
finally
|
|
finally
|
|
|
{
|
|
{
|
|
@@ -909,22 +775,16 @@ public static partial class LuaVirtualMachine
|
|
|
|
|
|
|
|
(var newBase, var argumentCount) = PrepareForFunctionCall(thread, func, instruction, RA, resultBuffer.AsSpan(), true);
|
|
(var newBase, var argumentCount) = PrepareForFunctionCall(thread, func, instruction, RA, resultBuffer.AsSpan(), true);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = argumentCount;
|
|
|
|
|
- funcContext.FrameBase = newBase;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- return await func.InvokeAsync(funcContext, buffer, cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
|
|
+ return await func.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = argumentCount,
|
|
|
|
|
+ FrameBase = newBase,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, buffer, cancellationToken);
|
|
|
}
|
|
}
|
|
|
case OpCode.Return:
|
|
case OpCode.Return:
|
|
|
{
|
|
{
|
|
@@ -1008,24 +868,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.UnsafeGet(nextBase + 1) = stack.UnsafeGet(RA + 2);
|
|
stack.UnsafeGet(nextBase + 1) = stack.UnsafeGet(RA + 2);
|
|
|
stack.NotifyTop(nextBase + 2);
|
|
stack.NotifyTop(nextBase + 2);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = nextBase;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
-
|
|
|
|
|
- int resultCount;
|
|
|
|
|
- try
|
|
|
|
|
|
|
+ var resultCount = await iterator.InvokeAsync(new()
|
|
|
{
|
|
{
|
|
|
- resultCount = await iterator.InvokeAsync(funcContext, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
- }
|
|
|
|
|
- finally
|
|
|
|
|
- {
|
|
|
|
|
- LuaFunctionExecutionContextPool.Return(funcContext);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ FrameBase = nextBase,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, resultBuffer.AsMemory(), cancellationToken);
|
|
|
|
|
|
|
|
stack.EnsureCapacity(RA + instruction.C + 3);
|
|
stack.EnsureCapacity(RA + instruction.C + 3);
|
|
|
for (int i = 1; i <= instruction.C; i++)
|
|
for (int i = 1; i <= instruction.C; i++)
|
|
@@ -1118,7 +970,7 @@ public static partial class LuaVirtualMachine
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- static (ValueTask<int> Task, LuaFunctionExecutionContext? Context) GetTableValue(LuaState state, LuaThread thread, Chunk chunk, Chunk rootChunk, int pc, LuaValue table, LuaValue key, Memory<LuaValue> buffer, CancellationToken cancellationToken)
|
|
|
|
|
|
|
+ static ValueTask<int> GetTableValue(LuaState state, LuaThread thread, Chunk chunk, Chunk rootChunk, int pc, LuaValue table, LuaValue key, Memory<LuaValue> buffer, CancellationToken cancellationToken)
|
|
|
{
|
|
{
|
|
|
var stack = thread.Stack;
|
|
var stack = thread.Stack;
|
|
|
var isTable = table.TryRead<LuaTable>(out var t);
|
|
var isTable = table.TryRead<LuaTable>(out var t);
|
|
@@ -1126,7 +978,7 @@ public static partial class LuaVirtualMachine
|
|
|
if (isTable && t.TryGetValue(key, out var result))
|
|
if (isTable && t.TryGetValue(key, out var result))
|
|
|
{
|
|
{
|
|
|
buffer.Span[0] = result;
|
|
buffer.Span[0] = result;
|
|
|
- return (new(1), null);
|
|
|
|
|
|
|
+ return new(1);
|
|
|
}
|
|
}
|
|
|
else if (table.TryGetMetamethod(state, Metamethods.Index, out var metamethod))
|
|
else if (table.TryGetMetamethod(state, Metamethods.Index, out var metamethod))
|
|
|
{
|
|
{
|
|
@@ -1138,21 +990,21 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(table);
|
|
stack.Push(table);
|
|
|
stack.Push(key);
|
|
stack.Push(key);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 2;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 2;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
-
|
|
|
|
|
- return (indexTable.InvokeAsync(funcContext, buffer, cancellationToken), funcContext);
|
|
|
|
|
|
|
+ return indexTable.InvokeAsync(new()
|
|
|
|
|
+ {
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 2,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ FrameBase = stack.Count - 2,
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, buffer, cancellationToken);
|
|
|
}
|
|
}
|
|
|
else if (isTable)
|
|
else if (isTable)
|
|
|
{
|
|
{
|
|
|
buffer.Span[0] = LuaValue.Nil;
|
|
buffer.Span[0] = LuaValue.Nil;
|
|
|
- return (new(1), null);
|
|
|
|
|
|
|
+ return new(1);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -1161,7 +1013,7 @@ public static partial class LuaVirtualMachine
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- static (ValueTask<int> Task, LuaFunctionExecutionContext? Context) SetTableValue(LuaState state, LuaThread thread, Chunk chunk, Chunk rootChunk, int pc, LuaValue table, LuaValue key, LuaValue value, Memory<LuaValue> buffer, CancellationToken cancellationToken)
|
|
|
|
|
|
|
+ static ValueTask<int> SetTableValue(LuaState state, LuaThread thread, Chunk chunk, Chunk rootChunk, int pc, LuaValue table, LuaValue key, LuaValue value, Memory<LuaValue> buffer, CancellationToken cancellationToken)
|
|
|
{
|
|
{
|
|
|
var stack = thread.Stack;
|
|
var stack = thread.Stack;
|
|
|
var isTable = table.TryRead<LuaTable>(out var t);
|
|
var isTable = table.TryRead<LuaTable>(out var t);
|
|
@@ -1178,7 +1030,7 @@ public static partial class LuaVirtualMachine
|
|
|
if (isTable)
|
|
if (isTable)
|
|
|
{
|
|
{
|
|
|
t[key] = value;
|
|
t[key] = value;
|
|
|
- return (new(1), null);
|
|
|
|
|
|
|
+ return new(1);
|
|
|
}
|
|
}
|
|
|
else if (table.TryGetMetamethod(state, Metamethods.NewIndex, out var metamethod))
|
|
else if (table.TryGetMetamethod(state, Metamethods.NewIndex, out var metamethod))
|
|
|
{
|
|
{
|
|
@@ -1191,16 +1043,16 @@ public static partial class LuaVirtualMachine
|
|
|
stack.Push(key);
|
|
stack.Push(key);
|
|
|
stack.Push(value);
|
|
stack.Push(value);
|
|
|
|
|
|
|
|
- var funcContext = LuaFunctionExecutionContextPool.Rent();
|
|
|
|
|
- funcContext.State = state;
|
|
|
|
|
- funcContext.Thread = thread;
|
|
|
|
|
- funcContext.ArgumentCount = 3;
|
|
|
|
|
- funcContext.FrameBase = stack.Count - 3;
|
|
|
|
|
- funcContext.SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc);
|
|
|
|
|
- funcContext.ChunkName = chunk.Name;
|
|
|
|
|
- funcContext.RootChunkName = rootChunk.Name;
|
|
|
|
|
-
|
|
|
|
|
- return (indexTable.InvokeAsync(funcContext, buffer, cancellationToken), funcContext);
|
|
|
|
|
|
|
+ return indexTable.InvokeAsync(new()
|
|
|
|
|
+ {
|
|
|
|
|
+ State = state,
|
|
|
|
|
+ Thread = thread,
|
|
|
|
|
+ ArgumentCount = 3,
|
|
|
|
|
+ FrameBase = stack.Count - 3,
|
|
|
|
|
+ SourcePosition = MemoryMarshalEx.UnsafeElementAt(chunk.SourcePositions, pc),
|
|
|
|
|
+ ChunkName = chunk.Name,
|
|
|
|
|
+ RootChunkName = rootChunk.Name,
|
|
|
|
|
+ }, buffer, cancellationToken);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|