aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/v3_kernel.erl
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-01-23 13:38:47 +0100
committerFredrik Gustafsson <[email protected]>2013-01-23 13:38:47 +0100
commite6c35e1d4a7b9dc0683c7703efa8f1e06680843d (patch)
tree72cdd29507666ce28b91dde8246a66ea72d98515 /lib/compiler/src/v3_kernel.erl
parent47de15b52c46bce34c9e0a172e54411622eb08f1 (diff)
downloadotp-e6c35e1d4a7b9dc0683c7703efa8f1e06680843d.tar.gz
otp-e6c35e1d4a7b9dc0683c7703efa8f1e06680843d.tar.bz2
otp-e6c35e1d4a7b9dc0683c7703efa8f1e06680843d.zip
Revert "Merge branch 'nox/rm-reverse-eta-conversion/OTP-10682'"
This reverts commit 750ecdea08fa5fa7e32b7f3019eed96c1699427e, reversing changes made to 2cfa0466c3b3c7bd5e3621aff0f3e2ca30addb68.
Diffstat (limited to 'lib/compiler/src/v3_kernel.erl')
-rw-r--r--lib/compiler/src/v3_kernel.erl31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl
index b1bff47f69..8ef71e1346 100644
--- a/lib/compiler/src/v3_kernel.erl
+++ b/lib/compiler/src/v3_kernel.erl
@@ -235,8 +235,16 @@ gexpr_test_add(Ke, St0) ->
%% expr(Cexpr, Sub, State) -> {Kexpr,[PreKexpr],State}.
%% Convert a Core expression, flattening it at the same time.
-expr(#c_var{anno=A,name={Name,Arity}}, Sub, St) ->
- {#k_local{anno=A,name=get_fsub(Name, Arity, Sub),arity=Arity},[],St};
+expr(#c_var{anno=A,name={_Name,Arity}}=Fname, Sub, St) ->
+ %% A local in an expression.
+ %% For now, these are wrapped into a fun by reverse
+ %% etha-conversion, but really, there should be exactly one
+ %% such "lambda function" for each escaping local name,
+ %% instead of one for each occurrence as done now.
+ Vs = [#c_var{name=list_to_atom("V" ++ integer_to_list(V))} ||
+ V <- integers(1, Arity)],
+ Fun = #c_fun{anno=A,vars=Vs,body=#c_apply{anno=A,op=Fname,args=Vs}},
+ expr(Fun, Sub, St);
expr(#c_var{anno=A,name=V}, Sub, St) ->
{#k_var{anno=A,name=get_vsub(V, Sub)},[],St};
expr(#c_literal{anno=A,val=V}, _Sub, St) ->
@@ -1655,19 +1663,6 @@ uexpr(#ifun{anno=A,vars=Vs,body=B0}, {break,Rs}, St0) ->
#k_int{val=Index},#k_int{val=Uniq}|Fvs],
ret=Rs},
Free,add_local_function(Fun, St)};
-uexpr(#k_local{anno=A,name=Name,arity=Arity}, {break,Rs}, St) ->
- Fs = get_free(Name, Arity, St),
- FsCount = length(Fs),
- Free = lit_list_vars(Fs),
- %% Set dummy values for Index and Uniq -- the real values will
- %% be assigned by beam_asm.
- Index = Uniq = 0,
- Bif = #k_bif{anno=#k{us=Free,ns=lit_list_vars(Rs),a=A},
- op=#k_internal{name=make_fun,arity=FsCount+3},
- args=[#k_atom{val=Name},#k_int{val=FsCount+Arity},
- #k_int{val=Index},#k_int{val=Uniq}|Fs],
- ret=Rs},
- {Bif,Free,St};
uexpr(Lit, {break,Rs0}, St0) ->
%% Transform literals to puts here.
%%ok = io:fwrite("uexpr ~w:~p~n", [?LINE,Lit]),
@@ -1848,6 +1843,12 @@ make_list(Es) ->
#c_cons{hd=E,tl=Acc}
end, #c_literal{val=[]}, Es).
+%% List of integers in interval [N,M]. Empty list if N > M.
+
+integers(N, M) when N =< M ->
+ [N|integers(N + 1, M)];
+integers(_, _) -> [].
+
%% is_in_guard(State) -> true|false.
is_in_guard(#kern{guard_refc=Refc}) ->