Changes between Initial Version and Version 1 of References


Ignore:
Timestamp:
03/15/16 15:10:00 (10 years ago)
Author:
zmanchun
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • References

    v1 v1  
     1= Thoughts on references =
     2
     3Create 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
     11Interface:
     12
     13The following methods can go in `ReferenceExpression`:
     14
     15{{{
     16/** Is this the null reference? */
     17boolean isNullReference();
     18
     19/** Is this the identity reference? */
     20boolean isIdentityReference();
     21
     22/** Is this an array element reference? */
     23boolean isArrayElementReference();
     24
     25/** Is this a tuple component reference? */
     26boolean isTupleComponentReference();
     27
     28/** Is this a union element reference? */
     29boolean isUnionMemberReference();
     30
     31/** Is this an "offset reference" ? */
     32boolean isOffsetReference();
     33}}}
     34
     35The 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.
     41ReferenceExpression getParent();
     42}}}
     43
     44In `ArrayElementReference`:
     45{{{
     46NumericExpression getIndex();
     47}}}
     48
     49In `TupleComponentReference`:
     50{{{
     51IntObject getIndex();
     52}}}
     53
     54In `UnionMemberReference`:
     55{{{
     56IntObject getIndex();
     57}}}
     58
     59In `OffsetReference`:
     60{{{
     61NumericExpression getOffset();
     62}}}
     63
     64
     65The following can go in `SymbolicUniverse`:
     66
     67{{{
     68/** Returns the type of all reference expressions. */
     69SymbolicType 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. */
     74ReferenceExpression 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. */
     78SymbolicExpression 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. */
     82ReferenceExpression 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 */
     86ArrayElementReference 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 */
     89TupleComponentReference 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 */
     93UnionMemberReference unionElementReference(ReferenceExpression unionReference, IntObject memberIndex);
     94
     95OffsetReference 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. */
     99SymbolicExpression assign(SymbolicExpression value, ReferenceExpression reference, SymbolicExpression subValue);
     100}}}