11-module (elixir_quote ).
2- -export ([escape /3 , linify /3 , linify_with_context_counter /3 , build /7 , quote /5 , has_unquotes /1 , fun_to_quoted /1 ]).
2+ -export ([escape /3 , linify /3 , linify_with_context_counter /3 , build /8 , quote /3 , has_unquotes /1 , fun_to_quoted /1 ]).
33-export ([dot /5 , tail_list /3 , list /2 , validate_runtime /2 ]). % % Quote callbacks
44
55-include (" elixir.hrl" ).
@@ -200,7 +200,7 @@ bad_escape(Arg) ->
200200
201201% % Quote entry points
202202
203- build (Meta , Line , File , Context , Unquote , Generated , E ) ->
203+ build (Meta , Line , File , Context , Unquote , Generated , Binding , E ) ->
204204 Acc0 = [],
205205 {ELine , Acc1 } = validate_compile (Meta , line , Line , Acc0 ),
206206 {EFile , Acc2 } = validate_compile (Meta , file , File , Acc1 ),
@@ -219,7 +219,15 @@ build(Meta, Line, File, Context, Unquote, Generated, E) ->
219219 generated = Generated
220220 },
221221
222- {Q , Acc3 }.
222+ Vars =
223+ [{'{}' , [],
224+ ['=' , [], [
225+ {'{}' , [], [K , Meta , EContext ]},
226+ V
227+ ]
228+ ]} || {K , V } <- Binding ],
229+
230+ {Q , Vars , Acc3 }.
223231
224232validate_compile (_Meta , line , Value , Acc ) when is_boolean (Value ) ->
225233 {Value , Acc };
@@ -255,30 +263,16 @@ is_valid(context, Context) -> is_atom(Context) andalso (Context /= nil);
255263is_valid (generated , Generated ) -> is_boolean (Generated );
256264is_valid (unquote , Unquote ) -> is_boolean (Unquote ).
257265
258- quote (_Meta , {unquote_splicing , _ , [_ ]}, _Binding , # elixir_quote {unquote = true }, _ ) ->
266+ quote ({unquote_splicing , _ , [_ ]}, # elixir_quote {unquote = true }, _ ) ->
259267 argument_error (<<" unquote_splicing only works inside arguments and block contexts, "
260268 " wrap it in parens if you want it to work with one-liners" >>);
261269
262- quote (Meta , Expr , Binding , Q , Prelude ) ->
263- Context = Q # elixir_quote .context ,
264-
265- Vars = [{'{}' , [],
266- ['=' , [], [
267- {'{}' , [], [K , Meta , Context ]},
268- V
269- ]]
270- } || {K , V } <- Binding ],
271-
270+ quote (Expr , Q , Prelude ) ->
272271 Quoted = do_quote (Expr , Q ),
273272
274- WithVars = case Vars of
275- [] -> Quoted ;
276- _ -> {'{}' , [], ['__block__' , [], Vars ++ [Quoted ]]}
277- end ,
278-
279273 case Prelude of
280- [] -> WithVars ;
281- _ -> {'__block__' , [], Prelude ++ [WithVars ]}
274+ [] -> Quoted ;
275+ _ -> {'__block__' , [], Prelude ++ [Quoted ]}
282276 end .
283277
284278% % quote/unquote
0 commit comments