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:
Dmitry Petrov
2018-02-01 16:18:01 +03:00
parent f4ed4ec9d9
commit 9137e68d4e
33 changed files with 1566 additions and 233 deletions
+3 -4
View File
@@ -39,18 +39,17 @@ CONTENT
1 SET_VAR 'number: Int' type=kotlin.Unit origin=DIVEQ
2 GET_VAR 'number: Int' type=kotlin.Int origin=null
3 CONST Int type=kotlin.Int value=0
4 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT
OUTGOING -> BB 4, 5
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
BB 4
INCOMING <- BB 3
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, 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
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
CONTENT
OUTGOING -> BB 6
Do..while exit: DO_WHILE label=null origin=DO_WHILE_LOOP
+6 -8
View File
@@ -34,37 +34,35 @@ CONTENT
6 GET_VAR 'm: Int' type=kotlin.Int origin=null
7 CALL 'rem(Int): Int' type=kotlin.Int origin=PERC
8 CONST Int type=kotlin.Int value=0
9 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT
OUTGOING -> BB 3, 4
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
BB 3
INCOMING <- BB 2
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
CONTENT
1 CONTINUE label=null loop.label=null
OUTGOING -> BB 1
While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE
BB 4
INCOMING <- BB 2
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
CONTENT
1 SET_VAR 'sum: Int' type=kotlin.Unit origin=PLUSEQ
2 WHEN type=kotlin.Unit origin=null
3 GET_VAR 'sum: Int' type=kotlin.Int origin=null
4 GET_VAR 'value-parameter n: Int' type=kotlin.Int origin=null
5 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT
OUTGOING -> BB 5, 6
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
BB 5
INCOMING <- BB 4
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
CONTENT
1 BREAK label=null loop.label=null
OUTGOING -> BB 8
While exit: WHILE label=null origin=FOR_LOOP_INNER_WHILE
BB 6
INCOMING <- BB 4
CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT
CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
CONTENT
OUTGOING -> BB 1
While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE