diff options
author | Björn Gustavsson <[email protected]> | 2012-12-19 08:06:02 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-01-22 19:20:10 +0100 |
commit | 844e2126e3b814f9fa058be367be3af745c7a80b (patch) | |
tree | 2d7a1e5e43f2f72b66a5a29cc4b3f39d9bfbf54b /lib/asn1/src/prepare_templates.erl | |
parent | 953b858de46f46f42e2ba45ba30a9b0b278a526d (diff) | |
download | otp-844e2126e3b814f9fa058be367be3af745c7a80b.tar.gz otp-844e2126e3b814f9fa058be367be3af745c7a80b.tar.bz2 otp-844e2126e3b814f9fa058be367be3af745c7a80b.zip |
Generate modules with selected run-time functions for compiler usage
Diffstat (limited to 'lib/asn1/src/prepare_templates.erl')
-rw-r--r-- | lib/asn1/src/prepare_templates.erl | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/asn1/src/prepare_templates.erl b/lib/asn1/src/prepare_templates.erl index 7242166989..83155b2e52 100644 --- a/lib/asn1/src/prepare_templates.erl +++ b/lib/asn1/src/prepare_templates.erl @@ -18,7 +18,7 @@ %% -module(prepare_templates). --export([gen_asn1ct_rtt/1]). +-export([gen_asn1ct_rtt/1,gen_asn1ct_eval/1]). gen_asn1ct_rtt(Ms) -> io:format("%% Generated by ~s. DO NOT EDIT THIS FILE.\n" @@ -46,6 +46,29 @@ gen_asn1ct_rtt(Ms) -> io:format("code() ->\n~p.\n\n", [Funcs]), halt(0). +gen_asn1ct_eval([File]) -> + {ok,Funcs} = file:consult(File), + asn1ct_func:start_link(), + [asn1ct_func:need(MFA) || MFA <- Funcs], + io:format("%% Generated by ~s. DO NOT EDIT THIS FILE.\n" + "%%\n" + "%% Input file: ~s\n\n", [?MODULE,File]), + io:format("-module(~s).\n", [filename:rootname(File)]), + gen_asn1ct_eval_exp(Funcs), + asn1ct_func:generate(group_leader()), + halt(0). + +gen_asn1ct_eval_exp(Funcs) -> + io:put_chars("-export(["), + gen_asn1ct_eval_exp_1(Funcs, ""), + io:put_chars("]).\n"). + +gen_asn1ct_eval_exp_1([{_,F,A}|T], Sep) -> + io:put_chars(Sep), + io:format("~p/~p", [F,A]), + gen_asn1ct_eval_exp_1(T, ",\n"); +gen_asn1ct_eval_exp_1([], _) -> ok. + defined([H|T]) -> io:format("assert_defined(~p) -> ok", [H]), case T of |