@@ -96,6 +96,9 @@ elixir_to_erl(Tree, Ann) when is_binary(Tree) ->
96
96
% % considers a string in a binary to be encoded in latin1, so the bytes
97
97
% % are not changed in any fashion.
98
98
{bin , Ann , [{bin_element , Ann , {string , Ann , binary_to_list (Tree )}, default , default }]};
99
+ elixir_to_erl (Tree , Ann ) when is_bitstring (Tree ) ->
100
+ Segments = [elixir_to_erl_bitstring_segment (X , Ann ) || X <- bitstring_to_list (Tree )],
101
+ {bin , Ann , Segments };
99
102
elixir_to_erl (Tree , Ann ) when is_function (Tree ) ->
100
103
case (erlang :fun_info (Tree , type ) == {type , external }) andalso
101
104
(erlang :fun_info (Tree , env ) == {env , []}) of
@@ -115,6 +118,13 @@ elixir_to_erl(Tree, Ann) ->
115
118
elixir_to_erl_cons ([H | T ], Ann ) -> {cons , Ann , elixir_to_erl (H , Ann ), elixir_to_erl_cons (T , Ann )};
116
119
elixir_to_erl_cons (T , Ann ) -> elixir_to_erl (T , Ann ).
117
120
121
+ elixir_to_erl_bitstring_segment (Int , Ann ) when is_integer (Int ) ->
122
+ {bin_element , Ann , {integer , Ann , Int }, default , [integer ]};
123
+ elixir_to_erl_bitstring_segment (Rest , Ann ) when is_bitstring (Rest ) ->
124
+ Size = bit_size (Rest ),
125
+ <<Int :Size >> = Rest ,
126
+ {bin_element , Ann , {integer , Ann , Int }, {integer , Ann , Size }, [integer ]}.
127
+
118
128
% % Returns a scope for translation.
119
129
120
130
scope (_Meta , ExpandCaptures ) ->
0 commit comments