Kotlin: Add more expressions

This commit is contained in:
Ian Lynagh
2021-08-12 17:16:37 +01:00
parent 492dc3dfb3
commit 90161b9e9d
3 changed files with 80 additions and 3 deletions

View File

@@ -391,6 +391,48 @@ class KotlinFileExtractor(val tw: TrapWriter) {
tw.writeExprs_remexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
id
} c.origin == EQEQ -> {
val id = tw.getFreshIdLabel<DbEqexpr>()
val typeId = useType(c.type)
val locId = tw.getLocation(c.startOffset, c.endOffset)
tw.writeExprs_eqexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
id
} c.origin == EXCLEQ -> {
val id = tw.getFreshIdLabel<DbNeexpr>()
val typeId = useType(c.type)
val locId = tw.getLocation(c.startOffset, c.endOffset)
tw.writeExprs_neexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
id
} c.origin == LT -> {
val id = tw.getFreshIdLabel<DbLtexpr>()
val typeId = useType(c.type)
val locId = tw.getLocation(c.startOffset, c.endOffset)
tw.writeExprs_ltexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
id
} c.origin == LTEQ -> {
val id = tw.getFreshIdLabel<DbLeexpr>()
val typeId = useType(c.type)
val locId = tw.getLocation(c.startOffset, c.endOffset)
tw.writeExprs_leexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
id
} c.origin == GT -> {
val id = tw.getFreshIdLabel<DbGtexpr>()
val typeId = useType(c.type)
val locId = tw.getLocation(c.startOffset, c.endOffset)
tw.writeExprs_gtexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
id
} c.origin == GTEQ -> {
val id = tw.getFreshIdLabel<DbGeexpr>()
val typeId = useType(c.type)
val locId = tw.getLocation(c.startOffset, c.endOffset)
tw.writeExprs_geexpr(id, typeId, parent, idx)
tw.writeHasLocation(id, locId)
id
} else -> {
extractorBug("Unrecognised IrCall: " + c.render())
return

View File

@@ -11,9 +11,28 @@
| exprs.kt:7:14:7:14 | x |
| exprs.kt:7:14:7:18 | ... % ... |
| exprs.kt:7:18:7:18 | y |
| exprs.kt:15:12:15:14 | 123 |
| exprs.kt:15:12:15:20 | ... + ... |
| exprs.kt:15:18:15:20 | 456 |
| exprs.kt:15:15:15:15 | x |
| exprs.kt:15:15:15:20 | ... == ... |
| exprs.kt:15:20:15:20 | y |
| exprs.kt:16:15:16:15 | x |
| exprs.kt:16:15:16:20 | ... != ... |
| exprs.kt:16:15:16:20 | ... != ... |
| exprs.kt:16:20:16:20 | y |
| exprs.kt:17:15:17:15 | x |
| exprs.kt:17:15:17:19 | ... < ... |
| exprs.kt:17:19:17:19 | y |
| exprs.kt:18:15:18:15 | x |
| exprs.kt:18:15:18:20 | ... <= ... |
| exprs.kt:18:20:18:20 | y |
| exprs.kt:19:15:19:15 | x |
| exprs.kt:19:15:19:19 | ... > ... |
| exprs.kt:19:19:19:19 | y |
| exprs.kt:20:15:20:15 | x |
| exprs.kt:20:15:20:20 | ... >= ... |
| exprs.kt:20:20:20:20 | y |
| exprs.kt:23:12:23:14 | 123 |
| exprs.kt:23:12:23:20 | ... + ... |
| exprs.kt:23:18:23:20 | 456 |
| file://:0:0:0:0 | i1 |
| file://:0:0:0:0 | i2 |
| file://:0:0:0:0 | i3 |
@@ -26,3 +45,11 @@
| file://:0:0:0:0 | i10 |
| file://:0:0:0:0 | i11 |
| file://:0:0:0:0 | i12 |
| file://:0:0:0:0 | i13 |
| file://:0:0:0:0 | i14 |
| file://:0:0:0:0 | i15 |
| file://:0:0:0:0 | i16 |
| file://:0:0:0:0 | i17 |
| file://:0:0:0:0 | i18 |
| file://:0:0:0:0 | i20 |
| file://:0:0:0:0 | i21 |

View File

@@ -12,6 +12,14 @@ fun topLevelMethod(x: Int, y: Int): Int {
val i10 = x or y
val i11 = x xor y
val i12 = x.inv()
val i13 = x == y
val i14 = x != y
val i15 = x < y
val i16 = x <= y
val i17 = x > y
val i18 = x >= y
val i20 = x in x .. y
val i21 = x !in x .. y
return 123 + 456
}