aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/compiler/diameter_codegen.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-12-01 14:19:27 +0100
committerAnders Svensson <[email protected]>2013-12-01 19:34:22 +0100
commit2eb76ba556b8775cffc94eac26b448eac70af267 (patch)
treeca08b7baf11525683b9f7b642aae572174f6d723 /lib/diameter/src/compiler/diameter_codegen.erl
parent743773a87e24db2ba0f0222bcf4dcaba7ae7adcf (diff)
downloadotp-2eb76ba556b8775cffc94eac26b448eac70af267.tar.gz
otp-2eb76ba556b8775cffc94eac26b448eac70af267.tar.bz2
otp-2eb76ba556b8775cffc94eac26b448eac70af267.zip
Return compilable forms instead of beam
That is, preprocessed forms that can be passed to compile:forms/1,2.
Diffstat (limited to 'lib/diameter/src/compiler/diameter_codegen.erl')
-rw-r--r--lib/diameter/src/compiler/diameter_codegen.erl26
1 files changed, 5 insertions, 21 deletions
diff --git a/lib/diameter/src/compiler/diameter_codegen.erl b/lib/diameter/src/compiler/diameter_codegen.erl
index 47da193457..22422f2ef2 100644
--- a/lib/diameter/src/compiler/diameter_codegen.erl
+++ b/lib/diameter/src/compiler/diameter_codegen.erl
@@ -49,7 +49,7 @@
when File :: string(),
ParseD :: orddict:orddict(),
Opts :: list(),
- Mode :: parse | forms | erl | hrl | beam.
+ Mode :: parse | forms | erl | hrl.
from_dict(File, ParseD, Opts, Mode) ->
Outdir = proplists:get_value(outdir, Opts, "."),
@@ -85,8 +85,6 @@ do_write(M, Path, T)
when M == parse;
M == forms ->
write_term(Path, T);
-do_write(beam, Path, {_Mod, Beam}) ->
- write(Path, Beam);
do_write(_, Path, T) ->
write(Path, T).
@@ -130,10 +128,7 @@ gen(parse, ParseD, _Mod) ->
[?VERSION | ParseD];
gen(forms, ParseD, Mod) ->
- erl_forms(Mod, ParseD);
-
-gen(beam, ParseD, Mod) ->
- compile(pp(erl_forms(Mod, ParseD)));
+ pp(erl_forms(Mod, ParseD));
gen(hrl, ParseD, Mod) ->
gen_hrl(Mod, ParseD);
@@ -141,17 +136,6 @@ gen(hrl, ParseD, Mod) ->
gen(erl, ParseD, Mod) ->
[header(), prettypr(erl_forms(Mod, ParseD)), $\n].
-compile({ok, Forms}) ->
- case compile:forms(Forms, [debug_info, return]) of
- {ok, Mod, Beam, _Warnings} ->
- {Mod, Beam};
- {error, Errors, _Warnings} ->
- erlang:error({compile, Errors})
- end;
-
-compile({error, Reason}) ->
- erlang:error(Reason).
-
erl_forms(Mod, ParseD) ->
Forms = [[{?attribute, module, Mod},
{?attribute, compile, {parse_transform, diameter_exprecs}},
@@ -866,10 +850,10 @@ pp(Forms) ->
pp(Forms, {ok, Code}) ->
Files = files(Code, []),
- {ok, lists:flatmap(fun(T) -> include(T, Files) end, Forms)};
+ lists:flatmap(fun(T) -> include(T, Files) end, Forms);
-pp(_, {error, _} = No) ->
- No.
+pp(Forms, {error, Reason}) ->
+ erlang:error({forms, Reason, Forms}).
include({attribute, _, include_lib, Path}, Files) ->
Inc = filename:basename(Path),