aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_constructed_per.erl
AgeCommit message (Collapse)Author
2013-05-31PER: Generate code for deep table constraints at compile-timeBjörn Gustavsson
For the PER backends, generate code for accessing deep table constraints at compile-time in the same way as is done for BER. While at it, remove the complicated indentation code. Also modernize the test suite and add a test for a deeper nested constraint.
2013-05-31Normalize data representation for table constraintsBjörn Gustavsson
The name of the referenced object set name in #simpletableattributes{} would when used by INSTANCE OF be an atom, but in all other cases be a {Module,ObjectSetName} tuple. Simplify the code by always using the latter format.
2013-05-31asn1ct_constructed_per: Remove dead code for handling of ENUMERATEDBjörn Gustavsson
An ENUMERATED is always represented as a two-tuple, never as three-tuple.
2013-05-31PER/UPER: Eliminate gen_encode_prim_wrapper() and DoTag argumentBjörn Gustavsson
asn1ct_constructed_per:gen_encode_prim_wrapper() no longer serves any useful purpose, as it is easier to call asn1ct_per:gen_encode_prim() directly. Also, the DoTag argument for asn1ct_per:gen_encode_prim() is never actually used, so it can be eliminated at the same time.
2013-05-31Eliminate the {notype,_} return value from asn1ct_gen:type/1Björn Gustavsson
The last clause in asn1ct_gen:type/1 does a catched call to type2/1. If the type2/1 fails {notype,X} is returned. Since the body of type2/1 essentially is: case lists:member(X, [...]) of true -> {primitive,bif}; false -> case lists:member(X, [...]) of true -> {constructed,bif}; false -> {undefined,user} end end there is no way that type2/1 can fail. Therefore, we can eliminate the catch and put the body of type2/1 into the last clause of type/1. We can also eliminate the code in the callers of type/1 that match {notype,X}.
2013-05-31Introduce asn1ct_gen_per:gen_decode_external/3Björn Gustavsson
Hiding the details of decoding an external type will facilitate changing the calling convention in a future commit.
2013-05-31Normalize SIZE constraints to simplify backendsBjörn Gustavsson
2013-05-31Eliminate general use of #typereference{}Björn Gustavsson
The record #typereference{} is only used internally within the asn1ct_parser2 module (the parser translates it to an #'Externaltypereference{} record).
2013-05-31asn1ct_constructed_per: Optimize decoding of OPTIONALBjörn Gustavsson
2013-05-31asn1ct_constructed_per: Break out part of gen_dec_comp_call()Björn Gustavsson
Improve readability and maintainability.
2013-05-31asn1_constructed_per: Optimize decoding of CHOICEBjörn Gustavsson
Optimize the decoding of CHOICE. Most important is to inline decoding of the extension bit (if present) and decoding of the choice index to give the BEAM compiler more opportunities for optimization. We will also change the structure of the generated code. The current code uses a flattened case for both the root and extension alternatives: case Choice + NumRootChoices * Ext of %% Root alternatives. 0 - ...; : LastRootAlternative -> ...; %% Extension alternatives. LastRootAlternative+1 -> ...; : %% Unknown extension. _ -> ...; end We will instead generate nested cases: case Ext of 0 -> case Choice of %% Root alternatives. 0 - ...; : LastRootAlternative -> ... end; 1 -> %% Extension alternatives. <Decode the open type here> case Choice of 0 -> ...; : LastExtensionAlternative -> ...; %% Unknown extension. _ -> ...; end end Nested cases should be slightly faster. For decoding of the extensions, it also makes it possible to hoist the decoding of the open type up from each case to before the case switching on the extension index, thus reducing the size of the generated code. We will also do another change to the structure. Currently, the big flat clase is wrapped in code that repackages the return values: {Alt,{Value,RemainingEncodedData}} = case Choice + NumRootChoices * Ext of : end, {{Value,Alt},RemainingEncodedData}. We still need to do the repackaging, but we can push it down to the case arm for decoding each alternative. In many cases, that will give the BEAM compiler the opportunity to avoid building the temporary tuples.
2013-05-31Refactor decoding of items in SEQUENCEs and CHOICEsBjörn Gustavsson
We will need more explicit control of decoding of open types for CHOICEs, so refactor the gen_dec_line() and gen_dec_line_imm() to break out the decoding of the open types. Note that gen_dec_line_special() will not generate correct code if Ext =/= noext; thus, we can eliminate the Ext parameter.
2013-05-31asn1ct_constructed_per: Refactor gen_dec_choice2()Björn Gustavsson
gen_dec_choice2() is unnecessarily complicated. Code is duplicated merely to avoid outputting a ";" separator after the last item, and there is code to skip extensionmarks that are never actually present. While at it, eliminate the the wrap_gen_dec_line() function which is not needed. It puts a {component_type,C} key in the process dictionary, but that is actually never used. Besides that, it only shuffles the argument.
2013-05-31asn1_constructed_per: Refactor gen_enc_choice2()Björn Gustavsson
gen_enc_choice2() duplicates code merely to avoid outputting a ";" separator after the last item.
2013-05-31Don't call asn1ct_name:clear/0 directly after asn1ct_name:start/0Björn Gustavsson
Ensure that asn1ct_name:start/0 will call asn1ct_name:clear/0 if the name server process is already running so that we can be sure that the variables are cleared.
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2013-01-23per,uper: Optimize decoding of the remaining data typesBjörn Gustavsson
2013-01-22Add and use asn1rtt_extBjörn Gustavsson
2013-01-22Add run-time library templates and use themBjörn Gustavsson
The template modules (asn1rtt_*.erl) are based on the existing run-time modules, but with some simplifications and improvements, for example: The run-time functions for BER encoding took a Constraint argument which was not used. It has been eliminated, along with the unused StringType argument for the encode_restricted_string function. The Range argument for decode_enumerated() has been dropped since it was not used.
2013-01-22Fix a bug where necessary alignment would be skippedBjörn Gustavsson
2013-01-10Merge branch 'bjorn/asn1/extension-addition-groups/OTP-10664'Björn Gustavsson
* bjorn/asn1/extension-addition-groups/OTP-10664: Fix a bug for multiple extension addition groups
2013-01-07Fix a bug for multiple extension addition groupsBjörn Gustavsson
Encoding would fail.
2012-12-21Always inline decoding of open typesBjörn Gustavsson
2012-12-18Fix a bug in skipping of extensionsBjörn Gustavsson
Extensions following a double bracket group were not skipped correctly. Fix this bug and add tests to ensure that extensions are skipped correctly.
2012-12-06Optimize decoding of extensionsBjörn Gustavsson
2012-12-06Do alignment optimization of SEQUENCEs and SETsBjörn Gustavsson
2012-12-06Refactor code generation for decoding SEQUENCE/SETBjörn Gustavsson
In order to optimize the generated code, we will need data structures that can be traversed in several passes before the actual code is generated. Refactor the code so that if first builds (essentially) a list of funs that do the actual code generation, and a second function that will call the funs one at the time.
2012-12-06Use asn1ct_imm to optimize decoding of per and uperBjörn Gustavsson
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.
2012-12-06Eliminate the useless 'telltype' argument in component decodingBjörn Gustavsson
2012-12-06Suppress warnings for unused variables using a compiler optionBjörn Gustavsson
Currently, the generated code suppresses warnings for unusued variables by assigning to the "_Val" variable, for example: _Val = Tmpval5 To be completely safe, that should have been: _ = Tmpval5 in case there happens to more than one such assignment in the same scope. However, a better way to suppress warnings is to simply use the 'nowarn_unused_vars' compiler option. That method will also work for more complicated expressions there it would be cumbersome to suppress warnings by assignment to "_".
2012-11-23Remove obsolete back-ends and simplify the optionsBjörn Gustavsson
It is time to clean up the mess of back-ends. Remove all the obsolete back-ends and simplify the options used to select them. New Option Old Equivalent ---------- -------------- ber ber_bin,optimize,nif per per,optimize,nif uper uper_bin The old options will still be recognized and translated to the new options, but will also print a warning. That implies that deprecated features that only are implemented in the old 'ber' back-end will no longer work (e.g. the {Typename,Value} notation). Also make the return type for the generated encode/2 function consistent. It used to be a binary for per and uper, and an iolist for ber. Always make it a binary.
2012-11-22Remove support for the obsolete {Typename,Value} tuple notationBjörn Gustavsson
Of the back-ends that we are going to keep, only the UPER back-end support the obsolete {Typename,Value} notation. For consistency with the PER and BER encodings, remove the support for UPER encoding too. Also remove vestiges of the support for the notation in the other back-ends.
2012-08-31Update copyright yearsBjörn-Egil Dahlberg
2012-08-28Remove Dialyzer warningsKenneth Lundin
2012-05-04Add support for multiple ExtensionAdditionGroupsKenneth Lundin
2011-08-01Remove driver support for per encodingLukas Larsson
Handle the new error messages from the asn1 nifs Remove dead code for erlang optimized per decode
2011-08-01Add support for nif option to optimized PER asn1 compilationLukas Larsson
2011-07-21Move fixopt to do more work in ct than rt for opimized per_binLukas Larsson
Instead of looping over the list of which options contain defaults, one case statement is generated for each optional attribute.
2011-07-21Optmized encode_length by doing some calculations at compile time rather ↵Lukas Larsson
than runtime
2011-07-21Optmized decode_length by doing some calculations as compile time rather ↵Lukas Larsson
than runtime
2011-05-19Corrected handling of long length in driver and updated test suitesKenneth Lundin
2010-11-18Shut off some dialyzer warningsKostis Sagonas
2010-10-04Add additional test to cover this correctionKenneth Lundin
2010-09-24correct the encoding of ExtensionAdditionGroupKenneth Lundin
2010-09-23tempKenneth Lundin
2010-08-25Add support for Extension addition groupKenneth Lundin
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP