Loops and break/continue can have labels (as strings) (for KJS & other transpilers).

This commit is contained in:
Dmitry Petrov
2016-08-25 11:29:06 +03:00
committed by Dmitry Petrov
parent dc4bb3015c
commit 1ff12b4cb6
9 changed files with 73 additions and 59 deletions
+26 -26
View File
@@ -2,59 +2,59 @@ IrFile /breakContinue.kt
IrFunction public fun test1(): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=null operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=WHILE_LOOP depth=0
DO_WHILE operator=DO_WHILE_LOOP
BREAK label=null depth=0
DO_WHILE label=null operator=DO_WHILE_LOOP
body: BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=DO_WHILE_LOOP depth=0
BREAK label=null depth=0
condition: CONST Boolean type=kotlin.Boolean value='true'
WHILE operator=WHILE_LOOP
WHILE label=null operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=WHILE_LOOP depth=0
DO_WHILE operator=DO_WHILE_LOOP
CONTINUE label=null depth=0
DO_WHILE label=null operator=DO_WHILE_LOOP
body: BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=DO_WHILE_LOOP depth=0
CONTINUE label=null depth=0
condition: CONST Boolean type=kotlin.Boolean value='true'
IrFunction public fun test2(): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=OUTER operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=INNER operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=WHILE_LOOP depth=0
BREAK loop.operator=WHILE_LOOP depth=1
BREAK loop.operator=WHILE_LOOP depth=0
WHILE operator=WHILE_LOOP
BREAK label=INNER depth=0
BREAK label=OUTER depth=1
BREAK label=OUTER depth=0
WHILE label=OUTER operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=INNER operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=WHILE_LOOP depth=0
CONTINUE loop.operator=WHILE_LOOP depth=1
CONTINUE loop.operator=WHILE_LOOP depth=0
CONTINUE label=INNER depth=0
CONTINUE label=OUTER depth=1
CONTINUE label=OUTER depth=0
IrFunction public fun test3(): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=L operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=L operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=WHILE_LOOP depth=0
BREAK loop.operator=WHILE_LOOP depth=0
WHILE operator=WHILE_LOOP
BREAK label=L depth=0
BREAK label=L depth=0
WHILE label=L operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=L operator=WHILE_LOOP
condition: CONST Boolean type=kotlin.Boolean value='true'
body: BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=WHILE_LOOP depth=0
CONTINUE loop.operator=WHILE_LOOP depth=0
CONTINUE label=L depth=0
CONTINUE label=L depth=0
+2 -2
View File
@@ -6,7 +6,7 @@ IrFile /for.kt
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=null operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
@@ -23,7 +23,7 @@ IrFile /for.kt
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>>
CALL .iterator type=kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> operator=FOR_LOOP_ITERATOR
$this: GET_VAR pp type=kotlin.collections.List<kotlin.Pair<kotlin.Int, kotlin.String>> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=null operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.Pair<kotlin.Int, kotlin.String>> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
+16 -16
View File
@@ -6,7 +6,7 @@ IrFile /forWithBreakContinue.kt
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=null operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
@@ -14,7 +14,7 @@ IrFile /forWithBreakContinue.kt
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
BREAK label=null depth=0
IrFunction public fun testForBreak2(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
@@ -22,7 +22,7 @@ IrFile /forWithBreakContinue.kt
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=OUTER operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
@@ -34,7 +34,7 @@ IrFile /forWithBreakContinue.kt
VAR val tmp1_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=INNER operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
@@ -42,10 +42,10 @@ IrFile /forWithBreakContinue.kt
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=1
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
BREAK loop.operator=FOR_LOOP_INNER_WHILE depth=0
BREAK label=OUTER depth=1
BREAK label=INNER depth=0
BREAK label=null depth=0
BREAK label=OUTER depth=0
IrFunction public fun testForContinue1(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
@@ -53,7 +53,7 @@ IrFile /forWithBreakContinue.kt
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=null operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
@@ -61,7 +61,7 @@ IrFile /forWithBreakContinue.kt
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
CONTINUE label=null depth=0
IrFunction public fun testForContinue2(/*0*/ ss: kotlin.collections.List<kotlin.String>): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
@@ -69,7 +69,7 @@ IrFile /forWithBreakContinue.kt
VAR val tmp0_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=OUTER operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
@@ -81,7 +81,7 @@ IrFile /forWithBreakContinue.kt
VAR val tmp1_iterator: kotlin.collections.Iterator<kotlin.String>
CALL .iterator type=kotlin.collections.Iterator<kotlin.String> operator=FOR_LOOP_ITERATOR
$this: GET_VAR ss type=kotlin.collections.List<kotlin.String> operator=null
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=INNER operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE
@@ -89,7 +89,7 @@ IrFile /forWithBreakContinue.kt
CALL .next type=kotlin.String operator=FOR_LOOP_NEXT
$this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator<kotlin.String> operator=null
BLOCK type=<no-type> hasResult=false operator=null
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=1
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
CONTINUE loop.operator=FOR_LOOP_INNER_WHILE depth=0
CONTINUE label=OUTER depth=1
CONTINUE label=INNER depth=0
CONTINUE label=null depth=0
CONTINUE label=OUTER depth=0
+1 -1
View File
@@ -10,7 +10,7 @@ IrFile /forWithImplicitReceivers.kt
CALL .iterator type=IntCell operator=FOR_LOOP_ITERATOR
$this: $RECEIVER of: test type=IReceiver
$receiver: GET_OBJECT FiveTimes type=FiveTimes
WHILE operator=FOR_LOOP_INNER_WHILE
WHILE label=null operator=FOR_LOOP_INNER_WHILE
condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT
$this: $RECEIVER of: test type=IReceiver
$receiver: GET_VAR tmp0_iterator type=IntCell operator=null
+6 -6
View File
@@ -4,7 +4,7 @@ IrFile /whileDoWhile.kt
BLOCK type=<no-type> hasResult=false operator=null
VAR var x: kotlin.Int
CONST Int type=kotlin.Int value='0'
WHILE operator=WHILE_LOOP
WHILE label=null operator=WHILE_LOOP
condition: CALL .LT0 type=kotlin.Boolean operator=LT
arg0: CALL .compareTo type=kotlin.Int operator=LT
$this: GET_VAR x type=kotlin.Int operator=null
@@ -16,7 +16,7 @@ IrFile /whileDoWhile.kt
CALL .inc type=kotlin.Int operator=POSTFIX_INCR
$this: GET_VAR tmp0 type=kotlin.Int operator=null
GET_VAR tmp0 type=kotlin.Int operator=null
WHILE operator=WHILE_LOOP
WHILE label=null operator=WHILE_LOOP
condition: CALL .LT0 type=kotlin.Boolean operator=LT
arg0: CALL .compareTo type=kotlin.Int operator=LT
$this: GET_VAR x type=kotlin.Int operator=null
@@ -29,7 +29,7 @@ IrFile /whileDoWhile.kt
CALL .inc type=kotlin.Int operator=POSTFIX_INCR
$this: GET_VAR tmp1 type=kotlin.Int operator=null
GET_VAR tmp1 type=kotlin.Int operator=null
DO_WHILE operator=DO_WHILE_LOOP
DO_WHILE label=null operator=DO_WHILE_LOOP
body: BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR
VAR val tmp2: kotlin.Int
GET_VAR x type=kotlin.Int operator=POSTFIX_INCR
@@ -41,7 +41,7 @@ IrFile /whileDoWhile.kt
arg0: CALL .compareTo type=kotlin.Int operator=LT
$this: GET_VAR x type=kotlin.Int operator=null
other: CONST Int type=kotlin.Int value='15'
DO_WHILE operator=DO_WHILE_LOOP
DO_WHILE label=null operator=DO_WHILE_LOOP
body: BLOCK type=kotlin.Int hasResult=true operator=null
BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR
VAR val tmp3: kotlin.Int
@@ -63,11 +63,11 @@ IrFile /whileDoWhile.kt
if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.Boolean
GET_VAR a type=kotlin.Any? operator=null
then: BLOCK type=<no-type> hasResult=false operator=null
WHILE operator=WHILE_LOOP
WHILE label=null operator=WHILE_LOOP
condition: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Boolean
GET_VAR a type=kotlin.Any? operator=null
body: BLOCK type=<no-type> hasResult=false operator=null
DO_WHILE operator=DO_WHILE_LOOP
DO_WHILE label=null operator=DO_WHILE_LOOP
body: BLOCK type=<no-type> hasResult=false operator=null
condition: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Boolean
GET_VAR a type=kotlin.Any? operator=null