package types

import "github.com/azin-lang/Azin/internal/types"

Index

Constants

const (
	UnitTypeName    = "unit"
	BoolTypeName    = "bool"
	IntTypeName     = "int"
	FloatTypeName   = "float"
	StringTypeName  = "string"
	CharTypeName    = "char"
	UnknownTypeName = "<unknown>"
	ErrorTypeName   = "<error>"
)

Functions

func IsAssignable

func IsAssignable(from, to *TypeInfo) bool

Types

type Kind

type Kind uint8
const (
	Error Kind = iota

	Bool   // Boolean type
	Int    // Integer type
	Float  // Floating-point type
	String // String type
	Char   // Character type

	Unknown // Unknown type (type inference not yet performed)
	Unit    // Unit type
	Nominal // Nominal type (user-defined types)

)

type TypeInfo

type TypeInfo struct {
	Kind Kind
	Name string
}

TypeInfo represents the type information of a value in the type system.

func BoolType
func BoolType() *TypeInfo

BoolType returns the TypeInfo for the boolean type.

func CharType
func CharType() *TypeInfo

CharType returns the TypeInfo for the character type.

func ErrorType
func ErrorType() *TypeInfo

ErrorType returns a TypeInfo representing an invalid type.

func FloatType
func FloatType() *TypeInfo

FloatType returns the TypeInfo for the floating-point type.

func GetPrimitiveTypeByName
func GetPrimitiveTypeByName(name string) *TypeInfo

GetPrimitiveTypeByName returns the TypeInfo for a given primitive TypeKind or nil if the kind is not a primitive type.

func IntType
func IntType() *TypeInfo

IntType returns the TypeInfo for the integer type.

func NominalType
func NominalType(name string) *TypeInfo

NominalType returns a TypeInfo representing a nominal (user-defined) type with the given name.

func StringType
func StringType() *TypeInfo

StringType returns the TypeInfo for the string type.

func UnitType
func UnitType() *TypeInfo

UnitType returns the TypeInfo for the unit type.

func UnknownType
func UnknownType() *TypeInfo

UnknownType returns a TypeInfo representing an unknown type, used for type inference before the actual type is determined.

func (*TypeInfo) Equals
func (t *TypeInfo) Equals(other *TypeInfo) bool
func (*TypeInfo) IsBool
func (t *TypeInfo) IsBool() bool

IsBool checks if the type is a boolean type.

func (*TypeInfo) IsChar
func (t *TypeInfo) IsChar() bool

IsChar checks if the type is a character type.

func (*TypeInfo) IsComplete
func (t *TypeInfo) IsComplete() bool

IsComplete checks if the TypeInfo represents a complete type (not unknown or error).

func (*TypeInfo) IsFloat
func (t *TypeInfo) IsFloat() bool

IsFloat checks if the type is a floating-point type.

func (*TypeInfo) IsInt
func (t *TypeInfo) IsInt() bool

IsInt checks if the type is an integer type.

func (*TypeInfo) IsNominal
func (t *TypeInfo) IsNominal() bool

IsNominal checks if the type is a nominal (user-defined) type.

func (*TypeInfo) IsNumeric
func (t *TypeInfo) IsNumeric() bool

IsNumeric checks if the type is either an integer or a floating-point type.

func (*TypeInfo) IsPrimitive
func (t *TypeInfo) IsPrimitive() bool

IsPrimitive checks if the type is a primitive type (bool, int, float, string, char).

func (*TypeInfo) IsString
func (t *TypeInfo) IsString() bool

IsString checks if the type is a string type.

func (*TypeInfo) IsUnit
func (t *TypeInfo) IsUnit() bool

IsUnit checks if the TypeInfo represents the unit type.

func (*TypeInfo) IsUnknown
func (t *TypeInfo) IsUnknown() bool

IsUnknown checks if the TypeInfo represents an unknown type (needs type inference).

func (*TypeInfo) IsValid
func (t *TypeInfo) IsValid() bool

IsValid checks if the TypeInfo is valid (not nil and not Invalid).