Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a3e70fd

Browse files
committed
Kotlin: Add support for ieee754equals
1 parent 78d2ef5 commit a3e70fd

4 files changed

Lines changed: 238 additions & 189 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinExtractorExtension.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,13 @@ open class KotlinFileExtractor(
15571557
tw.writeExprs_neexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
15581558
binop(id, dr, callable)
15591559
}
1560+
c.origin == EXCLEQ && isFunction("kotlin", "Boolean", "not") && c.valueArgumentsCount == 0 && dr != null && dr is IrCall && isBuiltinCall(dr, "ieee754equals") -> {
1561+
val id = tw.getFreshIdLabel<DbNeexpr>()
1562+
val type = useType(c.type)
1563+
// TODO: Is this consistent with Java?
1564+
tw.writeExprs_neexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1565+
binop(id, dr, callable)
1566+
}
15601567
// We need to handle all the builtin operators defines in BuiltInOperatorNames in
15611568
// compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt
15621569
// as they can't be extracted as external dependencies.
@@ -1615,6 +1622,34 @@ open class KotlinFileExtractor(
16151622
tw.writeExprs_eqexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
16161623
binop(id, c, callable)
16171624
}
1625+
isBuiltinCall(c, "ieee754equals") -> {
1626+
if(c.origin != EQEQ) {
1627+
logger.warnElement(Severity.ErrorSevere, "Unexpected origin for ieee754equals: ${c.origin}", c)
1628+
}
1629+
// TODO: Is this consistent with Java?
1630+
val id = tw.getFreshIdLabel<DbEqexpr>()
1631+
val type = useType(c.type)
1632+
tw.writeExprs_eqexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1633+
binop(id, c, callable)
1634+
}
1635+
isBuiltinCall(c, "THROW_CCE") -> {
1636+
logger.warnElement(Severity.ErrorSevere, "Unhandled builtin", c)
1637+
}
1638+
isBuiltinCall(c, "THROW_ISE") -> {
1639+
logger.warnElement(Severity.ErrorSevere, "Unhandled builtin", c)
1640+
}
1641+
isBuiltinCall(c, "noWhenBranchMatchedException") -> {
1642+
logger.warnElement(Severity.ErrorSevere, "Unhandled builtin", c)
1643+
}
1644+
isBuiltinCall(c, "illegalArgumentException") -> {
1645+
logger.warnElement(Severity.ErrorSevere, "Unhandled builtin", c)
1646+
}
1647+
isBuiltinCall(c, "ANDAND") -> {
1648+
logger.warnElement(Severity.ErrorSevere, "Unhandled builtin", c)
1649+
}
1650+
isBuiltinCall(c, "OROR") -> {
1651+
logger.warnElement(Severity.ErrorSevere, "Unhandled builtin", c)
1652+
}
16181653
else -> {
16191654
val id = tw.getFreshIdLabel<DbMethodaccess>()
16201655
val type = useType(c.type)

java/ql/test/kotlin/library-tests/exprs/binop.expected

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
| exprs.kt:25:15:25:20 | ... >= ... | exprs.kt:25:15:25:15 | x | exprs.kt:25:20:25:20 | y |
1111
| exprs.kt:26:15:26:21 | ... == ... | exprs.kt:26:15:26:15 | x | exprs.kt:26:21:26:21 | y |
1212
| exprs.kt:27:15:27:21 | ... != ... | exprs.kt:27:15:27:15 | x | exprs.kt:27:21:27:21 | y |
13-
| exprs.kt:52:16:52:26 | ... + ... | exprs.kt:52:16:52:19 | str1 | exprs.kt:52:23:52:26 | str2 |
14-
| exprs.kt:55:12:55:23 | ... > ... | exprs.kt:55:12:55:19 | variable | exprs.kt:55:23:55:23 | 0 |
15-
| exprs.kt:59:12:59:20 | ... + ... | exprs.kt:59:12:59:14 | 123 | exprs.kt:59:18:59:20 | 456 |
16-
| exprs.kt:85:8:85:16 | ... != ... | exprs.kt:85:8:85:8 | r | exprs.kt:85:13:85:16 | null |
13+
| exprs.kt:34:14:34:21 | ... == ... | exprs.kt:34:14:34:15 | dx | exprs.kt:34:20:34:21 | dy |
14+
| exprs.kt:35:14:35:21 | ... != ... | exprs.kt:35:14:35:15 | dx | exprs.kt:35:20:35:21 | dy |
15+
| exprs.kt:56:16:56:26 | ... + ... | exprs.kt:56:16:56:19 | str1 | exprs.kt:56:23:56:26 | str2 |
16+
| exprs.kt:59:12:59:23 | ... > ... | exprs.kt:59:12:59:19 | variable | exprs.kt:59:23:59:23 | 0 |
17+
| exprs.kt:63:12:63:20 | ... + ... | exprs.kt:63:12:63:14 | 123 | exprs.kt:63:18:63:20 | 456 |
18+
| exprs.kt:89:8:89:16 | ... != ... | exprs.kt:89:8:89:8 | r | exprs.kt:89:13:89:16 | null |

0 commit comments

Comments
 (0)