Changes between Version 42 and Version 43 of Language


Ignore:
Timestamp:
05/21/23 22:02:09 (3 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Language

    v42 v43  
    793793== Contract Annotations #contracts
    794794
    795 clauses
     795Function contracts can be specified as annotations---formatted comments---preceding a function prototype or definition.
     796The language for these annotations is based on the specification language [https://frama-c.com/html/acsl.html ACSL] used by Frama-C.
     797The high-level syntax is
     798
     799  `/*@` ''clause''* `*/`
     800
     801Optionally, any line after the first line (which begins with `/*@` in the contract may have `*` as its first non-white-space character;
     802this character is ignored.
     803
     804There are clauses for preconditions, postconditions, and other concepts.
     805These are used in various experimental extensions of CIVL.
     806Here me describe the two clauses which are fully supported and in effect by the CIVL model checker.
     807
     808=== Specifying a guard: `enabled_when`
     809
     810This clause has syntax
     811  `enabled_when` ''expr'' `;`
     812It may be used with an [#atomic_f atomic] or [#system system] function.
     813This clause specifies a guard that applies whenever the function is called.
     814The ''expr'' may use the formal parameters of the functions as well as any other variables that are in scope.
     815Whenever control in a process is at a call to the function, the call will be enabled only if the guard evaluates to ''true''.
     816The actual arguments used in the call are substituted for the formal parameters in the guard expression.
     817
     818Note: if the actual arguments have side-effects, they are automatically refactored so that the side-effects occur once, before the call.
     819I.e., the call
     820  ''f''`(`''expr,,1,,''`,` ''expr,,2,,''`,` ...`)`
     821is semantically equivalent to
     822  `t1 =` ''expr,,1,,''`;`
     823
     824  `t2 =` ''expr,,2,,''`;`
     825
     826  ...
     827
     828  ''f''`(t1, t2,` ... `)`
     829
     830Hence the guard may be evaluated any number of times without causing additional side-effects.
     831
    796832
    797833=== The `depends_on` clause #depends_on