FuncDeclaration

extern (C++)
class FuncDeclaration : Declaration {
DsymbolTable localsymtab;
ILS inlineStatusStmt;
ILS inlineStatusExp;
PINLINE inlining;
ReturnStatements* returns;
bool requiresClosure;
FuncDeclarations* inlinedNestedCallees;
AttributeViolation* nogcViolation;
AttributeViolation* pureViolation;
AttributeViolation* nothrowViolation;
enum LevelError;
}

Members

Functions

buildEnsureRequire
void buildEnsureRequire()

Rewrite contracts as statements.

buildResultVar
void buildResultVar(Scope* sc, Type tret)

Declare result variable lazily.

canInferAttributes
bool canInferAttributes(Scope* sc)

Decide if attributes for this function can be inferred from examining the function body.

checkClosure
bool checkClosure()

Check that the function contains any closure. If it's @nogc, report suitable errors. This is mostly consistent with FuncDeclaration::needsClosure().

checkForwardRef
bool checkForwardRef(Loc loc)

Check that this function type is properly resolved. If not, report "forward reference error" and return true.

checkNRVO
bool checkNRVO()

Check all return statements for a function to verify that returning using NRVO is possible.

checkNestedReference
bool checkNestedReference(Scope* sc, Loc loc)

In the current function, we are calling 'this' function. 1. Check to see if the current function can call 'this' function, issue error if not. 2. If the current function is not the parent of 'this' function, then add the current function to the list of siblings of 'this' function. 3. If the current function is a literal, and it's accessing an uplevel scope, then mark it as a delegate. Returns true if error occurs.

declareThis
void declareThis(Scope* sc)

Creates and returns the hidden parameters for this function declaration.

findTemplateDeclRoot
TemplateDeclaration findTemplateDeclRoot()

find function template root in overload list

findVtblIndex
int findVtblIndex(Dsymbols* vtbl, int dim)

Find index of function in vtbl[0..length] that this function overrides. Prefer an exact match to a covariant one.

functionSemantic
bool functionSemantic()

Resolve forward reference of function signature - parameter types, return type, and attributes.

functionSemantic3
bool functionSemantic3()

Resolve forward reference of function body. Returns false if any errors exist in the body.

getLevel
int getLevel(FuncDeclaration fd, int intypeof)

Determine lexical level difference from this to nested function fd.

getLevelAndCheck
int getLevelAndCheck(Loc loc, Scope* sc, FuncDeclaration fd, Declaration decl)

Determine lexical level difference from this to nested function fd. Issue error if this cannot call fd.

getParameterList
ParameterList getParameterList()
hasNestedFrameRefs
bool hasNestedFrameRefs()

Determine if function's variables are referenced by a function nested within it.

inUnittest
bool inUnittest()

Returns true if function was declared directly or indirectly in a unittest block

initInferAttributes
void initInferAttributes()

Initialize for inferring the attributes of this function.

isAbstract
bool isAbstract()

Override so it can work even if semantic() hasn't yet been run.

isNested
bool isNested()

Determine if function needs a static frame pointer.

isReturnIsolated
bool isReturnIsolated()

See if pointers from function parameters, mutable globals, or uplevel functions could leak into return value.

isThis
inout(AggregateDeclaration) isThis()

Determine if function is a non-static member function that has an implicit 'this' expression.

isTypeIsolated
bool isTypeIsolated(Type t)
bool isTypeIsolated(Type t, StringTable!Type parentTypes)

See if pointers from function parameters, mutable globals, or uplevel functions could leak into type t.

isUnique
bool isUnique()
leastAsSpecialized
MATCH leastAsSpecialized(FuncDeclaration g, Identifiers* names)

Determine partial specialization order of 'this' vs g. This is very similar to TemplateDeclaration::leastAsSpecialized().

mergeFensure
Statement mergeFensure(Statement sf, Identifier oid, Expressions* params)

Merge into this function the 'out' contracts of all it overrides. 'out's are AND'd together, i.e. all of them need to pass.

mergeFrequire
Statement mergeFrequire(Statement sf, Expressions* params)

Merge into this function the 'in' contracts of all it overrides. 'in's are OR'd together, i.e. only one of them needs to pass.

mergeFrequireInclusivePreview
Statement mergeFrequireInclusivePreview(Statement sf, Expressions* params)

Merge into this function the 'in' contracts of all it overrides.

needsClosure
bool needsClosure()

Look at all the variables in this function that are referenced by nested functions, and determine if a closure needs to be created for them.

overloadExactMatch
FuncDeclaration overloadExactMatch(Type t)

Find function in overload list that exactly matches t.

overloadInsert
bool overloadInsert(Dsymbol s)

Overload this FuncDeclaration with the new one f. Return true if successful; i.e. no conflict.

overloadModMatch
FuncDeclaration overloadModMatch(Loc loc, Type tthis, bool hasOverloads)

Find function in overload list that matches to the 'this' modifier. There's four result types.

overrideInterface
BaseClass* overrideInterface()

If function a function in a base class, return that base class.

overrides
int overrides(FuncDeclaration fd)

Determine if 'this' overrides fd. Return !=0 if it does.

searchLabel
LabelDsymbol searchLabel(Identifier ident, Loc loc)

Searches for a label with the given identifier. This function will insert a new LabelDsymbol into labtab if it does not contain a mapping for ident.

setGC
bool setGC(Loc loc, const(char)* fmt, RootObject arg0)

The function is doing something that may allocate with the GC, so mark it as not nogc (not no-how).

setGCCall
bool setGCCall(FuncDeclaration f)

The function calls non-@nogc function f, mark it as not nogc.

setImpure
bool setImpure(Loc loc, const(char)* fmt, RootObject arg0)

The function is doing something impure, so mark it as impure.

setThrow
void setThrow(Loc loc, const(char)* fmt, RootObject arg0)

The function is doing something that may throw an exception, register that in case nothrow is being inferred

setThrowCall
void setThrowCall(Loc loc, FuncDeclaration f)

The function calls non-nothrow function f, register that in case nothrow is being inferred

setUnsafe
bool setUnsafe(bool gag, Loc loc, const(char)* fmt, RootObject arg0, RootObject arg1, RootObject arg2)

The function is doing something unsafe, so mark it as unsafe.

setUnsafeCall
bool setUnsafeCall(FuncDeclaration f)

The function is calling @system function f, so mark it as unsafe.

toFullSignature
const(char)* toFullSignature()

for diagnostics, e.g. 'int foo(int x, int y) pure'

Static functions

genCfunc
FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, StorageClass stc)

Generate a FuncDeclaration for a runtime library function.

needsFensure
bool needsFensure(FuncDeclaration fd)

Determine whether an 'out' contract is declared inside the given function or any of its overrides.

Variables

alignSectionVars
VarDeclarations* alignSectionVars;

local variables with alignment needs larger than stackAlign

builtin
BUILTIN builtin;

set if this is a known, builtin function we can evaluate at compile time

closureVars
VarDeclarations closureVars;

local variables in this function which are referenced by nested functions (They'll get put into the "closure" for this function.)

endloc
Loc endloc;

location of closing curly bracket

fbody
Statement fbody;

function body

fdensure
FuncDeclaration fdensure;

function that does the out contract

fdensureParams
Expressions* fdensureParams;

argument list for __ensure

fdrequire
FuncDeclaration fdrequire;

function that does the in contract

fdrequireParams
Expressions* fdrequireParams;

argument list for __require

fensure
Statement fensure;

lowered out contract

fensures
Ensures* fensures;

out contracts

fes
ForeachStatement fes;

if foreach body, this is the foreach

foverrides
FuncDeclarations foverrides;

functions this function overrides

frequire
Statement frequire;

lowered in contract

frequires
Statements* frequires;

in contracts

gotos
GotoStatements* gotos;

Gotos with forward references

hasReturnExp
int hasReturnExp;

1 if there's a return exp; statement 2 if there's a throw statement 4 if there's an assert(0) 8 if there's inline asm 16 if there are multiple return statements

inlineNest
int inlineNest;

!=0 if nested inline

interfaceVirtual
BaseClass* interfaceVirtual;

if virtual, but only appears in base interface vtbl[]

isTypeIsolatedCache
bool[size_t] isTypeIsolatedCache;

cache for the potentially very expensive isTypeIsolated check

labtab
DsymbolTable labtab;

statement label symbol table

mangleString
const(char)* mangleString;

mangled symbol created from mangleExact()

nrvo_var
VarDeclaration nrvo_var;

variable to replace with shidden

objc
ObjcFuncDeclaration objc;

Data for a function declaration that is needed for the Objective-C integration.

outerVars
VarDeclarations outerVars;

Outer variables which are referenced by this nested function (the inverse of closureVars)

overnext
Dsymbol overnext;

next in overload list

overnext0
FuncDeclaration overnext0;

next in overload list (only used during IFTI)

parameters
VarDeclarations* parameters;

Array of VarDeclaration's for parameters

returnLabel
LabelDsymbol returnLabel;

where the return goes

safetyViolation
AttributeViolation* safetyViolation;

In case of failed @safe inference, store the error that made the function @system for better diagnostics

salignSection
Symbol* salignSection;

pointer to aligned section, if any

shidden
Symbol* shidden;

hidden pointer passed to function

siblingCallers
FuncDeclarations siblingCallers;

Sibling nested functions which called this one

storage_class2
StorageClass storage_class2;

storage class for template onemember's

tintro
Type tintro;

if !=NULL, then this is the type of the 'introducing' function this one is overriding

tookAddressOf
int tookAddressOf;

set if someone took the address of this function

v_argptr
VarDeclaration v_argptr;

'_argptr' variable

v_arguments
VarDeclaration v_arguments;

'_arguments' parameter

vresult
VarDeclaration vresult;

result variable for out contracts

vtblIndex
int vtblIndex;

for member functions, index into vtbl[]

vthis
VarDeclaration vthis;

'this' parameter (member and nested)

Inherited Members

From Declaration

checkDisabled
bool checkDisabled(Loc loc, Scope* sc, bool isAliasedDeclaration)

Issue an error if an attempt to call a disabled method is made

checkModify
Modifiable checkModify(Loc loc, Scope* sc, Expression e1, ModifyFlags flag)

Check to see if declaration can be modified in this context (sc). Issue error if not.

resolvedLinkage
LINK resolvedLinkage()

Returns the linkage, resolving the target-specific System one.

isReference
bool isReference()

Meta