Skip to content

Instantly share code, notes, and snippets.

@jackalcooper
Created June 7, 2023 03:33
Show Gist options
  • Save jackalcooper/ae22fd06dff7683c0c60c98f7a399515 to your computer and use it in GitHub Desktop.
Save jackalcooper/ae22fd06dff7683c0c60c98f7a399515 to your computer and use it in GitHub Desktop.
add handler for passes after core
diff --git a/lib/elixir/src/elixir_erl_compiler.erl b/lib/elixir/src/elixir_erl_compiler.erl
index a299ab4c2d..98462f7148 100644
--- a/lib/elixir/src/elixir_erl_compiler.erl
+++ b/lib/elixir/src/elixir_erl_compiler.erl
@@ -50,7 +50,16 @@ compile(Forms, File, Opts) when is_list(Forms), is_list(Opts), is_binary(File) -
format_warnings(Opts, CoreWarnings),
CompileOpts = [no_spawn_compiler_process, from_core, no_core_prepare,
no_auto_import, return, {source, Source} | Opts],
-
+ case compile:noenv_forms(CoreForms, [dprecg|CompileOpts]) of
+ {ok, _Mod, SSA, _} ->
+ % TODO: find a way to send them to a process
+ FileName = lists:concat([elixir_utils:characters_to_list(File), ".", "erl"]),
+ file:write_file(FileName, io_lib:format("~p.~n",[SSA])),
+ io:format("[dump]~p\n", [FileName]);
+
+ _ ->
+ nil
+ end,
case compile:noenv_forms(CoreForms, CompileOpts) of
{ok, Module, Binary, Warnings} when is_binary(Binary) ->
format_warnings(Opts, Warnings),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment