Class KotlinSafeCallOperatorFilter
java.lang.Object
org.jacoco.core.internal.analysis.filter.KotlinSafeCallOperatorFilter
- All Implemented Interfaces:
IFilter
Filters bytecode that Kotlin compiler generates for chains of safe call
operators (
?.).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfilter(org.objectweb.asm.tree.MethodNode methodNode, IFilterContext context, IFilterOutput output) This method is called for every method.private static Collection<ArrayList<org.objectweb.asm.tree.JumpInsnNode>> findChains(org.objectweb.asm.tree.MethodNode methodNode) "optimized" chain:private static booleanisUnoptimizedSafeCallFollowedByElvis(org.objectweb.asm.tree.JumpInsnNode jump, org.objectweb.asm.tree.AbstractInsnNode target, ArrayList<org.objectweb.asm.tree.JumpInsnNode> chain) private static org.objectweb.asm.tree.AbstractInsnNodepreceding(org.objectweb.asm.tree.AbstractInsnNode i, int opcode)
-
Constructor Details
-
KotlinSafeCallOperatorFilter
KotlinSafeCallOperatorFilter()
-
-
Method Details
-
filter
public void filter(org.objectweb.asm.tree.MethodNode methodNode, IFilterContext context, IFilterOutput output) Description copied from interface:IFilterThis method is called for every method. The filter implementation is expected to inspect the provided method and report its result to the givenIFilterOutputinstance. -
findChains
private static Collection<ArrayList<org.objectweb.asm.tree.JumpInsnNode>> findChains(org.objectweb.asm.tree.MethodNode methodNode) "optimized" chain:DUP IFNULL label ... // call 0 ... DUP IFNULL label ... // call N label: POP
"unoptimized" chain:ALOAD v0 IFNULL label ... // call 0 ... ASTORE v1 ALOAD v1 IFNULL label ... // call N label: ACONST_NULL
"unoptimized" safe call operator(s) followed by elvis operator:ALOAD v0 IFNULL nullCase ... // call 0 ASTORE v1 ALOAD v1 IFNULL nullCase ... // call 1 ... ASTORE vN ALOAD vN IFNULL nullCase ALOAD vN GOTO nonNullCase nullCase: ... // right hand side of elvis operator nonNullCase: ...
-
isUnoptimizedSafeCallFollowedByElvis
private static boolean isUnoptimizedSafeCallFollowedByElvis(org.objectweb.asm.tree.JumpInsnNode jump, org.objectweb.asm.tree.AbstractInsnNode target, ArrayList<org.objectweb.asm.tree.JumpInsnNode> chain) -
preceding
private static org.objectweb.asm.tree.AbstractInsnNode preceding(org.objectweb.asm.tree.AbstractInsnNode i, int opcode) - Returns:
- non pseudo-instruction preceding given if it has given opcode,
nullotherwise
-