implement lambda call stack

This commit is contained in:
2022-07-20 18:25:24 +09:00
parent 3ad18e3f0e
commit b443e71b46
7 changed files with 128 additions and 60 deletions

View File

@@ -68,7 +68,8 @@ class Imm final : public nf7::File, public nf7::DirItem, public nf7::Node {
return std::make_unique<Imm>(env, data.type, nf7::Value{data.value});
}
std::shared_ptr<nf7::Lambda> CreateLambda() noexcept override;
std::shared_ptr<nf7::Lambda> CreateLambda(
const std::shared_ptr<nf7::Lambda::Owner>&) noexcept override;
void UpdateNode(Node::Editor&) noexcept override;
@@ -110,7 +111,8 @@ class Imm final : public nf7::File, public nf7::DirItem, public nf7::Node {
class Imm::Lambda final : public nf7::Lambda,
public std::enable_shared_from_this<Imm::Lambda> {
public:
Lambda(Imm& owner) noexcept : value_(owner.mem_.data().value) {
Lambda(Imm& f, const std::shared_ptr<Owner>& owner) noexcept :
nf7::Lambda(owner), value_(f.mem_.data().value) {
}
void Handle(size_t, nf7::Value&&, const std::shared_ptr<nf7::Lambda>& recv) noexcept override {
@@ -120,8 +122,9 @@ class Imm::Lambda final : public nf7::Lambda,
private:
nf7::Value value_;
};
std::shared_ptr<nf7::Lambda> Imm::CreateLambda() noexcept {
return std::make_shared<Imm::Lambda>(*this);
std::shared_ptr<nf7::Lambda> Imm::CreateLambda(
const std::shared_ptr<nf7::Lambda::Owner>& owner) noexcept {
return std::make_shared<Imm::Lambda>(*this, owner);
}