mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Name refactoring.
This commit is contained in:
parent
471ed98277
commit
97235c313b
@ -103,13 +103,13 @@ private:
|
||||
if (fv.params.size() <= args.size()) {
|
||||
auto callEnv = make_shared<Environment>();
|
||||
|
||||
callEnv->declare("self", f, false);
|
||||
callEnv->initialize("self", f, false);
|
||||
|
||||
for (auto i = 0u; i < fv.params.size(); i++) {
|
||||
auto param = fv.params[i];
|
||||
auto arg = args[i];
|
||||
auto val = eval(*arg, env);
|
||||
callEnv->declare(param.name, val, param.mut);
|
||||
callEnv->initialize(param.name, val, param.mut);
|
||||
}
|
||||
|
||||
return fv.eval(callEnv);
|
||||
@ -167,7 +167,7 @@ private:
|
||||
if (env->has(var)) {
|
||||
env->assign(var, val);
|
||||
} else {
|
||||
env->declare(var, val, mut == "mut");
|
||||
env->initialize(var, val, mut == "mut");
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
@ -217,15 +217,17 @@ struct Environment
|
||||
outer_->assign(s, val);
|
||||
return;
|
||||
}
|
||||
// NOTREACHED
|
||||
throw std::logic_error("invalid internal condition.");
|
||||
}
|
||||
|
||||
void declare(const std::string& s, const Value& val, bool mut) {
|
||||
void initialize(const std::string& s, const Value& val, bool mut) {
|
||||
assert(!has(s));
|
||||
dic_[s] = Symbol{val, mut};
|
||||
}
|
||||
|
||||
void setup_built_in_functions() {
|
||||
declare(
|
||||
initialize(
|
||||
"pp",
|
||||
Value(Value::FunctionValue {
|
||||
{ {"arg", true} },
|
||||
|
Loading…
Reference in New Issue
Block a user