mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-10 07:56:08 +02:00
Code cleanup
This commit is contained in:
@@ -80,4 +80,4 @@ internal static class ExitMessages
|
||||
{
|
||||
return $"Failed to start \"{program}\". {message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,4 +25,4 @@ internal class FunctionScope(int callerLine, Stack<string> arguments)
|
||||
|
||||
/// <summary>Gets the stack of output values pushed via <c>push_out</c>, consumed by the caller via <c>%out</c>.</summary>
|
||||
public Stack<string> Results { get; } = new();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a single source line together with its location metadata.
|
||||
|
||||
@@ -197,4 +197,4 @@ internal sealed class RuntimeInformation
|
||||
{
|
||||
Exit(ExitMessages.TerminatedByParentTask, stopAllTasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using YesNt.Interpreter.Attributes;
|
||||
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
@@ -6,4 +7,4 @@ namespace YesNt.Interpreter.Runtime;
|
||||
/// <summary>
|
||||
/// Pre-calculated statement handler information for faster matching.
|
||||
/// </summary>
|
||||
internal record StatementHandler(StatementAttribute Attribute, Action<string> Handler, string FullName);
|
||||
internal record StatementHandler(StatementAttribute Attribute, Action<string> Handler, string FullName);
|
||||
@@ -430,9 +430,9 @@ public class YesNtInterpreter
|
||||
{
|
||||
runtimeInfo.BlockBoundaries.Clear();
|
||||
lineMatchingHandlers = new List<List<StatementHandler>>(runtimeInfo.Lines.Count);
|
||||
|
||||
|
||||
// Dictionary to track open blocks by their expected end statement name
|
||||
var openBlocks = new Dictionary<string, Stack<int>>();
|
||||
Dictionary<string, Stack<int>> openBlocks = [];
|
||||
|
||||
for (int i = 0; i < runtimeInfo.Lines.Count; i++)
|
||||
{
|
||||
@@ -449,7 +449,7 @@ public class YesNtInterpreter
|
||||
string blockPair = handler.Attribute.BlockPair;
|
||||
if (!string.IsNullOrEmpty(blockPair) && !handler.Attribute.IsBlockIntermediate)
|
||||
{
|
||||
if (!openBlocks.TryGetValue(blockPair, out var stack))
|
||||
if (!openBlocks.TryGetValue(blockPair, out Stack<int> stack))
|
||||
{
|
||||
stack = new Stack<int>();
|
||||
openBlocks[blockPair] = stack;
|
||||
@@ -460,7 +460,7 @@ public class YesNtInterpreter
|
||||
// Track block ends
|
||||
if (handler.Attribute.IsBlockEnd)
|
||||
{
|
||||
if (openBlocks.TryGetValue(handler.Attribute.Name, out var stack) && stack.Count > 0)
|
||||
if (openBlocks.TryGetValue(handler.Attribute.Name, out Stack<int> stack) && stack.Count > 0)
|
||||
{
|
||||
int startLine = stack.Pop();
|
||||
runtimeInfo.BlockBoundaries[startLine] = i;
|
||||
@@ -474,7 +474,7 @@ public class YesNtInterpreter
|
||||
string intermediatePair = handler.Attribute.BlockPair;
|
||||
if (!string.IsNullOrEmpty(intermediatePair))
|
||||
{
|
||||
if (!openBlocks.TryGetValue(intermediatePair, out var stack))
|
||||
if (!openBlocks.TryGetValue(intermediatePair, out Stack<int> stack))
|
||||
{
|
||||
stack = new Stack<int>();
|
||||
openBlocks[intermediatePair] = stack;
|
||||
@@ -507,4 +507,4 @@ public class YesNtInterpreter
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user