class IndexWalker

Defined at line 33 of file ../../src/developer/debug/zxdb/expr/index_walker.h

Provides an interface to walk the symbol index by component. This is used to iterate over the

the current namespace looking for matches.

This search is extra complicated because each index node is separated by child type (namespaces,

functions, etc.). This means there can be more than one path to a given identifier depending on

the types of things.

This class provides an interface that walks into all such matches. This means that at any

given level there can be multiple "current" nodes (this list is called a "Stage"). The "path_"

is the hierarchy of these stages.

It's possible for this graph to explode but the branching factor is currently only 4, and in

practice it will almost always be 1 and will rarely be 2 (there are two different classes of

symbol with the same name). As a result, an explosion of items to iterate over is unlikely.

Public Methods

const Stage & current ()

There should always be a "current" item which is at least the root of the index.

Defined at line 43 of file ../../src/developer/debug/zxdb/expr/index_walker.h

void IndexWalker (const Index * index)

Starts from the root scope in the index. The pointer must outlive this class.

Defined at line 53 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

void ~IndexWalker ()

Defined at line 62 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool WalkUp ()

Goes up one level. If the current scope is "my_namespace::MyClass", the new scope will be

"my_namespace". Returns true if anything happened. Returns false if the current location is at

the root already.

Defined at line 64 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool WalkInto (const ParsedIdentifierComponent & comp)

Moves to the children of the current component that's an exact match of the given component

name. Returns true if there was a match, false if not (in which case the location has not

changed).

This ignores the separator, so if the input component is "::foo" this won't be treated as

the global name "foo" and go back to the root as C++ would, but will instead go into "foo" from

the current location. This is because this function will be called for each sub-component of an

identifier, and all non-toplevel components will have separators.

Defined at line 76 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool WalkInto (const ParsedIdentifier & ident)

Moves to the children of the current component that matches the given identifier (following all

components). Returns true if there was a match, false if not (in which case the location has

not changed).

NOTE: this does not treat identifiers that start with "::" differently, so will always attempt

to do a relative name resolution. Handling which scopes to search in is the job of the caller.

Defined at line 127 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

void WalkIntoSpecific (const IndexNode * node)

Walks into a specific node. This node should be a child of one of the current() nodes. This

is used when code identifies a specific child rather than a general name it wants to walk

into.

Defined at line 137 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool WalkIntoClosest (const ParsedIdentifier & ident)

Like WalkInto but does a best effort and always commits the results. This is typically used to

move to the starting point in an index for searching: just because that exact namespace isn't

in the index, doesn't mean one can't resolve variables in it.

If given "foo::Bar", and "foo" exists but has no "Bar inside of it, this will walk to "foo" and

returns false. If "Bar" did exist, it would walk into it and return true.

Defined at line 139 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool ComponentMatches (const std::string & index_string, const ParsedIdentifierComponent & comp)

Returns true if the given component matches the given string from the index. This will do

limited canonicalization on the index string so a comparison of template parameters is

possible.

Defined at line 151 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool ComponentMatchesNameOnly (const std::string & index_string, const ParsedIdentifierComponent & comp)

Returns true if the component name matches the stuff in the index string before any template

parameters.

Defined at line 160 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool ComponentMatchesTemplateOnly (const std::string & index_string, const ParsedIdentifierComponent & comp)

Returns true if the template parts of the component match a canonicalized version of the

template parameters extracted from the index string.

Defined at line 175 of file ../../src/developer/debug/zxdb/expr/index_walker.cc

bool IsIndexStringBeyondName (std::string_view index_name, std::string_view name)

Returns true if all templates using the given base |name| will be before the given indexed name

in an index sorted by ASCII string values.

Defined at line 195 of file ../../src/developer/debug/zxdb/expr/index_walker.cc