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 using a local clone.


Compiler implementation of the D programming language.

Source: attrib.d

abstract class AttribDeclaration: dmd.dsymbol.Dsymbol;
static Scope* createNewScope(Scope* sc, StorageClass stc, LINK linkage, CPPMANGLE cppmangle, Prot protection, int explicitProtection, AlignDeclaration aligndecl, PINLINE inlining);
Create a new scope if one or more given attributes are different from the sc's. If the returned scope != sc, the caller should pop the scope after it used.
Scope* newScope(Scope* sc);
A hook point to supply scope for members. addMember, setScope, importAll, semantic, semantic2 and semantic3 will use this.
final void addLocalClass(ClassDeclarations* aclasses);
class StorageClassDeclaration: dmd.attrib.AttribDeclaration;
class DeprecatedDeclaration: dmd.attrib.StorageClassDeclaration;
Scope* newScope(Scope* sc);
Provides a new scope with STCdeprecated and Scope.depdecl set
Calls StorageClassDeclaration.newScope (as it must be called or copied in any function overriding newScope), then set the Scope's depdecl.
Always a new scope, to use for this DeprecatedDeclaration's members.
class LinkDeclaration: dmd.attrib.AttribDeclaration;
class CPPMangleDeclaration: dmd.attrib.AttribDeclaration;
class ProtDeclaration: dmd.attrib.AttribDeclaration;
this(Loc loc, Prot p, Dsymbols* decl);
Loc loc source location of attribute token
Prot p protection attribute data
Dsymbols* decl declarations which are affected by this protection attribute
this(Loc loc, Identifiers* pkg_identifiers, Dsymbols* decl);
Loc loc source location of attribute token
Identifiers* pkg_identifiers list of identifiers for a qualified package name
Dsymbols* decl declarations which are affected by this protection attribute
class AlignDeclaration: dmd.attrib.AttribDeclaration;
class AnonDeclaration: dmd.attrib.AttribDeclaration;
class PragmaDeclaration: dmd.attrib.AttribDeclaration;
class ConditionalDeclaration: dmd.attrib.AttribDeclaration;
class StaticIfDeclaration: dmd.attrib.ConditionalDeclaration;
Dsymbols* include(Scope* sc);
Different from other AttribDeclaration subclasses, include() call requires the completion of addMember and setScope phases.
class StaticForeachDeclaration: dmd.attrib.AttribDeclaration;
Static foreach at declaration scope, like: static foreach (i; [0, 1, 2]){ }
StaticForeach sfe;
contains static foreach expansion logic
ScopeDsymbol scopesym;
cached enclosing scope (mimics static if declaration)
bool cached;
include can be called multiple times, but a static foreach should be expanded at most once. Achieved by caching the result of the first call. We need both cached and cache, because null is a valid value for cache.
class ForwardingAttribDeclaration: dmd.attrib.AttribDeclaration;
Collection of declarations that stores foreach index variables in a local symbol table. Other symbols declared within are forwarded to another scope, like:
static foreach (i; 0 .. 10) // loop variables for different indices do not conflict. { // this body is expanded into 10 ForwardingAttribDeclarations, where i has storage class STClocal mixin("enum x" ~ to!string(i) ~ " = i"); // ok, can access current loop variable }
static foreach (i; 0.. 10) { pragma(msg, mixin("x" ~ to!string(i))); // ok, all 10 symbols are visible as they were forwarded to the global scope }
static assert (!is(typeof(i))); // loop index variable is not visible outside of the static foreach loop
A StaticForeachDeclaration generates one ForwardingAttribDeclaration for each expansion of its body. The AST of the ForwardingAttribDeclaration contains both the `static foreach variables and the respective copy of the static foreach` body. The functionality is achieved by using a ForwardingScopeDsymbol as the parent symbol for the generated declarations.
Scope* newScope(Scope* sc);
Use the ForwardingScopeDsymbol as the parent symbol for members.
void addMember(Scope* sc, ScopeDsymbol sds);
Lazily initializes the scope to forward to.
class CompileDeclaration: dmd.attrib.AttribDeclaration;
Mixin declarations, like: mixin("int x");
class UserAttributeDeclaration: dmd.attrib.AttribDeclaration;
User defined attributes look like: @(args, ...)