From be2e04aac78b04b4f016c3e0920388bd5c7f5ac6 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Mon, 21 Oct 2019 21:48:00 +0200 Subject: Fixes apply('bind'), optimizes 'bind', 'ternary'. --- src/ataxic.erl | 4 +++- src/ataxic_optimize.erl | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ataxic.erl b/src/ataxic.erl index bb9e561..2993639 100644 --- a/src/ataxic.erl +++ b/src/ataxic.erl @@ -155,7 +155,9 @@ apply_basic_to (#letr{ bindings = Bindings, op = OP }, Val, S0Mem) -> S1Mem = lists:foldl ( - fun ({Key, Value}, Memory) -> dict:store(Key, Value, Memory) end, + fun ({Key, Value}, Memory) -> + dict:store(Key, apply_basic_to(Value, Val, Memory), Memory) + end, S0Mem, Bindings ), diff --git a/src/ataxic_optimize.erl b/src/ataxic_optimize.erl index 39f45f7..cf6cd3a 100644 --- a/src/ataxic_optimize.erl +++ b/src/ataxic_optimize.erl @@ -303,6 +303,20 @@ aggressive (In = #value{ op = OP }) -> In#value{ op = aggressive(OP) }; aggressive (In = #mseq{ ops = OPs }) -> In#mseq{ ops = lists:map(fun aggressive/1, OPs) }; +aggressive (In = #letr{ bindings = Bs, op = OP }) -> + In#letr + { + op = aggressive(OP), + bindings = + lists:map(fun ({Key, Value}) -> {Key, aggressive(Value)} end, Bs) + }; +aggressive (In = #tern{ condition = C, then = T, else = E }) -> + In#tern + { + condition = aggressive(C), + then = aggressive(T), + else = aggressive(E) + }; aggressive (Other) -> Other. -- cgit v1.2.3-70-g09d2