Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions inkcpp/include/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ class runner_interface
* to the content at the specified path.
*
* @param path path to search and move execution to
* @param reset_callstack If true, discard the call stack when moving.
* This is the default, safe, behaviour. Otherwise retain the current
* stack as far as possible.
*
* @return If the path was found
*/
virtual bool move_to(hash_t path) = 0;
virtual bool move_to(hash_t path, bool reset_callstack = true) = 0;

/**
* Moves the runner to the specified path.
Expand All @@ -73,9 +77,12 @@ class runner_interface
* to the content at the specified path.
*
* @param path path to search and move execution to
* @param reset_callstack If true, discard the call stack when moving.
* This is the default, safe, behaviour. Otherwise retain the current
* stack as far as possible.
* @return If the path was found
*/
bool move_to(const char* path) { return move_to(ink::hash_string(path)); }
bool move_to(const char* path, bool reset_callstack = true) { return move_to(ink::hash_string(path), reset_callstack); }

/**
* Can the runner continue?
Expand Down
12 changes: 8 additions & 4 deletions inkcpp/runner_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ const char* runner_impl::getline_alloc()
return res;
}

bool runner_impl::move_to(hash_t path)
bool runner_impl::move_to(hash_t path, bool reset_callstack)
{
// find the path
ip_t destination = _story->find_offset_for(path);
Expand All @@ -832,9 +832,13 @@ bool runner_impl::move_to(hash_t path)
return false;
}

// Clear state and move to destination
reset();
_ptr = _story->instructions();
// Clear state if requested,
if (reset_callstack) {
reset();
_ptr = _story->instructions();
}

// Don't track visit (are we sure this is right?)
const bool record_visits = false;
const bool track_knot_visit = false;
jump(destination, record_visits, track_knot_visit);
Expand Down
2 changes: 1 addition & 1 deletion inkcpp/runner_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class runner_impl
virtual const char* getline_alloc() override;

// move to path
virtual bool move_to(hash_t path) override;
virtual bool move_to(hash_t path, bool reset_callstack = true) override;

// move to path but keep as much state as possible
bool migrate_to(const loader& loader, hash_t path);
Expand Down
Loading