Compiler implementation of the D programming language.
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.
A hook point to supply scope for members. addMember, setScope, importAll, semantic, semantic2 and semantic3 will use this.
Provides a new scope with STC.deprecated_
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.
DeprecatedDeclaration
's members.A node to represent an extern(C++)
namespace attribute
There 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.
A CPPNamespaceDeclaration
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 additional CPPNamespaceDeclaration
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 a CPPNamespaceDeclaration
with its ident
set to "bar"
, and its namespace
field pointing to another CPPNamespaceDeclaration
with its ident
set to "foo"
.
CTFE-able expression, resolving to TupleExp
or StringExp
this
as namespace
and C++ linkageLoc loc
| source location of attribute token |
Prot protection
| protection attribute data |
Dsymbols* decl
| declarations which are affected by this protection attribute |
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 |
Different from other AttribDeclaration subclasses, include() call requires the completion of addMember and setScope phases.
Static foreach at declaration scope, like: static foreach (i; [0, 1, 2]){ }
contains static foreach
expansion logic
cached enclosing scope (mimics static if
declaration)
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
.
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.
Use the ForwardingScopeDsymbol as the parent symbol for members.
Lazily initializes the scope to forward to.
Mixin declarations, like: mixin("int x"); https://dlang.org/spec/module.html#mixin-declaration
User defined attributes look like: @foo(args, ...) @(args, ...)
© 1999–2019 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/dmd_attrib.html