Code cleanup

This commit is contained in:
Stone_Red
2026-03-05 22:55:11 +01:00
parent 276ae421e8
commit 789f56ba95
35 changed files with 100 additions and 80 deletions
+1 -1
View File
@@ -80,4 +80,4 @@ internal static class ExitMessages
{
return $"Failed to start \"{program}\". {message}";
}
}
}
+1 -1
View File
@@ -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 -3
View File
@@ -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
};
}
}
}