| 97 | | * `Tuple[type0, type1, ...]`: a tuple type which contains a sequence of sub-types |
| 98 | | * `Union`: similar to structs |
| 99 | | * `Array[T]` : array-of-T |
| 100 | | * `Function[S1,...,Sn;T]` |
| 101 | | * function consuming `S1,...,Sn` and returning `T`. `T` can be void. The actual notation is the horrible C notation. |
| | 90 | * `Union[T0, T1, ...]`: union type, the disjoint union of T0, T1, ... |
| | 91 | * `Array[T]` : arrays of any length whose elements belong to T |
| | 92 | * `Function[(T0,T1,...),T]` : functions consuming T0,T1,... and returning T. T can be `void` to indicate nothing is returned. |
| 109 | | **Pure types** contain no values anywhere in the type tree. That is, there is no array length expression in the type. The pure types are the static types of the CIVL-IR. Each variable is declared to have some pure type. |
| 110 | | |
| 111 | | **Augmented types** include all the pure types plus possible length expressions. |
| 112 | | |
| 113 | | A **type name** is a syntactic element that names a (pure or augmented) type Examples include `int[]` and `int[n*m]`. This is the same as in C. |
| 114 | | |
| 115 | | The expression `\new(T)` takes a type name and returns the initial value for an object of that type. The initial value of `Integer` and other primitive (non-compound) types is "undefined". The initial value of `Array[Integer]` is an array of length 0 of `Integer`. The initial value of `Pointer[Real]` is the undefined pointer to `Real`. The initial value of `Array[Real, 10]` is the array of length 10 in which each element is undefined. In general, the initial value of an array of length n is the sequence of length n in which every element is the initial value of the element type of the array. The initial value of a structure is the tuple in which each component is assigned the initial value for its type. |
| 116 | | |
| 117 | | Example: |
| | 101 | **Static types** are the types assigned to variables in a program statically. A static type contains no values anywhere in the type tree. That is, there is no array length expression in the type. These are the types that are used in declarations. Each variable is declared to have some static type. |
| | 102 | |
| | 103 | **Value types** are the types associated to values. They include all the static types plus possible length expressions. A value type refines a static type if when you delete the values from the value type you get the static type. |
| | 104 | |
| | 105 | A **type name** is a syntactic element that names a (static or value) type. Examples of type names include `Array[Integer]` and `Array[Integer,24]`. |
| | 106 | |
| | 107 | The expression `\new(t)` takes a Dytype and returns the initial value for an object of that type. The initial value of `Integer` and other primitive (non-compound) types is "undefined". The initial value of `Array[Integer]` is an array of length 0 of `Integer`. The initial value of `Pointer[Real]` is the undefined pointer to `Real`. The initial value of `Array[Real, 10]` is the array of length 10 in which each element is undefined. In general, the initial value of an array of length n is the sequence of length n in which every element is the initial value of the element type of the array. The initial value of a tuple type is the tuple in which each component is assigned the initial value for its type. |
| | 108 | |
| | 109 | Example: the C code |
| | 110 | {{{ |
| | 111 | int n = 10; |
| | 112 | struct S { int a[n]; }; |
| | 113 | struct S x1; |
| | 114 | n=20; |
| | 115 | struct S x2; |
| | 116 | }}} |
| | 117 | |
| | 118 | may be translated as |
| | 119 | |
| 158 | | * 123, -123, 3.1415, etc. : values of type `Integer`, `Int`, `Real`, `Float` |
| 159 | | * **what particular notations for floating values?** |
| 160 | | * 'a', 'b', ... **UNICODE?** |
| 161 | | * `\array(T, (e0, e1, e2, ...))`: values of type `Array[T]`; and `\array(T, n, e)`: an array of type `T` with `n` elements each of which being `e` |
| 162 | | * `\tuple(S, (e0, e1, ...))` : values of type `S` (struct literal) |
| 163 | | * `e1..e2`, `e1..e2#e3` : values of type `\Range` |
| 164 | | * `\domain(r1,...,rn)` : value of type `Domain[n]` |
| 165 | | * `"abc"` : string literals: value of type `Array[Char]` |
| | 145 | * 123, -123, 3.1415, etc. : values of type `Integer`, `Int`, `Real`, `Float`. **NEED TO BE MORE SPECIFIC** |
| | 146 | * 'a', 'b', ... : Char values. **UNICODE?** |
| | 147 | * `\array(T, (e0, ..., en-1))`: value of type `Array[T, n]`, a literal array |
| | 148 | * `\array(T, n, e)`: value of type `Array[T,n]` in which each of the n elements is `e` |
| | 149 | * `\tuple(S, (e0, e1, ...))` : value of tuple type `S` (tuple literal) |
| | 150 | * `\range(e1,e2,e3)` : value of type `Range` consisting of the integers e1, e1+e3, e1+2*e3, ... that are less than or equal to e2. |
| | 151 | * `\domain(r1,...,rn)` : value of type `Domain[n]`, the ordered Cartesian product of the n ranges (dictionary order) |
| | 152 | * `"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`) |
| 174 | | * `\has_next(dom, i, j, k, …)`: an expression of boolean type, testing if the domain `dom` contains any element after `(i, j, k, ...)` |
| | 161 | * `\has_next(dom, (i, j, …))`: an expression of boolean type, testing if the domain `dom` contains any element after `(i, j, ...)` |
| 202 | | * **Memory set expressions**: are these literal values of type `Mem`? |
| 203 | | * a left-hand-side expression, when used in certain contexts, is automatically converted to `Mem`. The contexts are: arguments to the built-in functions `\access`, `\read`, and `\write` described below, or occurrence in the list of an `\assigns` clause |
| 204 | | * `\array_chunk(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`. |
| 205 | | * `\region(ptr)`, where `ptr` is an expression with a pointer type. This represents the set of all memory units reachable from `ptr`, including the memory unit pointed to by `ptr` itself. |
| 206 | | * **\mem_reach ?** |
| 207 | | * `\mem_union(mem1, mem2)`, where `mem1` and `mem2` are expressions of type `Memory`. This is the union of the two sets. |
| | 187 | * a left-hand-side expression, when used in certain contexts, is automatically converted to `Mem`. The contexts are: arguments to the built-in functions `\access`, `\read`, and `\write` described below, or occurrence in the list of an `\assigns` clause |
| | 188 | * `\array_chunk(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`. |
| | 189 | * `\region(ptr)`, where `ptr` is an expression with a pointer type. This represents the set of all memory units reachable from `ptr`, including the memory unit pointed to by `ptr` itself. |
| | 190 | * **\mem_reach ?** |
| | 191 | * `\mem_union(mem1, mem2)`, where `mem1` and `mem2` are expressions of type `Memory`. This is the union of the two sets. |