Class SimObject
- java.lang.Object
-
- com.tonic.analysis.simulation.heap.SimObject
-
public final class SimObject extends Object
Immutable abstract heap object for one allocation site, holding a set of possible values per field; every mutator returns a new instance.
-
-
Constructor Summary
Constructors Constructor Description SimObject(AllocationSite site)Creates an unescaped object with no fields written.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Set<SimValue>getField(FieldKey key)Set<FieldKey>getFieldKeys()AllocationSitegetSite()booleanhasEscaped()booleanhasField(FieldKey key)inthashCode()SimObjectmarkEscaped()SimObjectmerge(SimObject other)Unions the field value sets of two views of the same allocation site, escaping the result if either side escaped.StringtoString()SimObjectwithField(FieldKey key, SimValue value)Adds one value to a field's set - a weak update, keeping whatever is already there.SimObjectwithFieldSet(FieldKey key, Set<SimValue> values)Adds several values to a field's set - a weak update, keeping whatever is already there.
-
-
-
Constructor Detail
-
SimObject
public SimObject(AllocationSite site)
Creates an unescaped object with no fields written.- Parameters:
site- the allocation site it stands for- Throws:
NullPointerException- if the site is null
-
-
Method Detail
-
getSite
public AllocationSite getSite()
- Returns:
- the site
-
hasEscaped
public boolean hasEscaped()
- Returns:
- whether escaped
-
getFieldKeys
public Set<FieldKey> getFieldKeys()
- Returns:
- an unmodifiable view of the fields written so far
-
getField
public Set<SimValue> getField(FieldKey key)
- Parameters:
key- the field to read- Returns:
- an unmodifiable view of its values, empty if never written
-
hasField
public boolean hasField(FieldKey key)
- Parameters:
key- the field to test- Returns:
- true if the field has been written
-
withField
public SimObject withField(FieldKey key, SimValue value)
Adds one value to a field's set - a weak update, keeping whatever is already there.- Parameters:
key- the fieldvalue- the value to add- Returns:
- the updated copy
-
withFieldSet
public SimObject withFieldSet(FieldKey key, Set<SimValue> values)
Adds several values to a field's set - a weak update, keeping whatever is already there.- Parameters:
key- the fieldvalues- the values to add; an empty set is a no-op- Returns:
- the updated copy, or this object if nothing was added
-
markEscaped
public SimObject markEscaped()
- Returns:
- a copy flagged as escaped, or this object if it already is
-
merge
public SimObject merge(SimObject other)
Unions the field value sets of two views of the same allocation site, escaping the result if either side escaped.- Parameters:
other- the other view of this site- Returns:
- the merged object
- Throws:
IllegalArgumentException- if the allocation sites differ
-
-