summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-11-20 16:59:31 +0100
committertomsmeding <tom.smeding@gmail.com>2016-11-20 16:59:31 +0100
commit91e5244add56bf284142ba332931377622e876c6 (patch)
treeecf51e769c5e669f0e9836fe222b91a2e3658165
parente609a3d6a94163f0dfea814378cd4e2dbed3d8e8 (diff)
Fix definitions not overwriting older defs
-rw-r--r--environment.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/environment.cpp b/environment.cpp
index 1d2c657..cb4b0e4 100644
--- a/environment.cpp
+++ b/environment.cpp
@@ -9,24 +9,28 @@ using namespace std;
void Environment::load(const Environment &other){
- defs.insert(other.defs.begin(),other.defs.end());
- hooks.insert(other.hooks.begin(),other.hooks.end());
+ for(const auto &p : other.defs){
+ defs[p.first]=p.second;
+ }
+ for(const auto &p : other.hooks){
+ hooks[p.first]=p.second;
+ }
}
void Environment::define(const Name &name,const AST &ast){
- defs.insert({name,ast});
+ defs[name]=ast;
}
void Environment::define(const Name &name,const Hook &hook){
- hooks.insert({name,hook});
+ hooks[name]=hook;
}
void Environment::define2(const Name &name,const Hook2 &hook2){
- hooks.insert({name,[hook2](Environment &env,const AST &arg1) -> AST {
+ hooks[name]=[hook2](Environment &env,const AST &arg1) -> AST {
return AST::makeNative([&env,arg1,hook2](const AST &arg2) -> AST {
return hook2(env,arg1,arg2);
});
- }});
+ };
}
AST Environment::get(const Name &name){