Package com.tonic.analysis.query.util
Class ArgumentTypeAnalyzer
- java.lang.Object
-
- com.tonic.analysis.query.util.ArgumentTypeAnalyzer
-
public class ArgumentTypeAnalyzer extends Object
Static helpers for classifying invoke-instruction arguments by how they are produced.
-
-
Constructor Summary
Constructors Constructor Description ArgumentTypeAnalyzer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ArgumentTypeclassifyInstruction(Instruction instr)Buckets a producing instruction into the argument kind a query matches on.static intcountDescriptorArguments(String desc)Counts the parameters in a method descriptor, treating an array and its element as one parameter.static InstructionfindArgumentProducer(CodeWriter codeWriter, int invokeIndex, int argIndex, int totalArgs, Instruction invokeInstr)Walks backwards from an invoke, tracking stack depth, to find the instruction that pushed one of its arguments.static intgetArgumentCount(Instruction invokeInstr)Counts the declared arguments of an invoke, receiver excluded.static StringgetDescriptor(Instruction invokeInstr)Reads the callee descriptor off an invoke; for invokedynamic the descriptor is cut out of the resolved call site signature.static booleanisInvokeInstruction(Instruction instr)
-
-
-
Method Detail
-
isInvokeInstruction
public static boolean isInvokeInstruction(Instruction instr)
- Parameters:
instr- the instruction to test- Returns:
- true for any of the five invoke opcodes
-
getArgumentCount
public static int getArgumentCount(Instruction invokeInstr)
Counts the declared arguments of an invoke, receiver excluded.- Parameters:
invokeInstr- the invoke instruction- Returns:
- the argument count, 0 if the descriptor cannot be resolved
-
countDescriptorArguments
public static int countDescriptorArguments(String desc)
Counts the parameters in a method descriptor, treating an array and its element as one parameter.- Parameters:
desc- the method descriptor- Returns:
- the parameter count, 0 if the descriptor is null or does not start with '('
-
findArgumentProducer
public static Instruction findArgumentProducer(CodeWriter codeWriter, int invokeIndex, int argIndex, int totalArgs, Instruction invokeInstr)
Walks backwards from an invoke, tracking stack depth, to find the instruction that pushed one of its arguments.- Parameters:
codeWriter- the body being scannedinvokeIndex- index of the invoke instructionargIndex- the argument position to tracetotalArgs- the invoke's argument countinvokeInstr- the invoke instruction, used for slot widths- Returns:
- the producing instruction, or null if none was reached
-
getDescriptor
public static String getDescriptor(Instruction invokeInstr)
Reads the callee descriptor off an invoke; for invokedynamic the descriptor is cut out of the resolved call site signature.- Parameters:
invokeInstr- the invoke instruction- Returns:
- the method descriptor, or null if the instruction is not an invoke
-
classifyInstruction
public static ArgumentType classifyInstruction(Instruction instr)
Buckets a producing instruction into the argument kind a query matches on.- Parameters:
instr- the instruction that produced the value- Returns:
- LITERAL, FIELD, LOCAL, CALL, DYNAMIC, or ANY when nothing matches
-
-