|
1 | 1 | -module(elixir_module). |
2 | | --export([translate/4, compile/5, data_table/1, eval_quoted/4, format_error/1]). |
| 2 | +-export([translate/4, compile/5, data_table/1, eval_quoted/4, |
| 3 | + format_error/1, eval_callbacks/5]). |
3 | 4 | -include("elixir.hrl"). |
4 | 5 | -compile({parse_transform, elixir_transform}). |
5 | 6 |
|
@@ -133,7 +134,8 @@ eval_form(Line, Module, Block, Vars, RawS) -> |
133 | 134 | S = scope_for_eval(Module, RawS), |
134 | 135 | { Value, NewS } = elixir_compiler:eval_forms([Block], Line, Vars, S), |
135 | 136 | elixir_def_overridable:store_pending(Module), |
136 | | - eval_callbacks(Line, Module, before_compile, [Module], NewS), |
| 137 | + Env = elixir_scope:to_ex_env({ Line, S }), |
| 138 | + eval_callbacks(Line, Module, before_compile, [Env], NewS), |
137 | 139 | elixir_def_overridable:store_pending(Module), |
138 | 140 | Value. |
139 | 141 |
|
@@ -238,7 +240,8 @@ spec_for_macro(Else) -> Else. |
238 | 240 | load_form(Line, Forms, S) -> |
239 | 241 | elixir_compiler:module(Forms, S, fun(Module, Binary) -> |
240 | 242 | EvalS = scope_for_eval(Module, S), |
241 | | - eval_callbacks(Line, Module, after_compile, [Module, Binary], EvalS), |
| 243 | + Env = elixir_scope:to_ex_env({ Line, EvalS }), |
| 244 | + eval_callbacks(Line, Module, after_compile, [Env, Binary], EvalS), |
242 | 245 |
|
243 | 246 | case get(elixir_compiled) of |
244 | 247 | Current when is_list(Current) -> |
@@ -321,20 +324,16 @@ else_clause() -> |
321 | 324 | % HELPERS |
322 | 325 |
|
323 | 326 | eval_callbacks(Line, Module, Name, Args, RawS) -> |
324 | | - S = RawS#elixir_scope{check_clauses=false}, |
| 327 | + S = RawS#elixir_scope{check_clauses=false,check_requires=false}, |
325 | 328 | Binding = binding_for_eval(Module, []), |
326 | 329 | Callbacks = lists:reverse(ets:lookup_element(data_table(Module), Name, 2)), |
327 | | - Requires = S#elixir_scope.requires, |
328 | 330 | Meta = [{line,Line}], |
329 | 331 |
|
330 | 332 | lists:foreach(fun({M,F}) -> |
331 | | - Expr = { { '.', Meta, [M,F] }, Meta, Args }, |
332 | | - Scope = case ordsets:is_element(M, Requires) of |
333 | | - true -> S; |
334 | | - false -> S#elixir_scope{requires=ordsets:add_element(M, Requires)} |
335 | | - end, |
336 | | - |
337 | | - { Tree, _ } = elixir_translator:translate_each(Expr, Scope), |
| 333 | + { Tree, _ } = elixir_dispatch:dispatch_require(Meta, M, F, Args, S, fun() -> |
| 334 | + apply(M, F, Args), |
| 335 | + { { nil, 0 }, S } |
| 336 | + end), |
338 | 337 |
|
339 | 338 | try |
340 | 339 | erl_eval:exprs([Tree], Binding) |
|
0 commit comments