Changes between Version 43 and Version 44 of IR
- Timestamp:
- 11/24/15 08:54:38 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IR
v43 v44 5 5 6 6 * the language is not intended to be written by humans; it is an intermediate form constructed by CIVL. However it should be readable to help debug things 7 * the language (and grammar) are subsets of CIVL-C 7 * the language (and grammar) are subsets of CIVL-C. **MAYBE, MAYBE NOT** 8 8 * a CIVL-IR program represents a guarded-transition system explicitly 9 9 * as in CIVL-C, there are functions, scopes, and functions can be defined in any scope 10 * all blocks (including a function body) consist of the following elements :10 * all blocks (including a function body) consist of the following elements, in this order: 11 11 * a sequence of type definitions 12 12 * a sequence of variable declarations with no initializers … … 15 15 * an array is declared without any length expression. When it is initialized it can specify length. 16 16 17 **Can we specify that elements must appear in the order above?** Or would that create a problem in something like18 {{{19 {20 $integer x=3*y;21 $integer a[x+1];22 }23 }}}24 25 26 17 Example: 27 28 18 {{{ 29 19 $integer f() { … … 52 42 }}} 53 43 44 Example: 45 {{{ 46 { 47 $integer x=3*y; 48 $integer a[x+1]; 49 } 50 }}} 51 translates to: 52 {{{ 53 { 54 $integer x; 55 $integer a[]; 56 L1: 57 $choose { $when ($true) x=3*y; goto L2; } 58 L2: 59 $choose { $when ($true) a=$initval($integer[x+1]); goto L3; } 60 L3: 61 } 62 63 54 64 == Types == 55 65 … … 60 70 * `$scope` : scope type 61 71 * `$char` : character type. Alternatively, get rid of this and just use an integer type. 62 * `$mem` : type representing set of memory units63 72 * `$bundle` : type representing some un-typed chunk of data 64 73 * `$heap` : heap type 65 74 * `$range` : ordered set of integers 66 75 * `$domain` : ordered set of tuples of integers 67 * `$domain(n)`, n is an integer at least 1; subtype of abovein which all tuples have arity n.76 * `$domain(n)`, n is an integer at least 1; subtype of `$domain` in which all tuples have arity n. 68 77 * `enum` types. 69 78 * **different from integers or like C?** … … 78 87 * IEEE754 floating point numbers 79 88 * `$hreal` : Herbrand real numbers. Values are unsimplified symbolic expressions. 80 * `struct(T1,...,Tn)` 89 * `struct` types 90 * `struct tag { decl1; ...; decln };` or 91 * `struct tag;` 81 92 * structure type with named fields. Names may not seem necessary but if you want a subset of CIVL-C... 82 93 * **What about bit-widths?** 83 * `union (T1,...,Tn)` : similar to struct94 * `union`: similar to structs 84 95 * `T[]` : array-of-T 85 96 * Function<S1,...,Sn;T> 86 97 * function consuming S1,...,Sn and returning T. T can be void. The actual notation is the horrible C notation. 87 * `void*` : all pointers 88 * `T*` : pointer-to-T, subtype of above 98 * `$mem` : type representing a memory set. May be thought of as a set of pointers. 99 * `void*` : all pointers, a subtype of `$mem` 100 * `T*` : pointer-to-T, subtype of `void*` 89 101 90 102 Type facts: … … 128 140 129 141 130 == Declarations ==131 132 Declarations follow the C notation. Function prototypes are considered to be declarations similar to variable declarations.133 134 Example of declaration of a function:135 {{{136 $integer f($real x, $bool y);137 }}}138 139 Additional modifiers that may be placed on any of above:140 * `$pure` : the function has no side effects, but may be nondeterministic141 * `$abstract`: function is a pure, mathematical function: deterministic function of inputs142 * `$atomic_f`: function definition is atomic, and it never blocks143 144 System functions:145 * A function declaration which is not abstract and for which no definition is provided is a system function.146 * 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.147 * A system function may modify any memory it can reach. This includes allocating new data on heaps it can reach.148 * A system function may have a guard.149 150 Example of a declaration of a system function with guard.151 {{{152 $bool g($real x, $bool y) { ... }153 $integer f($real x, $bool y) $guard {g};154 }}}155 142 156 143 … … 239 226 * For_dom_enter (for domains): `$for_enter(i,j,k..: dom);` 240 227 241 242 == Contracts of Functions == 228 == Declarations and Function Definitions == 229 230 Declarations follow the C notation. Function prototypes are considered to be declarations similar to variable declarations. 231 232 Example of declaration of a function: 233 {{{ 234 $integer f($real x, $bool y); 235 }}} 236 237 Additional modifiers that may be placed on any of above: 238 * `$pure` : the function has no side effects, but may be nondeterministic 239 * `$abstract`: function is a pure, mathematical function: deterministic function of inputs 240 * `$atomic_f`: function definition is atomic, and it never blocks 241 242 System functions: 243 * A function declaration which is not abstract and for which no definition is provided is a system function. 244 * 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. 245 * A system function may modify any memory it can reach. This includes allocating new data on heaps it can reach. 246 * A system function may have a guard. 247 248 Example of a declaration of a system function with guard. 249 {{{ 250 $bool g($real x, $bool y) { ... } 251 $integer f($real x, $bool y) $guard {g}; 252 }}} 253 254 255 == Function Contracts == 256 243 257 * event set expressions: 244 258 {{{ … … 302 316 }}} 303 317 304 == Function definition ==305 306 318 == Program == 307 319 … … 321 333 322 334 323 324 335 === Transitions === 325 336 326 337 327 328 338 == Libraries ==
