aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src
AgeCommit message (Collapse)Author
2017-02-16asn1ct_gen: Polish the file headerBjörn Gustavsson
2017-02-15asn1ct_gen: Clean up generation of .hrl file headerBjörn Gustavsson
Note that put(currmod, Mod) is not needed because it has already been done by the caller.
2017-02-15asn1ct_gen: Clean up generation records in .hrl fileBjörn Gustavsson
2017-02-15asn1ct_gen: Clean up generation of -export directivesBjörn Gustavsson
2017-02-15asn1ct_gen: Clean up generation of valuesBjörn Gustavsson
2017-02-06Teach the ASN.1 compiler the 'maps' optionBjörn Gustavsson
When the 'maps' option is given, the SEQUENCE and SET types are represented as maps instead of as records. Optional and default values must be not be given as asn1_NOVALUE or asn1_DEFAULT in a map passed to the M:encode/2 function; they must be omitted from the map. Similarly, when decoding missing values will be omitted from the map. No .hrl files will be generated when the 'maps' options is used. That means values in an ASN.1 module must be retrieved by calling the appropriate function in generated module. Since we one day hope to get rid of the options 'compact_bit_string', 'legacy_bit_string', and 'legacy_erlang_types', we will not allow them to be combined with the 'maps' option.
2017-02-03Refactor decoding as a preparation for handling mapsBjörn Gustavsson
2017-02-03Refactor encoding of optional valuesBjörn Gustavsson
As a preparation for supporting maps in a future commit, refactor the functions for encoding optional values.
2017-02-03Clean up filtering of optionsBjörn Gustavsson
2017-02-03Refactor code generation optionsBjörn Gustavsson
Most options to the code generation pass are passed through the process dictionary. At the same time, an Erule or Erules argument is passed to most code generation functions. The Erule argument is only an atom indicating the encoding rules ('ber', 'per', or 'uper'). Introduce a new record #gen{} to contain code generation options and parameters. Pass it as the Erule argument (renaming it to Gen in functions that we will have to touch anyway). In this commit, eliminate the use of the variable 'encoding_options' in the process dictionary.
2017-02-03Simplify gen_enc_components_call() and friendsBjörn Gustavsson
2017-02-03asn1ct_check: Number the components in INSTANCE OFBjörn Gustavsson
asn1ct_check numbers all components in SEQUENCEs and SETs, except for the associated sequence for INSTANCE OF. Remove this exception so that the code generation pass can depend on SEQUENCEs being numbered.
2017-02-03Refactor gen_encode_constructed_imm/3Björn Gustavsson
Introduce helper functions to simplify and reduce the size of gen_encode_constructed_imm/3.
2017-02-03Clean up handling of textual orderBjörn Gustavsson
The to_encoding_order/1 function can be eliminated if we incorporate its functionality into textual_order/2. textual_order/2 has a workaround for TermList being longer than OrderList. Remove the workaround, because the code being generated would certainly be wrong (better let the compiler crash and receive a bug report if it happens). The workaround was not necessary to successfully compile the entire Erlang/OTP and to run the asn1 test suite.
2017-02-03Break apart function with 6 argumentsBjörn Gustavsson
As a preparation for future changes, simplify gen_dec_constructed_imm_2/6 by breaking it apart to two functions.
2017-01-13asn1: Remove deprecated functionsBjörn Gustavsson
Remove the entire asn1rt module. All functions in it were deprecated in OTP 17. In asn1ct, remove the deprecated functions asn1ct:encode/3 and asn1ct:decode/3. Also remove asn1ct:encode/2, which has not been formally deprecated but is undocumented.
2016-08-12Support 'make -j' when compiling ASN.1 modulesBjörn Gustavsson
When attempting to build multiple ASN.1 modules in parallel (e.g. by running 'make -j'), the ASN.1 compiler could crash because the names of the .asn1db files clashed. For example, if A.asn1 and B.asn1 both import from C.asn1, the compiler would write a C.asn1db file when compiling A.asn1 and when compiling B.asn1. We can avoid this problem if the compiler only writes the module's own .asn1db file. That is, when compiling A.asn1, the compiler would only write A.asn1db, not C.asn1db. Also, make sure that we make the write atomic by first writing to a temporary file that is then renamed.
2016-05-12Eliminate dialyzer warnings for unmatched returnsBjörn Gustavsson
Dialyzer complains that three calls to gen_dec_line/7 ignore the return value. It turns out that when the last argument to gen_dec_line/7 is 'false', the return value will always be {[],[]}. Introduce gen_dec_line/6 as helper to make it clear that we don't ignore a useful return value.
2016-03-15update copyright-yearHenrik Nord
2016-02-22Merge branch 'maint'Hans Bolinder
* maint: Fix a few dialyzer warnings
2016-02-22Fix a few dialyzer warningsHans Bolinder
2016-02-15Merge branch 'maint'Björn Gustavsson
* maint: asn1: Suppress warnings for improper lists in generated code
2016-02-12asn1: Suppress warnings for improper lists in generated codeBjörn Gustavsson
2016-01-22Merge branch 'maint'Björn Gustavsson
* maint: PER: Correct compilation of named INTEGERs
2016-01-21PER: Correct compilation of named INTEGERsBjörn Gustavsson
When a constrained INTEGER has more than 16536 values and named values, the compiler would crash when compiling to the PER format. Example: Longitude ::= INTEGER { oneMicrodegreeEast(10), oneMicrodegreeWest(-10), unavailable(1800000001) } (-1799999999..1800000001) Reported-by: Ingars
2015-12-11Use 'rand' instead of the obsolete 'random' moduleBjörn Gustavsson
In most cases, we don't have to seed the random number generator, as the rand:uniform/1 takes care about that itself.
2015-11-30BER: Fix encoding of empty named BIT STRINGBjörn Gustavsson
Encoding an empty named BIT STRING would fail for BER. Noticed-by: Svilen Ivanov
2015-06-18Change license text to APLv2Bruce Yinhe
2015-04-30asn1: Use module erl_annoHans Bolinder
2015-03-20Merge branch 'rickard/time_api/OTP-11997'Rickard Green
* rickard/time_api/OTP-11997: (22 commits) Update primary bootstrap inets: Suppress deprecated warning on erlang:now/0 inets: Cleanup of multiple copies of functions Add inets_lib with common functions used by multiple modules inets: Update comments Suppress deprecated warning on erlang:now/0 Use new time API and be back-compatible in inets Remove unused functions and removed redundant test asn1 test SUITE: Eliminate use of now/0 Disable deprecated warning on erlang:now/0 in diameter_lib Use new time API and be back-compatible in ssh Replace all calls to now/0 in CT with new time API functions test_server: Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API Replace usage of erlang:now() with usage of new API otp_SUITE: Warn for calls to erlang:now/0 Replace usage of erlang:now() with usage of new API Multiple timer wheels Erlang based BIF timer implementation for scalability Implement ethread events with timeout ... Conflicts: bootstrap/bin/start.boot bootstrap/bin/start_clean.boot bootstrap/lib/compiler/ebin/beam_asm.beam bootstrap/lib/compiler/ebin/compile.beam bootstrap/lib/kernel/ebin/auth.beam bootstrap/lib/kernel/ebin/dist_util.beam bootstrap/lib/kernel/ebin/global.beam bootstrap/lib/kernel/ebin/hipe_unified_loader.beam bootstrap/lib/kernel/ebin/inet_db.beam bootstrap/lib/kernel/ebin/inet_dns.beam bootstrap/lib/kernel/ebin/inet_res.beam bootstrap/lib/kernel/ebin/os.beam bootstrap/lib/kernel/ebin/pg2.beam bootstrap/lib/stdlib/ebin/dets.beam bootstrap/lib/stdlib/ebin/dets_utils.beam bootstrap/lib/stdlib/ebin/erl_tar.beam bootstrap/lib/stdlib/ebin/escript.beam bootstrap/lib/stdlib/ebin/file_sorter.beam bootstrap/lib/stdlib/ebin/otp_internal.beam bootstrap/lib/stdlib/ebin/qlc.beam bootstrap/lib/stdlib/ebin/random.beam bootstrap/lib/stdlib/ebin/supervisor.beam bootstrap/lib/stdlib/ebin/timer.beam erts/aclocal.m4 erts/emulator/beam/bif.c erts/emulator/beam/erl_bif_info.c erts/emulator/beam/erl_db_hash.c erts/emulator/beam/erl_init.c erts/emulator/beam/erl_process.h erts/emulator/beam/erl_thr_progress.c erts/emulator/beam/utils.c erts/emulator/sys/unix/sys.c erts/preloaded/ebin/erlang.beam erts/preloaded/ebin/erts_internal.beam erts/preloaded/ebin/init.beam erts/preloaded/src/erts_internal.erl lib/common_test/test/ct_hooks_SUITE_data/cth/tests/empty_cth.erl lib/diameter/src/base/diameter_lib.erl lib/kernel/src/os.erl lib/ssh/test/ssh_basic_SUITE.erl system/doc/efficiency_guide/advanced.xml
2015-03-20Replace usage of erlang:now() with usage of new APIRickard Green
2015-03-17PER, UPER: Eliminate compiler warning for SeqPrim.asn1Björn Gustavsson
The BEAM compiler now warns more aggressively for expressions whose values are not used. For example, the generated Erlang code for the following ASN.1 code will now cause a warning: Seq ::= SEQUENCE { ..., os OCTET STRING (SIZE (17000..30000)) } The generated Erlang code looks similar to the following: Enc9@bin = iolist_to_binary(Enc9@output), Enc9@len = byte_size(Enc9@bin), [align|encode_fragmented(Enc9@bin, 8)] The variable Enc9@len is not used and the BEAM compiler will complain that the value returned from the byte_size/1 call is not used. Improve the optimization of the intermediate code to eliminate the assignment to the unused variable.
2015-03-12Merge branch 'maint'Björn Gustavsson
* maint: asn1ct_gen: Correct generation of .hrl files for multiple ellipses Fix BER code generation
2015-03-06asn1ct_gen: Correct generation of .hrl files for multiple ellipsesBjörn Gustavsson
2015-03-06Fix BER code generationDan Gudmundsson
PKIX1Explicit-2009 did not compile. This commit was cherry-picked from 3ab3b07a already merged into master.
2015-01-16Merge branch 'oliv3/math_log2/OTP-12411'Marcus Arendt
* oliv3/math_log2/OTP-12411: Add math:log2/1
2015-01-14Add math:log2/1Olivier Girondel
2015-01-12Remove the old unused yecc-based parserBjörn Gustavsson
2015-01-12Improve error handling for illegal object definitionsBjörn Gustavsson
2015-01-12Reimplement storeindb/2 to avoid excessive process communicationBjörn Gustavsson
As currently implemented, there is one call to asn1db:dbget() and asn1db:dbput() for each type/value definitions in an ASN.1 specification. If we check for duplicate definitions locally, we can send all definitions in a single call.
2015-01-12Remove useless fields in #state{}Björn Gustavsson
Three fields ('type','value', and 'vname') are almost unused. They are set, but almost never read. Eliminate the last remaining uses and the fields themselves.
2015-01-12Remove vestiges of obsolete {TypeName,Value} notationBjörn Gustavsson
2015-01-12Remove old error handlingDan Gudmundsson
And while we are at it cleanup and rewrite code to use try catch.
2015-01-12Modernize the remaining casesDan Gudmundsson
2015-01-12Further improve error handling for instatiation of parameterized typesDan Gudmundsson
2015-01-12asn1ct_tok: Clean upBjörn Gustavsson
2015-01-12asn1ct_parser2: Remove expensive lookahead_assignment/1 functionBjörn Gustavsson
In the parsing of a value assignment, such as: value INTEGER ::= 42 there is call to a function called lookahead_assignment/1 that will ensure that the sequence of tokens that follows the value is a valid assignment. The problem is that if the next assignment is a value assignment, that too will look ahead to the next assignment. That means that the complexity will be quadratic if there are many value assignments following each other. The reason for the test in the first place is unclear; my guess is that it was an attempt to provide better error reporting.
2015-01-12asn1ct_parser2: Clean up error handling and reportingBjörn Gustavsson
Errors were reported using a throw like this: throw({asn1_error,{get_line(hd(Tokens)),get(asn1_module), [got,get_token(hd(Tokens)),expected,typereference]}}). The attempt to tell the user what was expected was often mis-leading. It is time-consuming and non-trival to provide correct information of what is expected. Therefore, we will not even try. Instead we will spend more effort to report the token where the error was discovered. We will replace each throw with a function call: parse_error(Tokens). Also add the syntax_SUITE test suite to test error reporting and to cover all error reporting code. Remove the old c_syntax/1 test case. Also remove all out-commented code.
2015-01-12asn1ct, asn1ct_parser2: Refactor the upper levels of error handlingBjörn Gustavsson
Responsibilities for parse error handling were split between asn1ct and asn1ct_parser2 in a confusing way. Let asn1ct_parser2 return structured_error tuples in the same way as the check pass.
2015-01-12asn1ct_parser2: Eliminate all uses of old-style 'catch'Björn Gustavsson
Most uses of 'catch' are not necessary. For example, parse_or/2 is typically called like this: case catch parse_or(Tokens, Flist) of {'EXIT',Reason} -> exit(Reason); {asn1_error,_}=AsnErr -> throw(AsnErr); Result -> Result end. Since {asn1_error,_} is always thrown (never returned) and a successful is always returned (never thrown), the 'case' and the 'catch' are not necessary. The code can be simplified too: parse_or(Tokens, Flist) In a few cases, we will need to replace the 'catch' with 'try'...'catch'.