mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Kotlin: Add while statements
This commit is contained in:
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrWhen
|
||||
import org.jetbrains.kotlin.ir.expressions.IrElseBranch
|
||||
import org.jetbrains.kotlin.ir.expressions.IrWhileLoop
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
|
||||
@@ -288,6 +289,16 @@ class KotlinFileExtractor(val tw: TrapWriter) {
|
||||
tw.writeStmts_returnstmt(id, parent, idx, callable)
|
||||
tw.writeHasLocation(id, locId)
|
||||
extractExpression(s.value, id, 0)
|
||||
} is IrWhileLoop -> {
|
||||
val id = tw.getFreshIdLabel<DbWhilestmt>()
|
||||
val locId = tw.getLocation(s.startOffset, s.endOffset)
|
||||
tw.writeStmts_whilestmt(id, parent, idx, callable)
|
||||
tw.writeHasLocation(id, locId)
|
||||
extractExpression(s.condition, id, 0)
|
||||
val body = s.body
|
||||
if(body != null) {
|
||||
extractExpression(body, id, 1) // TODO: The QLLs think this is a Stmt
|
||||
}
|
||||
} is IrWhen -> {
|
||||
val x: IrWhen = s
|
||||
if(s.origin == IF) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
| stmts.kt:2:41:8:1 | { ... } |
|
||||
| stmts.kt:2:41:10:1 | { ... } |
|
||||
| stmts.kt:3:8:3:12 | if (...) |
|
||||
| stmts.kt:4:15:4:19 | if (...) |
|
||||
| stmts.kt:7:5:7:16 | return ... |
|
||||
| stmts.kt:7:5:8:16 | while (...) |
|
||||
| stmts.kt:9:5:9:16 | return ... |
|
||||
|
||||
@@ -4,6 +4,8 @@ fun topLevelMethod(x: Int, y: Int): Int {
|
||||
} else if(x < y) {
|
||||
} else {
|
||||
}
|
||||
while(x > y)
|
||||
return x
|
||||
return x + y
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user