View source code
Display the source code in dmd/dsymbol.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.
Function dmd.dsymbol.Dsymbol.toParentLocal
parent
field returns a lexically enclosing scope symbol this is a member of.
toParent()
returns a logically enclosing scope symbol this is a member of.
It skips over TemplateMixin's.
toParent2()
returns an enclosing scope symbol this is living at runtime.
It skips over both TemplateInstance's and TemplateMixin's.
It's used when looking for the 'this' pointer of the enclosing function/class.
toParentDecl()
similar to toParent2()
but always follows the template declaration scope
instead of the instantiation scope.
toParentLocal()
similar to toParentDecl()
but follows the instantiation scope
if a template declaration is non-local i.e. global or static.
Examples
module mod;
template Foo(alias a) { mixin Bar!(); }
mixin template Bar() {
public { // VisibilityDeclaration
void baz() { a = 2; }
}
}
void test() {
int v = 1;
alias foo = Foo!(v);
foo .baz();
assert(v == 2);
}
// s == FuncDeclaration('mod.test.Foo!().Bar!().baz()')
// s.parent == TemplateMixin('mod.test.Foo!().Bar!()')
// s.toParent() == TemplateInstance('mod.test.Foo!()')
// s.toParent2() == FuncDeclaration('mod.test')
// s.toParentDecl() == Module('mod')
// s.toParentLocal() == FuncDeclaration('mod.test')
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.