diff options
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 |