Changes between Version 86 and Version 87 of IR


Ignore:
Timestamp:
11/29/15 10:52:03 (10 years ago)
Author:
siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • IR

    v86 v87  
    4848{{{
    4949fun f(u:Integer, a:Array[Real]): Integer {
    50   x: Real;
    51   y: Real;
    52   z: Float[16,23];
     50  var x: Real;
     51  var y: Real;
     52  var z: Float[16,23];
    5353 
    5454L1 :
     
    7979{{{
    8080{
    81   x: Integer;
    82   a_t : Dytype[Array[Integer]];
    83   a: Array[Integer];
     81  var x: Integer;
     82  var a_t : Dytype[Array[Integer]];
     83  var a: Array[Integer];
    8484
    8585  ASSIGN "x", mul(3,"y");
     
    150150type S=Tuple[<Array[Integer]>];
    151151
    152 n: Integer;
    153 S_d: Dytype[S];
    154 x1: S;
    155 x2: S;
     152var n: Integer;
     153var S_d: Dytype[S];
     154var x1: S;
     155var x2: S;
    156156
    157157ASSIGN "n", 10;
     
    270270* `FOR_ENTER dom;` **FIX ME**
    271271
    272 == Declarations and Function Definitions ==
    273 
    274 Function prototypes are considered to be declarations similar to variable declarations.
     272==  Function Definitions ==
     273
     274The general form of a function definition:
     275
     276{{{
     277fun[options] foo(x:Integer, ...) : Real {
     278
     279  // contract clauses (optional):
     280  requires expr;
     281  ensures expr ;
     282  mpi_requires expr ;
     283  mpi_ensures expr ;
     284  assigns expr ;
     285  reads expr ;
     286  depends actions ;
     287
     288  // all of the following are missing for a system function...
     289
     290  // types defns:
     291  type T=tuple[<blah, blay>];
     292  type U=blah;
     293
     294  // variable decls:
     295  var x : T;
     296  var y : U;
     297
     298  // body:
     299  ASSIGN x, 0;
     300  ...
     301}
     302}}}
     303
    275304
    276305Example of declaration of a system function defined in library Concurrency:
    277306{{{
    278 fun[lib="edu.udel.cis.vsl.civl.lib.Concurrency"] f(x: Real, b: Bool): Float[32,33];
     307fun[lib="edu.udel.cis.vsl.civl.lib.Concurrency"] f(x: Real, b: Bool): Float[32,33] {}
    279308}}}
    280309
     
    287316
    288317System functions:
    289 * A function declaration which is not abstract and for which no definition is provided is a system function.
     318* A function declaration which contains an option `lib=...` is a system function
     319* A system function will have no body.  It may have any number (including 0) of contract clauses.
    290320* If the system function is called anywhere in the program, it must be defined by providing Java code in an Enabler and Executor.  Failure to do so will result in an exception.
    291 * A system function may modify any memory it can reach.  This includes allocating new data on heaps it can reach.
    292 * A system function may have a guard.
     321* A system function may modify only memory it can reach.  This includes allocating new data on heaps it can reach.   This modifiable memory can be further limit by the contract.
     322* A system function may have a guard, which is another function taking the same types of inputs, but returning `Bool`.
    293323
    294324Example of a declaration of a system function with guard.
    295325{{{
    296 g(x:Real):Bool { ... }
    297 fun[lib="Blah",guard="g"] f(x:Real):Integer;
    298 }}}
    299 
    300 
    301 == Function Contracts ==
     326fun g(x:Real):Bool { ... }
     327fun[lib="Blah",guard="g"] f(x:Real):Integer {}
     328}}}
     329
     330
     331=== Function Contracts ===
     332
     333**THIS NEEDS TO BE UPDATED**
    302334
    303335* event set expressions:
     
    396428
    397429* fix notation for contracts
    398 * can labels, whens, chooses be optional?   See proposed statement grammar below.
    399430* quotes around variables in declarations?  Could be awkward but might simplify parsing.
    400431* quotes around function names in definitions, prototypes?  Could be awkward.
     
    402433* should we leave our parameter names in abstract and system functions?  They are not needed for anything.  THEY ARE NEEDED FOR CONTRACTS, sometimes, and maybe for documentation.    Consider making them optional.
    403434
    404