mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 16:06:08 +02:00
Add support for maps
This commit is contained in:
@@ -51,6 +51,16 @@ internal static class ExitMessages
|
||||
return $"List \"{list}\" not found";
|
||||
}
|
||||
|
||||
internal static string MapNotFound(string map)
|
||||
{
|
||||
return $"Map \"{map}\" not found";
|
||||
}
|
||||
|
||||
internal static string KeyNotFound(string key)
|
||||
{
|
||||
return $"Key \"{key}\" not found";
|
||||
}
|
||||
|
||||
internal static string InvalidIndex(string rawIndex)
|
||||
{
|
||||
return $"\"{rawIndex}\" is not a valid index";
|
||||
|
||||
@@ -17,6 +17,9 @@ internal class FunctionScope(int callerLine, Stack<string> arguments)
|
||||
/// <summary>Gets the local list table for this function invocation.</summary>
|
||||
public Dictionary<string, List<string>> Lists { get; } = [];
|
||||
|
||||
/// <summary>Gets the local map table for this function invocation.</summary>
|
||||
public Dictionary<string, Dictionary<string, string>> Maps { get; } = [];
|
||||
|
||||
/// <summary>Gets the local label table for this function invocation.</summary>
|
||||
public Dictionary<string, int> Labels { get; } = [];
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ internal sealed class RuntimeInformation : IStatementContext
|
||||
private static int internalTaskId = 0;
|
||||
private readonly Dictionary<string, string> topVariables = [];
|
||||
private readonly Dictionary<string, List<string>> topLists = [];
|
||||
private readonly Dictionary<string, Dictionary<string, string>> topMaps = [];
|
||||
|
||||
public Dictionary<string, string> GlobalVariables { get; set; } = [];
|
||||
public Dictionary<string, int> Functions { get; } = [];
|
||||
@@ -54,6 +55,7 @@ internal sealed class RuntimeInformation : IStatementContext
|
||||
|
||||
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, Dictionary<string, string>> Maps => FunctionCallStack.Count == 0 ? topMaps : FunctionCallStack.Peek().Maps;
|
||||
|
||||
public Dictionary<string, int> Labels { get => FunctionCallStack.Count == 0 ? field : FunctionCallStack.Peek().Labels; } = [];
|
||||
|
||||
@@ -173,6 +175,7 @@ internal sealed class RuntimeInformation : IStatementContext
|
||||
{
|
||||
topVariables.Clear();
|
||||
topLists.Clear();
|
||||
topMaps.Clear();
|
||||
Lines.Clear();
|
||||
GlobalVariables.Clear();
|
||||
Labels.Clear();
|
||||
|
||||
Reference in New Issue
Block a user