IR Type Nodes

IR Nodes

Used to express the types of the Volt Language.

A Type, in broad terms, defines how an instance of that type manifests in memory. Various passes work with Types to assign and ensure the semantic meaning of the program.

Volt is a statically typed language. As a result, all expressions have a Type. The ExpTyper pass assigns types to expressions.

All Types have to be able to be instantiated, and thus well defined -- the TypeVerifier ensures all user defined types (structs, classes, function's underlying function types) are well defined. Where well defined means 'able to be composed of other well defined types'. This is not circular, as there are primitive types that the language knows about with no user interaction.

There are also passes that deal with Types in small ways -- the UserResolver associates a user defined type with a Type object. The MangleWriter mangles type strings. The Context pass creates scopes on Types that have them.

This module does not contain all the Types that Volt has -- things like structs and classes are in toplevel, as they contain top level declarations, but they are also Types, and are children of Type.

Classes

Type Base class for all types.
PrimitiveType PrimitiveTypes are types that are entirely well known to the compiler ahead of time. Consisting mostly of integral types, the only abstract one is Void, which indicates no type or (in the case of arrays and pointers) any type.
TypeReference A TypeReference is generated for user defined types, and a pass fills in the information so it can act as a cache, and not require multiple lookups.
PointerType A pointer is an abstraction of an address. You can dereference a pointer (get the thing it's pointing to), perform pointer arithmetic (move to the next possible address that could contain the same type), or reseat a pointer (change what it points to). You can also slice a pointer to get an array.
NullType The NullType represents the Type of a null.
ArrayType An ArrayType represents a slice of memory. It contains a pointer, that contains elements of the base type, and a length, which says how many elements this slice shows. This is lowered into a struct before the backend gets it.
AmbiguousArrayType A type that is either an AAType or a StaticArrayType, but we cannot tell which yet.
StaticArrayType A StaticArray is a list of elements of type base with a statically (known at compile time) number of elements. Unlike C, these are passed by value to functions.
AAType An AAType is an associative array -- it associates keys with values.
FunctionType A FunctionType represents the form of a function, and defines how it is called. It has a return type and a number of parameters.
DelegateType A DelegateType is a function pointer with an additional context pointer.
StorageType A StorageType changes how a Type behaves.
AutoType For representing inferred types. auto a = 3; const b = 2;
AliasStaticIf A special kind of type that allows an alias to have multiple configurations.
Named Named is a base class for named types, like Enum, Struct, Class and so on. This is slightly different from Aggregate since Enum is not a Aggregate, but is a named type.
Aggregate Aggregate is a base class for Struct, Union & Class.
Class Java style class declaration. Classes enable polymorphism, and are always accessed through opaque references (to prevent slicing -- look it up!)
_Interface Java style interface declaration. An interface defines multiple functions that an implementing class must define. A class can inherit from multiple interfaces, and can be treated as an instance of any one of them.
Union C style union. Structs are a POD data type, and should be binary compatible with the same union as defined by your friendly neighbourhood C compiler.
Struct C style struct. Structs are a POD data type, and should be binary compatible with the same struct as defined by your friendly neighbourhood C compiler.
Enum C style Enum. Enums create symbols that are associated with compile time constants. By default, they are enumerated with ascending numbers, hence the name.