Package proguard.analysis.cpa.jvm.state
Class JvmAbstractState<ContentT extends AbstractState<ContentT>>
- java.lang.Object
-
- proguard.analysis.cpa.jvm.state.JvmAbstractState<ContentT>
-
- Type Parameters:
ContentT- The type of the states contained in the JVM state. e.g., for taint analysis this would be aSetAbstractStatecontaining the taints and for value analysis aValueAbstractState.
- All Implemented Interfaces:
AbstractState<JvmAbstractState<ContentT>>,ProgramLocationDependent
- Direct Known Subclasses:
JvmValueAbstractState
public class JvmAbstractState<ContentT extends AbstractState<ContentT>> extends java.lang.Object implements AbstractState<JvmAbstractState<ContentT>>, ProgramLocationDependent
TheJvmAbstractStateconsists of the method frameJvmFrameAbstractStateand the heapJvmHeapAbstractState.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FIELDprotected JvmFrameAbstractState<ContentT>frameprotected JvmHeapAbstractState<ContentT>heapprotected JvmCfaNodeprogramLocationprotected MapAbstractState<java.lang.String,ContentT>staticFieldsprotected static JvmCfaNodetopLocation
-
Constructor Summary
Constructors Constructor Description JvmAbstractState(JvmCfaNode programLocation, JvmFrameAbstractState<ContentT> frame, JvmHeapAbstractState<ContentT> heap, MapAbstractState<java.lang.String,ContentT> staticFields)Create a JVM abstract state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearOperandStack()Empties the operand stack.JvmAbstractState<ContentT>copy()Creates a copy of itself.booleanequals(java.lang.Object obj)<T> ContentTgetArrayElementOrDefault(T array, ContentT index, ContentT abstractDefault)Returns an abstract state for thearrayelement at the givenindexor theabstractDefaultif there is no information available.<T> ContentTgetFieldOrDefault(T object, ContentT defaultValue)Returns an abstract state representing the default field of theobjectordefaultStateif there is no entry.<T> ContentTgetFieldOrDefault(T object, java.lang.String descriptor, ContentT defaultValue)Returns an abstract state representing the fielddescriptorof theobjectordefaultStateif there is no entry.JvmFrameAbstractState<ContentT>getFrame()Returns the frame abstract state.JvmHeapAbstractState<ContentT>getHeap()Returns the heap abstract state.JvmCfaNodegetProgramLocation()Returns the program location.MapAbstractState<java.lang.String,ContentT>getStaticFields()Returns the static field table abstract state.ContentTgetStaticOrDefault(java.lang.String fqn, ContentT defaultState)Returns an abstract state representing the static fieldfqnordefaultStateif there is no entry.ContentTgetVariableOrDefault(int index, ContentT defaultState)Returns an abstract state at theindexth position of the variable array ordefaultStateif there is no entry.inthashCode()booleanisLessOrEqual(JvmAbstractState<ContentT> abstractState)Compares itself to theabstractState(i.e., compare the states on the partial order provided by the domain of the analysis).JvmAbstractState<ContentT>join(JvmAbstractState<ContentT> abstractState)Computes a join over itself and another abstract stateabstractState(i.e., finds the least upper bound on the semilattice).ContentTnewArray(java.lang.String type, java.util.List<ContentT> dimensions)Returns an abstract state for a new array for the giventypeanddimentions.ContentTnewObject(java.lang.String className)Returns an abstract state for a new object of the givenclassName.ContentTnewObject(Clazz clazz)Returns an abstract state for a new object of the givenClazz.ContentTpeek()Returns the top element of the operand stack.ContentTpeek(int index)Returns theindexth element from the top of the operand stack.ContentTpeekOrDefault(int index, ContentT defaultState)Returns theindexth element from the top of the operand stack or returnsdefaultStateif the stack does not have enough elements.ContentTpeekOrDefault(ContentT defaultState)Returns the top element of the operand stack or returnsdefaultStateif the stack is empty.ContentTpop()Removes the top element of the operand stack end returns it.ContentTpopOrDefault(ContentT defaultState)Removes the top element of the operand stack end returns it.ContentTpush(ContentT state)Insertsstateto the top of the operand stack and returns it.java.util.List<ContentT>pushAll(java.util.List<ContentT> states)Consequentially inserts elements ofstatesto the top of the operand stack and returnsstates.<T> voidsetArrayElement(T array, ContentT index, ContentT value)Sets thearrayelement at the givenindexto thevalue.<T> voidsetField(T object, ContentT value)Sets the default field of theobjecttovalue.<T> voidsetField(T object, java.lang.String descriptor, ContentT value)Sets the fielddescriptorof theobjecttovalue.voidsetProgramLocation(JvmCfaNode programLocation)Sets the program location.voidsetStatic(java.lang.String fqn, ContentT value, ContentT defaultState)Sets the static fieldfqntovalue, unless the value isdefaultState.ContentTsetVariable(int index, ContentT state, ContentT defaultState)Sets theindexth position of the variable array tostateand returnsstate.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface proguard.analysis.cpa.interfaces.AbstractState
getPrecision, isLess
-
-
-
-
Field Detail
-
DEFAULT_FIELD
public static final java.lang.String DEFAULT_FIELD
- See Also:
- Constant Field Values
-
frame
protected final JvmFrameAbstractState<ContentT extends AbstractState<ContentT>> frame
-
heap
protected final JvmHeapAbstractState<ContentT extends AbstractState<ContentT>> heap
-
staticFields
protected final MapAbstractState<java.lang.String,ContentT extends AbstractState<ContentT>> staticFields
-
programLocation
protected JvmCfaNode programLocation
-
topLocation
protected static final JvmCfaNode topLocation
-
-
Constructor Detail
-
JvmAbstractState
public JvmAbstractState(JvmCfaNode programLocation, JvmFrameAbstractState<ContentT> frame, JvmHeapAbstractState<ContentT> heap, MapAbstractState<java.lang.String,ContentT> staticFields)
Create a JVM abstract state.- Parameters:
programLocation- a CFA nodeframe- a frame abstract stateheap- a heap abstract statestaticFields- a static field table
-
-
Method Detail
-
join
public JvmAbstractState<ContentT> join(JvmAbstractState<ContentT> abstractState)
Description copied from interface:AbstractStateComputes a join over itself and another abstract stateabstractState(i.e., finds the least upper bound on the semilattice).- Specified by:
joinin interfaceAbstractState<ContentT extends AbstractState<ContentT>>
-
isLessOrEqual
public boolean isLessOrEqual(JvmAbstractState<ContentT> abstractState)
Description copied from interface:AbstractStateCompares itself to theabstractState(i.e., compare the states on the partial order provided by the domain of the analysis).- Specified by:
isLessOrEqualin interfaceAbstractState<ContentT extends AbstractState<ContentT>>
-
getProgramLocation
public JvmCfaNode getProgramLocation()
Description copied from interface:ProgramLocationDependentReturns the program location.- Specified by:
getProgramLocationin interfaceProgramLocationDependent
-
setProgramLocation
public void setProgramLocation(JvmCfaNode programLocation)
Description copied from interface:ProgramLocationDependentSets the program location.- Specified by:
setProgramLocationin interfaceProgramLocationDependent
-
copy
public JvmAbstractState<ContentT> copy()
Description copied from interface:AbstractStateCreates a copy of itself.- Specified by:
copyin interfaceAbstractState<ContentT extends AbstractState<ContentT>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfaceAbstractState<ContentT extends AbstractState<ContentT>>- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceAbstractState<ContentT extends AbstractState<ContentT>>- Overrides:
hashCodein classjava.lang.Object
-
peek
public ContentT peek()
Returns the top element of the operand stack.
-
peek
public ContentT peek(int index)
Returns theindexth element from the top of the operand stack.
-
peekOrDefault
public ContentT peekOrDefault(ContentT defaultState)
Returns the top element of the operand stack or returnsdefaultStateif the stack is empty.
-
peekOrDefault
public ContentT peekOrDefault(int index, ContentT defaultState)
Returns theindexth element from the top of the operand stack or returnsdefaultStateif the stack does not have enough elements.
-
pop
public ContentT pop()
Removes the top element of the operand stack end returns it.
-
popOrDefault
public ContentT popOrDefault(ContentT defaultState)
Removes the top element of the operand stack end returns it. ReturnsdefaultStateif the stack is empty.
-
push
public ContentT push(ContentT state)
Insertsstateto the top of the operand stack and returns it.
-
pushAll
public java.util.List<ContentT> pushAll(java.util.List<ContentT> states)
Consequentially inserts elements ofstatesto the top of the operand stack and returnsstates.
-
clearOperandStack
public void clearOperandStack()
Empties the operand stack.
-
getVariableOrDefault
public ContentT getVariableOrDefault(int index, ContentT defaultState)
Returns an abstract state at theindexth position of the variable array ordefaultStateif there is no entry.
-
setVariable
public ContentT setVariable(int index, ContentT state, ContentT defaultState)
Sets theindexth position of the variable array tostateand returnsstate. If the array has to be extended, the added cells are padded withdefaultState.
-
getStaticOrDefault
public ContentT getStaticOrDefault(java.lang.String fqn, ContentT defaultState)
Returns an abstract state representing the static fieldfqnordefaultStateif there is no entry.
-
setStatic
public void setStatic(java.lang.String fqn, ContentT value, ContentT defaultState)Sets the static fieldfqntovalue, unless the value isdefaultState.
-
getFieldOrDefault
public <T> ContentT getFieldOrDefault(T object, java.lang.String descriptor, ContentT defaultValue)
Returns an abstract state representing the fielddescriptorof theobjectordefaultStateif there is no entry.
-
getFieldOrDefault
public <T> ContentT getFieldOrDefault(T object, ContentT defaultValue)
Returns an abstract state representing the default field of theobjectordefaultStateif there is no entry.
-
setField
public <T> void setField(T object, java.lang.String descriptor, ContentT value)Sets the fielddescriptorof theobjecttovalue.
-
setField
public <T> void setField(T object, ContentT value)Sets the default field of theobjecttovalue.
-
getFrame
public JvmFrameAbstractState<ContentT> getFrame()
Returns the frame abstract state.
-
getStaticFields
public MapAbstractState<java.lang.String,ContentT> getStaticFields()
Returns the static field table abstract state.
-
getHeap
public JvmHeapAbstractState<ContentT> getHeap()
Returns the heap abstract state.
-
newArray
public ContentT newArray(java.lang.String type, java.util.List<ContentT> dimensions)
Returns an abstract state for a new array for the giventypeanddimentions.
-
newObject
public ContentT newObject(java.lang.String className)
Returns an abstract state for a new object of the givenclassName.
-
newObject
public ContentT newObject(Clazz clazz)
Returns an abstract state for a new object of the givenClazz.
-
getArrayElementOrDefault
public <T> ContentT getArrayElementOrDefault(T array, ContentT index, ContentT abstractDefault)
Returns an abstract state for thearrayelement at the givenindexor theabstractDefaultif there is no information available.
-
-