Commit Graph

162 Commits

Author SHA1 Message Date
M. Anthony Aiello
a56199837b Merge pull request #9 from AdaCore/feature/rogers-gpr-update
Feature/rogers gpr update
2021-10-13 08:43:43 -04:00
rogers
10f947a2b1 Move the functionality of copying data to/from a buffer into a child package
to allow for a "fast" version using memcpy and a "provable" version that uses
Ada assignment statements. The fast version disables SPARK_Mode at the package body
level, whereas the "provable" version does not.

There are two package bodies implementing this copying facility, for a single common
package decl (that has SPARK_Mode enabled). Thus there are two source files.

Define and use a scenario variable to control the selection of the source file to
use as the body of this package.
2021-10-12 16:16:37 -05:00
rogers
0910228a26 provable version without use of memcpy
re-enable pragma Assertion_Policy (Pre => Check) since we need those because we are not proving clients

formatting for readability

replace unsigned 32 type used for indexes with a signed 64-bit type having the same range

fix off-by-one for post in Unbounded_Slice

For the other two Append routines' postconditions, replace the calls
to the Head functions with explicit quantified expressions using Element.

Give complete post for Slice and Unbounded_Slice functions

formatting

move the two lemma procs for Get_*String to package level and name them with "Lemma_" prefix

formatting and comment cleanup

the two Get_* for strings now prove, with Claire/Joffrey's lemma in place and change to post in unbounded strings package

apply gnata to unbounded strings package

disable pragma requiring pre checks only, until finished developing proofs

comment fixes etc

make function Element be an expression function in the spec for the sake of proof, which means we need to enable the preconditions as well.

full post for Append routines

minor formatting

take the post off Equal so it can be inlined

on ghost function Equal, we don't need the precondition, and we can at least have a little postcondition

remove commented-out Raw_Slice

general improvements

add stored length checks in calls to Get_Unbounded_String

move the Stored_Length Raw_Bytes check up in the postcondition

simpler postcondition

add post to verify Stored_Length at the right position in Get_Unbounded_String

clean up comments

new Get_String postcondition verifying Stored_Length in Raw_Bytes

minor subprogram decl reordering

add comments

weaker preconditions on Put_* numerics

correct a comment

Get_Real* both now have postconditions verifying that
the value returned in the parameter corresponds to the
raw bytes starting at the Position when Get was called

don't need the Bswap* intrinsics

minor formatting

simplified preconditions on Get_* for the two reals

Get_UInt32 at First now proves successfully

Get_UInt32 at First still not proving, but has parts we want to keep anyway

all the Get_* for ints are proving complete postconditions, except for
Get_UInt32 that specifies an absolute position via First

proving with less preconditions

use correct conversion routines for actuals passed to lemma proc

intermediate version of ByteBuffers package that successfully provers
a postcondition for Get_Int16 saying that the two bytes equal the retrieved parameter value returned

formatting

make and use a New_Content_Equal function for Byte_Array too

while package proves successfully (--level=4 --proof=progressive)

Remove post on Raw_Bytes returning Byte_Array since it is an expression function and this would preclude inlining (and is not useful anyway)

For Raw_Bytes returning String, remove useless Pre for Min_String_Length and make Post reflect actual body

remove unnecessary conversion

no use of Retrieve_x_Bytes generic

framing conditions for all Put routines in place and proving successfully!!

Get_String and Get_Unbounded_String can have postconditions simplified and strengthened;

the precondition for Get_Unbounded_String can be weakened

The final, additional byte comparisons for numeric insertion routines' postconditions are partially implemented and not proving yet

In the body, comment out the expected-to-be-unused for proof code.

remove commented-out pragma Annotate

Put_Raw_Bytes for String now proves, so now all routines do.

Next: we need to augment the numeric insertion routines'
postconditions to test that the Content slice actually
contains the argument value passed to insert

now proving Put_Raw_Bytes for input of type ByteArray

inserting into cm (permanently)

Put_Raw_Bytes can allow zero-length input arrays

simpler preconditions, but Put_Raw_* still don't prove

remove Ada2020 switch

inserting

minor formatting

Put_Raw_Bytes for Byte_Array doesn't need to check that Value'Length <= Index'Last

Put_Raw_Bytes procs don't require Value'First = 1

New_Content_Equal need not require Comparand'First to be 1

Make New_Content_Equal allow empty string input

Have Put_String and Put_Unbounded_String call New_Content_Equal and Prior_Content_Unchanged

slight refinement
additional assertions at end

intermediate commit, Put_Raw_Bytes still a problem

minor formatting

remove Length references and proc Clear

In Put_Raw_Bytes taking a Byte_Array, add the loop invariant saying that the prior content was unchanged

Intermediate checkin:

Many framing conditions proved, but not Put_Raw_Bytes
for the bytearray type

Lacking the Post for checking that the integers/real
values inserted into buffers are written where expected

update text in justifications for unchecked conversion to reals in Get_Realxx

remove Get_String_with_Recovery, per discussion with Laura

Get_Unbounded_String proves now, with modified Ada.Strings.Unbounded

First pass at Put_Raw_Bytes framing condition, not proving yet

better names for subtypes Count and Buffer_Size

ensure no wrap-around

add wrapper for memcpy, currently in comments

get unbounded strings not yet proving; needs pre/post in Ada.Strings.Unbounded

trivial indentation fix

all routines classwide now, except for Get_String_With_Recovery which won't prove without the pre/post being classwide

Get_String and Get_String_with_Recovery prove successfully.
Working on the Unbounded_Strng version.

intermediate commit, Get_String post is not proving yet

scalar stuff proves
2021-08-12 15:45:20 -05:00
lhumphrey
82746e2bc2 Merge pull request #31 from AdaCore/integration
Enhancements to Ada Code Generation
2020-12-08 17:12:57 -05:00
M. Anthony Aiello
eccb478018 Rogers/casing fix (#6)
* fix casing for generated/copied files, for TB04-026

* Add docstrings, remove redundant calls.

Docstrings are added to elements that are introduced in this change set
or are updated by this change set. The intent of the docstrings is to
explain the purpose of the various elements and, where appropriate,
suggest how they might be improved going forward.

There were several instances of redundant calls to the `SPECIAL_CASING`
map or to `getDeconflictedName`. These have been eliminated. Similarly,
redundant calls to `toLowerCase` have been eliminated where possible.

The `descending_namespace_spec` method has been significantly edited to
improve code quality.

* Previously flagged redundancies are removed. Most variables have been
  marked final. There were many instances of reuse of local variable
  for a different purpose, which challenges readability and maintenance;
  these have been eliminated and protected against through the
  systematic use of `final`.

* Inefficient string concatenation (concatenating strings with
  variables) are replaced by use of `MessageFormat`.

* Multiline strings are (efficiently) broken across over multiple lines,
  for readability.

More could be done to improve `descending_namespace_spec`, specifically
to eliminate the for loops; possibly a recursive implementation would
fit well. That was not undertaken for this commit.

For testing, Ada sources were generated from all MDMs and spot-checked
for reasonableness.

Co-authored-by: rogers <rogers@adacore.com>
2020-12-04 08:44:41 -05:00
rogers
800b572928 fix bug in Space_Available (wraparound with unsigned quantities)
Have Put_String always write the bounds but not an empty string
minor formatting
2020-10-22 14:03:27 -05:00
rogers
96065c660f fix spelling errors in comments 2020-10-22 11:16:41 -05:00
rogers
d4d8f54dc0 fix spelling errors in comments 2020-10-22 11:11:09 -05:00
lhumphrey
df705fa942 Merge pull request #30 from AdaCore/integration
Ada Fixes
2020-08-28 10:28:59 -04:00
M. Anthony Aiello
68deb577a8 Remove redundant ada directory. (#3)
This material was migrated into src a while ago and is now out of date.
2020-08-26 13:32:25 -04:00
Pat Rogers
93cdadac46 Merge pull request #5 from pat-rogers/fix_byte_buffers
Use a more robust approach
2020-08-24 15:40:58 -05:00
rogers
cd91a07e97 Use a more robust approach
* prevent numeric overflow when working with huge strings
* now raise an exception when reading a string length > message length
* now preconditions prevent inserting a string with length great than UInt16'Last
* add unit test program
2020-08-24 15:37:14 -05:00
James Hamil
3a75248e53 Merge ada branch 2020-07-24 16:34:44 -04:00
M. Anthony Aiello
d3942b2a2b Enhancements to support building Ada code (#29)
* calculate_packed_size_body must first call ancestor version

* first clear vector contents before loading them here

* correct handling for Get_Unbounded_String

* correct value used for subscriptions in series template specs

* better pre/post

* additional contracts; minor formatting

* allow putting empty unbounded_strings into buffers

* must account for 'Size that is less than 8, such as Boolean

* unpack object components into record components instead of local temp

* generate a full gpr file with generated sources

* enable warnings but not about unused/redundant entities

* fix typo in comment

* minor refinement to preclude warning msg

* Update AdaMethods to use Formal Containers

Now using formal containers, with a set size of 200. Many updates to required because the formal containers are not tagged types and cannot use the distinguished receiver syntax.

* Revert "Update AdaMethods to use Formal Containers"

This reverts commit c9af76c1f5.

* Correct the checksum calculation and usage

Co-authored-by: rogers <rogers@adacore.com>
2020-07-24 16:30:17 -04:00
lhumphrey
f63f8fea22 Change to check Python series name for None or empty string 2020-06-22 16:26:00 -04:00
Pat Rogers
27be89765f Merge pull request #27 from hamilj/develop
Generation of reference LMCP message set
2019-04-17 17:02:37 -05:00
James Hamil
39e5ed95e2 Remove generation of xml reference messages
Update existing verification code (python and C++) to test their xml
serialization/deserialization functions using the generated reference binary
byte streams.
2019-04-17 14:19:18 -04:00
James Hamil
8ebffbd76e Update precision used when writing floating point numbers as decimal strings to ensure their values remain consistent 2019-04-17 14:19:18 -04:00
James Hamil
31ef74406f Correctly handle optional empty string fields for python target 2019-04-17 14:19:18 -04:00
James Hamil
89e5c43ecf Change python xml output to only write enclosing tag for non-null struct fields, matching C++ implementation 2019-04-17 14:19:18 -04:00
James Hamil
5e4c3184c2 Allow C++ xml deserializers to accept an empty tag for potentially null struct fields 2019-04-17 14:19:18 -04:00
James Hamil
ee79cf7b6d Add C++ program and corresponding Makefile to verify the C++ generated code using the lmcp reference message set 2019-04-17 14:19:18 -04:00
James Hamil
91e96bc299 Add python script to verify its generated code using the lmcp reference message set 2019-04-17 14:19:18 -04:00
James Hamil
3ba3a65da6 Add python script to generate reference lmcp message set 2019-04-17 14:19:18 -04:00
lhumphrey
b454eb5b6d Merge pull request #26 from manthonyaiello/ada
Improvements to Generated Ada Code
2019-03-26 09:12:49 -04:00