aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
AgeCommit message (Collapse)Author
2014-01-31asn1ct_check: Use a return value to silence a dialyzer warningBjörn Gustavsson
Unfortunately the code in question is not covered by our test suites, but it should be correct to do the same thing as in the clause above.
2014-01-31asn1ct_check: Remove useless call to check_integer/3Björn Gustavsson
check_integer/3 can check nothing for an INTEGER without any named values. Remove the useless call to silence a dialyzer warning for unmatched return.
2014-01-31asn1ct_check: Correct error handling for illegal OCTET STRING valuesBjörn Gustavsson
The value for an OCTET STRING must be specified as either a bstring or an hstring. Everything else (including character strings) is illegal. This correction also removes the offending code that caused an unmatched return warning from dialyzer.
2014-01-31asn1ct: Silence dialyzer warnings for unmatched returnsBjörn Gustavsson
2014-01-31asn1ct_table: Remove unused flexibility in table creationBjörn Gustavsson
Unused flexibility complicates the code and can hide bugs. new/1 is never called with a table name that already exists, so we should remove the code that allows for that. That will increase the coverage of asn1ct_table to 100%. Also remove the new/2 and new_reuse/2 functions which are never called externally.
2014-01-31asn1ct_table: Silence a dialyzer warning for unmatched returnBjörn Gustavsson
Change the code so that delete/1 always returns 'true'. While at it, also remove the TODO comment and explain in a comment why we want to keep the delete/1 function.
2014-01-31asn1ct_gen: Silence dialyzer warnings for unmatched returnsBjörn Gustavsson
2014-01-31asn1ct_value: Silence a dialyzer warning for unmatched returnBjörn Gustavsson
2014-01-31asn1ct_tok: Check return value from file:close/1Björn Gustavsson
This will silence a dialyzer warning for unmatched return.
2014-01-24Fix open typesBjörn Gustavsson
2014-01-24Fix OCTET STRINGBjörn Gustavsson
2014-01-24Fix BIT STRINGBjörn Gustavsson
2014-01-24Add legacy_erlang_typesBjörn Gustavsson
2014-01-20Optimize code surrounding calls to complete/1Björn Gustavsson
complete/1 is used when encoding open types (as well as in the encode/2 function in a generated module). The use of complete/1 for encoding open types used to be optimized in two different places. One place was in the alignment optimization pass, where we attempted to replace the call to complete/1 with a call to iolist_to_binary/1. That optimization was taken out in a previous commit that introduced the {list,_,_} intermediate instruction. The other place was when creating the intermediate representation for the encoding of the open type. When attempting to wrap primitive types in an open type, we would attempt to optimize the encoding of the length decscriptor. We will remove that optimization in this commit. Since the previous two optimizations did not optimize encoding of open types as much as we would want, we will introduce a new optimization in a separate pass that will go further than the previous optimizations.
2014-01-20asn1ct_imm: Add the intermediate instruction {list,List,Dst}Björn Gustavsson
The {list,List,Dst} instruction gives us as general way to capture the building of something into a variable. That will make inlining of intermediate code much easier. It also allows us to eliminate the versions of the apply, call_gen, and cond instructions that takes a target variable. Also remove the optimization in the alignment optimization pass that attempts to replace calls to complete/1 with calls to iolist_to_binary/1. That optimization will not work anymore without rewriting, so we will remove it in this commit and introcude a more powerful optimization in a future commit.
2014-01-20Generate intermediate code that is easier to optimizeBjörn Gustavsson
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}.
2014-01-20asn1ct_imm: Add the {set,{var,Src},{var,Dst}} instructionBjörn Gustavsson
The {assign,Dst,Src} instruction is difficult to cope with when doing advanced optimizations, since its source argument is a string which may contain any expression. Instead of changing how {assign,_,_} works, we will introduce new instructions that can be used instead of {assign,_}, and remove {assign,_,_} in a later commit when it is no longer used. The first new instruction we will introduce is: {set,{var,Src},{var,Dst}} It is useful for common sub-expression elemination among other things. For the moment, we will only allow a variable as a source argument, but we could extend it in the future to allow constants as well.
2014-01-20Keep type information in the apply intermediate instructionBjörn Gustavsson
To facilitate inlining of apply calls in the intermediate format.
2014-01-20asn1ct_imm: Add a field for intermediate code for call_genBjörn Gustavsson
It will greatly facilitate further optimizations if we include the intermediate code (if available) in the call_gen tuple.
2014-01-20Introduce asn1ct_gen:open_output_file/1Björn Gustavsson
2014-01-20Factor out printing of verbose messagesBjörn Gustavsson
2014-01-20Improve optimization of alignment for encodingBjörn Gustavsson
2014-01-20Improve construction of {cons,H,T} instructionsBjörn Gustavsson
Make sure that we don't construct: {cons,{integer,I},{cons,{binary,B},T}} - OR - {cons,{binary,B},{cons,{integer,I},T}} but: {cons,{binary,[{put_bits,I,8,[1]}|B]},T} - OR - {cons,{binary,B++[{put_bits,I,8,[1]}]},T}
2014-01-20Teach asn1ct_func:call_gen/4 to quote the generated function nameBjörn Gustavsson
The function name could contain hyphens or other characters not allowed in non-quoted function names.
2013-12-02Merge branch 'maint'Björn Gustavsson
* maint: PER/UPER: Handle a range in the extension part of the constraint
2013-12-02Merge branch 'bjorn/asn1/fix-integer-constraint/OTP-11504' into maintBjörn Gustavsson
* bjorn/asn1/fix-integer-constraint/OTP-11504: PER/UPER: Handle a range in the extension part of the constraint
2013-11-29PER/UPER: Handle a range in the extension part of the constraintBjörn Gustavsson
Constraints such as: INTEGER (1..10, ..., 11..20) would fail to compile. Make sure it is properly ignored.
2013-11-20Merge branch 'maint'Björn Gustavsson
* maint: Fix complicated union of INTEGER constraints
2013-11-20Merge branch 'bjorn/asn1/fix-union-bug/OTP-11411' into maintBjörn Gustavsson
* bjorn/asn1/fix-union-bug/OTP-11411: Fix complicated union of INTEGER constraints
2013-10-21Merge branch 'maint'Björn Gustavsson
* maint: PER/UPER: Correct encoding for single-value extensible constraints asn1ct_value: Handle named INTEGERs with constraints
2013-10-21Merge branch 'bjorn/asn1/fix-extensible-single-values/OTP-11415' into maintBjörn Gustavsson
* bjorn/asn1/fix-extensible-single-values/OTP-11415: PER/UPER: Correct encoding for single-value extensible constraints asn1ct_value: Handle named INTEGERs with constraints
2013-10-18Merge branch 'maint'Björn Gustavsson
* maint: Fix broken handling of default values for BIT STRINGs
2013-10-18Merge branch 'bjorn/asn1/fix-default-values/OTP-11319' into maintBjörn Gustavsson
* bjorn/asn1/fix-default-values/OTP-11319: Fix broken handling of default values for BIT STRINGs
2013-10-17Merge branch 'maint'Björn Gustavsson
* maint: Cope with .erlang files that print to stdout
2013-10-17Fix complicated union of INTEGER constraintsBjörn Gustavsson
A constraint that was an union of integer ranges: Type ::= INTEGER (lb1..ub1 | ... | lbN..ubN) would sometimes (depending on the values) not all always be properly combined to a single effective range, but would become: Type ::= INTEGER (lb2..ub2) (lb3..ub3) If that type was used in a SEQUENCE: S ::= SEQUENCE { v Type } the constraint would be simplified, taking the intersection of the ranges.
2013-10-01Fix broken handling of default values for BIT STRINGsBjörn Gustavsson
For DER/PER/UPER, a value equal to the DEFAULT is not supposed to be encoded. BIT STRINGs values can be represented as Erlang terms in four different ways: as an integer, as a list of zeroes and ones, as a {Unused,Binary} tuple, or as an Erlang bitstring. When encoding a BIT STRING, only certain representations of BIT STRINGs values were recognized. All representations must be recognized. When decoding a DEFAULT value for a BIT STRING, the actual value given in the decoding would be either an integer or a list of zeroes and one (depending on how the literal was written in the specification). We expect that the default value should be in the same representation as any other BIT STRING value (i.e. by default an Erlang bitstring, or a list if the 'legacy_bitstring' option has been given, or as compact bitstring if 'compact_bitstring' has been given).
2013-09-30Cope with .erlang files that print to stdoutBjörn Gustavsson
Don't redirect standard output when auto-generating the asn1ct_rtt.erl and asn1ct_eval*.erl source files, because anything printed form .erlang will end up in them, probably causing a compilation error.
2013-09-30PER/UPER: Correct encoding for single-value extensible constraintsBjörn Gustavsson
An extensible constraint which is a union of single values, such as: INTEGER (1|17, ...) would be incorrectly encoded.
2013-09-30asn1ct_value: Handle named INTEGERs with constraintsBjörn Gustavsson
The asn1ct:value/2 function would crash for name INTEGERs with constraints, such as INTEGER {a(2),b(3),z(17)} (2|3|17, ...).
2013-09-30Merge branch 'maint'Björn Gustavsson
* maint: Teach the ASN.1 compiler the no_ok_wrapper option Optimize the generated decode/2 function
2013-09-27Teach the ASN.1 compiler the no_ok_wrapper optionBjörn Gustavsson
Add the no_ok_wrapper option so that the generated M:encode/2 and M:decode/2 functions will not wrap a successful return value in an {ok,...} tuple. Errors will cause exceptions. Eliminating the wrapping tuple allows simpler nesting of calls.
2013-09-27Optimize the generated decode/2 functionBjörn Gustavsson
Use 'try' instead of 'catch', and don't match anything that cannot actually be returned from the generated encoding code.
2013-09-27Merge branch 'maint'Björn Gustavsson
* maint: (24 commits) No longer compile the X420 specs for plain BER Combine the testSeqIndefinite/1 and testSetIndefinite/1 test cases Remove asn1_wrapper Eliminate the use of asn1_wrapper Simplify tests of CHOICE with OPTIONAL asn1_test_lib: Add roundtrip functions and use them everywhere Makefile: Release Emakefile to ensure warnings are treated as errors Don't allow unused exported functions in test case helpers Move out specific tests from asn1_test_lib testMegaco: Remove unused exported function msg11/0 ASN.1 tests: Don't export functions that are only locally called Remove unused pem_performance.erl file asn1_SUITE: Reinstate test of sub-constraint ASN.1 tests: Remove unused choice_extension.erl Remove unused compile() functions asn1_test_lib: Remove unnecessary loading of a compiled ASN.1 spec Slightly clean up testX420 asn1_SUITE: Combine most tests that use External.asn1 asn1ct_gen: Clean up process dictionary after generating asn1ct_parser2: Clean the process dictionary after parsing ...
2013-09-18asn1ct_gen: Clean up process dictionary after generatingBjörn Gustavsson
Cleanliness.
2013-09-18asn1ct_parser2: Clean the process dictionary after parsingBjörn Gustavsson
Apart from cleanliness, the test suite runs many tests cases in parallel, so it never hurts to reduce the memory pressure.
2013-09-04Merge branch 'maint'Björn Gustavsson
* maint: (26 commits) genop.tab: Add documentation for many BEAM instructions asn1ct_constucted_per: Directly call asn1ct_gen_per Clean up handling of .asn1db files PER, UPER: Fix encoding/decoding of open types greater than 16K PER, UPER: Optimize table constraints PER, UPER: Optimize encoding using an intermediate format Refactor decoding of components of SEQUENCE OF / SET OF PER,UPER: Get rid of unused 'telltype' argument in decoding functions Optimize the generated encode/2 function UPER: Optimize complete/1 Clean up checking of objects Improve tests of deep table constraints BER: Handle multiple optional SEQUENCE fields with table constraints Test OPTIONAL and DEFAULT for open types PER/UPER: Fix encoding of an object set with multiple inlined constructs Remove broken support for multiple UNIQUE Extend the test for parameterized information objects asn1_SUITE: Remove off-topic (and slow) smp/1 test case SeqOf: Add more tricky SEQUENCE OF tests Clean up handling of extension addition groups ...
2013-09-03asn1ct_constucted_per: Directly call asn1ct_gen_perBjörn Gustavsson
2013-09-03Clean up handling of .asn1db filesBjörn Gustavsson
There is (differenct) code for reading .asn1db files both in asn1ct and asn1_db. Consolidate the reading into one routine in asn1db. Another problem is that the encoding rule that the .asn1db file was created for is not in the .asn1db, but only in the generated Erlang module. It is much easier and safer to put the encoding rule in the .asn1db file itself. We will also put the version number of the asn1 application into the file, to ensure that we don't use an old .asn1db file that could potentially be incompatible.
2013-09-03PER, UPER: Fix encoding/decoding of open types greater than 16KBjörn Gustavsson
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.