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