Code Map
module volta.ir.base;
public import volta.ir.location;
public import volta.ir.token;
//! Each concrete class derived from ir.Node has a value in this
//! enumeration. The value for the type is stored in ir.Node.nodeType by
//! the constructor. While using type tags is not very OOP, it is extremely
//! convenient. For example, during debugging you can simply inspect
//! ir.Node.nodeType to find out the actual type of the object.
enum NodeType
{
Invalid,
NonVisiting,
QualifiedName,
Identifier,
Module,
TopLevelBlock,
Import,
Unittest,
Struct,
Class,
Interface,
Union,
Enum,
Attribute,
Condition,
ConditionTopLevel,
MixinFunction,
MixinTemplate,
PrimitiveType,
TypeReference,
PointerType,
ArrayType,
AmbiguousArrayType,
StaticArrayType,
AAType,
AAPair,
FunctionType,
DelegateType,
FunctionSetType,
StorageType,
TypeOf,
NullType,
AutoType,
NoType,
AliasStaticIf,
Variable,
Alias,
Function,
FunctionParam,
FunctionSet,
EnumDeclaration,
ReturnStatement,
BlockStatement,
AsmStatement,
IfStatement,
WhileStatement,
DoStatement,
ForStatement,
ForeachStatement,
LabelStatement,
ExpStatement,
SwitchStatement,
SwitchCase,
ContinueStatement,
BreakStatement,
GotoStatement,
WithStatement,
SynchronizedStatement,
TryStatement,
ThrowStatement,
ScopeStatement,
PragmaStatement,
ConditionStatement,
MixinStatement,
AssertStatement,
Constant,
BinOp,
Ternary,
Unary,
Postfix,
ArrayLiteral,
AssocArray,
IdentifierExp,
Assert,
StringImport,
Typeid,
IsExp,
FunctionLiteral,
ExpReference,
StructLiteral,
UnionLiteral,
ClassLiteral,
TypeExp,
StoreExp,
StatementExp,
TokenExp,
VaArgExp,
PropertyExp,
BuiltinExp,
AccessExp,
RunExp,
ComposableString,
TemplateInstance,
TemplateDefinition,
}
//! Common access levels used on declared functions, methods, classes,
//! interfaces, structs, enums and variables.
enum Access
{
Invalid,
Public,
Private,
Protected,
}
//! Controls the calling convention and how symbols are mangled.
enum Linkage
{
Volt,
C,
CPlusPlus,
D,
Windows,
Pascal,
System,
}
//! Used by ScopeStatement and other nodes.
enum ScopeKind
{
Exit,
Failure,
Success,
}
//! Type used for node unique ids.
alias NodeID = size_t;
//! Base class for all IR nodes.
class Node
{
public:
loc: Location;
docComment: string;
public:
//! Retrieve the NodeType for this Node.
fn nodeType() NodeType { }
//! Retrieve the unique id of this node.
fn uniqueId() size_t { }
fn toIdentifierFast() Identifier { }
fn toIdentifierChecked() Identifier { }
fn toQualifiedNameFast() QualifiedName { }
fn toQualifiedNameChecked() QualifiedName { }
fn toModuleFast() Module { }
fn toModuleChecked() Module { }
fn toTopLevelBlockFast() TopLevelBlock { }
fn toTopLevelBlockChecked() TopLevelBlock { }
fn toImportFast() Import { }
fn toImportChecked() Import { }
fn toUnittestFast() Unittest { }
fn toUnittestChecked() Unittest { }
fn toStructFast() Struct { }
fn toStructChecked() Struct { }
fn toClassFast() Class { }
fn toClassChecked() Class { }
fn toInterfaceFast() _Interface { }
fn toInterfaceChecked() _Interface { }
fn toUnionFast() Union { }
fn toUnionChecked() Union { }
fn toEnumFast() Enum { }
fn toEnumChecked() Enum { }
fn toAttributeFast() Attribute { }
fn toAttributeChecked() Attribute { }
fn toConditionFast() Condition { }
fn toConditionChecked() Condition { }
fn toConditionTopLevelFast() ConditionTopLevel { }
fn toConditionTopLevelChecked() ConditionTopLevel { }
fn toMixinFunctionFast() MixinFunction { }
fn toMixinFunctionChecked() MixinFunction { }
fn toMixinTemplateFast() MixinTemplate { }
fn toMixinTemplateChecked() MixinTemplate { }
fn toTypeFast() Type { }
fn toTypeChecked() Type { }
fn toPrimitiveTypeFast() PrimitiveType { }
fn toPrimitiveTypeChecked() PrimitiveType { }
fn toTypeReferenceFast() TypeReference { }
fn toTypeReferenceChecked() TypeReference { }
fn toPointerTypeFast() PointerType { }
fn toPointerTypeChecked() PointerType { }
fn toArrayTypeFast() ArrayType { }
fn toArrayTypeChecked() ArrayType { }
fn toAmbiguousArrayTypeFast() AmbiguousArrayType { }
fn toAmbiguousArrayTypeChecked() AmbiguousArrayType { }
fn toStaticArrayTypeFast() StaticArrayType { }
fn toStaticArrayTypeChecked() StaticArrayType { }
fn toAATypeFast() AAType { }
fn toAATypeChecked() AAType { }
fn toAAPairFast() AAPair { }
fn toAAPairChecked() AAPair { }
fn toFunctionTypeFast() FunctionType { }
fn toFunctionTypeChecked() FunctionType { }
fn toDelegateTypeFast() DelegateType { }
fn toDelegateTypeChecked() DelegateType { }
fn toFunctionSetTypeFast() FunctionSetType { }
fn toFunctionSetTypeChecked() FunctionSetType { }
fn toStorageTypeFast() StorageType { }
fn toStorageTypeChecked() StorageType { }
fn toTypeOfFast() TypeOf { }
fn toTypeOfChecked() TypeOf { }
fn toNullTypeFast() NullType { }
fn toNullTypeChecked() NullType { }
fn toAutoTypeFast() AutoType { }
fn toAutoTypeChecked() AutoType { }
fn toNoTypeFast() NoType { }
fn toNoTypeChecked() NoType { }
fn toAliasStaticIfFast() AliasStaticIf { }
fn toAliasStaticIfChecked() AliasStaticIf { }
fn toCallableTypeFast() CallableType { }
fn toCallableTypeChecked() CallableType { }
fn toVariableFast() Variable { }
fn toVariableChecked() Variable { }
fn toAliasFast() Alias { }
fn toAliasChecked() Alias { }
fn toFunctionFast() Function { }
fn toFunctionChecked() Function { }
fn toFunctionParamFast() FunctionParam { }
fn toFunctionParamChecked() FunctionParam { }
fn toFunctionSetFast() FunctionSet { }
fn toFunctionSetChecked() FunctionSet { }
fn toEnumDeclarationFast() EnumDeclaration { }
fn toEnumDeclarationChecked() EnumDeclaration { }
fn toReturnStatementFast() ReturnStatement { }
fn toReturnStatementChecked() ReturnStatement { }
fn toBlockStatementFast() BlockStatement { }
fn toBlockStatementChecked() BlockStatement { }
fn toAsmStatementFast() AsmStatement { }
fn toAsmStatementChecked() AsmStatement { }
fn toIfStatementFast() IfStatement { }
fn toIfStatementChecked() IfStatement { }
fn toWhileStatementFast() WhileStatement { }
fn toWhileStatementChecked() WhileStatement { }
fn toDoStatementFast() DoStatement { }
fn toDoStatementChecked() DoStatement { }
fn toForStatementFast() ForStatement { }
fn toForStatementChecked() ForStatement { }
fn toForeachStatementFast() ForeachStatement { }
fn toForeachStatementChecked() ForeachStatement { }
fn toLabelStatementFast() LabelStatement { }
fn toLabelStatementChecked() LabelStatement { }
fn toExpStatementFast() ExpStatement { }
fn toExpStatementChecked() ExpStatement { }
fn toSwitchStatementFast() SwitchStatement { }
fn toSwitchStatementChecked() SwitchStatement { }
fn toSwitchCaseFast() SwitchCase { }
fn toSwitchCaseChecked() SwitchCase { }
fn toContinueStatementFast() ContinueStatement { }
fn toContinueStatementChecked() ContinueStatement { }
fn toBreakStatementFast() BreakStatement { }
fn toBreakStatementChecked() BreakStatement { }
fn toGotoStatementFast() GotoStatement { }
fn toGotoStatementChecked() GotoStatement { }
fn toWithStatementFast() WithStatement { }
fn toWithStatementChecked() WithStatement { }
fn toSynchronizedStatementFast() SynchronizedStatement { }
fn toSynchronizedStatementChecked() SynchronizedStatement { }
fn toTryStatementFast() TryStatement { }
fn toTryStatementChecked() TryStatement { }
fn toThrowStatementFast() ThrowStatement { }
fn toThrowStatementChecked() ThrowStatement { }
fn toScopeStatementFast() ScopeStatement { }
fn toScopeStatementChecked() ScopeStatement { }
fn toPragmaStatementFast() PragmaStatement { }
fn toPragmaStatementChecked() PragmaStatement { }
fn toConditionStatementFast() ConditionStatement { }
fn toConditionStatementChecked() ConditionStatement { }
fn toMixinStatementFast() MixinStatement { }
fn toMixinStatementChecked() MixinStatement { }
fn toAssertStatementFast() AssertStatement { }
fn toAssertStatementChecked() AssertStatement { }
fn toConstantFast() Constant { }
fn toConstantChecked() Constant { }
fn toBinOpFast() BinOp { }
fn toBinOpChecked() BinOp { }
fn toTernaryFast() Ternary { }
fn toTernaryChecked() Ternary { }
fn toUnaryFast() Unary { }
fn toUnaryChecked() Unary { }
fn toPostfixFast() Postfix { }
fn toPostfixChecked() Postfix { }
fn toArrayLiteralFast() ArrayLiteral { }
fn toArrayLiteralChecked() ArrayLiteral { }
fn toAssocArrayFast() AssocArray { }
fn toAssocArrayChecked() AssocArray { }
fn toIdentifierExpFast() IdentifierExp { }
fn toIdentifierExpChecked() IdentifierExp { }
fn toAssertFast() Assert { }
fn toAssertChecked() Assert { }
fn toStringImportFast() StringImport { }
fn toStringImportChecked() StringImport { }
fn toTypeidFast() Typeid { }
fn toTypeidChecked() Typeid { }
fn toIsExpFast() IsExp { }
fn toIsExpChecked() IsExp { }
fn toFunctionLiteralFast() FunctionLiteral { }
fn toFunctionLiteralChecked() FunctionLiteral { }
fn toExpReferenceFast() ExpReference { }
fn toExpReferenceChecked() ExpReference { }
fn toStructLiteralFast() StructLiteral { }
fn toStructLiteralChecked() StructLiteral { }
fn toUnionLiteralFast() UnionLiteral { }
fn toUnionLiteralChecked() UnionLiteral { }
fn toClassLiteralFast() ClassLiteral { }
fn toClassLiteralChecked() ClassLiteral { }
fn toTypeExpFast() TypeExp { }
fn toTypeExpChecked() TypeExp { }
fn toStoreExpFast() StoreExp { }
fn toStoreExpChecked() StoreExp { }
fn toStatementExpFast() StatementExp { }
fn toStatementExpChecked() StatementExp { }
fn toTokenExpFast() TokenExp { }
fn toTokenExpChecked() TokenExp { }
fn toVaArgExpFast() VaArgExp { }
fn toVaArgExpChecked() VaArgExp { }
fn toPropertyExpFast() PropertyExp { }
fn toPropertyExpChecked() PropertyExp { }
fn toBuiltinExpFast() BuiltinExp { }
fn toBuiltinExpChecked() BuiltinExp { }
fn toAccessExpFast() AccessExp { }
fn toAccessExpChecked() AccessExp { }
fn toRunExpFast() RunExp { }
fn toRunExpChecked() RunExp { }
fn toComposableStringFast() ComposableString { }
fn toComposableStringChecked() ComposableString { }
fn toTemplateInstanceFast() TemplateInstance { }
fn toTemplateInstanceChecked() TemplateInstance { }
fn toTemplateDefinitionFast() TemplateDefinition { }
fn toTemplateDefinitionChecked() TemplateDefinition { }
}
//! A series of identifiers and dots referring to a declared item.
class QualifiedName : Node
{
public:
identifiers: Identifier[];
leadingDot: bool;
public:
this() { }
this(old: QualifiedName) { }
fn toString() string { }
fn strings() string[] { }
fn equals(qname: QualifiedName) bool { }
}
//! A single string that could be a part of an ir.QualifiedName or
//! stand-alone node inside of the ir, referencing a declared item.
class Identifier : Node
{
public:
value: string;
public:
this() { }
this(s: string) { }
this(old: Identifier) { }
fn equals(ident: Identifier) bool { }
}
//! Return the given Access as a string.
fn accessToString(access: Access) string { }
//! Return the given Linkage as a string.
fn linkageToString(linkage: Linkage) string { }
//! Returns a string representing the node's nodeType.
fn nodeToString(node: Node) string { }
//! Returns a string representing the nodeType.
fn nodeToString(nodeType: NodeType) string { }
//! For debugging helpers.
fn getNodeAddressString(node: Node) string { }
//! For debugging helpers.
fn getNodeUniqueString(node: Node) string { }
Each concrete class derived from ir.Node
has a value in this
enumeration. The value for the type is stored in ir.Node.nodeType
by the constructor. While using type tags is not very OOP, it is
extremely convenient. For example, during debugging you can simply
inspect ir.Node.nodeType
to find out the actual type of the object.
In addition, it is possible to use a switch-statement based on
ir.Node.nodeType
to select different behaviour for different object
types. For functions that have only slight differences for several
object types, this allows writing very straightforward, readable
code.
Comment totally stolen from Mesa code.
Common access levels used on declared functions, methods, classes, interfaces, structs, enums and variables.
Return the given Access
as a string.
Controls the calling convention and how symbols are mangled.
Linkages are mangled in functions like so:
Volt
is mangled as "Q".C
is mangled as "U".CPlusPlus
is mangled as "R".D
is mangled as "F".Windows
is mangled as "W".Pascal
is mangled as "V".System
is asC
on non Windows systems, and asWindows
on Windows systems.
Return the given Linkage
as a string.
Used by ScopeStatement and other nodes.
Type used for node unique ids.
Base class for all IR nodes.
A Node has a Location and a type. The Location points to where in the source code this Node was defined, and the NodeType allows you to determine the more specific IR type of it.
Retrieve the NodeType for this Node.
Retrieve the unique id of this node.
A series of identifiers and dots referring to a declared item.
A single string that could be a part of an ir.QualifiedName or stand-alone node inside of the ir, referencing a declared item.
Returns a string representing the node's nodeType.
Returns a string representing the nodeType.
This is just a string representing the Node's name, it doesn't supply strings appropriate for error messages, for example.
For debugging helpers.
For debugging helpers.