mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 23:43:16 +02:00
Upgrade to .NET 8 and code cleanup
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace YesNt.Interpreter.Runtime
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
|
||||
public class DebugEventArgs : EventArgs
|
||||
{
|
||||
public class DebugEventArgs : EventArgs
|
||||
{
|
||||
public int LineNumber { get; internal set; }
|
||||
public string CurrentLine { get; internal set; }
|
||||
public string OriginalLine { get; internal set; }
|
||||
public int TaskId { get; internal set; }
|
||||
public bool IsTask { get; internal set; }
|
||||
}
|
||||
public int LineNumber { get; internal set; }
|
||||
public string CurrentLine { get; internal set; }
|
||||
public string OriginalLine { get; internal set; }
|
||||
public int TaskId { get; internal set; }
|
||||
public bool IsTask { get; internal set; }
|
||||
}
|
||||
@@ -2,17 +2,11 @@
|
||||
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
|
||||
internal class FunctionScope
|
||||
internal class FunctionScope(int callerLine, Stack<string> arguments)
|
||||
{
|
||||
public int CallerLine { get; }
|
||||
public Dictionary<string, string> Variables { get; } = new();
|
||||
public Dictionary<string, int> Labels { get; } = new();
|
||||
public Stack<string> Arguemtns { get; }
|
||||
public int CallerLine { get; } = callerLine;
|
||||
public Dictionary<string, string> Variables { get; } = [];
|
||||
public Dictionary<string, int> Labels { get; } = [];
|
||||
public Stack<string> Arguments { get; } = arguments;
|
||||
public Stack<string> Results { get; } = new();
|
||||
|
||||
public FunctionScope(int callerLine, Stack<string> arguemtns)
|
||||
{
|
||||
CallerLine = callerLine;
|
||||
Arguemtns = arguemtns;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
namespace YesNt.Interpreter.Runtime
|
||||
{
|
||||
internal class Line
|
||||
{
|
||||
public Line(string content, string fileName, int lineNumber)
|
||||
{
|
||||
Content = content;
|
||||
FileName = fileName;
|
||||
LineNumber = lineNumber;
|
||||
}
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
|
||||
public string Content { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public int LineNumber { get; set; }
|
||||
}
|
||||
internal class Line(string content, string fileName, int lineNumber)
|
||||
{
|
||||
public string Content { get; set; } = content;
|
||||
|
||||
public string FileName { get; set; } = fileName;
|
||||
|
||||
public int LineNumber { get; set; } = lineNumber;
|
||||
}
|
||||
@@ -14,16 +14,16 @@ internal sealed class RuntimeInformation
|
||||
private event Action<string, bool> OnExit;
|
||||
|
||||
private static int internalTaskId = 0;
|
||||
private readonly Dictionary<string, string> topVariables = new();
|
||||
private readonly Dictionary<string, int> topLabels = new();
|
||||
private readonly Dictionary<string, string> topVariables = [];
|
||||
private readonly Dictionary<string, int> topLabels = [];
|
||||
private RuntimeInformation parentRuntimeInformation;
|
||||
private int taskId = 0;
|
||||
public Dictionary<string, string> GloablVariables { get; set; } = new();
|
||||
public Dictionary<string, int> Functions { get; } = new();
|
||||
public Dictionary<string, string> GlobalVariables { get; set; } = [];
|
||||
public Dictionary<string, int> Functions { get; } = [];
|
||||
public Stack<FunctionScope> FunctionCallStack { get; } = new();
|
||||
public Stack<string> InParametersStack { get; } = new();
|
||||
public Stack<string> OutParametersStack { get; set; } = new();
|
||||
public List<Line> Lines { get; set; } = new();
|
||||
public List<Line> Lines { get; set; } = [];
|
||||
public string CurrentLine { get; set; } = string.Empty;
|
||||
public string SearchLabel { get; set; } = string.Empty;
|
||||
public string SearchFunction { get; set; } = string.Empty;
|
||||
@@ -149,7 +149,7 @@ internal sealed class RuntimeInformation
|
||||
{
|
||||
topVariables.Clear();
|
||||
Lines.Clear();
|
||||
GloablVariables.Clear();
|
||||
GlobalVariables.Clear();
|
||||
Labels.Clear();
|
||||
Functions.Clear();
|
||||
FunctionCallStack.Clear();
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
using YesNt.Interpreter.Enums;
|
||||
|
||||
namespace YesNt.Interpreter.Runtime
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
|
||||
public class StatementInformation
|
||||
{
|
||||
public class StatementInformation
|
||||
{
|
||||
public string Name { get; internal set; }
|
||||
public SearchMode SearchMode { get; internal set; }
|
||||
public SpaceAround SpaceAround { get; internal set; }
|
||||
public ConsoleColor Color { get; internal set; }
|
||||
public bool IgnoreSyntaxHighlighting { get; internal set; }
|
||||
public string Seperator { get; set; }
|
||||
}
|
||||
public string Name { get; internal set; }
|
||||
public SearchMode SearchMode { get; internal set; }
|
||||
public SpaceAround SpaceAround { get; internal set; }
|
||||
public ConsoleColor Color { get; internal set; }
|
||||
public bool IgnoreSyntaxHighlighting { get; internal set; }
|
||||
public string Separator { get; set; }
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace YesNt.Interpreter.Runtime
|
||||
namespace YesNt.Interpreter.Runtime;
|
||||
|
||||
internal abstract class StatementRuntimeInformation
|
||||
{
|
||||
internal abstract class StatementRuntimeInformation
|
||||
{
|
||||
public RuntimeInformation RuntimeInfo { get; set; }
|
||||
}
|
||||
public RuntimeInformation RuntimeInfo { get; set; }
|
||||
}
|
||||
@@ -18,14 +18,14 @@ public class YesNtInterpreter
|
||||
public event Action<string> OnDebugOutput;
|
||||
|
||||
private readonly RuntimeInformation runtimeInfo = new RuntimeInformation();
|
||||
private Dictionary<StatementAttribute, Action<string>> statements = new();
|
||||
private List<KeyValuePair<StaticStatementAttribute, Action>> staticStatements = new();
|
||||
private Dictionary<StatementAttribute, Action<string>> statements = [];
|
||||
private List<KeyValuePair<StaticStatementAttribute, Action>> staticStatements = [];
|
||||
|
||||
public ReadOnlyCollection<StatementInformation> StatementInformation
|
||||
{
|
||||
get
|
||||
{
|
||||
List<StatementInformation> informations = statements.Select(s =>
|
||||
List<StatementInformation> information = statements.Select(s =>
|
||||
{
|
||||
return new StatementInformation()
|
||||
{
|
||||
@@ -34,11 +34,11 @@ public class YesNtInterpreter
|
||||
SpaceAround = s.Key.SpaceAround,
|
||||
Color = s.Key.Color,
|
||||
IgnoreSyntaxHighlighting = s.Key.IgnoreSyntaxHighlighting,
|
||||
Seperator = s.Key.Seperator
|
||||
Separator = s.Key.Separator
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
return new ReadOnlyCollection<StatementInformation>(informations);
|
||||
return new ReadOnlyCollection<StatementInformation>(information);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,14 +118,14 @@ public class YesNtInterpreter
|
||||
Execute();
|
||||
}
|
||||
|
||||
internal void Execute(List<Line> lines, Dictionary<string, string> gloablVariables, int startLine, RuntimeInformation parentRuntimeInformation)
|
||||
internal void Execute(List<Line> lines, Dictionary<string, string> globalVariables, int startLine, RuntimeInformation parentRuntimeInformation)
|
||||
{
|
||||
runtimeInfo.Reset();
|
||||
runtimeInfo.IsDebugMode = parentRuntimeInformation.IsDebugMode;
|
||||
runtimeInfo.Lines = lines;
|
||||
runtimeInfo.LineNumber = startLine;
|
||||
runtimeInfo.ParentRuntimeInformation = parentRuntimeInformation;
|
||||
runtimeInfo.GloablVariables = gloablVariables;
|
||||
runtimeInfo.GlobalVariables = globalVariables;
|
||||
if (parentRuntimeInformation.StopAllTasks)
|
||||
{
|
||||
runtimeInfo.Exit($"Parent task was terminated!", parentRuntimeInformation.StopAllTasks);
|
||||
@@ -195,7 +195,7 @@ public class YesNtInterpreter
|
||||
_ => statementAttribute.Name.Trim()
|
||||
};
|
||||
|
||||
if (statementAttribute.Seperator is null || runtimeInfo.CurrentLine.Contains(statementAttribute.Seperator))
|
||||
if (statementAttribute.Separator is null || runtimeInfo.CurrentLine.Contains(statementAttribute.Separator))
|
||||
{
|
||||
if (statementAttribute.SearchMode == SearchMode.StartOfLine && runtimeInfo.CurrentLine.StartsWith(name))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user