This commit is contained in:
nub31
2025-07-06 22:38:00 +02:00
parent c79985bc05
commit 5658e0e25d
8 changed files with 503 additions and 713 deletions

View File

@@ -1,4 +1,3 @@
using System.Diagnostics;
using Common;
using NubLang.Diagnostics;
using NubLang.Syntax.Node;
@@ -14,8 +13,8 @@ public sealed class Binder
private readonly DefinitionTable _definitionTable;
// TODO: Implement proper variable tracking and scoping
private Dictionary<string, BoundNubType> _variables = new();
private BoundNubType? _functionReturnType;
private Dictionary<string, NubType> _variables = new();
private NubType? _functionReturnType;
public Binder(SyntaxTree syntaxTree, DefinitionTable definitionTable)
{
@@ -70,14 +69,14 @@ public sealed class Binder
foreach (var parameter in function.Parameters)
{
_variables[parameter.Name] = BindType(parameter.Type);
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, BindType(parameter.Type)));
_variables[parameter.Name] = parameter.Type;
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, parameter.Type));
}
functions.Add(new BoundTraitFuncImplNode(function.Tokens, function.Name, parameters, BindType(function.ReturnType), BindBlock(function.Body)));
functions.Add(new BoundTraitFuncImplNode(function.Tokens, function.Name, parameters, function.ReturnType, BindBlock(function.Body)));
}
return new BoundTraitImplNode(node.Tokens, node.Namespace, BindType(node.TraitType), BindType(node.ForType), functions);
return new BoundTraitImplNode(node.Tokens, node.Namespace, node.TraitType, node.ForType, functions);
}
private BoundTraitNode BindTraitDefinition(TraitNode node)
@@ -90,10 +89,10 @@ public sealed class Binder
foreach (var parameter in function.Parameters)
{
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, BindType(parameter.Type)));
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, parameter.Type));
}
functions.Add(new BoundTraitFuncNode(node.Tokens, function.Name, parameters, BindType(function.ReturnType)));
functions.Add(new BoundTraitFuncNode(node.Tokens, function.Name, parameters, function.ReturnType));
}
return new BoundTraitNode(node.Tokens, node.Namespace, node.Name, functions);
@@ -109,10 +108,10 @@ public sealed class Binder
if (field.Value.HasValue)
{
value = BindExpression(field.Value.Value, BindType(field.Type));
value = BindExpression(field.Value.Value, field.Type);
}
structFields.Add(new BoundStructFieldNode(field.Tokens, field.Index, field.Name, BindType(field.Type), value));
structFields.Add(new BoundStructFieldNode(field.Tokens, field.Index, field.Name, field.Type, value));
}
return new BoundStructNode(node.Tokens, node.Namespace, node.Name, structFields);
@@ -124,28 +123,28 @@ public sealed class Binder
foreach (var parameter in node.Parameters)
{
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, BindType(parameter.Type)));
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, parameter.Type));
}
return new BoundExternFuncNode(node.Tokens, node.Namespace, node.Name, node.CallName, parameters, BindType(node.ReturnType));
return new BoundExternFuncNode(node.Tokens, node.Namespace, node.Name, node.CallName, parameters, node.ReturnType);
}
private BoundLocalFuncNode BindLocalFuncDefinition(LocalFuncNode node)
{
_variables.Clear();
_functionReturnType = BindType(node.ReturnType);
_functionReturnType = node.ReturnType;
var parameters = new List<BoundFuncParameterNode>();
foreach (var parameter in node.Parameters)
{
_variables[parameter.Name] = BindType(parameter.Type);
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, BindType(parameter.Type)));
_variables[parameter.Name] = parameter.Type;
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, parameter.Type));
}
var body = BindBlock(node.Body);
return new BoundLocalFuncNode(node.Tokens, node.Namespace, node.Name, parameters, body, BindType(node.ReturnType), node.Exported);
return new BoundLocalFuncNode(node.Tokens, node.Namespace, node.Name, parameters, body, node.ReturnType, node.Exported);
}
private BoundBlock BindBlock(BlockNode node)
@@ -206,7 +205,7 @@ public sealed class Binder
);
}
return new BoundIfNode(statement.Tokens, BindExpression(statement.Condition, BoundNubPrimitiveType.Bool), BindBlock(statement.Body), elseStatement);
return new BoundIfNode(statement.Tokens, BindExpression(statement.Condition, new NubPrimitiveType(PrimitiveTypeKind.Bool)), BindBlock(statement.Body), elseStatement);
}
private BoundReturnNode BindReturn(ReturnNode statement)
@@ -228,11 +227,11 @@ public sealed class Binder
private BoundVariableDeclarationNode BindVariableDeclaration(VariableDeclarationNode statement)
{
BoundNubType? type = null;
NubType? type = null;
if (statement.ExplicitType.HasValue)
{
type = BindType(statement.ExplicitType.Value);
type = statement.ExplicitType.Value;
}
var assignment = Optional<BoundExpressionNode>.Empty();
@@ -255,10 +254,10 @@ public sealed class Binder
private BoundWhileNode BindWhile(WhileNode statement)
{
return new BoundWhileNode(statement.Tokens, BindExpression(statement.Condition, BoundNubPrimitiveType.Bool), BindBlock(statement.Body));
return new BoundWhileNode(statement.Tokens, BindExpression(statement.Condition, new NubPrimitiveType(PrimitiveTypeKind.Bool)), BindBlock(statement.Body));
}
private BoundExpressionNode BindExpression(ExpressionNode node, BoundNubType? expectedType = null)
private BoundExpressionNode BindExpression(ExpressionNode node, NubType? expectedType = null)
{
return node switch
{
@@ -281,7 +280,7 @@ public sealed class Binder
private BoundAddressOfNode BindAddressOf(AddressOfNode expression)
{
var inner = BindExpression(expression.Expression);
return new BoundAddressOfNode(expression.Tokens, new BoundNubPointerType(inner.Type), inner);
return new BoundAddressOfNode(expression.Tokens, new NubPointerType(inner.Type), inner);
}
private BoundAnonymousFuncNode BindAnonymousFunc(AnonymousFuncNode expression)
@@ -290,24 +289,24 @@ public sealed class Binder
foreach (var parameter in expression.Parameters)
{
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, BindType(parameter.Type)));
parameters.Add(new BoundFuncParameterNode(parameter.Tokens, parameter.Name, parameter.Type));
}
var body = BindBlock(expression.Body);
return new BoundAnonymousFuncNode(expression.Tokens, new BoundNubFuncType(BindType(expression.ReturnType), parameters.Select(x => x.Type).ToList()), parameters, body, BindType(expression.ReturnType));
return new BoundAnonymousFuncNode(expression.Tokens, new NubFuncType(expression.ReturnType, parameters.Select(x => x.Type).ToList()), parameters, body, expression.ReturnType);
}
private BoundArrayIndexAccessNode BindArrayIndexAccess(ArrayIndexAccessNode expression)
{
var boundArray = BindExpression(expression.Target);
var elementType = ((BoundNubArrayType)boundArray.Type).ElementType;
return new BoundArrayIndexAccessNode(expression.Tokens, elementType, boundArray, BindExpression(expression.Index, BoundNubPrimitiveType.U64));
var elementType = ((NubArrayType)boundArray.Type).ElementType;
return new BoundArrayIndexAccessNode(expression.Tokens, elementType, boundArray, BindExpression(expression.Index, new NubPrimitiveType(PrimitiveTypeKind.U64)));
}
private BoundArrayInitializerNode BindArrayInitializer(ArrayInitializerNode expression)
{
return new BoundArrayInitializerNode(expression.Tokens, new BoundNubArrayType(BindType(expression.ElementType)), BindExpression(expression.Capacity, BoundNubPrimitiveType.U64), BindType(expression.ElementType));
return new BoundArrayInitializerNode(expression.Tokens, new NubArrayType(expression.ElementType), BindExpression(expression.Capacity, new NubPrimitiveType(PrimitiveTypeKind.U64)), expression.ElementType);
}
private BoundBinaryExpressionNode BindBinaryExpression(BinaryExpressionNode expression)
@@ -320,7 +319,7 @@ public sealed class Binder
private BoundDereferenceNode BindDereference(DereferenceNode expression)
{
var boundExpression = BindExpression(expression.Expression);
var dereferencedType = ((BoundNubPointerType)boundExpression.Type).BaseType;
var dereferencedType = ((NubPointerType)boundExpression.Type).BaseType;
return new BoundDereferenceNode(expression.Tokens, dereferencedType, boundExpression);
}
@@ -328,7 +327,7 @@ public sealed class Binder
{
var boundExpression = BindExpression(expression.Expression);
var funcType = (BoundNubFuncType)boundExpression.Type;
var funcType = (NubFuncType)boundExpression.Type;
var parameters = new List<BoundExpressionNode>();
@@ -361,7 +360,7 @@ public sealed class Binder
var localFunc = localFuncs[0];
var type = new NubFuncType(localFunc.ReturnType, localFunc.Parameters.Select(p => p.Type).ToList());
return new BoundLocalFuncIdentNode(expression.Tokens, BindType(type), @namespace, expression.Name);
return new BoundLocalFuncIdentNode(expression.Tokens, type, @namespace, expression.Name);
}
var externFuncs = _definitionTable.LookupExternFunc(@namespace, expression.Name).ToArray();
@@ -375,7 +374,7 @@ public sealed class Binder
var externFunc = externFuncs[0];
var type = new NubFuncType(externFunc.ReturnType, externFunc.Parameters.Select(p => p.Type).ToList());
return new BoundExternFuncIdentNode(expression.Tokens, BindType(type), @namespace, expression.Name);
return new BoundExternFuncIdentNode(expression.Tokens, type, @namespace, expression.Name);
}
if (!expression.Namespace.HasValue)
@@ -386,14 +385,14 @@ public sealed class Binder
throw new BindException(Diagnostic.Error($"No identifier with then name {(expression.Namespace.HasValue ? $"{expression.Namespace.Value}::" : "")}{expression.Name} exists").Build());
}
private BoundLiteralNode BindLiteral(LiteralNode expression, BoundNubType? expectedType = null)
private BoundLiteralNode BindLiteral(LiteralNode expression, NubType? expectedType = null)
{
var type = expectedType ?? expression.Kind switch
{
LiteralKind.Integer => BoundNubPrimitiveType.I64,
LiteralKind.Float => BoundNubPrimitiveType.F64,
LiteralKind.String => new BoundNubStringType(),
LiteralKind.Bool => BoundNubPrimitiveType.Bool,
LiteralKind.Integer => new NubPrimitiveType(PrimitiveTypeKind.I64),
LiteralKind.Float => new NubPrimitiveType(PrimitiveTypeKind.F64),
LiteralKind.String => new NubStringType(),
LiteralKind.Bool => new NubPrimitiveType(PrimitiveTypeKind.Bool),
_ => throw new ArgumentOutOfRangeException()
};
@@ -404,7 +403,7 @@ public sealed class Binder
{
var boundExpression = BindExpression(expression.Target);
var traitFuncImpls = _definitionTable.LookupTraitFuncImpl(UnbindType(boundExpression.Type), expression.Member).ToArray();
var traitFuncImpls = _definitionTable.LookupTraitFuncImpl(boundExpression.Type, expression.Member).ToArray();
if (traitFuncImpls.Length > 0)
{
if (traitFuncImpls.Length > 1)
@@ -414,18 +413,18 @@ public sealed class Binder
var impl = traitFuncImpls[0];
var type = new BoundNubFuncType(BindType(impl.ReturnType), impl.Parameters.Select(p => BindType(p.Type)).ToList());
var type = new NubFuncType(impl.ReturnType, impl.Parameters.Select(p => p.Type).ToList());
return new BoundTraitImplFuncAccessNode(expression.Tokens, type, boundExpression, expression.Member);
}
if (boundExpression.Type is BoundNubTraitType traitType)
if (boundExpression.Type is NubCustomType customType)
{
var traits = _definitionTable.LookupTrait(traitType.Namespace, traitType.Name).ToArray();
var traits = _definitionTable.LookupTrait(customType.Namespace, customType.Name).ToArray();
if (traits.Length > 0)
{
if (traits.Length > 1)
{
throw new BindException(Diagnostic.Error($"Trait {traitType.Namespace}::{traitType.Name} has multiple definitions").Build());
throw new BindException(Diagnostic.Error($"Trait {customType.Namespace}::{customType.Name} has multiple definitions").Build());
}
var trait = traits[0];
@@ -440,20 +439,17 @@ public sealed class Binder
var traitFunc = traitFuncs[0];
var type = new BoundNubFuncType(BindType(traitFunc.ReturnType), traitFunc.Parameters.Select(p => BindType(p.Type)).ToList());
return new BoundTraitFuncAccessNode(expression.Tokens, type, traitType, boundExpression, expression.Member);
var type = new NubFuncType(traitFunc.ReturnType, traitFunc.Parameters.Select(p => p.Type).ToList());
return new BoundTraitFuncAccessNode(expression.Tokens, type, customType, boundExpression, expression.Member);
}
}
}
if (boundExpression.Type is BoundNubStructType structType)
{
var structs = _definitionTable.LookupStruct(structType.Namespace, structType.Name).ToArray();
var structs = _definitionTable.LookupStruct(customType.Namespace, customType.Name).ToArray();
if (structs.Length > 0)
{
if (structs.Length > 1)
{
throw new BindException(Diagnostic.Error($"Struct {structType.Namespace}::{structType.Name} has multiple definitions").Build());
throw new BindException(Diagnostic.Error($"Struct {customType.Namespace}::{customType.Name} has multiple definitions").Build());
}
var @struct = structs[0];
@@ -468,7 +464,7 @@ public sealed class Binder
var field = fields[0];
return new BoundStructFieldAccessNode(expression.Tokens, BindType(field.Type), structType, boundExpression, expression.Member);
return new BoundStructFieldAccessNode(expression.Tokens, field.Type, customType, boundExpression, expression.Member);
}
}
}
@@ -513,23 +509,23 @@ public sealed class Binder
throw new BindException(Diagnostic.Error($"Struct {@struct.Namespace}::{@struct.Name} has multiple fields with the name {field}").Build());
}
initializers[field] = BindExpression(initializer, BindType(fields[0].Type));
initializers[field] = BindExpression(initializer, fields[0].Type);
}
return new BoundStructInitializerNode(expression.Tokens, BindType(structType), new BoundNubStructType(@struct.Namespace, @struct.Name), initializers);
return new BoundStructInitializerNode(expression.Tokens, structType, new NubCustomType(@struct.Namespace, @struct.Name), initializers);
}
private BoundUnaryExpressionNode BindUnaryExpression(Node_UnaryExpressionNode expression)
{
var boundOperand = BindExpression(expression.Operand);
BoundNubType? type = null;
NubType? type = null;
switch (expression.Operator)
{
case UnaryExpressionOperator.Negate:
{
boundOperand = BindExpression(expression.Operand, BoundNubPrimitiveType.I64);
boundOperand = BindExpression(expression.Operand, new NubPrimitiveType(PrimitiveTypeKind.I64));
if (boundOperand.Type.IsNumber)
{
@@ -540,9 +536,9 @@ public sealed class Binder
}
case UnaryExpressionOperator.Invert:
{
boundOperand = BindExpression(expression.Operand, BoundNubPrimitiveType.Bool);
boundOperand = BindExpression(expression.Operand, new NubPrimitiveType(PrimitiveTypeKind.Bool));
type = new BoundNubPrimitiveType(PrimitiveTypeKind.Bool);
type = new NubPrimitiveType(PrimitiveTypeKind.Bool);
break;
}
}
@@ -554,82 +550,6 @@ public sealed class Binder
return new BoundUnaryExpressionNode(expression.Tokens, type, expression.Operator, boundOperand);
}
private BoundNubType BindType(NubType type)
{
switch (type)
{
case NubCustomType customType:
{
var structs = _definitionTable.LookupStruct(customType.Namespace, customType.Name).ToArray();
if (structs.Length > 1)
{
throw new BindException(Diagnostic.Error($"Struct {type} has multiple definitions").Build());
}
var traits = _definitionTable.LookupTrait(customType.Namespace, customType.Name).ToArray();
if (traits.Length > 1)
{
throw new BindException(Diagnostic.Error($"Trait {type} has multiple definitions").Build());
}
if (structs.Length == 0 && traits.Length == 0)
{
throw new BindException(Diagnostic.Error($"Failed to resolve type {type} to a struct or trait").Build());
}
if (structs.Length > 0 && traits.Length > 0)
{
throw new BindException(Diagnostic.Error($"Unable to determine if type {type} is a struct or trait").WithHelp($"Make {type} is not defined as bot a struct and trait").Build());
}
if (structs.Length == 1)
{
return new BoundNubStructType(customType.Namespace, customType.Name);
}
if (traits.Length == 1)
{
return new BoundNubTraitType(customType.Namespace, customType.Name);
}
throw new UnreachableException();
}
case NubArrayType arrayType:
return new BoundNubArrayType(BindType(arrayType.ElementType));
case NubCStringType:
return new BoundNubCStringType();
case NubStringType:
return new BoundNubStringType();
case NubFuncType funcType:
return new BoundNubFuncType(BindType(funcType.ReturnType), funcType.Parameters.Select(BindType).ToList());
case NubPointerType pointerType:
return new BoundNubPointerType(BindType(pointerType.BaseType));
case NubPrimitiveType primitiveType:
return new BoundNubPrimitiveType(primitiveType.Kind);
case NubVoidType:
return new BoundNubVoidType();
default:
throw new ArgumentOutOfRangeException(nameof(type));
}
}
private NubType UnbindType(BoundNubType type)
{
return type switch
{
BoundNubArrayType arrayType => new NubArrayType(UnbindType(arrayType.ElementType)),
BoundNubCStringType => new NubCStringType(),
BoundNubStringType => new NubStringType(),
BoundNubStructType structType => new NubCustomType(structType.Namespace, structType.Name),
BoundNubTraitType traitType => new NubCustomType(traitType.Namespace, traitType.Name),
BoundNubFuncType funcType => new NubFuncType(UnbindType(funcType.ReturnType), funcType.Parameters.Select(UnbindType).ToList()),
BoundNubPointerType pointerType => new NubPointerType(UnbindType(pointerType.BaseType)),
BoundNubPrimitiveType primitiveType => new NubPrimitiveType(primitiveType.Kind),
BoundNubVoidType => new NubVoidType(),
_ => throw new ArgumentOutOfRangeException(nameof(type))
};
}
}
public class BindException : Exception

View File

@@ -4,7 +4,7 @@ using NubLang.Syntax.Tokenization;
namespace NubLang.Syntax.Node;
public record FuncParameterNode(IEnumerable<Token> Tokens, string Name, NubType Type) : DefinitionNode(Tokens);
public record BoundFuncParameterNode(IEnumerable<Token> Tokens, string Name, BoundNubType Type) : DefinitionNode(Tokens);
public record BoundFuncParameterNode(IEnumerable<Token> Tokens, string Name, NubType Type) : DefinitionNode(Tokens);
public abstract record TopLevelNode(IEnumerable<Token> Tokens, string Namespace) : Node(Tokens);
public abstract record BoundTopLevelNode(IEnumerable<Token> Tokens, string Namespace) : BoundNode(Tokens);
@@ -13,25 +13,25 @@ public abstract record DefinitionNode(IEnumerable<Token> Tokens) : Node(Tokens);
public abstract record BoundDefinitionNode(IEnumerable<Token> Tokens) : BoundNode(Tokens);
public record LocalFuncNode(IEnumerable<Token> Tokens, string Namespace, string Name, List<FuncParameterNode> Parameters, BlockNode Body, NubType ReturnType, bool Exported) : TopLevelNode(Tokens, Namespace);
public record BoundLocalFuncNode(IEnumerable<Token> Tokens, string Namespace, string Name, List<BoundFuncParameterNode> Parameters, BoundBlock Body, BoundNubType ReturnType, bool Exported) : BoundTopLevelNode(Tokens, Namespace);
public record BoundLocalFuncNode(IEnumerable<Token> Tokens, string Namespace, string Name, List<BoundFuncParameterNode> Parameters, BoundBlock Body, NubType ReturnType, bool Exported) : BoundTopLevelNode(Tokens, Namespace);
public record ExternFuncNode(IEnumerable<Token> Tokens, string Namespace, string Name, string CallName, List<FuncParameterNode> Parameters, NubType ReturnType) : TopLevelNode(Tokens, Namespace);
public record BoundExternFuncNode(IEnumerable<Token> Tokens, string Namespace, string Name, string CallName, List<BoundFuncParameterNode> Parameters, BoundNubType ReturnType) : BoundTopLevelNode(Tokens, Namespace);
public record BoundExternFuncNode(IEnumerable<Token> Tokens, string Namespace, string Name, string CallName, List<BoundFuncParameterNode> Parameters, NubType ReturnType) : BoundTopLevelNode(Tokens, Namespace);
public record StructFieldNode(IEnumerable<Token> Tokens, int Index, string Name, NubType Type, Optional<ExpressionNode> Value) : DefinitionNode(Tokens);
public record StructNode(IEnumerable<Token> Tokens, string Namespace, string Name, List<StructFieldNode> Fields) : TopLevelNode(Tokens, Namespace);
public record BoundStructFieldNode(IEnumerable<Token> Tokens, int Index, string Name, BoundNubType Type, Optional<BoundExpressionNode> Value) : BoundDefinitionNode(Tokens);
public record BoundStructFieldNode(IEnumerable<Token> Tokens, int Index, string Name, NubType Type, Optional<BoundExpressionNode> Value) : BoundDefinitionNode(Tokens);
public record BoundStructNode(IEnumerable<Token> Tokens, string Namespace, string Name, List<BoundStructFieldNode> Fields) : BoundTopLevelNode(Tokens, Namespace);
public record TraitFuncNode(IEnumerable<Token> Tokens, string Name, List<FuncParameterNode> Parameters, NubType ReturnType) : DefinitionNode(Tokens);
public record TraitNode(IEnumerable<Token> Tokens, string Namespace, string Name, List<TraitFuncNode> Functions) : TopLevelNode(Tokens, Namespace);
public record BoundTraitFuncNode(IEnumerable<Token> Tokens, string Name, List<BoundFuncParameterNode> Parameters, BoundNubType ReturnType) : BoundDefinitionNode(Tokens);
public record BoundTraitFuncNode(IEnumerable<Token> Tokens, string Name, List<BoundFuncParameterNode> Parameters, NubType ReturnType) : BoundDefinitionNode(Tokens);
public record BoundTraitNode(IEnumerable<Token> Tokens, string Namespace, string Name, List<BoundTraitFuncNode> Functions) : BoundTopLevelNode(Tokens, Namespace);
public record TraitFuncImplNode(IEnumerable<Token> Tokens, string Name, List<FuncParameterNode> Parameters, NubType ReturnType, BlockNode Body) : DefinitionNode(Tokens);
public record TraitImplNode(IEnumerable<Token> Tokens, string Namespace, NubType TraitType, NubType ForType, List<TraitFuncImplNode> Functions) : TopLevelNode(Tokens, Namespace);
public record BoundTraitFuncImplNode(IEnumerable<Token> Tokens, string Name, List<BoundFuncParameterNode> Parameters, BoundNubType ReturnType, BoundBlock Body) : BoundDefinitionNode(Tokens);
public record BoundTraitImplNode(IEnumerable<Token> Tokens, string Namespace, BoundNubType TraitType, BoundNubType ForType, List<BoundTraitFuncImplNode> Functions) : BoundTopLevelNode(Tokens, Namespace);
public record BoundTraitFuncImplNode(IEnumerable<Token> Tokens, string Name, List<BoundFuncParameterNode> Parameters, NubType ReturnType, BoundBlock Body) : BoundDefinitionNode(Tokens);
public record BoundTraitImplNode(IEnumerable<Token> Tokens, string Namespace, NubType TraitType, NubType ForType, List<BoundTraitFuncImplNode> Functions) : BoundTopLevelNode(Tokens, Namespace);

View File

@@ -24,44 +24,44 @@ public enum BinaryExpressionOperator
}
public abstract record ExpressionNode(IEnumerable<Token> Tokens) : Node(Tokens);
public abstract record BoundExpressionNode(IEnumerable<Token> Tokens, BoundNubType Type) : BoundNode(Tokens);
public abstract record BoundExpressionNode(IEnumerable<Token> Tokens, NubType Type) : BoundNode(Tokens);
public record BinaryExpressionNode(IEnumerable<Token> Tokens, ExpressionNode Left, BinaryExpressionOperator Operator, ExpressionNode Right) : ExpressionNode(Tokens);
public record BoundBinaryExpressionNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundExpressionNode Left, BinaryExpressionOperator Operator, BoundExpressionNode Right) : BoundExpressionNode(Tokens, Type);
public record BoundBinaryExpressionNode(IEnumerable<Token> Tokens, NubType Type, BoundExpressionNode Left, BinaryExpressionOperator Operator, BoundExpressionNode Right) : BoundExpressionNode(Tokens, Type);
public record UnaryExpressionNode(IEnumerable<Token> Tokens, UnaryExpressionOperator Operator, ExpressionNode Operand) : ExpressionNode(Tokens);
public record BoundUnaryExpressionNode(IEnumerable<Token> Tokens, BoundNubType Type, UnaryExpressionOperator Operator, BoundExpressionNode Operand) : BoundExpressionNode(Tokens, Type);
public record BoundUnaryExpressionNode(IEnumerable<Token> Tokens, NubType Type, UnaryExpressionOperator Operator, BoundExpressionNode Operand) : BoundExpressionNode(Tokens, Type);
public record FuncCallNode(IEnumerable<Token> Tokens, ExpressionNode Expression, List<ExpressionNode> Parameters) : ExpressionNode(Tokens);
public record BoundFuncCallNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundExpressionNode Expression, List<BoundExpressionNode> Parameters) : BoundExpressionNode(Tokens, Type);
public record BoundFuncCallNode(IEnumerable<Token> Tokens, NubType Type, BoundExpressionNode Expression, List<BoundExpressionNode> Parameters) : BoundExpressionNode(Tokens, Type);
public record IdentifierNode(IEnumerable<Token> Tokens, Optional<string> Namespace, string Name) : ExpressionNode(Tokens);
public record BoundVariableIdentNode(IEnumerable<Token> Tokens, BoundNubType Type, string Name) : BoundExpressionNode(Tokens, Type);
public record BoundLocalFuncIdentNode(IEnumerable<Token> Tokens, BoundNubType Type, string Namespace, string Name) : BoundExpressionNode(Tokens, Type);
public record BoundExternFuncIdentNode(IEnumerable<Token> Tokens, BoundNubType Type, string Namespace, string Name) : BoundExpressionNode(Tokens, Type);
public record BoundVariableIdentNode(IEnumerable<Token> Tokens, NubType Type, string Name) : BoundExpressionNode(Tokens, Type);
public record BoundLocalFuncIdentNode(IEnumerable<Token> Tokens, NubType Type, string Namespace, string Name) : BoundExpressionNode(Tokens, Type);
public record BoundExternFuncIdentNode(IEnumerable<Token> Tokens, NubType Type, string Namespace, string Name) : BoundExpressionNode(Tokens, Type);
public record ArrayInitializerNode(IEnumerable<Token> Tokens, ExpressionNode Capacity, NubType ElementType) : ExpressionNode(Tokens);
public record BoundArrayInitializerNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundExpressionNode Capacity, BoundNubType ElementType) : BoundExpressionNode(Tokens, Type);
public record BoundArrayInitializerNode(IEnumerable<Token> Tokens, NubType Type, BoundExpressionNode Capacity, NubType ElementType) : BoundExpressionNode(Tokens, Type);
public record ArrayIndexAccessNode(IEnumerable<Token> Tokens, ExpressionNode Target, ExpressionNode Index) : ExpressionNode(Tokens);
public record BoundArrayIndexAccessNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundExpressionNode Target, BoundExpressionNode Index) : BoundExpressionNode(Tokens, Type);
public record BoundArrayIndexAccessNode(IEnumerable<Token> Tokens, NubType Type, BoundExpressionNode Target, BoundExpressionNode Index) : BoundExpressionNode(Tokens, Type);
public record AnonymousFuncNode(IEnumerable<Token> Tokens, List<FuncParameterNode> Parameters, BlockNode Body, NubType ReturnType) : ExpressionNode(Tokens);
public record BoundAnonymousFuncNode(IEnumerable<Token> Tokens, BoundNubType Type, List<BoundFuncParameterNode> Parameters, BoundBlock Body, BoundNubType ReturnType) : BoundExpressionNode(Tokens, Type);
public record BoundAnonymousFuncNode(IEnumerable<Token> Tokens, NubType Type, List<BoundFuncParameterNode> Parameters, BoundBlock Body, NubType ReturnType) : BoundExpressionNode(Tokens, Type);
public record AddressOfNode(IEnumerable<Token> Tokens, ExpressionNode Expression) : ExpressionNode(Tokens);
public record BoundAddressOfNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundExpressionNode Expression) : BoundExpressionNode(Tokens, Type);
public record BoundAddressOfNode(IEnumerable<Token> Tokens, NubType Type, BoundExpressionNode Expression) : BoundExpressionNode(Tokens, Type);
public record LiteralNode(IEnumerable<Token> Tokens, string Literal, LiteralKind Kind) : ExpressionNode(Tokens);
public record BoundLiteralNode(IEnumerable<Token> Tokens, BoundNubType Type, string Literal, LiteralKind Kind) : BoundExpressionNode(Tokens, Type);
public record BoundLiteralNode(IEnumerable<Token> Tokens, NubType Type, string Literal, LiteralKind Kind) : BoundExpressionNode(Tokens, Type);
public record MemberAccessNode(IEnumerable<Token> Tokens, ExpressionNode Target, string Member) : ExpressionNode(Tokens);
public record BoundStructFieldAccessNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundNubStructType StructType, BoundExpressionNode Target, string Field) : BoundExpressionNode(Tokens, Type);
public record BoundTraitImplFuncAccessNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundExpressionNode Target, string FuncName) : BoundExpressionNode(Tokens, Type);
public record BoundTraitFuncAccessNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundNubTraitType TraitType, BoundExpressionNode Target, string FuncName) : BoundExpressionNode(Tokens, Type);
public record BoundStructFieldAccessNode(IEnumerable<Token> Tokens, NubType Type, NubCustomType StructType, BoundExpressionNode Target, string Field) : BoundExpressionNode(Tokens, Type);
public record BoundTraitImplFuncAccessNode(IEnumerable<Token> Tokens, NubType Type, BoundExpressionNode Target, string FuncName) : BoundExpressionNode(Tokens, Type);
public record BoundTraitFuncAccessNode(IEnumerable<Token> Tokens, NubType Type, NubCustomType TraitType, BoundExpressionNode Target, string FuncName) : BoundExpressionNode(Tokens, Type);
public record StructInitializerNode(IEnumerable<Token> Tokens, NubType StructType, Dictionary<string, ExpressionNode> Initializers) : ExpressionNode(Tokens);
public record BoundStructInitializerNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundNubStructType StructType, Dictionary<string, BoundExpressionNode> Initializers) : BoundExpressionNode(Tokens, Type);
public record BoundStructInitializerNode(IEnumerable<Token> Tokens, NubType Type, NubCustomType StructType, Dictionary<string, BoundExpressionNode> Initializers) : BoundExpressionNode(Tokens, Type);
public record DereferenceNode(IEnumerable<Token> Tokens, ExpressionNode Expression) : ExpressionNode(Tokens);
public record BoundDereferenceNode(IEnumerable<Token> Tokens, BoundNubType Type, BoundExpressionNode Expression) : BoundExpressionNode(Tokens, Type);
public record BoundDereferenceNode(IEnumerable<Token> Tokens, NubType Type, BoundExpressionNode Expression) : BoundExpressionNode(Tokens, Type);

View File

@@ -20,7 +20,7 @@ public record IfNode(IEnumerable<Token> Tokens, ExpressionNode Condition, BlockN
public record BoundIfNode(IEnumerable<Token> Tokens, BoundExpressionNode Condition, BoundBlock Body, Optional<Variant<BoundIfNode, BoundBlock>> Else) : BoundStatementNode(Tokens);
public record VariableDeclarationNode(IEnumerable<Token> Tokens, string Name, Optional<NubType> ExplicitType, Optional<ExpressionNode> Assignment) : StatementNode(Tokens);
public record BoundVariableDeclarationNode(IEnumerable<Token> Tokens, string Name, Optional<BoundExpressionNode> Assignment, BoundNubType Type) : BoundStatementNode(Tokens);
public record BoundVariableDeclarationNode(IEnumerable<Token> Tokens, string Name, Optional<BoundExpressionNode> Assignment, NubType Type) : BoundStatementNode(Tokens);
public record ContinueNode(IEnumerable<Token> Tokens) : StatementNode(Tokens);
public record BoundContinueNode(IEnumerable<Token> Tokens) : BoundStatementNode(Tokens);