add: get/set var
This commit is contained in:
parent
8be5386075
commit
74ad9cfe2c
12
context.h
12
context.h
|
|
@ -27,6 +27,18 @@ public:
|
||||||
if (!this->parent)
|
if (!this->parent)
|
||||||
delete this->funcs;
|
delete this->funcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Value> 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> value) {
|
||||||
|
this->variables[name] = std::move(value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue