Skip to content

Commit

Permalink
refactor(core): remove state snapshot functionality and add debug Las…
Browse files Browse the repository at this point in the history
…tError shard
  • Loading branch information
sinkingsugar committed Jan 15, 2025
1 parent 3db1e3f commit 17e62b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
14 changes: 0 additions & 14 deletions shards/core/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,6 @@ struct SHContext {
return out;
}

SHStateSnapshot takeStateSnapshot() {
return SHStateSnapshot{
state,
std::move(flowStorage),
std::move(errorMessage),
};
}

void restoreStateSnapshot(SHStateSnapshot &&snapshot) {
errorMessage = std::move(snapshot.errorMessage);
state = std::move(snapshot.state);
flowStorage = std::move(snapshot.flowStorage);
}

constexpr void rebaseFlow() { state = SHWireState::Rebase; }

constexpr void continueFlow() { state = SHWireState::Continue; }
Expand Down
13 changes: 13 additions & 0 deletions shards/modules/debug/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ struct DumpWireStack {
}
};

struct LastError {
static SHTypesInfo inputTypes() { return shards::CoreInfo::AnyType; }
static SHTypesInfo outputTypes() { return shards::CoreInfo::AnyType; }
static SHOptionalString help() { return SHCCSTR("Outputs the last error"); }

OwnedVar _lastError;

SHVar &activate(SHContext *shContext, const SHVar &input) {
_lastError = Var(shContext->getErrorMessage());
return _lastError;
}
};
} // namespace shards::Debug

namespace shards {
Expand All @@ -96,5 +108,6 @@ SHARDS_REGISTER_FN(debug) {
REGISTER_SHARD("Debug.Noop", DebugNoop);
REGISTER_SHARD("Debug.DumpEnv", DumpEnv);
REGISTER_SHARD("Debug.WireStack", DumpWireStack);
REGISTER_SHARD("Debug.LastError", LastError);
}
} // namespace shards

0 comments on commit 17e62b8

Please sign in to comment.