Remove Initialize calls and add AddStatement tests

This commit is contained in:
Stone_Red
2026-03-04 19:41:19 +01:00
parent 8e0abf155a
commit b2fdd9c841
8 changed files with 250 additions and 16 deletions
-1
View File
@@ -11,7 +11,6 @@ internal static class Program
if (args.Length == 1)
{
YesNtInterpreter interpreter = new YesNtInterpreter();
interpreter.Initialize();
interpreter.Execute(args[0]);
}
else
@@ -60,21 +60,19 @@ public class YesNtInterpreter
AddStatement(new StatementAttribute(name, searchMode, spaceAround, consoleColor), handler);
}
public void Stop()
public YesNtInterpreter()
{
runtimeInfo.Exit("Terminated by external process", true);
}
public void Initialize()
{
statements.Clear();
staticStatements.Clear();
GeneratedStatementRegistry.Register(runtimeInfo, out statements, out staticStatements);
runtimeInfo.OnDebugOutput += (s) => OnDebugOutput?.Invoke(s);
runtimeInfo.OnLineExecuted += (DebugEventArgs e) => OnLineExecuted?.Invoke(e);
}
public void Stop()
{
runtimeInfo.Exit("Terminated by external process", true);
}
public void Execute(string path, bool isDebugMode = false)
{
runtimeInfo.Reset();
@@ -50,8 +50,7 @@ internal partial class ProcessingStatements : StatementRuntimeInformation
_ = Task.Run(() =>
{
YesNtInterpreter interpreter = new YesNtInterpreter();
interpreter.Initialize();
interpreter.Execute(lines, RuntimeInfo.GlobalVariables, lineNumber, RuntimeInfo);
interpreter.Execute(lines, RuntimeInfo.GlobalVariables, lineNumber, RuntimeInfo);
});
RuntimeInfo.CurrentLine = string.Empty;