aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_gen_per.erl
AgeCommit message (Collapse)Author
2013-09-03PER, UPER: Optimize table constraintsBjörn Gustavsson
The generated code for table constraints has several problems: * For each object set, a function for getting an encoding or decoding fun is generated, regardless of whether it is actually used. In many specifications, the object set actually used is the union of several other object sets. That means that the code can become a lot bulkier than it would need to be. * The funs are not necessary. The funs just add to the code bloat and generate more unnecessary garbage at run-time. Also, one of the arguments of the fun is the name of the field in the class which is known at compile-time, and the fun for decoding has unused arguments. How to fix the problems: At each call site where an open type should be encoded/decoded, call a specific generated function specialized for the actual object set and the name of the field in the class. When generating the specialized functions, make sure that we re-use a previously generated function if possible.
2013-08-30PER, UPER: Optimize encoding using an intermediate formatBjörn Gustavsson
There are some minor incompatibilities for BIT STRING: {bit,Position} is now only only supported for a named BIT STRING type. Values longer than the maximum size for the BIT STRING type would be truncated silently - they now cause an exception.
2013-08-30PER,UPER: Get rid of unused 'telltype' argument in decoding functionsBjörn Gustavsson
2013-08-30Clean up checking of objectsBjörn Gustavsson
2013-08-30PER/UPER: Fix encoding of an object set with multiple inlined constructsBjörn Gustavsson
Also extend the test suite with more tests of inlined constructs in object sets.
2013-08-30Remove broken support for multiple UNIQUEBjörn Gustavsson
According to the ASN.1 standard, having multiple UNIQUE in class is allowed. For example: C ::= CLASS { &id1 INTEGER UNIQUE, &id2 INTEGER UNIQUE } In practice, no one uses multiple UNIQUE. The ASN.1 compiler will crash if a class with multiple UNIQUE is used, but the backends have half-hearted support for multiple UNIQUE in that they generate helper functions similar to: getenc_OBJECT_SET(id1, 42) -> fun enc_XXX/3; ... Since we have no plans to implement support for multiple UNIQUE (no one seems to have missed it), simplify the helper functions like this: getenc_OBJECT_SET(42) -> fun enc_XXX/3; ...
2013-08-30Refactor encoding of REALBjörn Gustavsson
To facilitate optimizing PER encoding using an intermediate format, we must change asn1rtt_real_common:encode_real/1 so that it only returns the encoded binary.
2013-06-07UPER: Correct encoding of ENUMERATED with more than 63 extended valuesBjörn Gustavsson
2013-05-31asn1ct_check: Don't pass on #'ObjectClassFieldType'{} with fixed typeBjörn Gustavsson
Simplify the backends by letting asn1ct_check replacing a with the actual type.
2013-05-31asn1ct_gen_per: Remove useless renewal of 'enumval'Björn Gustavsson
Since fbcb7fe589edbfe79d10d7fe01be8a9f77926b89, the 'enumval' variable is no longer used.
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 handling of #pobjectdef{} from the backendsBjörn Gustavsson
asn1ct_check does not pass #pobjectdef{} records on to the backends (all the original #pobjectdef{} records have been instantiated and changed to #objectdef{} records).
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-31PER/UPER: Remove support for a list argument for encode_open_type/1Björn Gustavsson
Almost always, encode_open_type/1 is called with the return value from complete/1, which always is a binary. In the rare situation that encode_open_type/1 is called directly with data from the user application, call iolist_to_binary/1 before calling encode_open_type/1.
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-31Get rid of 'ANY' in the backendsBjörn Gustavsson
asn1ct_check has translated all occurrences of 'ANY' to 'ASN1_OPEN_TYPE'.
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-31PER/UPER: Share all code except encoding of primitivesBjörn Gustavsson
The only code that is really different between the PER and UPER backends is encoding of primitive types.
2013-05-31Eliminate duplicated code in gen_inlined_{dec,enc}_funs()Björn Gustavsson
2013-05-31Remove unused function pgen/4 in all backendsBjörn Gustavsson
2013-05-31UPER: Fix bug in encoding/decoding of default typesBjörn Gustavsson
The wrong backend was used.
2013-05-31Remove unnecessary code duplication in gen_objset_{dec,enc}()Björn Gustavsson
2013-05-31asn1ct_name: Remove broken active/1Björn Gustavsson
active/1 always returned 'true' (curr(Var) can never return 'nil', except if Var =:= 'nil'). Therefore, we can eliminate its use and remove it.
2013-02-14per,uper: Fix breakage of compilation of InformationFrameworkBjörn Gustavsson
Commit f16f43446a04c459486356c0b4ad517cc9201895 broke compilation of InformationFramework for per and uper.
2013-01-25Update copyright yearsBjörn-Egil Dahlberg
2013-01-24Remove vestiges of support for the {TypeName,Value} notationBjörn Gustavsson
Support in BER was removed in 3d1279f3cebfdd2483c3afea9f225613fe45cd00.
2013-01-23per,uper: Optimize decoding of the remaining data typesBjörn Gustavsson
2013-01-23per,uper: Optimize decoding of the remaining string typesBjörn Gustavsson
2013-01-23per,uper: Optimize decoding of the string data typesBjörn Gustavsson
2013-01-23By default, encode BIT STRING to bitstringsBjörn Gustavsson
Add the option 'legacy_bit_string' to decode to the old list format.
2013-01-22uper: Look up some SizeConstraints at compile-timeBjörn Gustavsson
2013-01-22Refactor decoding of BIT STRINGsBjörn Gustavsson
Refactor decoding of BIT STRINGs so that the run-time code does not spend testing conditions that are known already at compile-time (which wastes time and produces unnecessary Dialyzer warnings). There are three ways to decode BIT STRINGs: 1) To a list of bit names (and {bit,Position} for unnamed positions) if the BIT STRING type has any bit names. 2a) To a list of ones and zeros if there are no named bits, and the compact_bit_string option was NOT given. 2b) To a {Unused,Bin} tuple if there are no named bits compact_bit_string option WAS given. Structure the decoding functions in the same way.
2013-01-22Optimize encoding of ENUMERATED in per and uperBjörn Gustavsson
Always pre-encode the values for the enumeration. Clean up the code and let the per and uper back-ends share the code.
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.
2012-12-21Always inline decoding of open typesBjörn Gustavsson
2012-12-19Eliminate code duplicationBjörn Gustavsson
It seems that the code was duplicated only to avoid emitting a semi-colon before the first case clause. Handle that by passing a Sep argument instead. While at it, also do the following clean-ups: * Replace lists:keysearch/3 with lists:keyfind/3. * Replace the use of is_record/2 with matching
2012-12-19Remove support for the {Typename,Value} notation in encodingBjörn Gustavsson
Support for the notation was removed in 6ef8cbdaaaa1c30a7dc462063.
2012-12-06Do alignment optimization of SEQUENCEs and SETsBjörn Gustavsson
2012-12-06Optimize decoding of OCTET STRINGsBjörn Gustavsson
Decoding of fragmented OCTET STRINGs was only implemented when the size was constrained to a single value. While at it, support decoding fragmented OCTET STRINGS in all circumstances.
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-06Use asn1ct_imm:effective_constraint/2Björn Gustavsson
It is error-prone to have several copies of the same function.
2012-12-06Optimize encoding/decoding of NULL in the per and uper back-endsBjörn Gustavsson
Don't waste time calling a trivial function in the run-time library for encoding and decoding of NULL values.
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-07-10In generation of encoding functions for enumeration types,Gustav Simonsson
the values used for generating the range check in case of a value range should be sorted and have duplicates removed. For per with optimization (per_rt2ct), sorting has been added. For both optimized and regular per, the sorting and duplicate removal code has been simplified. In case of value range, 'MIN' and 'MAX' is now also checked. The sorting of constraint values in the check phase remains.
2012-05-04Add support for multiple ExtensionAdditionGroupsKenneth Lundin
2012-03-30Update copyright yearsBjörn-Egil Dahlberg
2012-02-13Fix to integer and sequence definitionsGustav Simonsson
Enable re-use of integer definitions in subsequent definitions and added clauses to check greatest common range for sequence definitions
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