Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla 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 usinga local clone.

dmd.func

Defines a function declaration.

Includes

  • function/delegate literals
  • function aliases
  • (static/shared) constructors/destructors/post-blits
  • invariant
  • unittest

Authors:
Walter Bright
License:
Boost License 1.0

Sourcefunc.d

Documentationhttps://dlang.org/phobos/dmd_func.html

Coveragehttps://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/func.d

enumILS: ubyte;
Inline Status
uninitialized
not computed yet
no
cannot inline
yes
can inline
structEnsure;
Tuple of result identifier (possibly null) and statement. This is used to store out contracts: out(id){ ensure }
static Ensures*arraySyntaxCopy(Ensures*a);
Do syntax copy of an array of Ensure's.
classFuncDeclaration:dmd.declaration.Declaration;
Statementfbody;
function body
FuncDeclarationsfoverrides;
functions this function overrides
const(char)*mangleString;
mangled symbol created from mangleExact()
VarDeclarationvresult;
result variable for out contracts
LabelDsymbolreturnLabel;
where the return goes
bool[size_t]isTypeIsolatedCache;
cache for the potentially very expensive isTypeIsolated check
VarDeclarationvthis;
'this' parameter (member and nested)
VarDeclarationv_arguments;
'arguments' parameter
VarDeclarationv_argptr;
'argptr' variable
VarDeclarations*parameters;
Array of VarDeclaration's for parameters
DsymbolTablelabtab;
statement label symbol table
Dsymbolovernext;
next in overload list
FuncDeclarationovernext0;
next in overload list (only used during IFTI)
Locendloc;
location of closing curly bracket
intvtblIndex;
for member functions, index into vtbl[]
intinlineNest;
!=0 if nested inline
ForeachStatementfes;
if foreach body, this is the foreach
BaseClass*interfaceVirtual;
if virtual, but only appears in base interface vtbl[]
Typetintro;
if !=NULL, then this is the type of the 'introducing' function this one is overriding
STCstorage_class2;
storage class for template onemember's
VarDeclarationnrvo_var;
variable to replace with shidden
void*shidden;
hidden pointer passed to function
GotoStatements*gotos;
Gotos with forward references
BUILTINbuiltin;
set if this is a known, builtin function we can evaluate at compile time
inttookAddressOf;
set if someone took the address of this function
VarDeclarationsclosureVars;
local variables in this function which are referenced by nested functions (They'll get put into the "closure" for this function.)
VarDeclarationsouterVars;
Outer variables which are referenced by this nested function (the inverse of closureVars)
FuncDeclarationssiblingCallers;
Sibling nested functions which called this one
AttributeViolation*safetyViolation;
In case of failed@safe inference, store the error that made the function@system forbetter diagnostics
ObjcFuncDeclarationobjc;
Data for a function declaration that is needed for the Objective-C integration.
final TemplateDeclarationfindTemplateDeclRoot();
find function template root in overload list
final boolinUnittest();
Returns true if function was declared directly or indirectly in a unittest block
final LabelDsymbolsearchLabel(Identifierident, Locloc);
Searches for a label with the given identifier. This function will insert a newLabelDsymbol intolabtab if it does not contain a mapping forident.
Parameters:
Identifieridentidentifier of the requested label
Locloclocation used when creating a newLabelDsymbol
Returns:
theLabelDsymbol forident
final const(char)*toFullSignature();
for diagnostics, e.g. 'int foo(int x, int y) pure'
final boolisAbstract();
Override so it can work even if semantic() hasn't yet been run.
final voidsetThrow(Locloc, const(char)*format, RootObject[]args...);
The function is doing something that may throw an exception, register that in case nothrow is being inferred
Parameters:
Locloclocation of action
const(char)*formatformat string for error message
RootObject[]argsarguments to format string
final voidsetThrowCall(Locloc, FuncDeclarationfd);
The function calls non-nothrow function f, register that in case nothrow is being inferred
Parameters:
Locloclocation of call
FuncDeclarationfdfunction being called
boolisNested() const;
Determine if function needs a static frame pointer.
Returns:
true if function is really nested within other function.

ContractsIf isNested() returns true, isThis() should return false, unless the function needs a dual-context pointer.

inout(AggregateDeclaration)isThis() inout;
Determine if function is a non-static member function that has an implicit 'this' expression.
Returns:
The aggregate it is a member of, or null.

ContractsBoth isThis() and isNested() should return true if function needs a dual-context pointer, otherwise if isThis() returns true, isNested() should return false.

final boolhasNestedFrameRefs();
Determine if function's variables are referenced by a function nested within it.
final ParameterListgetParameterList();
Returns:
the function's parameter list, and whether it is variadic or not.
static FuncDeclarationgenCfunc(Parameters*fparams, Typetreturn, const(char)*name, STCstc = STC.none);
Generate a FuncDeclaration for a runtime library function.
autoMODMatchToBuffer(OutBuffer*buf, ubytelhsMod, ubyterhsMod);
Checks for mismatching modifiers betweenlhsMod andrhsMod and prints themismatching modifiers tobuf.
The modifiers of thelhsMod mismatching the ones with therhsMod are printed, i.e.lhs(shared) vs. rhs() prints "shared", wheras lhs() vs rhs(shared) prints "non-shared".
Parameters:
OutBuffer*bufoutput buffer to write to
ubytelhsModmodifier on the left-hand side
ubytelhsModmodifier on the right-hand side
Returns:
A tuple withisMutable andisNotShared setif thelhsMod is missing those modifiers (compared to rhs).
Examples:
OutBufferbuf;auto mismatches =MODMatchToBuffer(&buf, MODFlags.shared_, 0);assert(buf[] =="`shared` ");assert(!mismatches.isNotShared);buf.setsize(0);mismatches =MODMatchToBuffer(&buf, 0, MODFlags.shared_);assert(buf[] =="non-shared ");assert(mismatches.isNotShared);buf.setsize(0);mismatches =MODMatchToBuffer(&buf, MODFlags.const_, 0);assert(buf[] =="`const` ");assert(!mismatches.isMutable);buf.setsize(0);mismatches =MODMatchToBuffer(&buf, 0, MODFlags.const_);assert(buf[] =="mutable ");assert(mismatches.isMutable);
classFuncAliasDeclaration:dmd.func.FuncDeclaration;
Used as a way to import a set of functions from another scope into this one.
classFuncLiteralDeclaration:dmd.func.FuncDeclaration;
classCtorDeclaration:dmd.func.FuncDeclaration;
classPostBlitDeclaration:dmd.func.FuncDeclaration;
classDtorDeclaration:dmd.func.FuncDeclaration;
classStaticCtorDeclaration:dmd.func.FuncDeclaration;
classSharedStaticCtorDeclaration:dmd.func.StaticCtorDeclaration;
boolstandalone;
Exclude this constructor from cyclic dependency check
classStaticDtorDeclaration:dmd.func.FuncDeclaration;
classSharedStaticDtorDeclaration:dmd.func.StaticDtorDeclaration;
classInvariantDeclaration:dmd.func.FuncDeclaration;
classUnitTestDeclaration:dmd.func.FuncDeclaration;
classNewDeclaration:dmd.func.FuncDeclaration;
structAttributeViolation;
Stores a reason why a function failed to infer a function attribute like@safe orpure
Has two modes:
  • a regular safety error, stored inaction
  • a call to a function without the attribute, which is a special case, because in that case, that function might recursively also have aAttributeViolation. This way, in case of a big call stack, the error can go down all the way to the root cause.
Locloc;
location of error
FuncDeclarationfd;
function is the focus of the violation
stringaction;
Action that made the attribute fail to get inferred
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Fri Feb 20 17:56:28 2026

[8]ページ先頭

©2009-2026 Movatter.jp