mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 23:43:16 +02:00
Add list statement support with tests for creation, access, and errors
This commit is contained in:
@@ -6,7 +6,8 @@ internal class FunctionScope(int callerLine, Stack<string> arguments)
|
||||
{
|
||||
public int CallerLine { get; } = callerLine;
|
||||
public Dictionary<string, string> Variables { get; } = [];
|
||||
public Dictionary<string, List<string>> Lists { get; } = [];
|
||||
public Dictionary<string, int> Labels { get; } = [];
|
||||
public Stack<string> Arguments { get; } = arguments;
|
||||
public Stack<string> Results { get; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ internal sealed class RuntimeInformation
|
||||
|
||||
private static int internalTaskId = 0;
|
||||
private readonly Dictionary<string, string> topVariables = [];
|
||||
private readonly Dictionary<string, List<string>> topLists = [];
|
||||
private readonly Dictionary<string, int> topLabels = [];
|
||||
private RuntimeInformation parentRuntimeInformation;
|
||||
private int taskId = 0;
|
||||
@@ -43,6 +44,7 @@ internal sealed class RuntimeInformation
|
||||
}
|
||||
|
||||
public Dictionary<string, string> Variables => FunctionCallStack.Count == 0 ? topVariables : FunctionCallStack.Peek().Variables;
|
||||
public Dictionary<string, List<string>> Lists => FunctionCallStack.Count == 0 ? topLists : FunctionCallStack.Peek().Lists;
|
||||
|
||||
public Dictionary<string, int> Labels => FunctionCallStack.Count == 0 ? topLabels : FunctionCallStack.Peek().Labels;
|
||||
|
||||
@@ -148,6 +150,7 @@ internal sealed class RuntimeInformation
|
||||
public void Reset()
|
||||
{
|
||||
topVariables.Clear();
|
||||
topLists.Clear();
|
||||
Lines.Clear();
|
||||
GlobalVariables.Clear();
|
||||
Labels.Clear();
|
||||
@@ -176,4 +179,4 @@ internal sealed class RuntimeInformation
|
||||
{
|
||||
Exit($"Terminated by parent task", stopAllTasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user