Implement special desugaring for numeric comparisons in PSI2IR
This introduces the following IR built-in functions required for proper
implementation of the number comparisons:
- ieee754Equals(T, T): Boolean,
for each T in {Float?, Double?}
- less(T, T): Boolean
lessOrEqual(T, T): Boolean
greater(T, T): Boolean
greaterOrEqual(T, T): Boolean
for each T in {Int, Long, Float, Double}
This commit is contained in:
+18
-25
@@ -4,15 +4,13 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
VAR name:x type:kotlin.Int flags:var
|
||||
CONST Int type=kotlin.Int value=0
|
||||
WHILE label=null origin=WHILE_LOOP
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=0
|
||||
condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
WHILE label=null origin=WHILE_LOOP
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=5
|
||||
condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=5
|
||||
body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int flags:val
|
||||
@@ -22,10 +20,9 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
$this: GET_VAR 'tmp0: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp0: Int' type=kotlin.Int origin=null
|
||||
WHILE label=null origin=WHILE_LOOP
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=10
|
||||
condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=10
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||
@@ -37,10 +34,9 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
GET_VAR 'tmp1: Int' type=kotlin.Int origin=null
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=0
|
||||
condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
@@ -51,10 +47,9 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
$this: GET_VAR 'tmp2: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp2: Int' type=kotlin.Int origin=null
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=15
|
||||
condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=15
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: COMPOSITE type=kotlin.Unit origin=null
|
||||
@@ -66,10 +61,9 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||
$this: GET_VAR 'tmp3: Int' type=kotlin.Int origin=null
|
||||
GET_VAR 'tmp3: Int' type=kotlin.Int origin=null
|
||||
condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT
|
||||
$this: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
other: CONST Int type=kotlin.Int value=20
|
||||
condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT
|
||||
arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=20
|
||||
FUN name:testSmartcastInCondition visibility:public modality:FINAL <> () returnType:Unit flags:
|
||||
BLOCK_BODY
|
||||
VAR name:a type:kotlin.Any? flags:val
|
||||
@@ -88,4 +82,3 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
body: COMPOSITE type=kotlin.Unit origin=null
|
||||
condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean
|
||||
GET_VAR 'a: Any?' type=kotlin.Any? origin=null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user