Class TypeSafeInstructionFactory
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
- Author:
- Tobias Blaschke <code@tobiasblaschke.de>
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final IClassHierarchy
protected final JavaLanguage.JavaInstructionFactory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionArrayLoadInstruction
(int iindex, SSAValue result, SSAValue array, int index) result = array[index].ArrayStoreInstruction
(int iindex, SSAValue array, int index, SSAValue value) array[index] = value.ConditionalBranchInstruction
(int iindex, IConditionalBranchInstruction.IOperator operator, TypeReference type, int val1, int val2, int target) GetInstruction
(int iindex, SSAValue targetValue, SSAValue containingInstance, FieldReference field) targetValue = containingInstance.field.GetInstruction
(int iindex, SSAValue targetValue, FieldReference field) Reads static field into targetValue.GotoInstruction
(int iindex, int target) Unconditionally jump to a (non-Phi) Instruction.InvokeInstruction
(int iindex, SSAValue result, List<? extends SSAValue> params, SSAValue exception, CallSiteReference site) result = site(params).InvokeInstruction
(int iindex, List<? extends SSAValue> params, SSAValue exception, CallSiteReference site) Instruction that calls a void-method.boolean
isAssignableFrom
(TypeReference from, TypeReference to) NewInstruction
(int iindex, SSAValue result, NewSiteReference site) NewInstruction
(int iindex, SSAValue result, NewSiteReference site, Collection<? extends SSAValue> params) PhiInstruction
(int iindex, SSAValue result, Collection<? extends SSAValue> params) Combine SSA-Values into a newone.PutInstruction
(int iindex, SSAValue targetInstance, SSAValue newValue, FieldReference field) Writes newValue to field of targetInstance.PutInstruction
(int iindex, SSAValue newValue, FieldReference field) Writes newValue to static field.ReturnInstruction
(int iindex) Return from a void-function.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 Details
-
insts
-
cha
-
-
Constructor Details
-
TypeSafeInstructionFactory
-
-
Method Details
-
InvokeInstruction
public SSAAbstractInvokeInstruction 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.- See Also:
-
InvokeInstruction
public SSAAbstractInvokeInstruction 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.- Returns:
- the invocation instruction
- See Also:
-
ReturnInstruction
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- See Also:
-
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- See Also:
-
GetInstruction
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 therefield
- The description of the field- See Also:
-
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- See Also:
-
PutInstruction
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 methodnewValue
- The value to write to the fieldfield
- The description of the target- See Also:
-
NewInstruction
-
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- See Also:
-
isAssignableFrom
-
ReturnInstruction
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
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
-