Implements the type IR for the MIR phase (not yet), plus the TypeEnv, which stores the data for all types.
All types are addressed via TypeId, with the built-in types using static IDs.
Types
TypeEnv {.requiresInit.} = object map: TypeTable[TypeId] ## maps the hash of a type. Since the hash is not guaranteed to be ## unique, hash collisions are possible! types: Store[TypeId, PType] sizeType: TypeId ## the target-dependent integer type to use for size values usizeType: TypeId ## the target-dependent unsigned integer type to use for size values
- Stores the data associated with types. Has no valid default value, and must be explicitly initialized first. Source Edit
Consts
CstringType = 14'u32
- Source Edit
Float32Type = 11'u32
- Source Edit
Float64Type = 12'u32
- Source Edit
PointerType = 15'u32
- Source Edit
StringType = 13'u32
- Source Edit
UInt16Type = 8'u32
- Source Edit
UInt32Type = 9'u32
- Source Edit
UInt64Type = 10'u32
- Source Edit
Procs
proc add(env: var TypeEnv; t: PType): TypeId {....raises: [Exception], tags: [RootEffect].}
- If not registered yet, adds t to env and returns the ID to later look it up with. Basic structural type unification is performed. Source Edit
proc initTypeEnv(graph: ModuleGraph): TypeEnv {. ...raises: [KeyError, Exception, ERecoverableError], tags: [ReadDirEffect, RootEffect].}
- Returns a fully initialized type environment instance. Source Edit