...
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Common;
|
||||
using Syntax.Diagnostics;
|
||||
using Syntax.Parsing.Node;
|
||||
@@ -730,29 +729,9 @@ public static class Parser
|
||||
|
||||
if (TryExpectSymbol(Symbol.OpenBracket))
|
||||
{
|
||||
if (Peek().TryGetValue(out var token) && token is LiteralToken { Kind: LiteralKind.Integer, Value: var sizeValue })
|
||||
{
|
||||
Next();
|
||||
ExpectSymbol(Symbol.CloseBracket);
|
||||
var baseType = ParseType();
|
||||
|
||||
var size = int.Parse(sizeValue);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
return new NubFixedArrayType(baseType, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnreachableException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ExpectSymbol(Symbol.CloseBracket);
|
||||
var baseType = ParseType();
|
||||
return new NubArrayType(baseType);
|
||||
}
|
||||
ExpectSymbol(Symbol.CloseBracket);
|
||||
var baseType = ParseType();
|
||||
return new NubArrayType(baseType);
|
||||
}
|
||||
|
||||
if (!Peek().TryGetValue(out var peekToken))
|
||||
|
||||
@@ -166,24 +166,6 @@ public class NubArrayType(NubType elementType) : NubType
|
||||
}
|
||||
}
|
||||
|
||||
public class NubFixedArrayType(NubType elementType, int capacity) : NubType
|
||||
{
|
||||
public NubType ElementType { get; } = elementType;
|
||||
public int Capacity { get; } = capacity;
|
||||
|
||||
public override string ToString() => $"[{Capacity}]{ElementType}";
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is NubFixedArrayType other && ElementType.Equals(other.ElementType) && Capacity == other.Capacity;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(ElementType, Capacity);
|
||||
}
|
||||
}
|
||||
|
||||
public class NubAnyType : NubType
|
||||
{
|
||||
public override string ToString() => "any";
|
||||
|
||||
Reference in New Issue
Block a user