1
1
-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 ]).
3
3
-export ([dot /5 , tail_list /3 , list /2 , validate_runtime /2 ]). % % Quote callbacks
4
4
5
5
-include (" elixir.hrl" ).
@@ -200,7 +200,7 @@ bad_escape(Arg) ->
200
200
201
201
% % Quote entry points
202
202
203
- build (Meta , Line , File , Context , Unquote , Generated , E ) ->
203
+ build (Meta , Line , File , Context , Unquote , Generated , Binding , E ) ->
204
204
Acc0 = [],
205
205
{ELine , Acc1 } = validate_compile (Meta , line , Line , Acc0 ),
206
206
{EFile , Acc2 } = validate_compile (Meta , file , File , Acc1 ),
@@ -219,7 +219,15 @@ build(Meta, Line, File, Context, Unquote, Generated, E) ->
219
219
generated = Generated
220
220
},
221
221
222
- {Q , Acc3 }.
222
+ Vars =
223
+ [{'{}' , [],
224
+ ['=' , [], [
225
+ {'{}' , [], [K , Meta , EContext ]},
226
+ V
227
+ ]
228
+ ]} || {K , V } <- Binding ],
229
+
230
+ {Q , Vars , Acc3 }.
223
231
224
232
validate_compile (_Meta , line , Value , Acc ) when is_boolean (Value ) ->
225
233
{Value , Acc };
@@ -255,30 +263,16 @@ is_valid(context, Context) -> is_atom(Context) andalso (Context /= nil);
255
263
is_valid (generated , Generated ) -> is_boolean (Generated );
256
264
is_valid (unquote , Unquote ) -> is_boolean (Unquote ).
257
265
258
- quote (_Meta , {unquote_splicing , _ , [_ ]}, _Binding , # elixir_quote {unquote = true }, _ ) ->
266
+ quote ({unquote_splicing , _ , [_ ]}, # elixir_quote {unquote = true }, _ ) ->
259
267
argument_error (<<" unquote_splicing only works inside arguments and block contexts, "
260
268
" wrap it in parens if you want it to work with one-liners" >>);
261
269
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 ) ->
272
271
Quoted = do_quote (Expr , Q ),
273
272
274
- WithVars = case Vars of
275
- [] -> Quoted ;
276
- _ -> {'{}' , [], ['__block__' , [], Vars ++ [Quoted ]]}
277
- end ,
278
-
279
273
case Prelude of
280
- [] -> WithVars ;
281
- _ -> {'__block__' , [], Prelude ++ [WithVars ]}
274
+ [] -> Quoted ;
275
+ _ -> {'__block__' , [], Prelude ++ [Quoted ]}
282
276
end .
283
277
284
278
% % quote/unquote
0 commit comments