dmd.dsymbol
The base class for a D symbol, which can be a module, variable, function, enum, etc.
License
Source: dsymbol.d
Documentation: https://dlang.org/phobos/dmd_dsymbol.html
-
Declaration
int
foreachDsymbol
(Dsymbols*symbols
, scope int delegate(Dsymbol)dg
);Calls
dg
(Dsymbol *sym) for each Dsymbol. Ifdg
returns !=0, stops and returns that value else returns 0.Parameters
Dsymbols*
symbols
Dsymbols
int delegate(Dsymbol)
dg
delegate to call for each Dsymbol
Return Value
last value returned by
dg
()See Also
-
Declaration
void
foreachDsymbol
(Dsymbols*symbols
, scope void delegate(Dsymbol)dg
);Calls
dg
(Dsymbol *sym) for each Dsymbol.Parameters
Dsymbols*
symbols
Dsymbols
void delegate(Dsymbol)
dg
delegate to call for each Dsymbol
See Also
-
Declaration
class
Dsymbol
: dmd.ast_node.ASTNode;-
Declaration
CPPNamespaceDeclaration
cppnamespace
;C++ namespace this symbol belongs to
-
Declaration
final Module
getModule
();Determine which Module a Dsymbol is in.
-
Declaration
final Module
getAccessModule
();Determine which Module a Dsymbol is in, as far as access rights go.
-
Declaration
final inout inout(Dsymbol)
pastMixin
();
returns the enclosing symbol if this is a template mixin.pastMixin
Discussion
pastMixinAndNspace
does likewise, additionally skipping over Nspaces that are mangleOnly.
See alsoparent
,toParent
andtoParent2
. -
Declaration
final inout inout(Dsymbol)
toParent
();
final inout inout(Dsymbol)toParent2
();
final inout inout(Dsymbol)toParentDecl
();
final inout inout(Dsymbol)toParentLocal
();parent
field returns a lexically enclosing scope symbol this is a member of.Discussion
returns a logically enclosing scope symbol this is a member of. It skips over TemplateMixin's.toParent
()
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.toParent2
()
similar totoParentDecl
()
but always follows the template declaration scope instead of the instantiation scope.toParent2
()
similar totoParentLocal
()
but follows the instantiation scope if a template declaration is non-local i.e. global or static.toParentDecl
()Examples
module mod; template Foo(alias a) { mixin Bar!(); } mixin template Bar() { public { // ProtDeclaration 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')
-
Declaration
final Dsymbol
toParentP
(Dsymbolp1
, Dsymbolp2
= null);Returns the declaration scope scope of
this
unless any of the symbols
orp1
resides in its enclosing instantiation scope then the latter is returned.p2
-
Declaration
final bool
followInstantiationContext
(Dsymbolp1
, Dsymbolp2
= null);Returns
true
if any of the symbols
orp1
resides in the enclosing instantiation scope ofp2
this
. -
Declaration
static Dsymbols*
arraySyntaxCopy
(Dsymbols*a
);Do syntax copy of an array of Dsymbol's.
-
Declaration
Dsymbol
toAlias
();If this symbol is really an alias for another, return that other. If needed, semantic() is invoked due to resolve forward reference.
-
Declaration
Dsymbol
toAlias2
();Resolve recursive tuple expansion in eponymous template.
-
Declaration
void
setScope
(Scope*sc
);Set scope for future semantic analysis so we can deal better with forward references.
-
Declaration
Dsymbol
search
(ref const Locloc
, Identifierident
, intflags
= IgnoreNone);Search for
ident
as member of s.Parameters
Loc
loc
location to print for error messages
Identifier
ident
identifier to
search
forint
flags
IgnoreXXXX
Return Value
null
if not found -
Declaration
final Dsymbol
searchX
(ref const Locloc
, Scope*sc
, RootObjectid
, intflags
);Search for identifier
id
as a member ofthis
.
may be a template instance.id
Parameters
Loc
loc
location to print the error messages
Scope*
sc
the scope where the symbol is located
RootObject
id
the
id
of the symbolint
flags
the search
flags
which can beSearchLocalsOnly
orIgnorePrivateImports
Return Value
symbol found, NULL if not
-
Declaration
d_uns64
size
(ref const Locloc
);Return Value
SIZE_INVALID when the
size
cannot be determined -
Declaration
final inout inout(AggregateDeclaration)
isMember
();Returns an AggregateDeclaration when toParent() is that.
-
Declaration
final inout inout(AggregateDeclaration)
isMember2
();Returns an AggregateDeclaration when toParent2() is that.
-
Declaration
final inout inout(AggregateDeclaration)
isMemberDecl
();Returns an AggregateDeclaration when toParentDecl() is that.
-
Declaration
final inout inout(AggregateDeclaration)
isMemberLocal
();Returns an AggregateDeclaration when toParentLocal() is that.
-
Declaration
pure nothrow @nogc @safe Prot
prot
(); -
Declaration
Dsymbol
syntaxCopy
(Dsymbols
);Copy the syntax. Used for template instantiations. If
s
is NULL, allocate the new object, otherwise fill it in. -
Declaration
bool
oneMember
(Dsymbol*ps
, Identifierident
);Determine if this symbol is only one.
Return Value
false
, *ps
= NULL: There are 2 or more symbolstrue
, *ps
= NULL: There are zero symbolstrue
, *ps
= symbol: The one and only one symbol -
Declaration
static bool
oneMembers
(Dsymbols*members
, Dsymbol*ps
, Identifierident
);Same as Dsymbol::oneMember(), but look at an array of Dsymbols.
-
Declaration
bool
hasPointers
();Is Dsymbol a variable that contains pointers?
-
Declaration
void
addComment
(const(char)*comment
);Add documentation
comment
to Dsymbol. Ignore NULL comments. -
Declaration
final bool
inNonRoot
();Returns
true
if this symbol is defined in a non-root module without instantiation. -
Declaration
void
accept
(Visitorv
);
-
-
Declaration
class
ScopeDsymbol
: dmd.dsymbol.Dsymbol;Dsymbol that generates a scope
-
Declaration
Dsymbol
search
(ref const Locloc
, Identifierident
, intflags
= SearchLocalsOnly);This function is #1 on the list of functions that eat cpu time. Be very, very careful about slowing it down.
-
Declaration
final FuncDeclaration
findGetMembers
();Look for member of the form: const(MemberInfo)[] getMembers(string); Returns NULL if not found
-
Declaration
Dsymbol
symtabLookup
(Dsymbols
, Identifierid
);Look up identifier in symbol table.
-
Declaration
bool
hasStaticCtorOrDtor
();Return
true
if any of the members are static ctors or static dtors, or if any members have members that are. -
Declaration
static int
_foreach
(Scope*sc
, Dsymbols*members
, scope ForeachDgdg
, size_t*pn
= null);Expands attribute declarations in
members
in depth first order. Callsdg
(size_t symidx, Dsymbol *sym) for each member. Ifdg
returns !=0, stops and returns that value else returns 0. Use this function to avoid the O(N + N^2/2) complexity of calculating dim and calling N times getNth.Return Value
last value returned by
dg
()
-
-
Declaration
class
WithScopeSymbol
: dmd.dsymbol.ScopeDsymbol;With statement scope
-
Declaration
class
ArrayScopeSymbol
: dmd.dsymbol.ScopeDsymbol;Array Index/Slice scope
-
Declaration
Dsymbol
search
(ref const Locloc
, Identifierident
, intflags
= IgnoreNone);This override is used to solve
$
-
-
Declaration
class
OverloadSet
: dmd.dsymbol.Dsymbol;Overload Sets
-
Declaration
class
ForwardingScopeDsymbol
: dmd.dsymbol.ScopeDsymbol;Forwarding ScopeDsymbol. Used by ForwardingAttribDeclaration and ForwardingScopeDeclaration to forward symbol insertions to another scope. See
dmd.attrib.ForwardingAttribDeclaration
for more details.-
Declaration
ScopeDsymbol
forward
;Symbol to
forward
insertions to. Can benull
before being lazily initialized. -
Declaration
Dsymbol
symtabLookup
(Dsymbols
, Identifierid
);This override handles the following two cases: static foreach (i, i; [0]) { ... } and static foreach (i; [0]) { enum i = 2; }
-
-
Declaration
class
ExpressionDsymbol
: dmd.dsymbol.Dsymbol;Class that holds an expression in a Dsymbol wraper. This is not an AST node, but a class used to pass an expression as a function parameter of type Dsymbol.
-
Declaration
class
DsymbolTable
: dmd.root.rootobject.RootObject;Table of Dsymbol's
-
Declaration
const pure size_t
length
();Return Value
number of symbols in symbol table
-