Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lehvolk committed Oct 12, 2023
1 parent 865660d commit 5cafd3d
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,16 @@ class MethodNodeBuilder(
with(method.asmNode()) {
mn.visibleAnnotations = visibleAnnotations
mn.visibleTypeAnnotations = visibleTypeAnnotations
mn.visibleLocalVariableAnnotations = visibleLocalVariableAnnotations
mn.visibleParameterAnnotations = visibleParameterAnnotations
mn.invisibleAnnotations = invisibleAnnotations
mn.invisibleTypeAnnotations = invisibleTypeAnnotations
mn.invisibleLocalVariableAnnotations = invisibleLocalVariableAnnotations
mn.invisibleParameterAnnotations = invisibleParameterAnnotations

// this two line of code relies on labels in method body properly organized.

// mn.visibleLocalVariableAnnotations = visibleLocalVariableAnnotations
// mn.invisibleLocalVariableAnnotations = invisibleLocalVariableAnnotations

}
return mn
}
Expand Down Expand Up @@ -265,16 +269,27 @@ class MethodNodeBuilder(
var shouldReverse = false
val (zeroValue, zeroCmpOpcode, defaultOpcode) = when (cond) {
is JcRawEqExpr -> when {
cond.lhv.typeName == PredefinedPrimitives.Null.typeName() -> Triple(JcRawNull(), Opcodes.IFNULL, Opcodes.IF_ACMPEQ)
cond.lhv.typeName == PredefinedPrimitives.Null.typeName() -> Triple(
JcRawNull(),
Opcodes.IFNULL,
Opcodes.IF_ACMPEQ

Check warning on line 275 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/MethodNodeBuilder.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/MethodNodeBuilder.kt#L273-L275

Added lines #L273 - L275 were not covered by tests
)

cond.lhv.typeName.isPrimitive -> Triple(JcRawInt(0), Opcodes.IFEQ, Opcodes.IF_ICMPEQ)
else -> Triple(JcRawNull(), Opcodes.IFNULL, Opcodes.IF_ACMPEQ)
}

is JcRawNeqExpr -> when {
cond.lhv.typeName == PredefinedPrimitives.Null.typeName() -> Triple(JcRawNull(), Opcodes.IFNONNULL, Opcodes.IF_ACMPNE)
cond.lhv.typeName == PredefinedPrimitives.Null.typeName() -> Triple(
JcRawNull(),
Opcodes.IFNONNULL,
Opcodes.IF_ACMPNE
)

cond.lhv.typeName.isPrimitive -> Triple(JcRawInt(0), Opcodes.IFNE, Opcodes.IF_ICMPNE)
else -> Triple(JcRawNull(), Opcodes.IFNONNULL, Opcodes.IF_ACMPNE)
}

is JcRawGeExpr -> Triple(JcRawInt(0), Opcodes.IFGE, Opcodes.IF_ICMPGE)
is JcRawGtExpr -> Triple(JcRawInt(0), Opcodes.IFGT, Opcodes.IF_ICMPGT)
is JcRawLeExpr -> Triple(JcRawInt(0), Opcodes.IFLE, Opcodes.IF_ICMPLE)
Expand All @@ -295,10 +310,12 @@ class MethodNodeBuilder(
}
JumpInsnNode(invertedZeroCmpOpcode, trueTarget)
}

cond.rhv == zeroValue -> {
cond.lhv.accept(this)
JumpInsnNode(zeroCmpOpcode, trueTarget)
}

else -> {
cond.lhv.accept(this)
cond.rhv.accept(this)
Expand Down Expand Up @@ -571,7 +588,7 @@ class MethodNodeBuilder(
declaringClass.jvmClassName,
name,
if (argTypes.isEmpty() && tag <= H_GETSTATIC) {
returnType.jvmTypeName
returnType.jvmTypeName

Check warning on line 591 in jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/MethodNodeBuilder.kt

View check run for this annotation

Codecov / codecov/patch

jacodb-core/src/main/kotlin/org/jacodb/impl/cfg/MethodNodeBuilder.kt#L591

Added line #L591 was not covered by tests
} else {
"(${argTypes.joinToString("") { it.jvmTypeName }})${returnType.jvmTypeName}"
},
Expand Down Expand Up @@ -819,6 +836,7 @@ class MethodNodeBuilder(
}
nodesBetweenLabels.clear()
}

else -> nodesBetweenLabels.add(curInst)
}
++i
Expand Down

0 comments on commit 5cafd3d

Please sign in to comment.