diff --git a/context.h b/context.h index 0c0868e..37479c5 100644 --- a/context.h +++ b/context.h @@ -27,6 +27,18 @@ public: if (!this->parent) delete this->funcs; } + + std::shared_ptr getVariable(const std::string& name) const { + if (this->variables.contains(name)) + return this->variables[name]; + if (this->parent) + return this->parent->getVariable(name); + return nullptr; + } + + void setVariable(const std::string& name, std::shared_ptr value) { + this->variables[name] = std::move(value); + } }; }