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.
dmd.attrib
Defines declarations of various attributes.
The term 'attribute' refers to things that can apply to a larger scope than a single declaration.
Among them are:
- Alignment (align(8))
- User defined attributes (@UDA)
- Function Attributes (@safe)
- Storage classes (static, __gshared)
- Mixin declarations (mixin("int x;"))
- Conditional compilation (static if, static foreach)
- Linkage (extern(C))
- Anonymous structs / unions
- Protection (private, public)
- Deprecated declarations (@deprecated)
Authors:
License:
Source attrib.d
Documentation https://dlang.org/phobos/dmd_attrib.html
- abstract class
AttribDeclaration
: dmd.dsymbol.Dsymbol; -
- static Scope*
createNewScope
(Scope*sc
, StorageClassstc
, LINKlinkage
, CPPMANGLEcppmangle
, Protprotection
, intexplicitProtection
, AlignDeclarationaligndecl
, PINLINEinlining
); - 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 STC.deprecated_ and Scope.depdecl setCalls StorageClassDeclaration.
newScope
(as it must be called or copied in any function overridingnewScope
), then set the Scope's depdecl.Returns:Always a new scope, to use for this DeprecatedDeclaration's members.
- class
LinkDeclaration
: dmd.attrib.AttribDeclaration; - class
CPPMangleDeclaration
: dmd.attrib.AttribDeclaration; - class
CPPNamespaceDeclaration
: dmd.attrib.AttribDeclaration; - A node to represent an extern(C++) namespace attributeThere are two ways to declarate a symbol as member of a namespace: Nspace and
CPPNamespaceDeclaration
. The former creates a scope for the symbol, and inject them in the parent scope at the same time. The later, this class, has no semantic implications and is only used for mangling. Additionally, this class allows one to use reserved identifiers (D keywords) in the namespace. ACPPNamespaceDeclaration
can be created from an Identifier (already resolved) or from an Expression, which is CTFE-ed and can be either a TupleExp, in which can additionalCPPNamespaceDeclaration
nodes are created, or a StringExp. Note that this class, like Nspace, matches only one identifier part of a namespace. For the namespace "foo::bar", the will be aCPPNamespaceDeclaration
with its ident set to "bar", and its namespace field pointing to anotherCPPNamespaceDeclaration
with its ident set to "foo".- Expression
exp
; - CTFE-able expression, resolving to TupleExp or StringExp
- Scope*
newScope
(Scope*sc
); - Returns:A copy of the parent scope, with this as namespace and C++ linkage
- class
ProtDeclaration
: dmd.attrib.AttribDeclaration; -
- this(ref const Loc
loc
, Protprotection
, Dsymbols*decl
); - Parameters:
Loc loc
source location of attribute token Prot protection
protection attribute data Dsymbols* decl
declarations which are affected by this protection attribute - this(ref const Loc
loc
, Identifiers*pkg_identifiers
, Dsymbols*decl
); - Parameters:
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
onStack
; - 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 STC.local 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
, ScopeDsymbolsds
); - Lazily initializes the scope to forward to.
- class
CompileDeclaration
: dmd.attrib.AttribDeclaration; - Mixin declarations, like: mixin("int x"); https://dlang.org/spec/module.html#mixin-declaration
- class
UserAttributeDeclaration
: dmd.attrib.AttribDeclaration; - User defined attributes look like: @foo(args, ...) @(args, ...)
- static bool
isGNUABITag
(Expressione
); - Check if the provided expression references core.attribute.gnuAbiTagThis should be called after semantic has been run on the expression. Semantic on UDA happens in semantic2 (see dmd.semantic2).Parameters:
Expression e
Expression to check (usually from UserAttributeDeclaration.atts) Returns:true if the expression references the compiler-recognized gnuAbiTag - static void
checkGNUABITag
(Dsymbolsym
, LINKlinkage
); - Called from a symbol's semantic to check if gnuAbiTag UDA can be applied to themDirectly emits an error if the UDA doesn't work with this symbolParameters:
Dsymbol sym
symbol to check for gnuAbiTag LINK linkage
Linkage of the symbol (Declaration.link or sc.link)
Copyright © 1999-2022 by the D Language Foundation | Page generated by
Ddoc on (no date time)