...
This commit is contained in:
@@ -4,6 +4,8 @@ namespace Syntax.Typing;
|
||||
|
||||
public abstract class NubType
|
||||
{
|
||||
public abstract bool ValueIsPointer { get; }
|
||||
|
||||
public bool IsInteger => this is NubPrimitiveType
|
||||
{
|
||||
Kind: PrimitiveTypeKind.I8
|
||||
@@ -46,6 +48,8 @@ public abstract class NubType
|
||||
|
||||
public class NubCStringType : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => true;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is NubCStringType;
|
||||
@@ -64,6 +68,8 @@ public class NubCStringType : NubType
|
||||
|
||||
public class NubStringType : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => true;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return obj is NubStringType;
|
||||
@@ -82,6 +88,8 @@ public class NubStringType : NubType
|
||||
|
||||
public class NubFuncType(NubType returnType, List<NubType> parameters) : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => false;
|
||||
|
||||
public NubType ReturnType { get; } = returnType;
|
||||
public List<NubType> Parameters { get; } = parameters;
|
||||
|
||||
@@ -103,6 +111,8 @@ public class NubFuncType(NubType returnType, List<NubType> parameters) : NubType
|
||||
|
||||
public class NubStructType(string @namespace, string name) : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => true;
|
||||
|
||||
public string Namespace { get; } = @namespace;
|
||||
public string Name { get; } = name;
|
||||
|
||||
@@ -124,6 +134,8 @@ public class NubStructType(string @namespace, string name) : NubType
|
||||
|
||||
public class NubPointerType(NubType baseType) : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => false;
|
||||
|
||||
public NubType BaseType { get; } = baseType;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
@@ -144,6 +156,8 @@ public class NubPointerType(NubType baseType) : NubType
|
||||
|
||||
public class NubArrayType(NubType elementType) : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => true;
|
||||
|
||||
public NubType ElementType { get; } = elementType;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
@@ -168,6 +182,8 @@ public class NubArrayType(NubType elementType) : NubType
|
||||
|
||||
public class NubAnyType : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => false;
|
||||
|
||||
public override string ToString() => "any";
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
@@ -183,6 +199,8 @@ public class NubAnyType : NubType
|
||||
|
||||
public class NubVoidType : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => false;
|
||||
|
||||
public override string ToString() => "void";
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
@@ -198,6 +216,8 @@ public class NubVoidType : NubType
|
||||
|
||||
public class NubPrimitiveType(PrimitiveTypeKind kind) : NubType
|
||||
{
|
||||
public override bool ValueIsPointer => false;
|
||||
|
||||
public PrimitiveTypeKind Kind { get; } = kind;
|
||||
|
||||
public static NubPrimitiveType I64 => new(PrimitiveTypeKind.I64);
|
||||
|
||||
Reference in New Issue
Block a user