Code Map
module volta.ir.declaration;
//! Base class for all declarations.
class Declaration : Node
{
public:
enum Kind
{
Invalid,
Function,
Variable,
EnumDeclaration,
FunctionSet,
FunctionParam,
}
public:
annotations: Attribute[];
public:
this(nt: NodeType) { }
this(nt: NodeType, old: Declaration) { }
fn declKind() Kind { }
}
//! Represents an instance of a type.
class Variable : Declaration
{
public:
enum Storage
{
Invalid,
//! Member of a struct/class.
Field,
//! Variable in a function.
Function,
//! Accessed in a nested function.
Nested,
//! Stored in TLS.
Local,
//! Stored in the global data segment.
Global,
}
public:
isResolved: bool;
access: Access;
type: Type;
name: string;
mangledName: string;
assign: Exp;
storage: Storage;
linkage: Linkage;
isMergable: bool;
//! Only for global variables.
isExtern: bool;
//! The type will be a ref storage type if this is set.
isOut: bool;
//! Has this variable been declared yet? (only useful in extyper)
hasBeenDeclared: bool;
useBaseStorage: bool;
specialInitValue: bool;
noInitialise: bool;
public:
this() { }
//! Construct a Variable with a given type and name.
this(t: Type, name: string) { }
this(old: Variable) { }
public:
static fn storageToString(s: Storage) string { }
}
//! An Alias associates names with a Type. Once declared, using that name
//! is as using that Type directly.
class Alias : Node
{
public:
isResolved: bool;
access: Access;
name: string;
//! Non null type.
externAttr: Attribute;
type: Type;
id: QualifiedName;
staticIf: AliasStaticIf;
//! Where are we looking for the symbol.
lookScope: Scope;
//! Where are we looking for the symbol.
lookModule: Module;
store: Store;
//! Not with id. Optional.
templateInstance: Exp;
public:
this() { }
this(old: Alias) { }
}
//! A function is a block of code that takes parameters, and may return a
//! value. There may be additional implied context, depending on where it's
//! defined.
class Function : Declaration
{
public:
//! Used to specify function type.
enum Kind
{
Invalid,
//! foo()
Function,
//! this.foo()
Member,
//! Clazz.foo()
LocalMember,
//! Clazz.foo()
GlobalMember,
//! auto foo = new Clazz()
Constructor,
//! delete foo
Destructor,
//! local this() {}
LocalConstructor,
//! local ~this() {}
LocalDestructor,
//! global this() {}
GlobalConstructor,
//! global ~this() {}
GlobalDestructor,
//! void aFunction() { void foo() {} }
Nested,
//! void aFunction() { global void foo() {} }
GlobalNested,
}
public:
isResolved: bool;
isActualized: bool;
access: Access;
//! Needed for params
myScope: Scope;
//! What kind of function.
kind: Kind;
//! Prototype.
type: FunctionType;
params: FunctionParam[];
nestedFunctions: Function[];
//! The various scope (exit/success/failures) turned into inline
//! functions.
scopeSuccesses: Function[];
//! The various scope (exit/success/failures) turned into inline
//! functions.
scopeExits: Function[];
//! The various scope (exit/success/failures) turned into inline
//! functions.
scopeFailures: Function[];
//! Pre mangling.
name: string;
mangledName: string;
outParameter: string;
//! Optional in contract.
parsedIn: BlockStatement;
//! Optional out contract.
parsedOut: BlockStatement;
//! Optional body.
parsedBody: BlockStatement;
//! Optional lazy parsed in contract.
tokensIn: Token[];
//! Optional lazy parsed out contract.
tokensOut: Token[];
//! Optional lazy parsed body.
tokensBody: Token[];
thisHiddenParameter: Variable;
nestedHiddenParameter: Variable;
nestedVariable: Variable;
composableSinkVariable: Variable;
nestStruct: Struct;
isMergable: bool;
//! If this is a member function, where in the vtable does it live?
vtableIndex: i32;
loadDynamic: bool;
isMarkedOverride: bool;
isOverridingInterface: bool;
isAbstract: bool;
isFinal: bool;
isAutoReturn: bool;
//! Is this a function a lowered construct, like scope.
isLoweredScopeExit: bool;
//! Is this a function a lowered construct, like scope.
isLoweredScopeFailure: bool;
//! Is this a function a lowered construct, like scope.
isLoweredScopeSuccess: bool;
templateName: string;
templateType: Type;
public:
this() { }
this(old: Function) { }
fn hasBody() bool { }
fn hasInContract() bool { }
fn hasOutContract() bool { }
}
class EnumDeclaration : Declaration
{
public:
type: Type;
assign: Exp;
name: string;
prevEnum: EnumDeclaration;
resolved: bool;
access: Access;
isStandalone: bool;
public:
this() { }
this(old: EnumDeclaration) { }
}
//! Represents multiple functions associated with a single name.
class FunctionSet : Declaration
{
public:
functions: Function[];
//! For assigning an overloaded function to a delegate.
reference: ExpReference;
public:
this() { }
this(old: FunctionSet) { }
fn type() FunctionSetType { }
//! Update reference to indicate function set has been resolved. Returns
//! the function passed to it.
fn resolved(func: Function) Function { }
}
//! Represents a parameter to a function.
class FunctionParam : Declaration
{
public:
func: Function;
index: size_t;
assign: Exp;
name: string;
//! Has this parameter been nested into a nested context struct?
hasBeenNested: bool;
public:
this() { }
this(old: FunctionParam) { }
fn type() Type { }
}
Base class for all declarations.
Represents an instance of a type.
A Variable has a type and a single name that is an instance of that type. It may also have an expression that represents a value to assign to it.
Variables
are mangled as type + parent names + name.
Only for global variables.
The type will be a ref storage type if this is set.
Has this variable been declared yet? (only useful in extyper)
Construct a Variable
with a given type and name.
An Alias
associates names with a Type
. Once declared, using that name is
as using that Type
directly.
Non null type.
Where are we looking for the symbol.
Where are we looking for the symbol.
Not with id. Optional.
A function is a block of code that takes parameters, and may return a value. There may be additional implied context, depending on where it's defined.
Functions
are mangled as type + parent names + name.
Used to specify function type.
Some types have hidden arguments, like the this argument for member functions, constructors and destructors.
foo()
this.foo()
Clazz.foo()
Clazz.foo()
auto foo = new Clazz()
delete foo
local this() {}
local ~this() {}
global this() {}
global ~this() {}
void aFunction() { void foo() {} }
void aFunction() { global void foo() {} }
Needed for params
What kind of function.
Prototype.
The various scope (exit/success/failures) turned into inline functions.
The various scope (exit/success/failures) turned into inline functions.
The various scope (exit/success/failures) turned into inline functions.
Pre mangling.
Optional in contract.
Optional out contract.
Optional body.
Optional lazy parsed in contract.
Optional lazy parsed out contract.
Optional lazy parsed body.
If this is a member function, where in the vtable does it live?
Is this a function a lowered construct, like scope.
Is this a function a lowered construct, like scope.
Is this a function a lowered construct, like scope.
Represents multiple functions associated with a single name.
Contains the ExpReference that this set is associated with so that it can be transparently updated to point at the selected function.
For assigning an overloaded function to a delegate.
Update reference to indicate function set has been resolved. Returns the function passed to it.
Represents a parameter to a function.
Indirectly references the type which is on the Callable, and just contains the metadata parameters have (name, assign. etc).
Has this parameter been nested into a nested context struct?