aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen_per.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2012-11-25 11:25:05 +0100
committerBjörn Gustavsson <[email protected]>2012-12-06 14:22:37 +0100
commite55031640646c7439aff619dcf78bfa76e725109 (patch)
tree9d91415bd9ed9aab5378a0c150aa4b6f4871284d /lib/asn1/src/asn1ct_gen_per.erl
parentf770480d9336b5ae9905b5d53213a8021faa9bab (diff)
downloadotp-e55031640646c7439aff619dcf78bfa76e725109.tar.gz
otp-e55031640646c7439aff619dcf78bfa76e725109.tar.bz2
otp-e55031640646c7439aff619dcf78bfa76e725109.zip
Use asn1ct_imm to optimize decoding of per and uper
A long term goal is to eleminate the asn1ct_gen_per_rt2ct module in favor of the asn1ct_gen_per module, so will have asn1ct_gen_per_rt2ct call asn1ct_gen_per.
Diffstat (limited to 'lib/asn1/src/asn1ct_gen_per.erl')
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl36
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index 665f4c74c0..eab0f62ecf 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -1131,17 +1131,21 @@ gen_decode_user(Erules,D) when is_record(D,typedef) ->
gen_dec_prim(Erules,Att,BytesVar) ->
+ Aligned = case Erules of
+ uper -> false;
+ per -> true
+ end,
Typename = Att#type.def,
Constraint = Att#type.constraint,
case Typename of
'INTEGER' ->
- emit({"?RT_PER:decode_integer(",BytesVar,",",
- {asis,asn1ct_imm:effective_constraint(integer,Constraint)},")"});
+ Imm = asn1ct_imm:per_dec_integer(Constraint, Aligned),
+ asn1ct_imm:dec_code_gen(Imm, BytesVar);
{'INTEGER',NamedNumberList} ->
- emit({"?RT_PER:decode_integer(",BytesVar,",",
- {asis,asn1ct_imm:effective_constraint(integer,Constraint)},",",
- {asis,NamedNumberList},")"});
-
+ Imm = asn1ct_imm:per_dec_named_integer(Constraint,
+ NamedNumberList,
+ Aligned),
+ asn1ct_imm:dec_code_gen(Imm, BytesVar);
'REAL' ->
emit({"?RT_PER:decode_real(",BytesVar,")"});
@@ -1167,21 +1171,15 @@ gen_dec_prim(Erules,Att,BytesVar) ->
'ObjectDescriptor' ->
emit({"?RT_PER:decode_ObjectDescriptor(",
BytesVar,")"});
- {'ENUMERATED',{NamedNumberList1,NamedNumberList2}} ->
- NewTup = {list_to_tuple([X||{X,_} <- NamedNumberList1]),
- list_to_tuple([X||{X,_} <- NamedNumberList2])},
- NewC = [{'ValueRange',{0,size(element(1,NewTup))-1}}],
- emit({"?RT_PER:decode_enumerated(",BytesVar,",",
- {asis,NewC},",",
- {asis,NewTup},")"});
+ {'ENUMERATED',{Base,Ext}} ->
+ Imm = asn1ct_imm:per_dec_enumerated(Base, Ext, Aligned),
+ asn1ct_imm:dec_code_gen(Imm, BytesVar);
{'ENUMERATED',NamedNumberList} ->
- NewTup = list_to_tuple([X||{X,_} <- NamedNumberList]),
- NewC = [{'ValueRange',{0,size(NewTup)-1}}],
- emit({"?RT_PER:decode_enumerated(",BytesVar,",",
- {asis,NewC},",",
- {asis,NewTup},")"});
+ Imm = asn1ct_imm:per_dec_enumerated(NamedNumberList, Aligned),
+ asn1ct_imm:dec_code_gen(Imm, BytesVar);
'BOOLEAN'->
- emit({"?RT_PER:decode_boolean(",BytesVar,")"});
+ Imm = asn1ct_imm:per_dec_boolean(),
+ asn1ct_imm:dec_code_gen(Imm, BytesVar);
'OCTET STRING' ->
emit({"?RT_PER:decode_octet_string(",BytesVar,",",
{asis,Constraint},")"});