aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
AgeCommit message (Collapse)Author
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_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-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-05-31asnct1_name: Optimize clean/1Björn Gustavsson
clean/1 is used quite lot; while not a bottleneck it does seem unnecessary to stop and start the name server just to clear the variables. Since the change to clean/1 makes stop/1 unused, we can remove it.
2013-05-31asn1ct_name: Make new/1 asynchronousBjörn Gustavsson
Since new/1 does not return any useful value and cannot fail, there is no reason to wait for a response from the name server process.
2013-05-31asn1ct_name: Use a monitor instead of an arbitrary timeoutBjörn Gustavsson
2013-05-31asn1ct_name: Simplify the data structures of the name server processBjörn Gustavsson
Since we no longer need to support push/1 and pop/1, we can simplify the data structures used for keeping track of the variables. Each entry in the list can be simply {Var,integer()} instead of {Var,[integer()]}. While at it, eliminate calls to the obsolete lists:keysearch/3 function, don't use integer_to_list/0 within a call to lists:concat/1, and the catch all clause in get_prev/2 and get_next/2.
2013-05-31asn1ct_name: Remove unused functionsBjörn Gustavsson
asn1ct_name:delete/1 is used from asn1ct_gen_ber_bin_v2:add_removed_bytes/1, but that function is not used.
2013-04-27Fix some Makefile rules that didn't support silent rulesAnthony Ramine
2013-04-16Merge branch 'bjorn/asn1/fix-lost-extension-mark/OTP-10995' into maint-r16Erlang/OTP
* bjorn/asn1/fix-lost-extension-mark/OTP-10995: Prevent loss of objects after the extension marker Don't lose the extension mark for object set parameters
2013-04-03Prevent loss of objects after the extension markerBjörn Gustavsson
In an object set with a single root object, objects after the extension marker would be lost.
2013-04-03Don't lose the extension mark for object set parametersBjörn Gustavsson
When an object set is an actual parameter, the extension marker for the object set could get lost.
2013-03-12PER: Ensure that the complete encoding is at least one byteBjörn Gustavsson
If the encoding is empty (i.e. if a top-level type is single-valued and therefore not encoding), the result should be a single zero byte.
2013-03-08PER/UPER: Correct decoding of ENUMERATEDs with a single valueBjörn Gustavsson
An ENUMERATED with as single value is not encoded. The decoder incorrectly assumed that it was encoded in one bit.
2013-02-22Update copyright yearsBjörn-Egil Dahlberg
2013-02-16asn1ct: Eliminate use of obsolete size/1Björn Gustavsson
Also teach otp_SUITE:call_to_size/1 that calls to size/1 is no longer allowed within the asn1 application.
2013-02-16Eliminate use of obsolete size/1 in generated codeBjörn Gustavsson
It is recommended to use byte_size/1 or tuple_size/1 instead of size/1.
2013-02-15BER: Fix broken table constraints inside a SET OF/SEQUENCE OFBjörn Gustavsson
2013-02-14der: Correct code generation for checking of empty setsBjörn Gustavsson
The ASN.1 compiler would generate an Erlang module with incorrect syntax for: T DEFINITIONS AUTOMATIC TAGS ::= BEGIN Empty ::= SET { } S ::= SEQUENCE { e Empty DEFAULT {} } END
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-25Merge branch 'bjorn/asn1/further-cleanup/OTP-10588'Björn Gustavsson
* bjorn/asn1/further-cleanup/OTP-10588: (28 commits) Don't export encode_disp/2 and decode_disp/2 in generated modules Remove vestiges of support for the {TypeName,Value} notation Simplify the functions for decoding lengths per,uper: Optimize decoding of the remaining data types per,uper: Optimize decoding of the remaining string types Share all code for dec_gen_prim/3 between per/uper back-ends per,uper: Optimize decoding of the string data types testPrimStrings: Test some constraints By default, encode BIT STRING to bitstrings Teach encode functions to accept a bitstring term for a BIT STRING Fix EXTERNAL 1990/1994 conversion information loss uper: Look up some SizeConstraints at compile-time Enumeration decoding: Don't emit a default clause if it cannot match Slightly optimize per encoding of large INTEGERs with constraints BER run-time: Refactor decoding of string data types Refactor decoding of BIT STRINGs Optimize encoding of ENUMERATED in per and uper Remove the unused run-time modules eldap: Remove calls to undocumented asn1rt* functions BER: Correct bug in 'undec_rest' ...
2013-01-24Don't export encode_disp/2 and decode_disp/2 in generated modulesBjörn Gustavsson
Those functions were exported for no good reason.
2013-01-24Remove vestiges of support for the {TypeName,Value} notationBjörn Gustavsson
Support in BER was removed in 3d1279f3cebfdd2483c3afea9f225613fe45cd00.
2013-01-23Simplify the functions for decoding lengthsBjörn Gustavsson
Now that the decoding of all types are generated inline, we can take out most of the code for decoding lengths.
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-23Share all code for dec_gen_prim/3 between per/uper back-endsBjö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-23Turn warnings to errors on selected applicationsBjörn Gustavsson
2013-01-22Teach encode functions to accept a bitstring term for a BIT STRINGBjörn Gustavsson
We do it in the simplest possible way by converting the bitstring to a compact bitstring tuple. The encoding of BIT STRINGs should be cleaned up and optimized.
2013-01-22Fix EXTERNAL 1990/1994 conversion information lossBjörn Gustavsson
There are two different definitions of the EXTERNAL data type in ASN.1: the original from 1990 and an updated from 1994. Both defintions are encoded in the same way (in BER). There are still systems in use that use the old definition of EXTERNAL, so the asn1 application must still support both. It has been decided that the asn1 application should handle both the forms without any compiler options. Internally the asn1 application uses the 1990 definition. The encode functions will accept both definitions, but translate the 1994 format to the 1990 format if needed. When decoding, it will decode to the 1990 definition format first and then translate to the 1994 defintion format. One problem with this approach is that the conversion to the 1994 format may not be loss-less (where the 1990 defintion had a CHOICE between an OPEN TYPE, OCTET STRING, or BIT STRING, the 1994 definition only supports an OCTET STRING), and therefore it might not be possible to correctly re-encode the data in the 1990 format. It seems that the only reliable way to handle that problem is to not do the conversion to the 1994 format if the conversion is not loss-less. (There is an attempt when translating to the 1990 format to recover the CHOICE alternative based on the Erlang type of the data value, but that is neither reliable nor future-proof.) That is, when decoding an EXTERNAL value, the resulting tuple could either conform to the 1990 or 1994 definition, and applications must be prepared to handle that. The mail conversation where this issue was first reported can be found here: http://erlang.org/pipermail/erlang-questions/2011-April/057697.html Reported-by: Harald Welte <[email protected]>
2013-01-22uper: Look up some SizeConstraints at compile-timeBjörn Gustavsson
2013-01-22Enumeration decoding: Don't emit a default clause if it cannot matchBjörn Gustavsson
Dialyzer will warn for default clauses that cannot possible match.
2013-01-22Slightly optimize per encoding of large INTEGERs with constraintsBjörn Gustavsson
2013-01-22BER run-time: Refactor decoding of string data typesBjörn Gustavsson
In the BER run-time code (asn1rtt_ber), there is a general function for decoding a string: decode_restricted_string(Tlv, Range, StringType, TagsIn) But the StringType argument is not important. It is only used internally in asn1rtt_ber to distinguish universal strings and BMP strings from other strings. By slightly refactoring the string decoding code, we can eliminate the StringType argument and a subsequent run-time test on the string type. That will slightly reduce code size, slightly increase speed, and eliminate Dialyzer warnings.
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-22Remove the unused run-time modulesBjörn Gustavsson
2013-01-22Correct error handling for the NIF functionsBjörn Gustavsson
Also make sure that the error handling is contained within the asn1rt_nif module and does not leak out to generated code.