Changes between Version 74 and Version 75 of IR
- Timestamp:
- 11/26/15 15:47:13 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
IR
v74 v75 1 1 2 2 The CIVL-IR language. A program in this language is also known as a "CIVL model". 3 4 ** CAN WE GET RID OF ALL \S EVERYWHERE???**5 3 6 4 Properties of the language: … … 25 23 Example: 26 24 {{{ 27 f(u:Integer, a:Array[Real]): Integer {25 def f(u:Integer, a:Array[Real]): Integer { 28 26 x: Real; 29 27 y: Real; … … 31 29 32 30 L1 : 33 when (g1)stmt1; goto L2;34 when (g2)stmt2; goto L3;31 when g1 do stmt1; goto L2; 32 when g2 do stmt2; goto L3; 35 33 36 34 { // begin new scope 37 35 x: Real; 38 36 L2 : 39 when (g3)stmt3; goto L4;37 when g3 do stmt3; goto L4; 40 38 ... 41 39 } // end new scope … … 59 57 a: Array[Integer]; 60 58 L1: 61 when (\true) ASSIGN x, mul(3,y); goto L2;59 when true do ASSIGN "x", mul(3,"y"); goto L2; 62 60 L2: 63 when (\true) ASSIGN a_t, dytype(Array[Integer, add(x,1)]); goto L3;61 when true do ASSIGN "a_t", dytype(Array[Integer, add("x",1)]); goto L3; 64 62 L3: 65 when (\true) ASSIGN a, new(a_t); goto L4;63 when true do ASSIGN "a", new("a_t"); goto L4; 66 64 L4: 67 65 } … … 73 71 The types are: 74 72 75 * `Bool` : boolean type, values are ` \true` and `\false`73 * `Bool` : boolean type, values are `true` and `false` 76 74 * `Proc` : process type 77 75 * `Scope` : scope type … … 86 84 * `Integer` : the mathematical integers 87 85 * `Int[lo,hi,wrap]` 88 * `lo`, `hi` are integers, `wrap` is boolean86 * `lo`, `hi` are concrete (?) integers, `wrap` is boolean 89 87 * finite interval of integers `[lo,hi]`. If `wrap` is true then all operations "wrap", otherwise, any operation resulting in a value outside of the interval results in an exception being thrown. 90 88 * **Do we want to allow `lo` and `hi` to be any values of type `Integer`, which means they are dynamic types, like complete array types?** 91 89 * `HerbrandInt` : Herbrand integers. Values are unsimplified symbolic expressions. 92 90 * `Real` : the mathematical real numbers 93 * `Float[e,f]`, e, f are integers, each at least 1. **Same question for e and f as for lo and hi.**91 * `Float[e,f]`, `e`, `f` are concrete integers, each at least 1. 94 92 * IEEE754 floating point numbers 95 93 * `HerbrandReal` : Herbrand real numbers. Values are unsimplified symbolic expressions. … … 135 133 136 134 L0: 137 when (\true) ASSIGN n, 10; goto L1;135 when true do ASSIGN "n", 10; goto L1; 138 136 L1: 139 when (\true) ASSIGN S_d, dytype(Tuple[<Array[Integer, n]]>); goto L2;137 when true do ASSIGN "S_d", dytype(Tuple[<Array[Integer, "n"]]>); goto L2; 140 138 L2: 141 when (\true) ASSIGN x1, new(S_d); goto L3;139 when true do ASSIGN "x1", new("S_d"); goto L3; 142 140 L3: 143 when (\true) ASSIGN n, 20; goto L4;141 when true do ASSIGN "n", 20; goto L4; 144 142 L4: 145 when (\true) ASSIGN x2, new(S_d); goto L5;143 when true do ASSIGN "x2", new("S_d"); goto L5; 146 144 L5: 147 145 }}} … … 153 151 154 152 Logical 155 * ` \true`, `\false` : literal values of type `Bool`153 * `true`, `false` : literal values of type `Bool` 156 154 * `not(e)` : logical not 157 155 * `and(e1,e2)`, `or(e1,e2)`: logical and/or operation. These operators are short-circuiting, which matters because of exception side-effects. … … 173 171 Characters and Strings 174 172 * 'a', 'b', ... : Char values. **UNICODE?** 175 * ` "abc"` : string literals: value of type `Array[Char, n+1]`, where n is the length of the string (the last element is the character `\0`)173 * `string("abc")` : string literals: value of type `Array[Char, n+1]`, where n is the length of the string (the last element is the character `\0`) 176 174 Ranges and Domains 177 175 * `range(e1,e2,e3)` : value of type `Range`. If `e3` is positive, the integers e1, e1+e3, e1+2*e3, ... that are less than or equal to `e2`. If `e3` is negative, the integers e1, e1+e3, e1+2*e3, ... that are greater than or equal to `e2`. Exception if `e3` is 0. … … 205 203 * `mem_slice(a,dom)`, where `a` is an expression of array type and `dom` is an expression of `Domain` type. The dimension of the array must match the dimension of the domain. This represents all memory units which are the cells in the array indexed by a tuple in `dom`. 206 204 Scopes and Processes 207 * ` \root`, `\here` : values of type `Scope`208 * ` \self`, `\proc_null` : values of type `Proc`209 Other 210 * variables205 * `root`, `here` : values of type `Scope` 206 * `self`, `proc_null` : values of type `Proc` 207 Other expressions 208 * `"x"` : x is an identifier, naming either a type, variable, or function 211 209 * `sizeof_type(t)` : the size of the dynamic type t; `Integer` type 212 210 * `sizeof_expr(e)` : the size of the value of expression `e`; `Integer` type … … 219 217 * `ite(e1,e2,e3)`: if-then-else (conditional) expression, like `e1?e2:e3` in C. 220 218 * `call(e0,<e1,...,en>)` : a function invocation where `e0` must evaluate to either an abstract or pure system function 219 * `choose_int(e)` : nondeterministic choice of integer 221 220 222 221 == The Primitive Statements == … … 261 260 * `abstract`: function is a pure, mathematical function: deterministic function of inputs 262 261 * `atomic`: function definition is atomic, and it never blocks **ISN'T THIS TRUE OF EVERY SYSTEM FUNCTION? IN WHICH CASE, IS THIS ONLY FOR NON-SYSTEM FUNCTIONS?** 263 * `'lib="..."`: function is a system function defined in specified library 262 * `lib="..."`: function is a system function defined in specified library 263 * `guard="...":` the name of the guard function 264 264 265 265 System functions: … … 272 272 {{{ 273 273 g(x:Real):Bool { ... } 274 def[lib="Blah" ] f(x:Real):Integer guard g;274 def[lib="Blah",guard="g"] f(x:Real):Integer; 275 275 }}} 276 276 … … 344 344 == Program == 345 345 346 A program consists of a sequence of global variable declarations, which may include declarations annotated by ` $input` and `$output`,346 A program consists of a sequence of global variable declarations, which may include declarations annotated by `input` and `output`, 347 347 followed by a sequence of function declarations and definitions. 348 * ` \input`349 * ` \output`348 * `input` 349 * `output` 350 350 351 351 == Semantics == … … 365 365 366 366 == Libraries == 367 368 Which libraries require system functions? 369 pointer, ... 370 Should these be called part of the language, or not? 371
