| | 1 | = Thoughts on references = |
| | 2 | |
| | 3 | Create interfaces: |
| | 4 | * `ReferenceExpression extends SymbolicExpression` |
| | 5 | * `NTReferenceExpression extends ReferenceExpression` for non-trivial references, i.e., references to a tuple component, array element, or union member, or an "offset reference" |
| | 6 | * `ArrayElementReference extends NTReferenceExpression` |
| | 7 | * `TupleComponentReference extends NTReferenceExpression` |
| | 8 | * `UnionMemberReference extends NTReferenceExpression` |
| | 9 | * `OffsetReference extends NTReferenceExpression` |
| | 10 | |
| | 11 | Interface: |
| | 12 | |
| | 13 | The following methods can go in `ReferenceExpression`: |
| | 14 | |
| | 15 | {{{ |
| | 16 | /** Is this the null reference? */ |
| | 17 | boolean isNullReference(); |
| | 18 | |
| | 19 | /** Is this the identity reference? */ |
| | 20 | boolean isIdentityReference(); |
| | 21 | |
| | 22 | /** Is this an array element reference? */ |
| | 23 | boolean isArrayElementReference(); |
| | 24 | |
| | 25 | /** Is this a tuple component reference? */ |
| | 26 | boolean isTupleComponentReference(); |
| | 27 | |
| | 28 | /** Is this a union element reference? */ |
| | 29 | boolean isUnionMemberReference(); |
| | 30 | |
| | 31 | /** Is this an "offset reference" ? */ |
| | 32 | boolean isOffsetReference(); |
| | 33 | }}} |
| | 34 | |
| | 35 | The following methods can go in `NTReferenceExpression`: |
| | 36 | |
| | 37 | {{{ |
| | 38 | /** As this is a reference to an array element, tuple component, union member, |
| | 39 | * or an offset reference, returns the reference to the parent, |
| | 40 | * i.e., the array, tuple, union, or the other reference, resp. |
| | 41 | ReferenceExpression getParent(); |
| | 42 | }}} |
| | 43 | |
| | 44 | In `ArrayElementReference`: |
| | 45 | {{{ |
| | 46 | NumericExpression getIndex(); |
| | 47 | }}} |
| | 48 | |
| | 49 | In `TupleComponentReference`: |
| | 50 | {{{ |
| | 51 | IntObject getIndex(); |
| | 52 | }}} |
| | 53 | |
| | 54 | In `UnionMemberReference`: |
| | 55 | {{{ |
| | 56 | IntObject getIndex(); |
| | 57 | }}} |
| | 58 | |
| | 59 | In `OffsetReference`: |
| | 60 | {{{ |
| | 61 | NumericExpression getOffset(); |
| | 62 | }}} |
| | 63 | |
| | 64 | |
| | 65 | The following can go in `SymbolicUniverse`: |
| | 66 | |
| | 67 | {{{ |
| | 68 | /** Returns the type of all reference expressions. */ |
| | 69 | SymbolicType referenceType(); |
| | 70 | |
| | 71 | /** Returns the "null reference", a symbolic expression of reference type which is |
| | 72 | * not equal to a reference value returned by |
| | 73 | * any of the other methods, and which cannot be dereferenced. */ |
| | 74 | ReferenceExpression nullReference(); |
| | 75 | |
| | 76 | /** Given a reference and a value, returns the sub-expression of value specified by the reference. |
| | 77 | * Throws exception if the reference is not of the correct form for the type of value. */ |
| | 78 | SymbolicExpression dereference(SymbolicExpression value, ReferenceExpression reference); |
| | 79 | |
| | 80 | /** Returns the identity (or "trivial") reference I. This is the reference characterized by the |
| | 81 | * property that dereference(I,v) returns v for any symbolic expression v. */ |
| | 82 | ReferenceExpression identityReference(); |
| | 83 | |
| | 84 | /** Given a reference to an array and an index (integer), returns a reference to the element of the array |
| | 85 | * at that index */ |
| | 86 | ArrayElementReference arrayElementReference(ReferenceExpression arrayReference, NumericExpression index); |
| | 87 | |
| | 88 | /** Given a reference to a tuple, and a field index, returns a reference to that component of the tuple */ |
| | 89 | TupleComponentReference tupleComponentReference(ReferenceExpression tupleReference, IntObject fieldIndex); |
| | 90 | |
| | 91 | /** Given a reference to a union (expression of union type) and an index of a member type of that union, returns |
| | 92 | * a reference to the underlying element */ |
| | 93 | UnionMemberReference unionElementReference(ReferenceExpression unionReference, IntObject memberIndex); |
| | 94 | |
| | 95 | OffsetReference offsetReference(ReferenceExpression reference, NumericExpression offset); |
| | 96 | |
| | 97 | /** Given a symbolic expression value, a reference to a point within that value, and a subValue, returns |
| | 98 | * the symbolic expression obtained by replacing the referenced part of value with subValue. */ |
| | 99 | SymbolicExpression assign(SymbolicExpression value, ReferenceExpression reference, SymbolicExpression subValue); |
| | 100 | }}} |