View source code
Display the source code in dmd/funcsem.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.

Module dmd.funcsem

Does semantic analysis for functions.

Specification

Functions

Documentation

https://dlang.org/phobos/dmd_funcsem.html

Coverage

https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/funcsem.d

Functions

NameDescription
addInvariant(ad, vthis) Generate Expression to call the invariant.
arrayBoundsCheck(fd) Check to see if array bounds checking code has to be generated
buildEnsureRequire(thisfd) Rewrite contracts as statements.
buildResultVar(fd, sc, tret) Declare result variable lazily.
checkEscapingSiblings(f, outerFunc, p) Given a nested function f inside a function outerFunc, check if any sibling callers of f have escaped. If so, mark all the enclosing functions as needing closures. This is recursive: we need to check the callers of our siblings. Note that nested functions can only call lexically earlier nested functions, so loops are impossible.
checkForwardRef(fd, loc) Check that this function type is properly resolved. If not, report "forward reference error" and return true.
checkNestedReference(vd, sc, loc) Check to see if this variable is actually in an enclosing function rather than the current one. Update nestedrefs[], closureVars[] and outerVars[].
checkNRVO(fd) Check all return statements for a function to verify that returning using NRVO is possible.
declareThis(fd, sc) Creates and returns the hidden parameters for this function declaration.
findVtblIndex(fd, vtbl) Find index of function in vtbl[0..length] that this function overrides. Prefer an exact match to a covariant one.
funcDeclarationSemantic(sc, funcdecl) Main semantic routine for functions.
functionSemantic(fd) Resolve forward reference of function signature - parameter types, return type, and attributes.
functionSemantic3(fd) Resolve forward reference of function body. Returns false if any errors exist in the body.
getLevel(fd1, fd2, intypeof) Determine lexical level difference from fd1 to nested function fd2.
getLevelAndCheck(fd, loc, sc, target, decl) Determine lexical level difference from fd to nested function target. Issue error if fd cannot call target.
isReturnIsolated(fd) See if pointers from function parameters, mutable globals, or uplevel functions could leak into return value.
isRootTraitsCompilesScope(sc) When a traits(compiles) is used on a function literal call we need to take into account if the body of the function violates any attributes, however, we must not affect the attribute inference on the outer function. The attributes of the function literal still need to be inferred, therefore we need a way to check for the scope that the traits compiles introduces.
isTypeIsolated(fd, t) See if pointers from function parameters, mutable globals, or uplevel functions could leak into type t.
isUnique(fd)
leastAsSpecialized(f, g, names) Determine partial specialization order of functions f vs g. This is very similar to TemplateDeclaration::leastAsSpecialized().
mergeFensure(fd, sf, oid, 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(fd, sf, 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(fd, sf, params) Merge into this function the 'in' contracts of all it overrides.
modifyReturns(fld, sc, tret) Modify all expression type of return statements to tret.
needsClosure(fd) 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.
needsFensure(fd) Determine whether an 'out' contract is declared inside the given function or any of its overrides.
onlyOneMain(fd) Only one entry point function is allowed. Print error if more than one.
overloadApply(fstart, dg, sc) Visit each overloaded function/template in turn, and call dg(s) on it. Exit when no more, or dg(s) returns nonzero.
overloadExactMatch(thisfd, t) Find function in overload list that exactly matches t.
overloadModMatch(thisfd, loc, tthis, hasOverloads) Find function in overload list that matches to the 'this' modifier. There's four result types.
overrideInterface(fd) If function is a function in a base class, return that base class.
overrides(fd1, fd2) Determine if fd1 overrides fd2. Return !=0 if it does.
resolveFuncCall(loc, sc, s, tiargs, tthis, argumentList, flags) Given a symbol that could be either a FuncDeclaration or a function template, resolve it to a function symbol.
setImpure(fd, loc, fmt, args) The function is doing something impure, so mark it as impure.

Enums

NameDescription
FuncResolveFlag Flag used by resolveFuncCall.

Authors

Walter Bright

License

Boost License 1.0