Compiler implementation of the D programming language.
Inline Status
not computed yet
cannot inline
can inline
Tuple of result identifier (possibly null) and statement. This is used to store out contracts: out(id){ ensure }
Do syntax copy of an array of Ensure's.
All hidden parameters bundled.
The this
parameter for methods or nested functions.
For methods, it would be the class object or struct value the method is called on. For nested functions it would be the enclosing function's stack frame.
Is 'this' a pointer to a static array holding two contexts.
The selector parameter for Objective-C methods.
in contracts
out contracts
lowered in contract
lowered out contract
function body
functions this function overrides
function that does the in contract
function that does the out contract
argument list for __require
argument list for __ensure
mangled symbol created from mangleExact()
result variable for out contracts
where the return goes
'this' parameter (member and nested)
has a dual-context 'this' parameter
'arguments' parameter
Objective-C method selector (member function only)
Objective-C implicit selector parameter
'argptr' variable
Array of VarDeclaration's for parameters
statement label symbol table
next in overload list
next in overload list (only used during IFTI)
location of closing curly bracket
for member functions, index into vtbl[]
true if naked
true if function was generated by the compiler rather than
supplied by the user
has attribute pragma(crt_constructor(1)/crt_destructor(2))
not set before the glue layer
Local data (i.e. CompileCtfeFunction*) for module dinterpret
!=0 if nested inline
true if array operation
true if no exception unwinding is needed
true if errors in semantic3 this function's frame ptr
if foreach body, this is the foreach
if virtual, but only appears in base interface vtbl[]
true if 'introducing' function
if !=NULL, then this is the type of the 'introducing' function this one is overriding
true if return type is to be inferred
storage class for template onemember's
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
true means we can do NRVO
variable to replace with shidden
hidden pointer passed to function
Gotos with forward references
set if this is a known, builtin function we can evaluate at compile time
set if someone took the address of this function
local variables in this function which are referenced by nested functions
Sibling nested functions which called this one
FUNCFLAG.xxxxx
Resolve forward reference of function signature - parameter types, return type, and attributes. Returns false if any errors exist in the signature.
Resolve forward reference of function body. Returns false if any errors exist in the body.
Check that this function type is properly resolved. If not, report "forward reference error" and return true.
Creates and returns the hidden parameters for this function declaration.
Hidden parameters include the this
parameter of a class, struct or nested function and the selector parameter for Objective-C methods.
Determine if 'this' overrides fd. Return !=0 if it does.
Find index of function in vtbl[0..dim] that this function overrides. Prefer an exact match to a covariant one.
Dsymbols* vtbl
| vtable to use |
int dim
| maximal vtable dimension |
bool fix17349
| enable fix https://issues.dlang.org/show_bug.cgi?id=17349 |
If function a function in a base class, return that base class.
Overload this FuncDeclaration with the new one f. Return true if successful; i.e. no conflict.
Find function in overload list that exactly matches t.
Find function in overload list that matches to the 'this' modifier. There's four result types.
1. If the 'tthis' matches only one candidate, it's an "exact match". Returns the function and 'hasOverloads' is set to false. eg. If 'tthis" is mutable and there's only one mutable method. 2. If there's two or more match candidates, but a candidate function will be a "better match". Returns the better match function but 'hasOverloads' is set to true. eg. If 'tthis' is mutable, and there's both mutable and const methods, the mutable method will be a better match. 3. If there's two or more match candidates, but there's no better match, Returns null and 'hasOverloads' is set to true to represent "ambiguous match". eg. If 'tthis' is mutable, and there's two or more mutable methods. 4. If there's no candidates, it's "no match" and returns null with error report. e.g. If 'tthis' is const but there's no const methods.
find function template root in overload list
Returns true if function was declared directly or indirectly in a unittest block
Determine partial specialization order of 'this' vs g. This is very similar to TemplateDeclaration::leastAsSpecialized().
Labels are in a separate scope, one per function.
Determine lexical level difference from this
to nested function fd
.
FuncDeclaration fd
| target of call |
int intypeof
| !=0 if inside typeof |
fd
is nested within this
) LevelError error, this
cannot call fd
Determine lexical level difference from this
to nested function fd
. Issue error if this
cannot call fd
.
Loc loc
| location for error messages |
Scope* sc
| context |
FuncDeclaration fd
| target of call |
fd
is nested within 'this') LevelError errorfor diagnostics, e.g. 'int foo(int x, int y) pure'
Override so it can work even if semantic() hasn't yet been run.
Decide if attributes for this function can be inferred from examining the function body.
Initialize for inferring the attributes of this function.
The function is doing something impure, so mark it as impure. If there's a purity error, return true.
The function is doing something unsafe, so mark it as unsafe. If there's a safe error, return true.
The function is doing something that may allocate with the GC, so mark it as not nogc (not no-how).
See if pointers from function parameters, mutable globals, or uplevel functions could leak into return value.
See if pointers from function parameters, mutable globals, or uplevel functions could leak into type t
.
Type t
| type to check if it is isolated |
t
is isolated from any inputs to the functionDetermine if function needs a static frame pointer.
true
if function is really nested within other function. Determine if function is a non-static member function that has an implicit 'this' expression.
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.
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.
Check that the function contains any closure. If it's @nogc, report suitable errors. This is mostly consistent with FuncDeclaration::needsClosure().
Determine if function's variables are referenced by a function nested within it.
Declare result variable lazily.
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.
Determine whether an 'out' contract is declared inside the given function or any of its overrides.
FuncDeclaration fd
| the function to search |
Rewrite contracts as statements.
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.
Generate a FuncDeclaration for a runtime library function.
Check parameters and return type of D main() function. Issue error messages.
Generate Expression to call the invariant.
Visit each overloaded function/template in turn, and call dg(s) on it. Exit when no more, or dg(s) returns nonzero.
Dsymbol fstart
| symbol to start from |
int delegate(Dsymbol) dg
| the delegate to be called on the overload |
Scope* sc
| context used to check if symbol is accessible (and therefore visible), can be null |
Checks for mismatching modifiers between lhsMod
and rhsMod
and prints the mismatching modifiers to buf
.
The modifiers of the lhsMod
mismatching the ones with the rhsMod
are printed, i.e. lhs(shared) vs. rhs() prints "shared
", wheras lhs() vs rhs(shared) prints "non-shared".
OutBuffer* buf
| output buffer to write to |
ubyte lhsMod
| modifier on the left-hand side |
ubyte lhsMod
| modifier on the right-hand side |
isMutable
and isNotShared
set if the lhsMod
is missing those modifiers (compared to rhs).OutBuffer buf; auto mismatches = MODMatchToBuffer(&buf, MODFlags.shared_, 0); assert(buf.peekSlice == "`shared` "); assert(!mismatches.isNotShared); buf.reset; mismatches = MODMatchToBuffer(&buf, 0, MODFlags.shared_); assert(buf.peekSlice == "non-shared "); assert(mismatches.isNotShared); buf.reset; mismatches = MODMatchToBuffer(&buf, MODFlags.const_, 0); assert(buf.peekSlice == "`const` "); assert(!mismatches.isMutable); buf.reset; mismatches = MODMatchToBuffer(&buf, 0, MODFlags.const_); assert(buf.peekSlice == "mutable "); assert(mismatches.isMutable);
Flag used by resolveFuncCall
.
issue error messages, solve the call.
do not issue error message on no match, just return null
.
only resolve overloads.
Given a symbol that could be either a FuncDeclaration or a function template, resolve it to a function symbol.
Loc loc
| instantiation location |
Scope* sc
| instantiation scope |
Dsymbol s
| instantiation symbol |
Objects* tiargs
| initial list of template arguments |
Type tthis
| if !NULL, the this argument type |
Expressions* fargs
| arguments to function |
FuncResolveFlag flags
| see FuncResolveFlag . |
Returns an indirect type one step from t.
Returns true if any of the symbols p
resides in the enclosing instantiation scope of s
.
Used as a way to import a set of functions from another scope into this one.
Modify all expression type of return statements to tret.
On function literals, return type may be modified based on the context type after its semantic3 is done, in FuncExp::implicitCastTo.
A function() dg = (){ return new B(); } // OK if is(B : A) == true
If B to A conversion is convariant that requires offseet adjusting, all return statements should be adjusted to return expressions typed A.
© 1999–2019 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/dmd_func.html