The records (or change history) of a field in a class. In a Java program refactored with ptolemy.backtrack.eclipse.ast.Transformer to support backtracking, every change on a field by means of assignment is recorded. The old value of the field is stored in a
FieldRecord. Every entry in the record includes the information of the timestamp (see {@link ptolemy.backtrack.Checkpoint}) denoting the time when the value was recorded, as well as that old value of the field.
It is possible the records of a field have more than zero dimension, when the field is an array. In that case, records of different dimensions are stored in different tables. E.g., an int is considered zero-dimensional, and only one list is used to store its change history. an int[] is considered one-dimensional (with one possible index). Two lists are used in order to record assignments to the array itself, and the assignment to one of its element. In the latter case, the index of the changed element is also recorded. Similarly, a field of type int[][] requires three lists.
Lists of records are added with different add functions, which take a timestamp and record the old value taken at that timestamp at the head position of the corresponding list. Timestamps must be increasing. A value with larger timestamp means it is taken later in time.
To access the lists, iterators must be used to iterate from the most recent recorded value to the earliest ones. Records in the lists may also be removed with remove functions of the iterators. As with many other iterators, modifications cannot be made simultaneously with two different iterators. add functions cannot be called while accessing any list with an iterator, either. If changes are made simultaneously, the effect is unpredictable.
@author Thomas Feng
@version $Id: FieldRecord.java,v 1.26 2007/12/06 18:32:09 cxh Exp $
@since Ptolemy II 5.1
@Pt.ProposedRating Red (tfeng)
@Pt.AcceptedRating Red (tfeng)