| | 28 | == Translation == |
| | 29 | |
| | 30 | Thoughts on processing struct definitions: |
| | 31 | |
| | 32 | * transform the AST to factor out all struct definitions embedded in declarations. This is really part of "side-effect-removal". |
| | 33 | * translate a struct definition `struct foo { … } ` as follows. |
| | 34 | * Let `t` be the `CIVLType` resulting from translating the ABC type. |
| | 35 | * Create a new `Variable` of type `CIVLDynamicType` and add it to the current scope. Call the variable `__struct_foo__`. |
| | 36 | * Create as assignment statement at the current location: `__struct_foo__ = DynamicTypeOf(t)` |
| | 37 | * any variable declaration with a compound type (struct, union, array) should be translated as follows: |
| | 38 | * add the variable `v` to the current scope with the translated type `t` as usual |
| | 39 | * add an assignment statement at the current location: `v=InitialValue[v, CIVLDynamicType(t)]` |
| | 40 | * Evaluation of `CIVLDynamicType(t)` in a state `s` is defined as follows: |
| | 41 | * if `t` is a struct type, say with tag `foo`, then the result is the result of evaluating the variable (in s) `__struct_foo__` |
| | 42 | * if `t` is an array type with element type `E` and length expression `l`, the result is obtained by evaluating `CIVLDynamicType(E)`, call the result `de`; evaluating `l`, call the result `dl`; and return `completeArrayType(de,dl)` (eliding the wrapping and unwrapping of the symbolic type into a symbolic expression value) |
| | 43 | |
| | 44 | |
| | 45 | |