View source code
Display the source code in dmd/attrib.d from which this page was generated on github.
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 local clone.

Class dmd.attrib.ForwardingAttribDeclaration

Collection of declarations that stores foreach index variables in a local symbol table. Other symbols declared within are forwarded to another scope, like:

class ForwardingAttribDeclaration
  : AttribDeclaration ;

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.

Methods

NameDescription
addMember Lazily initializes the scope to forward to.
newScope Use the ForwardingScopeDsymbol as the parent symbol for members.
accept
addComment Add documentation comment to Dsymbol. Ignore NULL comments.
addLocalClass
apply Iterate this dsymbol or members of this scoped dsymbol, then call fp with the found symbol and param.
arraySyntaxCopy Do syntax copy of an array of Dsymbol's.
createNewScope 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.
factory Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor.
getAccessModule Determine which Module a Dsymbol is in, as far as access rights go.
getModule Determine which Module a Dsymbol is in.
hasPointers Is Dsymbol a variable that contains pointers?
inNonRoot Returns true if this symbol is defined in a non-root module without instantiation.
isMember Returns an AggregateDeclaration when toParent() is that.
isMember2 Returns an AggregateDeclaration when toParent2() is that.
oneMember Determine if this symbol is only one.
oneMembers Same as Dsymbol::oneMember(), but look at an array of Dsymbols.
opCmp Compare with another Object obj.
opEquals Test whether this is equal to o. The default implementation only compares by identity (using the is operator). Generally, overrides for opEquals should attempt to compare objects by their contents.
pastMixin pastMixin returns the enclosing symbol if this is a template mixin.
pastMixinAndNspace pastMixin returns the enclosing symbol if this is a template mixin.
prot
search Search for ident as member of s.
searchX Search for identifier id as a member of this. id may be a template instance.
setScope Set scope for future semantic analysis so we can deal better with forward references.
size
syntaxCopy Copy the syntax. Used for template instantiations. If s is NULL, allocate the new object, otherwise fill it in.
toAlias If this symbol is really an alias for another, return that other. If needed, semantic() is invoked due to resolve forward reference.
toAlias2 Resolve recursive tuple expansion in eponymous template.
toHash Compute hash function for Object.
toParent parent field returns a lexically enclosing scope symbol this is a member of.
toParent2 parent field returns a lexically enclosing scope symbol this is a member of.
toParent3 parent field returns a lexically enclosing scope symbol this is a member of.
toString
toString Convert Object to a human readable string.

Authors

Walter Bright

License

Boost License 1.0