WIP: implement the recursive scope expansion
Only a Record payload constitutes a nested scope. For all other (primitive) values, we return an empty iterator. When used within ScopeExplorer, this implementation will just lead to exposing any simple value once, while delving into iteration of nested scopes
This commit is contained in:
parent
3f91997cf1
commit
823b4fd322
1 changed files with 18 additions and 2 deletions
|
|
@ -257,7 +257,7 @@ namespace diff{
|
|||
|
||||
|
||||
|
||||
/** @internal diagnostics helper. Need to include format-helper.cpp */
|
||||
/** @internal diagnostics helper. Include format-helper.cpp on use */
|
||||
operator string() const
|
||||
{
|
||||
return "GenNode-"+string(idi)+"-"+string(data);
|
||||
|
|
@ -406,6 +406,8 @@ namespace diff{
|
|||
|
||||
/**
|
||||
* Building block for monad-like depth-first expansion of a GenNode.
|
||||
* When used within lib::IterStateWrapper, the result is an Iterator
|
||||
* to visit the contents of a GenNodet tree recursively depth-fist.
|
||||
*/
|
||||
class GenNode::ScopeExplorer
|
||||
{
|
||||
|
|
@ -439,7 +441,7 @@ namespace diff{
|
|||
iterNext (ScopeExplorer & explorer)
|
||||
{
|
||||
ScopeIter& current = explorer.scopes_.back();
|
||||
explorer.scopes_.emplace_back(current->data.expand());
|
||||
explorer.scopes_.emplace_back (current->data.expand());
|
||||
++current;
|
||||
while (!explorer.scopes_.empty() && !explorer.scopes_.back())
|
||||
explorer.scopes_.pop_back();
|
||||
|
|
@ -447,6 +449,20 @@ namespace diff{
|
|||
};
|
||||
|
||||
|
||||
/** @internal Core operation to expand nested scopes recursively */
|
||||
DataCap::Locator
|
||||
DataCap::expand() const
|
||||
{
|
||||
Rec* val = unConst(this)->maybeGet<Rec>();
|
||||
if (!val)
|
||||
return Locator();
|
||||
else
|
||||
return Locator(*val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for a specially crafted 'ref GenNode'.
|
||||
* The identity record of the generated object will be prepared
|
||||
|
|
|
|||
Loading…
Reference in a new issue