replace Context::parent() -> Context::children()
This commit is contained in:
@@ -291,10 +291,12 @@ class Network::ExecutionLambda : public nf7::Lambda {
|
||||
for (const auto& item : owner.items_) {
|
||||
if (auto inode = item->inode()) {
|
||||
if (auto lambda = inode->CreateLambdaForOuterInput()) {
|
||||
AddChild(lambda);
|
||||
input_handlers_.push_back(std::move(lambda));
|
||||
}
|
||||
}
|
||||
if (auto lambda = item->node().CreateLambda()) {
|
||||
AddChild(lambda);
|
||||
subs_[lambda.get()] = SubLambda {.lambda = lambda};
|
||||
lmap[item->id()] = std::move(lambda);
|
||||
}
|
||||
|
7
nf7.cc
7
nf7.cc
@@ -204,13 +204,16 @@ void File::Path::Validate() const {
|
||||
for (const auto& term : terms_) ValidateTerm(term);
|
||||
}
|
||||
|
||||
Context::Context(Env& env, File::Id initiator, const std::weak_ptr<Context>& parent) noexcept :
|
||||
env_(&env), initiator_(initiator), parent_(parent) {
|
||||
Context::Context(Env& env, File::Id initiator) noexcept :
|
||||
env_(&env), initiator_(initiator) {
|
||||
env_->AddContext(*this);
|
||||
}
|
||||
Context::~Context() noexcept {
|
||||
env_->RemoveContext(*this);
|
||||
}
|
||||
void Context::AddChild(const std::shared_ptr<Context>& ctx) noexcept {
|
||||
children_.emplace_back(ctx);
|
||||
}
|
||||
|
||||
void Env::Push(Env& env) noexcept {
|
||||
env_stack_.push_back(&env);
|
||||
|
9
nf7.hh
9
nf7.hh
@@ -212,7 +212,7 @@ class File::NotImplementedException : public Exception {
|
||||
class Context {
|
||||
public:
|
||||
Context() = delete;
|
||||
Context(Env&, File::Id, const std::weak_ptr<Context>& = {}) noexcept;
|
||||
Context(Env&, File::Id) noexcept;
|
||||
virtual ~Context() noexcept;
|
||||
|
||||
virtual void CleanUp() noexcept { }
|
||||
@@ -223,14 +223,17 @@ class Context {
|
||||
|
||||
Env& env() const noexcept { return *env_; }
|
||||
File::Id initiator() const noexcept { return initiator_; }
|
||||
const std::weak_ptr<Context>& parent() const noexcept { return parent_; }
|
||||
std::span<const std::weak_ptr<Context>> children() const noexcept { return children_; }
|
||||
|
||||
protected:
|
||||
void AddChild(const std::shared_ptr<Context>&) noexcept;
|
||||
|
||||
private:
|
||||
Env* const env_;
|
||||
|
||||
const File::Id initiator_;
|
||||
|
||||
std::weak_ptr<Context> parent_;
|
||||
std::vector<std::weak_ptr<Context>> children_;
|
||||
};
|
||||
|
||||
class Env {
|
||||
|
Reference in New Issue
Block a user