Do..while loop implementation and first test

This commit is contained in:
Mikhail Glukhikh
2016-09-23 15:04:42 +03:00
committed by Dmitry Petrov
parent bcf2b410ba
commit e03e13af43
4 changed files with 86 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
fun digitCountInNumber(n: Int, m: Int): Int {
var count = 0
var number = n
do {
if (m == number % 10) {
count++
}
number /= 10
} while (number > 0)
return count
}
+52
View File
@@ -0,0 +1,52 @@
// FILE: /digitCount.kt
// FUN: digitCountInNumber
BB 0
CONTENT
1 FUN public fun digitCountInNumber(n: kotlin.Int, m: kotlin.Int): kotlin.Int
2 CONST Int type=kotlin.Int value='0'
3 VAR var count: kotlin.Int
4 GET_VAR 'value-parameter n: Int' type=kotlin.Int origin=null
5 VAR var number: kotlin.Int
6 DO_WHILE label=null origin=DO_WHILE_LOOP
OUTGOING -> BB 1
Do..while entry: DO_WHILE label=null origin=DO_WHILE_LOOP
BB 1
INCOMING <- BB 0, 4
Do..while entry: DO_WHILE label=null origin=DO_WHILE_LOOP
CONTENT
1 WHEN type=kotlin.Unit origin=null
OUTGOING -> BB 2
CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ
BB 2
INCOMING <- BB 1
CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ
CONTENT
1 TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
OUTGOING -> BB 3
When exit: WHEN type=kotlin.Unit origin=null
BB 3
INCOMING <- BB 2
When exit: WHEN type=kotlin.Unit origin=null
CONTENT
1 SET_VAR 'number: Int' type=kotlin.Unit origin=DIVEQ
OUTGOING -> BB 4, 5
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
BB 4
INCOMING <- BB 3
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CONTENT
OUTGOING -> BB 1
Do..while entry: DO_WHILE label=null origin=DO_WHILE_LOOP
BB 5
INCOMING <- BB 3
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CONTENT
1 GET_VAR 'count: Int' type=kotlin.Int origin=null
2 RETURN type=kotlin.Nothing from='digitCountInNumber(Int, Int): Int'
OUTGOING -> NONE
Function exit: FUN public fun digitCountInNumber(n: kotlin.Int, m: kotlin.Int): kotlin.Int
// END FUN: digitCountInNumber
// END FILE: /digitCount.kt