Represents of abstract objects in pointer analysis. @see HeapModel
| 34 | * @see HeapModel |
| 35 | */ |
| 36 | public abstract class Obj implements Indexable { |
| 37 | |
| 38 | private int index = -1; |
| 39 | |
| 40 | void setIndex(int index) { |
| 41 | if (this.index != -1) { |
| 42 | throw new IllegalStateException("index already set"); |
| 43 | } |
| 44 | if (index < 0) { |
| 45 | throw new IllegalArgumentException( |
| 46 | "index must be 0 or positive number, given: " + index); |
| 47 | } |
| 48 | this.index = index; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public int getIndex() { |
| 53 | return index; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * An object is functional means that it can hold fields (or array indexes). |
| 58 | * |
| 59 | * @return {@code true} if this is a function {@link Obj}. |
| 60 | */ |
| 61 | public boolean isFunctional() { |
| 62 | return true; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @return the type of the object. |
| 67 | */ |
| 68 | public abstract Type getType(); |
| 69 | |
| 70 | /** |
| 71 | * @return the allocation of the object. |
| 72 | */ |
| 73 | public abstract Object getAllocation(); |
| 74 | |
| 75 | /** |
| 76 | * @return the method containing the allocation site of this object. |
| 77 | * For some special objects, e.g., string constants, which are not |
| 78 | * allocated in any method, this API returns an empty Optional. |
| 79 | */ |
| 80 | public abstract Optional<JMethod> getContainerMethod(); |
| 81 | |
| 82 | /** |
| 83 | * This method is useful for type sensitivity. |
| 84 | * |
| 85 | * @return the type containing the allocation site of this object. |
| 86 | * For special objects, the return values of this method are also special. |
| 87 | */ |
| 88 | public abstract Type getContainerType(); |
| 89 | } |
nothing calls this directly
no outgoing calls
no test coverage detected