Apply code review findings

This commit is contained in:
Tamas Vajk
2022-10-31 08:43:53 +01:00
parent d745381ebe
commit 4cd0f1ca66

View File

@@ -3191,9 +3191,7 @@ open class KotlinFileExtractor(
*/ */
if (e.origin != IrStatementOrigin.FOR_LOOP || if (e.origin != IrStatementOrigin.FOR_LOOP ||
e.statements.size != 2 || e.statements.size != 2) {
(e.statements[0] as? IrVariable)?.origin != IrDeclarationOrigin.FOR_LOOP_ITERATOR ||
(e.statements[1] as? IrWhileLoop)?.origin != IrStatementOrigin.FOR_LOOP_INNER_WHILE) {
return false return false
} }
@@ -3240,9 +3238,9 @@ open class KotlinFileExtractor(
} }
val id = extractLoop(innerWhile, null, parent, callable) { p, idx -> val id = extractLoop(innerWhile, null, parent, callable) { p, idx ->
val loopId = tw.getFreshIdLabel<DbEnhancedforstmt>() tw.getFreshIdLabel<DbEnhancedforstmt>().also {
tw.writeStmts_enhancedforstmt(loopId, p, idx, callable) tw.writeStmts_enhancedforstmt(it, p, idx, callable)
loopId }
} }
extractVariableExpr(loopVar, callable, id, 0, id, extractInitializer = false) extractVariableExpr(loopVar, callable, id, 0, id, extractInitializer = false)
@@ -4143,13 +4141,13 @@ open class KotlinFileExtractor(
) { ) {
val id = extractLoop(loop, 1, stmtExprParent, callable) { parent, idx -> val id = extractLoop(loop, 1, stmtExprParent, callable) { parent, idx ->
if (loop is IrWhileLoop) { if (loop is IrWhileLoop) {
val id = tw.getFreshIdLabel<DbWhilestmt>() tw.getFreshIdLabel<DbWhilestmt>().also {
tw.writeStmts_whilestmt(id, parent, idx, callable) tw.writeStmts_whilestmt(it, parent, idx, callable)
id }
} else { } else {
val id = tw.getFreshIdLabel<DbDostmt>() tw.getFreshIdLabel<DbDostmt>().also {
tw.writeStmts_dostmt(id, parent, idx, callable) tw.writeStmts_dostmt(it, parent, idx, callable)
id }
} }
} }
extractExpressionExpr(loop.condition, callable, id, 0, id) extractExpressionExpr(loop.condition, callable, id, 0, id)