aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 76c038593..fba5f5031 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -712,6 +712,34 @@ void printStaticEnvBindings(const Expr &expr)
}
+void mapStaticEnvBindings(const StaticEnv &se, const Env &env, valmap & vm)
+{
+ // add bindings for the next level up first.
+ if (env.up && se.up) {
+ mapStaticEnvBindings( *se.up, *env.up,vm);
+ }
+
+ // iterate through staticenv bindings.
+
+ auto map = valmap();
+ for (auto iter = se.vars.begin(); iter != se.vars.end(); ++iter)
+ {
+ map[iter->first] = env.values[iter->second];
+ }
+
+ vm.merge(map);
+
+}
+
+
+valmap * mapStaticEnvBindings(const StaticEnv &se, const Env &env)
+{
+ auto vm = new valmap();
+ mapStaticEnvBindings(se, env, *vm);
+ return vm;
+}
+
+
void printEnvPosChain(const Env &env, int lv )
{
std::cout << "printEnvPosChain " << lv << std::endl;