Skip to content

Commit 249b9f0

Browse files
authored
Unify JcNumericConstant operators and fix typo in 'minus' operator (#194)
Use actual operators instead of functions in operator implementations. Use '-' instead of erroneous 'div' in 'minus' operator.
1 parent a3767c8 commit 249b9f0

File tree

1 file changed

+16
-16
lines changed
  • jacodb-api/src/main/kotlin/org/jacodb/api/cfg

1 file changed

+16
-16
lines changed

jacodb-api/src/main/kotlin/org/jacodb/api/cfg/JcInst.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -906,19 +906,19 @@ data class JcByte(override val value: Byte, override val type: JcType) : JcNumer
906906
}
907907

908908
override fun minus(c: JcNumericConstant): JcNumericConstant {
909-
return JcInt(value.div(c.value.toByte()), type)
909+
return JcInt(value - c.value.toByte(), type)
910910
}
911911

912912
override fun times(c: JcNumericConstant): JcNumericConstant {
913-
return JcInt(value.times(c.value.toByte()), type)
913+
return JcInt(value * c.value.toByte(), type)
914914
}
915915

916916
override fun div(c: JcNumericConstant): JcNumericConstant {
917-
return JcInt(value.div(c.value.toByte()), type)
917+
return JcInt(value / c.value.toByte(), type)
918918
}
919919

920920
override fun rem(c: JcNumericConstant): JcNumericConstant {
921-
return JcInt(value.rem(c.value.toByte()), type)
921+
return JcInt(value % c.value.toByte(), type)
922922
}
923923

924924
override fun unaryMinus(): JcNumericConstant {
@@ -954,7 +954,7 @@ data class JcShort(override val value: Short, override val type: JcType) : JcNum
954954
}
955955

956956
override fun minus(c: JcNumericConstant): JcNumericConstant {
957-
return JcInt(value.div(c.value.toShort()), type)
957+
return JcInt(value - c.value.toShort(), type)
958958
}
959959

960960
override fun times(c: JcNumericConstant): JcNumericConstant {
@@ -966,7 +966,7 @@ data class JcShort(override val value: Short, override val type: JcType) : JcNum
966966
}
967967

968968
override fun rem(c: JcNumericConstant): JcNumericConstant {
969-
return JcInt(value.rem(c.value.toShort()), type)
969+
return JcInt(value % c.value.toShort(), type)
970970
}
971971

972972
override fun unaryMinus(): JcNumericConstant {
@@ -994,7 +994,7 @@ data class JcInt(override val value: Int, override val type: JcType) : JcNumeric
994994
}
995995

996996
override fun minus(c: JcNumericConstant): JcNumericConstant {
997-
return JcInt(value.div(c.value.toInt()), type)
997+
return JcInt(value - c.value.toInt(), type)
998998
}
999999

10001000
override fun times(c: JcNumericConstant): JcNumericConstant {
@@ -1006,7 +1006,7 @@ data class JcInt(override val value: Int, override val type: JcType) : JcNumeric
10061006
}
10071007

10081008
override fun rem(c: JcNumericConstant): JcNumericConstant {
1009-
return JcInt(value.rem(c.value.toInt()), type)
1009+
return JcInt(value % c.value.toInt(), type)
10101010
}
10111011

10121012
override fun unaryMinus(): JcNumericConstant {
@@ -1034,19 +1034,19 @@ data class JcLong(override val value: Long, override val type: JcType) : JcNumer
10341034
}
10351035

10361036
override fun minus(c: JcNumericConstant): JcNumericConstant {
1037-
return JcLong(value.div(c.value.toLong()), type)
1037+
return JcLong(value - c.value.toLong(), type)
10381038
}
10391039

10401040
override fun times(c: JcNumericConstant): JcNumericConstant {
10411041
return JcLong(value * c.value.toLong(), type)
10421042
}
10431043

10441044
override fun div(c: JcNumericConstant): JcNumericConstant {
1045-
return JcLong(value.div(c.value.toLong()), type)
1045+
return JcLong(value / c.value.toLong(), type)
10461046
}
10471047

10481048
override fun rem(c: JcNumericConstant): JcNumericConstant {
1049-
return JcLong(value.rem(c.value.toLong()), type)
1049+
return JcLong(value % c.value.toLong(), type)
10501050
}
10511051

10521052
override fun unaryMinus(): JcNumericConstant {
@@ -1074,23 +1074,23 @@ data class JcFloat(override val value: Float, override val type: JcType) : JcNum
10741074
}
10751075

10761076
override fun minus(c: JcNumericConstant): JcNumericConstant {
1077-
return JcFloat(value.div(c.value.toFloat()), type)
1077+
return JcFloat(value - c.value.toFloat(), type)
10781078
}
10791079

10801080
override fun times(c: JcNumericConstant): JcNumericConstant {
10811081
return JcFloat(value * c.value.toFloat(), type)
10821082
}
10831083

10841084
override fun div(c: JcNumericConstant): JcNumericConstant {
1085-
return JcFloat(value.div(c.value.toFloat()), type)
1085+
return JcFloat(value / c.value.toFloat(), type)
10861086
}
10871087

10881088
override fun rem(c: JcNumericConstant): JcNumericConstant {
1089-
return JcFloat(value.rem(c.value.toFloat()), type)
1089+
return JcFloat(value % c.value.toFloat(), type)
10901090
}
10911091

10921092
override fun unaryMinus(): JcNumericConstant {
1093-
return JcFloat(value.times(-1), type)
1093+
return JcFloat(-value, type)
10941094
}
10951095

10961096
override fun isLessThan(c: JcNumericConstant): Boolean {
@@ -1207,4 +1207,4 @@ data class JcMethodType(
12071207
override fun <T> accept(visitor: JcExprVisitor<T>): T {
12081208
return visitor.visitJcMethodType(this)
12091209
}
1210-
}
1210+
}

0 commit comments

Comments
 (0)