diff options
author | Björn Gustavsson <[email protected]> | 2017-04-26 12:47:41 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-04-26 12:47:41 +0200 |
commit | a46b05d3fd38c76824faf4eccba0f2117abd9bff (patch) | |
tree | 3d88cdc035ca32434ecd92fcbac9ab20568d1318 /lib/stdlib/src/erl_abstract_code.erl | |
parent | 9ded73921e8a6a5ecf00c27028fcff1bf1961992 (diff) | |
parent | 9dfb4eda78ade372ff5055b618612e478dc900e6 (diff) | |
download | otp-a46b05d3fd38c76824faf4eccba0f2117abd9bff.tar.gz otp-a46b05d3fd38c76824faf4eccba0f2117abd9bff.tar.bz2 otp-a46b05d3fd38c76824faf4eccba0f2117abd9bff.zip |
Merge pull request #1367 from josevalim/jv-dbgi-chunk
Introduce new "Dbgi" chunk
OTP-14369
Diffstat (limited to 'lib/stdlib/src/erl_abstract_code.erl')
-rw-r--r-- | lib/stdlib/src/erl_abstract_code.erl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/stdlib/src/erl_abstract_code.erl b/lib/stdlib/src/erl_abstract_code.erl new file mode 100644 index 0000000000..6e45f11aa3 --- /dev/null +++ b/lib/stdlib/src/erl_abstract_code.erl @@ -0,0 +1,28 @@ +-module(erl_abstract_code). +-export([debug_info/4]). + +debug_info(_Format, _Module, {none,_CompilerOpts}, _Opts) -> + {error, missing}; +debug_info(erlang_v1, _Module, {AbstrCode,_CompilerOpts}, _Opts) -> + {ok, AbstrCode}; +debug_info(core_v1, _Module, {AbstrCode,CompilerOpts}, Opts) -> + CoreOpts = add_core_returns(delete_reports(CompilerOpts ++ Opts)), + try compile:noenv_forms(AbstrCode, CoreOpts) of + {ok, _, Core, _} -> {ok, Core}; + _What -> {error, failed_conversion} + catch + error:_ -> {error, failed_conversion} + end; +debug_info(_, _, _, _) -> + {error, unknown_format}. + +delete_reports(Opts) -> + [Opt || Opt <- Opts, not is_report_option(Opt)]. + +is_report_option(report) -> true; +is_report_option(report_errors) -> true; +is_report_option(report_warnings) -> true; +is_report_option(_) -> false. + +add_core_returns(Opts) -> + [to_core, return_errors, return_warnings] ++ Opts. |