Changes between Version 86 and Version 87 of IR
- Timestamp:
- 11/29/15 10:52:03 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IR
v86 v87 48 48 {{{ 49 49 fun 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]; 53 53 54 54 L1 : … … 79 79 {{{ 80 80 { 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]; 84 84 85 85 ASSIGN "x", mul(3,"y"); … … 150 150 type S=Tuple[<Array[Integer]>]; 151 151 152 n: Integer;153 S_d: Dytype[S];154 x1: S;155 x2: S;152 var n: Integer; 153 var S_d: Dytype[S]; 154 var x1: S; 155 var x2: S; 156 156 157 157 ASSIGN "n", 10; … … 270 270 * `FOR_ENTER dom;` **FIX ME** 271 271 272 == Declarations and Function Definitions == 273 274 Function prototypes are considered to be declarations similar to variable declarations. 272 == Function Definitions == 273 274 The general form of a function definition: 275 276 {{{ 277 fun[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 275 304 276 305 Example of declaration of a system function defined in library Concurrency: 277 306 {{{ 278 fun[lib="edu.udel.cis.vsl.civl.lib.Concurrency"] f(x: Real, b: Bool): Float[32,33] ;307 fun[lib="edu.udel.cis.vsl.civl.lib.Concurrency"] f(x: Real, b: Bool): Float[32,33] {} 279 308 }}} 280 309 … … 287 316 288 317 System 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. 290 320 * 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`. 293 323 294 324 Example of a declaration of a system function with guard. 295 325 {{{ 296 g(x:Real):Bool { ... } 297 fun[lib="Blah",guard="g"] f(x:Real):Integer; 298 }}} 299 300 301 == Function Contracts == 326 fun g(x:Real):Bool { ... } 327 fun[lib="Blah",guard="g"] f(x:Real):Integer {} 328 }}} 329 330 331 === Function Contracts === 332 333 **THIS NEEDS TO BE UPDATED** 302 334 303 335 * event set expressions: … … 396 428 397 429 * fix notation for contracts 398 * can labels, whens, chooses be optional? See proposed statement grammar below.399 430 * quotes around variables in declarations? Could be awkward but might simplify parsing. 400 431 * quotes around function names in definitions, prototypes? Could be awkward. … … 402 433 * 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. 403 434 404
