diff options
author | Björn Gustavsson <[email protected]> | 2013-11-26 10:18:30 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-01-20 12:22:42 +0100 |
commit | e3ee8cb325d294b100d2f4b3894a5d7d3ec023e0 (patch) | |
tree | 46057b8ec1d1ab93c6a20dd19b9f287fb7261284 /lib/asn1/src/asn1ct_gen_per.erl | |
parent | 48360023d2f5ae72df19f0095da55738f63800db (diff) | |
download | otp-e3ee8cb325d294b100d2f4b3894a5d7d3ec023e0.tar.gz otp-e3ee8cb325d294b100d2f4b3894a5d7d3ec023e0.tar.bz2 otp-e3ee8cb325d294b100d2f4b3894a5d7d3ec023e0.zip |
Generate intermediate code that is easier to optimize
Instead of generating:
{assign,Dst,"element(2, Val)"}
generate:
{call,erlang,element,[2,{var,"Val"}],Dst}
The latter expression is easier to understand since there is no
need to parse a string which may contain an arbitrary expression.
While at it, also discontinue the practice to treat "naked"
atoms as variables. A variable must always be given as {var,String}.
Diffstat (limited to 'lib/asn1/src/asn1ct_gen_per.erl')
-rw-r--r-- | lib/asn1/src/asn1ct_gen_per.erl | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl index f3389be6b3..7ba649c874 100644 --- a/lib/asn1/src/asn1ct_gen_per.erl +++ b/lib/asn1/src/asn1ct_gen_per.erl @@ -99,7 +99,7 @@ gen_encode_user(Erules,D) when is_record(D,typedef) -> gen_encode_prim(Erules, D) -> - Value = asn1ct_gen:mk_var(asn1ct_name:curr(val)), + Value = {var,atom_to_list(asn1ct_gen:mk_var(asn1ct_name:curr(val)))}, gen_encode_prim(Erules, D, Value). gen_encode_prim(Erules, #type{}=D, Value) -> @@ -149,10 +149,10 @@ gen_encode_prim_imm(Val, #type{def=Type0,constraint=Constraint}, Aligned) -> case Constraint of [#'Externaltypereference'{type=Tname}] -> EncFunc = enc_func(Tname), - Imm = [{apply,{local,EncFunc,[]},[{expr,Val}]}], + Imm = [{apply,{local,EncFunc,[]},[Val]}], asn1ct_imm:per_enc_open_type(Imm, Aligned); [] -> - Imm = [{call,erlang,iolist_to_binary,[{expr,Val}]}], + Imm = [{call,erlang,iolist_to_binary,[Val]}], asn1ct_imm:per_enc_open_type(Imm, Aligned) end end. |