diff options
author | Björn Gustavsson <[email protected]> | 2013-06-10 10:08:25 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-08-28 07:31:04 +0200 |
commit | 7c067aeb33c6548fd3051cff06bf5e5d27a20ff4 (patch) | |
tree | 070b984d6ebc566e7703e663dba19bdcaf78b3d0 /lib/asn1/src/asn1ct_constructed_per.erl | |
parent | 1959412b1305a76ee2ddc9b1db20d134fa216c6f (diff) | |
download | otp-7c067aeb33c6548fd3051cff06bf5e5d27a20ff4.tar.gz otp-7c067aeb33c6548fd3051cff06bf5e5d27a20ff4.tar.bz2 otp-7c067aeb33c6548fd3051cff06bf5e5d27a20ff4.zip |
asn1ct_constructed_per: Simplify gen_enc_line() and friends
The first clause of gen_enc_line() allows us to pass in [] as
the value for Element; if we modify the only caller that passes
[] to pass an actual expression we can remove the first clause.
Furthermore, since the Pos argument was only used by the first
clause, we can remove the Pos argument.
We can also remove the first clause in gen_enc_component_optional(),
since the code in its body is exactly the same as in the following
clause.
Diffstat (limited to 'lib/asn1/src/asn1ct_constructed_per.erl')
-rw-r--r-- | lib/asn1/src/asn1ct_constructed_per.erl | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/lib/asn1/src/asn1ct_constructed_per.erl b/lib/asn1/src/asn1ct_constructed_per.erl index 92e6c9080a..8eb6b91d01 100644 --- a/lib/asn1/src/asn1ct_constructed_per.erl +++ b/lib/asn1/src/asn1ct_constructed_per.erl @@ -912,27 +912,9 @@ gen_enc_component_default(Erule,TopType,Cname,Type,Pos,DynamicEnc,Ext,DefaultVal emit({nl,"%% attribute number ",Pos," with type ", InnerType,nl}), NextElement = asn1ct_gen:mk_var(asn1ct_name:curr(tmpval)), - gen_enc_line(Erule,TopType,Cname,Type,NextElement, Pos,DynamicEnc,Ext), + gen_enc_line(Erule, TopType, Cname, Type, NextElement, DynamicEnc, Ext), emit({nl,"end"}). -gen_enc_component_optional(Erule,TopType,Cname, - Type=#type{def=#'SEQUENCE'{ - extaddgroup=Number, - components=_ExtGroupCompList}}, - Pos,DynamicEnc,Ext) when is_integer(Number) -> - - Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))), - emit({"case ",Element," of",nl}), - - emit({"asn1_NOVALUE -> [];",nl}), - asn1ct_name:new(tmpval), - emit({{curr,tmpval}," ->",nl}), - InnerType = asn1ct_gen:get_inner(Type#type.def), - emit({nl,"%% attribute number ",Pos," with type ", - InnerType,nl}), - NextElement = asn1ct_gen:mk_var(asn1ct_name:curr(tmpval)), - gen_enc_line(Erule,TopType,Cname,Type,NextElement, Pos,DynamicEnc,Ext), - emit({nl,"end"}); gen_enc_component_optional(Erule,TopType,Cname,Type,Pos,DynamicEnc,Ext) -> Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))), emit({"case ",Element," of",nl}), @@ -944,19 +926,17 @@ gen_enc_component_optional(Erule,TopType,Cname,Type,Pos,DynamicEnc,Ext) -> emit({nl,"%% attribute number ",Pos," with type ", InnerType,nl}), NextElement = asn1ct_gen:mk_var(asn1ct_name:curr(tmpval)), - gen_enc_line(Erule,TopType,Cname,Type,NextElement, Pos,DynamicEnc,Ext), + gen_enc_line(Erule, TopType, Cname, Type, NextElement, DynamicEnc, Ext), emit({nl,"end"}). gen_enc_component_mandatory(Erule,TopType,Cname,Type,Pos,DynamicEnc,Ext) -> + Element = make_element(Pos+1, asn1ct_gen:mk_var(asn1ct_name:curr(val))), InnerType = asn1ct_gen:get_inner(Type#type.def), emit({nl,"%% attribute number ",Pos," with type ", InnerType,nl}), - gen_enc_line(Erule,TopType,Cname,Type,[],Pos,DynamicEnc,Ext). + gen_enc_line(Erule, TopType, Cname, Type, Element, DynamicEnc, Ext). -gen_enc_line(Erule,TopType, Cname, Type, [], Pos,DynamicEnc,Ext) -> - Element = make_element(Pos+1,asn1ct_gen:mk_var(asn1ct_name:curr(val))), - gen_enc_line(Erule,TopType,Cname,Type,Element, Pos,DynamicEnc,Ext); -gen_enc_line(Erule,TopType,Cname,Type,Element, _Pos,DynamicEnc,Ext) -> +gen_enc_line(Erule, TopType, Cname, Type, Element, DynamicEnc, Ext) -> Atype = case Type of #type{def=#'ObjectClassFieldType'{type=InnerType}} -> @@ -1518,7 +1498,7 @@ gen_enc_choice2(Erule, TopType, [H|T], Pos, Sep0, Ext) -> _ -> Ext end, gen_enc_line(Erule, TopType, Cname, Type, "element(2, Val)", - Pos+1, EncObj, DoExt), + EncObj, DoExt), Sep = [";",nl], gen_enc_choice2(Erule, TopType, T, Pos+1, Sep, Ext); gen_enc_choice2(_, _, [], _, _, _) -> ok. |