Package com.ibm.wala.util.ssa
Class TypeSafeInstructionFactory
- java.lang.Object
-
- com.ibm.wala.util.ssa.TypeSafeInstructionFactory
-
public class TypeSafeInstructionFactory extends Object
Intended for SyntheticMethods, uses JavaInstructionFactory. As the name states this SSAInstructionFactory does type checks. If they pass the actual instructions are generated using the JavaInstructionFactory. Obviously this factory is not complete yet. It's extended on demand.- Since:
- 2013-10-20
- See Also:
JavaLanguage.JavaInstructionFactory
-
-
Field Summary
Fields Modifier and Type Field Description protected IClassHierarchy
cha
protected JavaLanguage.JavaInstructionFactory
insts
-
Constructor Summary
Constructors Constructor Description TypeSafeInstructionFactory(IClassHierarchy cha)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SSAArrayLoadInstruction
ArrayLoadInstruction(int iindex, SSAValue result, SSAValue array, int index)
result = array[index].SSAArrayStoreInstruction
ArrayStoreInstruction(int iindex, SSAValue array, int index, SSAValue value)
array[index] = value.SSAConditionalBranchInstruction
ConditionalBranchInstruction(int iindex, IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2, int target)
SSAGetInstruction
GetInstruction(int iindex, SSAValue targetValue, FieldReference field)
Reads static field into targetValue.SSAGetInstruction
GetInstruction(int iindex, SSAValue targetValue, SSAValue containingInstance, FieldReference field)
targetValue = containingInstance.field.SSAGotoInstruction
GotoInstruction(int iindex, int target)
Unconditionally jump to a (non-Phi) Instruction.SSAInvokeInstruction
InvokeInstruction(int iindex, SSAValue result, List<? extends SSAValue> params, SSAValue exception, CallSiteReference site)
result = site(params).SSAInvokeInstruction
InvokeInstruction(int iindex, List<? extends SSAValue> params, SSAValue exception, CallSiteReference site)
Instruction that calls a void-method.boolean
isAssignableFrom(TypeReference from, TypeReference to)
SSANewInstruction
NewInstruction(int iindex, SSAValue result, NewSiteReference site)
SSANewInstruction
NewInstruction(int iindex, SSAValue result, NewSiteReference site, Collection<? extends SSAValue> params)
SSAPhiInstruction
PhiInstruction(int iindex, SSAValue result, Collection<? extends SSAValue> params)
Combine SSA-Values into a newone.SSAPutInstruction
PutInstruction(int iindex, SSAValue newValue, FieldReference field)
Writes newValue to static field.SSAPutInstruction
PutInstruction(int iindex, SSAValue targetInstance, SSAValue newValue, FieldReference field)
Writes newValue to field of targetInstance.SSAReturnInstruction
ReturnInstruction(int iindex)
Return from a void-function.SSAReturnInstruction
ReturnInstruction(int iindex, SSAValue result)
Check if the type of the SSAValue is assignable to the return-value of the method it's valid in.
-
-
-
Field Detail
-
insts
protected final JavaLanguage.JavaInstructionFactory insts
-
cha
protected final IClassHierarchy cha
-
-
Constructor Detail
-
TypeSafeInstructionFactory
public TypeSafeInstructionFactory(IClassHierarchy cha)
-
-
Method Detail
-
InvokeInstruction
public SSAInvokeInstruction InvokeInstruction(int iindex, SSAValue result, List<? extends SSAValue> params, SSAValue exception, CallSiteReference site)
result = site(params). Instruction that calls a method which has a return-value. All parameters (but exception) are typechecked first. If the check passes they get unpacked and handed over to the corresponding JavaInstructionFactory.InvokeInstruction. Calls result.setAssigned()- Parameters:
iindex
- Zero or a positive number unique to any instruction of the same methodresult
- Where to place the return-value of the called method. Is SSAValue.setAssigned() automatically.params
- Parameters to the call starting with the implicit this-pointer if necessaryexception
- An SSAValue receiving the exception-object when something in the method throws unhandledsite
- The CallSiteReference to this call.
-
InvokeInstruction
public SSAInvokeInstruction InvokeInstruction(int iindex, List<? extends SSAValue> params, SSAValue exception, CallSiteReference site)
Instruction that calls a void-method. All parameters (but exception) are typechecked first. If the check passes they get unpacked and handed over to the corresponding JavaInstructionFactory.InvokeInstruction.- Parameters:
iindex
- Zero or a positive number unique to any instruction of the same methodparams
- Parameters to the call starting with the implicit this-pointer if necessaryexception
- An SSAValue receiving the exception-object when something in the method throws unhandledsite
- The CallSiteReference to this call.
-
ReturnInstruction
public SSAReturnInstruction ReturnInstruction(int iindex, SSAValue result)
Check if the type of the SSAValue is assignable to the return-value of the method it's valid in. If type check passes the corresponding ReturnInstruction of the JavaInstructionFactory is called.- Parameters:
iindex
- Zero or a positive number unique to any instruction of the same methodresult
- SSAValue to return _with_ validIn _set_!- Throws:
IllegalArgumentException
- if result has no validIn set
-
GetInstruction
public SSAGetInstruction GetInstruction(int iindex, SSAValue targetValue, SSAValue containingInstance, FieldReference field)
targetValue = containingInstance.field. Reads field from containingInstance into targetValue. If type check passes the corresponding GetInstruction of the JavaInstructionFactory is called. Calls targetValue.setAssigned()- Parameters:
iindex
- Zero or a positive number unique to any instruction of the same methodtargetValue
- the result of the GetInstruction is placed therecontainingInstance
- The Object instance to read the field fromfield
- The description of the field
-
GetInstruction
public SSAGetInstruction GetInstruction(int iindex, SSAValue targetValue, FieldReference field)
Reads static field into targetValue. If type check passes the corresponding GetInstruction of the JavaInstructionFactory is called. Calls targetValue.setAssigned()- Parameters:
iindex
- Zero or a positive number unique to any instruction of the same methodtargetValue
- the result of the GetInstruction is placed therecontainingInstance
- The Object instance to read the field fromfield
- The description of the field
-
PutInstruction
public SSAPutInstruction PutInstruction(int iindex, SSAValue targetInstance, SSAValue newValue, FieldReference field)
Writes newValue to field of targetInstance. If type check passes the corresponding PutInstruction of the JavaInstructionFactory is called.- Parameters:
iindex
- Zero or a psitive number unique to any instruction of the same methodtargetInstance
- the instance of the object to write a field ofnewValue
- The value to write to the fieldfield
- The description of the target
-
PutInstruction
public SSAPutInstruction PutInstruction(int iindex, SSAValue newValue, FieldReference field)
Writes newValue to static field. If type check passes the corresponding PutInstruction of the JavaInstructionFactory is called.- Parameters:
iindex
- Zero or a psitive number unique to any instruction of the same methodtargetInstance
- the instance of the object to write a field ofnewValue
- The value to write to the fieldfield
- The description of the target
-
NewInstruction
public SSANewInstruction NewInstruction(int iindex, SSAValue result, NewSiteReference site)
-
NewInstruction
public SSANewInstruction NewInstruction(int iindex, SSAValue result, NewSiteReference site, Collection<? extends SSAValue> params)
-
PhiInstruction
public SSAPhiInstruction PhiInstruction(int iindex, SSAValue result, Collection<? extends SSAValue> params)
Combine SSA-Values into a newone. If type check passes the corresponding PhiInstruction of the JavaInstructionFactory is called. Calls result.setAssigned().- Parameters:
iindex
- Zero or a positive number unique to any instruction of the same methodresult
- Where to write result toparams
- at least one SSAValue to read from
-
isAssignableFrom
public boolean isAssignableFrom(TypeReference from, TypeReference to)
-
ReturnInstruction
public SSAReturnInstruction ReturnInstruction(int iindex)
Return from a void-function. Handed through to JavaInstructionFactory directly (unless the iindex is negative).- Parameters:
iindex
- Zero or a positive number unique to any instruction of the same method
-
GotoInstruction
public SSAGotoInstruction GotoInstruction(int iindex, int target)
Unconditionally jump to a (non-Phi) Instruction.- Parameters:
target
- the iindex of the instruction to jump to
-
ConditionalBranchInstruction
public SSAConditionalBranchInstruction ConditionalBranchInstruction(int iindex, IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2, int target)
-
ArrayLoadInstruction
public SSAArrayLoadInstruction ArrayLoadInstruction(int iindex, SSAValue result, SSAValue array, int index)
result = array[index]. Load a a reference from an array.- Parameters:
result
- The SSAValue to store the loaded stuff inarray
- The array to load fromindex
- Te position in array to load from
-
ArrayStoreInstruction
public SSAArrayStoreInstruction ArrayStoreInstruction(int iindex, SSAValue array, int index, SSAValue value)
array[index] = value. Save a value to a specific position in an Array.- Parameters:
array
- the array to store toindex
- the position in the array to place value atvalue
- The SSAValue to store in the array
-
-