From 91e5244add56bf284142ba332931377622e876c6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 20 Nov 2016 16:59:31 +0100 Subject: Fix definitions not overwriting older defs --- environment.cpp | 16 ++++++++++------ 1 file 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){ -- cgit v1.2.3-70-g09d2