HeapCell.java

package edu.udel.cis.vsl.tass.dynamic.impl.cell;

import edu.udel.cis.vsl.tass.dynamic.IF.cell.HeapCellIF;
import edu.udel.cis.vsl.tass.model.IF.ModelIF;
import edu.udel.cis.vsl.tass.model.IF.ProcessIF;

public class HeapCell extends Cell implements
		HeapCellIF {

	private int heapIndex;

	private ProcessIF process;

	/**
	 * Every heap-allocated thing is an array, because the only way to generate
	 * a heap object is through a call to Allocate(type, length), which creates
	 * an array of that length of the given type.
	 */
	public HeapCell(ProcessIF process, int heapIndex) {
		super(DynamicScope.HEAP);
		this.heapIndex = heapIndex;
		this.process = process;
	}

	public int heapIndex() {
		return heapIndex;
	}

	public String toString() {
		return "__heap_" + process.pid() + "_" + heapIndex;
	}

	public boolean equals(Object object) {
		if (object instanceof HeapCell) {
			HeapCell that = (HeapCell) object;

			return super.equals(that) && process.equals(that.process)
					&& heapIndex == that.heapIndex;
		}
		return false;
	}

	public int hashCode() {
		return super.hashCode() + process.hashCode() + heapIndex;
	}

	public ProcessIF process() {
		return process;
	}

	public ModelIF model() {
		return process.model();
	}
}