Support all primitive literal types.

Apply simple unary operators to constants.
This commit is contained in:
Dmitry Petrov
2016-08-30 10:35:27 +03:00
committed by Dmitry Petrov
parent b3f605c4c4
commit fe46a02885
7 changed files with 65 additions and 19 deletions
+1 -2
View File
@@ -12,6 +12,5 @@ FILE /ifElseIf.kt
arg0: CALL .compareTo type=kotlin.Int operator=LT
$this: GET_VAR i type=kotlin.Int operator=null
other: CONST Int type=kotlin.Int value='0'
then: CALL .unaryMinus type=kotlin.Int operator=UMINUS
$this: CONST Int type=kotlin.Int value='1'
then: CONST Int type=kotlin.Int value='-1'
else: CONST Int type=kotlin.Int value='0'
+7 -1
View File
@@ -3,4 +3,10 @@ val test2 = -1
val test3 = true
val test4 = false
val test5 = "abc"
val test6 = null
val test6 = null
val test7 = 1L
val test8 = -1L
val test9 = 1.0
val test10 = -1.0
val test11 = 1.0f
val test12 = -1.0f
+19 -2
View File
@@ -4,8 +4,7 @@ FILE /literals.kt
CONST Int type=kotlin.Int value='1'
PROPERTY public val test2: kotlin.Int = -1 getter=null setter=null
EXPRESSION_BODY
CALL .unaryMinus type=kotlin.Int operator=UMINUS
$this: CONST Int type=kotlin.Int value='1'
CONST Int type=kotlin.Int value='-1'
PROPERTY public val test3: kotlin.Boolean = true getter=null setter=null
EXPRESSION_BODY
CONST Boolean type=kotlin.Boolean value='true'
@@ -18,3 +17,21 @@ FILE /literals.kt
PROPERTY public val test6: kotlin.Nothing? = null getter=null setter=null
EXPRESSION_BODY
CONST Null type=kotlin.Nothing? value='null'
PROPERTY public val test7: kotlin.Long = 1.toLong() getter=null setter=null
EXPRESSION_BODY
CONST Long type=kotlin.Long value='1'
PROPERTY public val test8: kotlin.Long = -1.toLong() getter=null setter=null
EXPRESSION_BODY
CONST Long type=kotlin.Long value='-1'
PROPERTY public val test9: kotlin.Double = 1.0.toDouble() getter=null setter=null
EXPRESSION_BODY
CONST Double type=kotlin.Double value='1.0'
PROPERTY public val test10: kotlin.Double = -1.0.toDouble() getter=null setter=null
EXPRESSION_BODY
CONST Double type=kotlin.Double value='-1.0'
PROPERTY public val test11: kotlin.Float = 1.0.toFloat() getter=null setter=null
EXPRESSION_BODY
CONST Float type=kotlin.Float value='1.0'
PROPERTY public val test12: kotlin.Float = -1.0.toFloat() getter=null setter=null
EXPRESSION_BODY
CONST Float type=kotlin.Float value='-1.0'
@@ -7,8 +7,7 @@ FILE /simpleUnaryOperators.kt
FUN public fun test2(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from=test2
CALL .unaryMinus type=kotlin.Int operator=UMINUS
$this: CONST Int type=kotlin.Int value='42'
CONST Int type=kotlin.Int value='-42'
FUN public fun test3(/*0*/ x: kotlin.Int): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from=test3
@@ -17,8 +16,7 @@ FILE /simpleUnaryOperators.kt
FUN public fun test4(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from=test4
CALL .unaryPlus type=kotlin.Int operator=UPLUS
$this: CONST Int type=kotlin.Int value='42'
CONST Int type=kotlin.Int value='42'
FUN public fun test5(/*0*/ x: kotlin.Boolean): kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from=test5
@@ -27,5 +25,4 @@ FILE /simpleUnaryOperators.kt
FUN public fun test6(): kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from=test6
CALL .not type=kotlin.Boolean operator=EXCL
$this: CONST Boolean type=kotlin.Boolean value='true'
CONST Boolean type=kotlin.Boolean value='false'