public class ParameterAccessor extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ParameterAccessor.BasedOn
The Constructor used to create ParameterAccessor influences the parameter-offset.
|
static class |
ParameterAccessor.ParamerterDisposition
The kind of parameter.
|
static class |
ParameterAccessor.Parameter
The representation of a Parameter handled using a ParameterAccessor.
|
static class |
ParameterAccessor.ParameterKey
This key is identified by type and parameter number.
|
Constructor and Description |
---|
ParameterAccessor(IMethod method)
Read the parameters from an IMethod.
|
ParameterAccessor(MethodReference mRef,
boolean hasImplicitThis)
Reads the parameters of a MethodReference CAUTION:.
|
ParameterAccessor(MethodReference mRef,
IClassHierarchy cha)
Reads the parameters of a MethodReference CAUTION:.
|
Modifier and Type | Method and Description |
---|---|
List<ParameterAccessor.Parameter> |
all()
This list _excludes_ the implicit this-pointer (if any).
|
List<ParameterAccessor.Parameter> |
allExtend(TypeName tName,
IClassHierarchy cha)
All parameters in the selector that are a subclass of tName (slow).
|
List<ParameterAccessor.Parameter> |
allExtend(TypeReference tRef,
IClassHierarchy cha)
All parameters in the selector that are a subclass of tRef (slow).
|
List<SSAValue> |
connectThrough(ParameterAccessor callee,
Set<? extends SSAValue> overrides,
Set<? extends SSAValue> defaults,
IClassHierarchy cha)
Assign parameters to a call based on their type.
|
List<SSAValue> |
connectThrough(ParameterAccessor callee,
Set<? extends SSAValue> overrides,
Set<? extends SSAValue> defaults,
IClassHierarchy cha,
IInstantiator instantiator,
Object... instantiatorArgs)
Connects though parameters from the calling function (overridable) - CAUTION:.
|
String |
dump()
Extensive output for debugging purposes.
|
ParameterAccessor.Parameter |
firstExtends(TypeName tName,
IClassHierarchy cha)
First parameter in the selector that is a subclass of tName (slow).
|
ParameterAccessor.Parameter |
firstExtends(TypeReference tRef,
IClassHierarchy cha)
First parameter in the selector that is a subclass of tRef (slow).
|
int |
firstInSelector()
The SSA-Value to acces the parameter appearing first in the Descriptor with.
|
ParameterAccessor.Parameter |
firstOf(TypeName tName)
First parameter in the selector that matches _exactly_.
|
ParameterAccessor.Parameter |
firstOf(TypeReference tRef)
First parameter in the selector that matches _exactly_.
|
int[] |
forInvokeStatic(List<? extends ParameterAccessor.Parameter> args,
MethodReference target,
IClassHierarchy cha)
Shorthand for forInvokeStatic(final List extends Parameter> args, final ParameterAccessor target, final IClassHierarchy cha).
|
int[] |
forInvokeStatic(List<? extends SSAValue> args)
Generate the params-param for an InvokeIstruction w/o type checking.
|
int[] |
forInvokeStatic(List<? extends SSAValue> args,
ParameterAccessor target,
IClassHierarchy cha)
Generate the params-param for an InvokeIstruction with type checking.
|
int[] |
forInvokeVirtual(int self,
List<? extends ParameterAccessor.Parameter> args,
MethodReference target,
IClassHierarchy cha)
Shorthand for forInvokeVirtual(final int self, final List extends Parameter> args, final ParameterAccessor target, final IClassHierarchy cha).
|
int[] |
forInvokeVirtual(int self,
List<? extends SSAValue> args)
Generate the params-param for an InvokeIstruction w/o type checking.
|
int[] |
forInvokeVirtual(int self,
List<? extends SSAValue> args,
ParameterAccessor target,
IClassHierarchy cha)
Generate the params-param for an InvokeIstruction with type checking.
|
MethodReference |
forMethod()
The method this accessor reads the parameters from.
|
int |
getFirstAfter()
The first SSA-Number after the parameters.
|
int |
getNumberOfParameters()
Number of parameters _excluding_ implicit this
|
ParameterAccessor.Parameter |
getParameter(int no)
Make an Parameter Object using a Descriptor-based numbering (starting with 1).
|
int |
getParameterNo(int no)
Return the SSA-Value to access a parameter using a Descriptor-based numbering (starting with 1).
|
int |
getParameterNo(ParameterAccessor.Parameter param)
Same as Parameter.getNumber().
|
TypeReference |
getParameterType(int no)
Prefer: getParameter(int no) or all().
|
TypeReference |
getReturnType()
Handed through to the IMethod / MethodReference
|
ParameterAccessor.Parameter |
getThis()
Return the implicit this-pointer (or throw).
|
ParameterAccessor.Parameter |
getThisAs(TypeReference asType)
Return the implicit this-pointer as a supertype.
|
int |
getThisNo()
Return the SSA-Value of the implicit this-pointer (or throw).
|
boolean |
hasImplicitThis()
If the method has an implicit this parameter.
|
boolean |
hasReturn()
If the method returns a value eg is non-void.
|
protected boolean |
isAssignable(SSAValue from,
SSAValue to,
IClassHierarchy cha)
Does "to x := from" hold?.
|
static boolean |
isAssignable(TypeReference from,
TypeReference to,
IClassHierarchy cha)
Does "to x := from" hold?.
|
static boolean |
isSubclassOf(TypeReference sub,
TypeReference superC,
IClassHierarchy cha)
Is sub a subclass of superC (or the same).
|
ParameterAccessor.Parameter |
makeReturn(int ssa)
Create a "Parameter" containing the Return-Type w/o Type-checking.
|
ParameterAccessor.Parameter |
makeReturn(int ssa,
TypeReference type,
IClassHierarchy cha)
Create a "Parameter" containing the Return-Type with Type-checking.
|
String |
toString() |
public ParameterAccessor(MethodReference mRef, IClassHierarchy cha)
#ParameterAccessor(ParameterAccessor, boolean)
.mRef
- The method to read the parameters from.public ParameterAccessor(MethodReference mRef, boolean hasImplicitThis)
#ParameterAccessor(MethodReference, IClassHierarchy
.mRef
- The method to read the parameters from.public ParameterAccessor(IMethod method)
method
- The method to read the parameters from.public ParameterAccessor.Parameter getParameter(int no)
no
- the number in the SelectorIllegalArgumentExceptions
- if the parameter is zeroArrayIndexOutOfBoundsException
- if no is not within bounds [1 to numberOfParameters]public int getParameterNo(int no)
no
- the number in the SelectorIllegalArgumentException
- if the parameter is zeroArrayIndexOutOfBoundsException
- if no is not within bounds [1 to numberOfParameters]public int getParameterNo(ParameterAccessor.Parameter param)
public List<ParameterAccessor.Parameter> all()
public ParameterAccessor.Parameter getThis()
IllegalStateException
- if the function has no implicit thispublic ParameterAccessor.Parameter getThisAs(TypeReference asType)
asType
- A type of a super-class of thispublic int getThisNo()
IllegalStateException
- if the function has no implicit this.public boolean hasImplicitThis()
public ParameterAccessor.Parameter makeReturn(int ssa)
IllegalStateException
- if used on a void-Functionpublic ParameterAccessor.Parameter makeReturn(int ssa, TypeReference type, IClassHierarchy cha)
ssa
- The value to returntype
- The type of ssacha
- The ClassHierarchy to use for the assignability testIllegalStateException
- if used on a void-Functionpublic int firstInSelector()
IllegalArgumentException
- if the method has no parameters in its Descriptor.public TypeReference getParameterType(int no)
no
- the number in the Selectorpublic ParameterAccessor.Parameter firstOf(TypeName tName)
IllegalArgumentException
- if searching for void or nullpublic ParameterAccessor.Parameter firstOf(TypeReference tRef)
IllegalArgumentException
- if searching for void or nullpublic List<ParameterAccessor.Parameter> allExtend(TypeName tName, IClassHierarchy cha)
IllegalArgumentException
- if searching for void or nullpublic List<ParameterAccessor.Parameter> allExtend(TypeReference tRef, IClassHierarchy cha)
IllegalArgumentException
- if searching for void or nullpublic ParameterAccessor.Parameter firstExtends(TypeName tName, IClassHierarchy cha)
IllegalArgumentException
- if searching for void or nullpublic ParameterAccessor.Parameter firstExtends(TypeReference tRef, IClassHierarchy cha)
IllegalArgumentException
- if searching for void or nullpublic int getFirstAfter()
public int[] forInvokeStatic(List<? extends SSAValue> args)
args
- list to build the arguments from - without implicit thispublic int[] forInvokeStatic(List<? extends SSAValue> args, ParameterAccessor target, IClassHierarchy cha)
args
- list to build the arguments from - without implicit thistarget
- the method to be called - for type checking onlycha
- if types don't match exactly needed for the assignability check (may be null if that check is not wanted)IllegalArgumentException
- if you call this method on a target that needs an implicit thisIllegalArgumentException
- if args length does not match the targets param-lengthIllegalArgumentException
- if a parameter is unassignablepublic int[] forInvokeVirtual(int self, List<? extends SSAValue> args)
self
- the this-pointer to useargs
- the rest of the arguments. Be shure it does not start with a
this pointer. This is _not_ checked so you can use a this-pointer as
an argument. However a warning is issued.IllegalArgumentException
- if the value of self is to small in the current
methodpublic int[] forInvokeVirtual(int self, List<? extends SSAValue> args, ParameterAccessor target, IClassHierarchy cha)
self
- the this-pointer to useargs
- list to build the arguments from - without implicit thistarget
- the method to be called - for type checking onlycha
- if types don't match exactly needed for the assignability check (may be null if that check is not wanted)IllegalArgumentException
- if you call this method on a target that needs an implicit thisIllegalArgumentException
- if args length does not match the targets param-lengthIllegalArgumentException
- if a parameter is unassignablepublic List<SSAValue> connectThrough(ParameterAccessor callee, Set<? extends SSAValue> overrides, Set<? extends SSAValue> defaults, IClassHierarchy cha, IInstantiator instantiator, Object... instantiatorArgs)
callee
- The function to generate the parameter-list foroverrides
- If a parameter occurs here, it is preferred over the ones present in thisdefaults
- If a parameter is not present in this or the overrides, defaults are searched. If the parameter is not present there null is assigned.cha
- Optional class hierarchy for testing assignabilitypublic static boolean isAssignable(TypeReference from, TypeReference to, IClassHierarchy cha)
public static boolean isSubclassOf(TypeReference sub, TypeReference superC, IClassHierarchy cha) throws ClassLookupException
ClassLookupException
public MethodReference forMethod()
protected boolean isAssignable(SSAValue from, SSAValue to, IClassHierarchy cha)
public int[] forInvokeStatic(List<? extends ParameterAccessor.Parameter> args, MethodReference target, IClassHierarchy cha)
public int[] forInvokeVirtual(int self, List<? extends ParameterAccessor.Parameter> args, MethodReference target, IClassHierarchy cha)
public boolean hasReturn()
public List<SSAValue> connectThrough(ParameterAccessor callee, Set<? extends SSAValue> overrides, Set<? extends SSAValue> defaults, IClassHierarchy cha)
callee
- The function to generate the parameter-list foroverrides
- If a parameter occurs here, it is preferred over the ones present in thisdefaults
- If a parameter is not present in this or the overrides, defaults are searched. If the parameter is not present there null is assigned.cha
- Optional class hierarchy for testing assignabilitypublic TypeReference getReturnType()
public int getNumberOfParameters()
public String dump()