aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_utils.erl
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-06-23 19:52:39 +0200
committerBjörn-Egil Dahlberg <[email protected]>2014-08-26 12:12:47 +0200
commitbbabf6204d9ac7083828ced6b9ace97e240794c8 (patch)
treeaba0e9679d50ff9f4556df257459b5d51e06d590 /lib/compiler/src/beam_utils.erl
parent83c35c4e7bcb7cabdad5f8b1082a7bfda9101600 (diff)
downloadotp-bbabf6204d9ac7083828ced6b9ace97e240794c8.tar.gz
otp-bbabf6204d9ac7083828ced6b9ace97e240794c8.tar.bz2
otp-bbabf6204d9ac7083828ced6b9ace97e240794c8.zip
compiler: Use variables in Map beam assmebler
Diffstat (limited to 'lib/compiler/src/beam_utils.erl')
-rw-r--r--lib/compiler/src/beam_utils.erl14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl
index 8ca368c167..e82ba82d38 100644
--- a/lib/compiler/src/beam_utils.erl
+++ b/lib/compiler/src/beam_utils.erl
@@ -26,6 +26,8 @@
code_at/2,bif_to_test/3,is_pure_test/1,
live_opt/1,delete_live_annos/1,combine_heap_needs/2]).
+-export([joineven/2,spliteven/1]).
+
-import(lists, [member/2,sort/1,reverse/1,splitwith/2]).
-record(live,
@@ -832,3 +834,15 @@ x_live([_|Rs], Regs) -> x_live(Rs, Regs);
x_live([], Regs) -> Regs.
is_live(X, Regs) -> ((Regs bsr X) band 1) =:= 1.
+
+%% spliteven/1
+%% [1,2,3,4,5,6] -> {[1,3,5],[2,4,6]}
+spliteven(Rs) -> spliteven(Rs,[],[]).
+spliteven([],Ss,Ds) -> {reverse(Ss),reverse(Ds)};
+spliteven([S,D|Rs],Ss,Ds) ->
+ spliteven(Rs,[S|Ss],[D|Ds]).
+
+%% joineven/1
+%% {[1,3,5],[2,4,6]} -> [1,2,3,4,5,6]
+joineven([],[]) -> [];
+joineven([S|Ss],[D|Ds]) -> [S,D|joineven(Ss,Ds)].