Ditch the IReadonlyCollection bullshit
This commit is contained in:
@@ -48,7 +48,7 @@ public class Lexer
|
||||
private string _src = string.Empty;
|
||||
private int _index;
|
||||
|
||||
public IReadOnlyCollection<Token> Lex(string src)
|
||||
public List<Token> Lex(string src)
|
||||
{
|
||||
_src = src;
|
||||
_index = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Nub.Lang.Frontend.Parsing;
|
||||
|
||||
public class BlockNode(IReadOnlyCollection<StatementNode> statements) : Node
|
||||
public class BlockNode(List<StatementNode> statements) : Node
|
||||
{
|
||||
public IReadOnlyCollection<StatementNode> Statements { get; } = statements;
|
||||
public List<StatementNode> Statements { get; } = statements;
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace Nub.Lang.Frontend.Parsing;
|
||||
|
||||
public class ExternFuncDefinitionNode(string name, IReadOnlyCollection<FuncParameter> parameters, Optional<Type> returnType) : DefinitionNode
|
||||
public class ExternFuncDefinitionNode(string name, List<FuncParameter> parameters, Optional<Type> returnType) : DefinitionNode
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public IReadOnlyCollection<FuncParameter> Parameters { get; } = parameters;
|
||||
public List<FuncParameter> Parameters { get; } = parameters;
|
||||
public Optional<Type> ReturnType { get; } = returnType;
|
||||
|
||||
public override string ToString() => $"{Name}({string.Join(", ", Parameters.Select(p => p.ToString()))}){(ReturnType.HasValue ? ": " + ReturnType.Value : "")}";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace Nub.Lang.Frontend.Parsing;
|
||||
|
||||
public class FuncCall(string name, IReadOnlyCollection<ExpressionNode> parameters)
|
||||
public class FuncCall(string name, List<ExpressionNode> parameters)
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public IReadOnlyCollection<ExpressionNode> Parameters { get; } = parameters;
|
||||
public List<ExpressionNode> Parameters { get; } = parameters;
|
||||
|
||||
public override string ToString() => $"{Name}()";
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace Nub.Lang.Frontend.Parsing;
|
||||
|
||||
public class LocalFuncDefinitionNode(string name, IReadOnlyCollection<FuncParameter> parameters, BlockNode body, Optional<Type> returnType) : DefinitionNode
|
||||
public class LocalFuncDefinitionNode(string name, List<FuncParameter> parameters, BlockNode body, Optional<Type> returnType) : DefinitionNode
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public IReadOnlyCollection<FuncParameter> Parameters { get; } = parameters;
|
||||
public List<FuncParameter> Parameters { get; } = parameters;
|
||||
public BlockNode Body { get; } = body;
|
||||
public Optional<Type> ReturnType { get; } = returnType;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace Nub.Lang.Frontend.Parsing;
|
||||
|
||||
public class ModuleNode(string path, IReadOnlyCollection<string> imports, IReadOnlyCollection<DefinitionNode> definitions) : Node
|
||||
public class ModuleNode(string path, List<string> imports, List<DefinitionNode> definitions) : Node
|
||||
{
|
||||
public string Path { get; } = path;
|
||||
public IReadOnlyCollection<string> Imports { get; } = imports;
|
||||
public IReadOnlyCollection<DefinitionNode> Definitions { get; } = definitions;
|
||||
public List<string> Imports { get; } = imports;
|
||||
public List<DefinitionNode> Definitions { get; } = definitions;
|
||||
}
|
||||
@@ -6,10 +6,10 @@ namespace Nub.Lang.Frontend.Parsing;
|
||||
|
||||
public class Parser
|
||||
{
|
||||
private IReadOnlyCollection<Token> _tokens = [];
|
||||
private List<Token> _tokens = [];
|
||||
private int _index;
|
||||
|
||||
public ModuleNode ParseModule(IReadOnlyCollection<Token> tokens, string path)
|
||||
public ModuleNode ParseModule(List<Token> tokens, string path)
|
||||
{
|
||||
_index = 0;
|
||||
_tokens = tokens;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Nub.Lang.Frontend.Parsing;
|
||||
|
||||
public class Syscall(IReadOnlyCollection<ExpressionNode> parameters)
|
||||
public class Syscall(List<ExpressionNode> parameters)
|
||||
{
|
||||
public IReadOnlyCollection<ExpressionNode> Parameters { get; } = parameters;
|
||||
public List<ExpressionNode> Parameters { get; } = parameters;
|
||||
}
|
||||
@@ -3,10 +3,10 @@ using Nub.Lang.Frontend.Parsing;
|
||||
|
||||
namespace Nub.Lang.Frontend.Typing;
|
||||
|
||||
public class Func(string name, IReadOnlyCollection<FuncParameter> parameters, Optional<BlockNode> body, Optional<Type> returnType)
|
||||
public class Func(string name, List<FuncParameter> parameters, Optional<BlockNode> body, Optional<Type> returnType)
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public IReadOnlyCollection<FuncParameter> Parameters { get; } = parameters;
|
||||
public List<FuncParameter> Parameters { get; } = parameters;
|
||||
public Optional<BlockNode> Body { get; } = body;
|
||||
public Optional<Type> ReturnType { get; } = returnType;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class ExpressionTyper
|
||||
private readonly List<GlobalVariableDefinitionNode> _variableDefinitions;
|
||||
private readonly Stack<Variable> _variables;
|
||||
|
||||
public ExpressionTyper(IReadOnlyCollection<DefinitionNode> definitions)
|
||||
public ExpressionTyper(List<DefinitionNode> definitions)
|
||||
{
|
||||
_variables = new Stack<Variable>();
|
||||
_functions = [];
|
||||
|
||||
Reference in New Issue
Block a user