...
This commit is contained in:
@@ -307,7 +307,11 @@ public abstract class ExpressionNode(List<Token> tokens, NubType type) : Node(to
|
||||
public NubType Type { get; } = type;
|
||||
}
|
||||
|
||||
public class StringLiteralNode(List<Token> tokens, string value) : ExpressionNode(tokens, new NubStringType())
|
||||
public abstract class LValue(List<Token> tokens, NubType type) : ExpressionNode(tokens, type);
|
||||
|
||||
public abstract class RValue(List<Token> tokens, NubType type) : ExpressionNode(tokens, type);
|
||||
|
||||
public class StringLiteralNode(List<Token> tokens, string value) : RValue(tokens, new NubStringType())
|
||||
{
|
||||
public string Value { get; } = value;
|
||||
|
||||
@@ -317,7 +321,7 @@ public class StringLiteralNode(List<Token> tokens, string value) : ExpressionNod
|
||||
}
|
||||
}
|
||||
|
||||
public class CStringLiteralNode(List<Token> tokens, string value) : ExpressionNode(tokens, new NubPointerType(new NubIntType(true, 8)))
|
||||
public class CStringLiteralNode(List<Token> tokens, string value) : RValue(tokens, new NubPointerType(new NubIntType(true, 8)))
|
||||
{
|
||||
public string Value { get; } = value;
|
||||
|
||||
@@ -327,7 +331,7 @@ public class CStringLiteralNode(List<Token> tokens, string value) : ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class I8LiteralNode(List<Token> tokens, sbyte value) : ExpressionNode(tokens, new NubIntType(true, 8))
|
||||
public class I8LiteralNode(List<Token> tokens, sbyte value) : RValue(tokens, new NubIntType(true, 8))
|
||||
{
|
||||
public sbyte Value { get; } = value;
|
||||
|
||||
@@ -337,7 +341,7 @@ public class I8LiteralNode(List<Token> tokens, sbyte value) : ExpressionNode(tok
|
||||
}
|
||||
}
|
||||
|
||||
public class I16LiteralNode(List<Token> tokens, short value) : ExpressionNode(tokens, new NubIntType(true, 16))
|
||||
public class I16LiteralNode(List<Token> tokens, short value) : RValue(tokens, new NubIntType(true, 16))
|
||||
{
|
||||
public short Value { get; } = value;
|
||||
|
||||
@@ -347,7 +351,7 @@ public class I16LiteralNode(List<Token> tokens, short value) : ExpressionNode(to
|
||||
}
|
||||
}
|
||||
|
||||
public class I32LiteralNode(List<Token> tokens, int value) : ExpressionNode(tokens, new NubIntType(true, 32))
|
||||
public class I32LiteralNode(List<Token> tokens, int value) : RValue(tokens, new NubIntType(true, 32))
|
||||
{
|
||||
public int Value { get; } = value;
|
||||
|
||||
@@ -357,7 +361,7 @@ public class I32LiteralNode(List<Token> tokens, int value) : ExpressionNode(toke
|
||||
}
|
||||
}
|
||||
|
||||
public class I64LiteralNode(List<Token> tokens, long value) : ExpressionNode(tokens, new NubIntType(true, 64))
|
||||
public class I64LiteralNode(List<Token> tokens, long value) : RValue(tokens, new NubIntType(true, 64))
|
||||
{
|
||||
public long Value { get; } = value;
|
||||
|
||||
@@ -367,7 +371,7 @@ public class I64LiteralNode(List<Token> tokens, long value) : ExpressionNode(tok
|
||||
}
|
||||
}
|
||||
|
||||
public class U8LiteralNode(List<Token> tokens, byte value) : ExpressionNode(tokens, new NubIntType(false, 8))
|
||||
public class U8LiteralNode(List<Token> tokens, byte value) : RValue(tokens, new NubIntType(false, 8))
|
||||
{
|
||||
public byte Value { get; } = value;
|
||||
|
||||
@@ -377,7 +381,7 @@ public class U8LiteralNode(List<Token> tokens, byte value) : ExpressionNode(toke
|
||||
}
|
||||
}
|
||||
|
||||
public class U16LiteralNode(List<Token> tokens, ushort value) : ExpressionNode(tokens, new NubIntType(false, 16))
|
||||
public class U16LiteralNode(List<Token> tokens, ushort value) : RValue(tokens, new NubIntType(false, 16))
|
||||
{
|
||||
public ushort Value { get; } = value;
|
||||
|
||||
@@ -387,7 +391,7 @@ public class U16LiteralNode(List<Token> tokens, ushort value) : ExpressionNode(t
|
||||
}
|
||||
}
|
||||
|
||||
public class U32LiteralNode(List<Token> tokens, uint value) : ExpressionNode(tokens, new NubIntType(false, 32))
|
||||
public class U32LiteralNode(List<Token> tokens, uint value) : RValue(tokens, new NubIntType(false, 32))
|
||||
{
|
||||
public uint Value { get; } = value;
|
||||
|
||||
@@ -397,7 +401,7 @@ public class U32LiteralNode(List<Token> tokens, uint value) : ExpressionNode(tok
|
||||
}
|
||||
}
|
||||
|
||||
public class U64LiteralNode(List<Token> tokens, ulong value) : ExpressionNode(tokens, new NubIntType(false, 64))
|
||||
public class U64LiteralNode(List<Token> tokens, ulong value) : RValue(tokens, new NubIntType(false, 64))
|
||||
{
|
||||
public ulong Value { get; } = value;
|
||||
|
||||
@@ -407,7 +411,7 @@ public class U64LiteralNode(List<Token> tokens, ulong value) : ExpressionNode(to
|
||||
}
|
||||
}
|
||||
|
||||
public class Float32LiteralNode(List<Token> tokens, float value) : ExpressionNode(tokens, new NubFloatType(32))
|
||||
public class Float32LiteralNode(List<Token> tokens, float value) : RValue(tokens, new NubFloatType(32))
|
||||
{
|
||||
public float Value { get; } = value;
|
||||
|
||||
@@ -417,7 +421,7 @@ public class Float32LiteralNode(List<Token> tokens, float value) : ExpressionNod
|
||||
}
|
||||
}
|
||||
|
||||
public class Float64LiteralNode(List<Token> tokens, double value) : ExpressionNode(tokens, new NubFloatType(64))
|
||||
public class Float64LiteralNode(List<Token> tokens, double value) : RValue(tokens, new NubFloatType(64))
|
||||
{
|
||||
public double Value { get; } = value;
|
||||
|
||||
@@ -427,7 +431,7 @@ public class Float64LiteralNode(List<Token> tokens, double value) : ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class BoolLiteralNode(List<Token> tokens, bool value) : ExpressionNode(tokens, new NubBoolType())
|
||||
public class BoolLiteralNode(List<Token> tokens, bool value) : RValue(tokens, new NubBoolType())
|
||||
{
|
||||
public bool Value { get; } = value;
|
||||
|
||||
@@ -437,7 +441,7 @@ public class BoolLiteralNode(List<Token> tokens, bool value) : ExpressionNode(to
|
||||
}
|
||||
}
|
||||
|
||||
public class BinaryExpressionNode(List<Token> tokens, NubType type, ExpressionNode left, BinaryOperator @operator, ExpressionNode right) : ExpressionNode(tokens, type)
|
||||
public class BinaryExpressionNode(List<Token> tokens, NubType type, ExpressionNode left, BinaryOperator @operator, ExpressionNode right) : RValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Left { get; } = left;
|
||||
public BinaryOperator Operator { get; } = @operator;
|
||||
@@ -450,7 +454,7 @@ public class BinaryExpressionNode(List<Token> tokens, NubType type, ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class UnaryExpressionNode(List<Token> tokens, NubType type, UnaryOperator @operator, ExpressionNode operand) : ExpressionNode(tokens, type)
|
||||
public class UnaryExpressionNode(List<Token> tokens, NubType type, UnaryOperator @operator, ExpressionNode operand) : RValue(tokens, type)
|
||||
{
|
||||
public UnaryOperator Operator { get; } = @operator;
|
||||
public ExpressionNode Operand { get; } = operand;
|
||||
@@ -461,7 +465,7 @@ public class UnaryExpressionNode(List<Token> tokens, NubType type, UnaryOperator
|
||||
}
|
||||
}
|
||||
|
||||
public class FuncCallNode(List<Token> tokens, NubType type, ExpressionNode expression, List<ExpressionNode> parameters) : ExpressionNode(tokens, type)
|
||||
public class FuncCallNode(List<Token> tokens, NubType type, ExpressionNode expression, List<ExpressionNode> parameters) : RValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Expression { get; } = expression;
|
||||
public List<ExpressionNode> Parameters { get; } = parameters;
|
||||
@@ -476,7 +480,7 @@ public class FuncCallNode(List<Token> tokens, NubType type, ExpressionNode expre
|
||||
}
|
||||
}
|
||||
|
||||
public class VariableIdentifierNode(List<Token> tokens, NubType type, IdentifierToken nameToken) : ExpressionNode(tokens, type)
|
||||
public class VariableIdentifierNode(List<Token> tokens, NubType type, IdentifierToken nameToken) : LValue(tokens, type)
|
||||
{
|
||||
public IdentifierToken NameToken { get; } = nameToken;
|
||||
|
||||
@@ -486,7 +490,7 @@ public class VariableIdentifierNode(List<Token> tokens, NubType type, Identifier
|
||||
}
|
||||
}
|
||||
|
||||
public class FuncIdentifierNode(List<Token> tokens, NubType type, IdentifierToken moduleToken, IdentifierToken nameToken, StringLiteralToken? externSymbolToken) : ExpressionNode(tokens, type)
|
||||
public class FuncIdentifierNode(List<Token> tokens, NubType type, IdentifierToken moduleToken, IdentifierToken nameToken, StringLiteralToken? externSymbolToken) : RValue(tokens, type)
|
||||
{
|
||||
public IdentifierToken ModuleToken { get; } = moduleToken;
|
||||
public IdentifierToken NameToken { get; } = nameToken;
|
||||
@@ -498,27 +502,7 @@ public class FuncIdentifierNode(List<Token> tokens, NubType type, IdentifierToke
|
||||
}
|
||||
}
|
||||
|
||||
public class ArrayInitializerNode(List<Token> tokens, NubType type, List<ExpressionNode> values) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public List<ExpressionNode> Values { get; } = values;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
return Values;
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstArrayInitializerNode(List<Token> tokens, NubType type, List<ExpressionNode> values) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public List<ExpressionNode> Values { get; } = values;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
return Values;
|
||||
}
|
||||
}
|
||||
|
||||
public class ArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : ExpressionNode(tokens, type)
|
||||
public class ArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : LValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Index { get; } = index;
|
||||
@@ -530,7 +514,7 @@ public class ArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : ExpressionNode(tokens, type)
|
||||
public class ConstArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : LValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Index { get; } = index;
|
||||
@@ -542,7 +526,7 @@ public class ConstArrayIndexAccessNode(List<Token> tokens, NubType type, Express
|
||||
}
|
||||
}
|
||||
|
||||
public class SliceIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : ExpressionNode(tokens, type)
|
||||
public class SliceIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : LValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Index { get; } = index;
|
||||
@@ -554,7 +538,7 @@ public class SliceIndexAccessNode(List<Token> tokens, NubType type, ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class AddressOfNode(List<Token> tokens, NubType type, ExpressionNode target) : ExpressionNode(tokens, type)
|
||||
public class AddressOfNode(List<Token> tokens, NubType type, ExpressionNode target) : RValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
|
||||
@@ -564,7 +548,7 @@ public class AddressOfNode(List<Token> tokens, NubType type, ExpressionNode targ
|
||||
}
|
||||
}
|
||||
|
||||
public class StructFieldAccessNode(List<Token> tokens, NubType type, ExpressionNode target, IdentifierToken fieldToken) : ExpressionNode(tokens, type)
|
||||
public class StructFieldAccessNode(List<Token> tokens, NubType type, ExpressionNode target, IdentifierToken fieldToken) : LValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public IdentifierToken FieldToken { get; } = fieldToken;
|
||||
@@ -575,7 +559,37 @@ public class StructFieldAccessNode(List<Token> tokens, NubType type, ExpressionN
|
||||
}
|
||||
}
|
||||
|
||||
public class StructInitializerNode(List<Token> tokens, NubType type, Dictionary<IdentifierToken, ExpressionNode> initializers) : ExpressionNode(tokens, type)
|
||||
public class DereferenceNode(List<Token> tokens, NubType type, ExpressionNode target) : LValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
yield return Target;
|
||||
}
|
||||
}
|
||||
|
||||
public class SizeNode(List<Token> tokens, NubType targetType) : RValue(tokens, new NubIntType(false, 64))
|
||||
{
|
||||
public NubType TargetType { get; } = targetType;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public class CastNode(List<Token> tokens, NubType type, ExpressionNode value) : RValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Value { get; } = value;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
yield return Value;
|
||||
}
|
||||
}
|
||||
|
||||
public class StructInitializerNode(List<Token> tokens, NubType type, Dictionary<IdentifierToken, ExpressionNode> initializers) : RValue(tokens, type)
|
||||
{
|
||||
public Dictionary<IdentifierToken, ExpressionNode> Initializers { get; } = initializers;
|
||||
|
||||
@@ -588,33 +602,13 @@ public class StructInitializerNode(List<Token> tokens, NubType type, Dictionary<
|
||||
}
|
||||
}
|
||||
|
||||
public class DereferenceNode(List<Token> tokens, NubType type, ExpressionNode target) : ExpressionNode(tokens, type)
|
||||
public class ConstArrayInitializerNode(List<Token> tokens, NubType type, List<ExpressionNode> values) : RValue(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public List<ExpressionNode> Values { get; } = values;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
yield return Target;
|
||||
}
|
||||
}
|
||||
|
||||
public class SizeNode(List<Token> tokens, NubType TargetType) : ExpressionNode(tokens, new NubIntType(false, 64))
|
||||
{
|
||||
public NubType TargetType { get; } = TargetType;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public class CastNode(List<Token> tokens, NubType type, ExpressionNode value) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Value { get; } = value;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
yield return Value;
|
||||
return Values;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user