Split CompileTimeConstant into two entities

1. ConstantValue
	* just holds some value and its type
	* implementations for concrete constants
2. CompileTimeConstant
	* is only produced by ConstantExpressionEvaluator
	* has additional flags (canBeUsedInAnnotation etc)
	* has two implementations TypedCompileTimeConstant containing a constant value
		and IntegerValueConstant which does not have exact type
	* can be converted to ConstantValue

Adjustt usages to use ConstantValue if flags are not needed
Add tests for some uncovered cases
This commit is contained in:
Pavel V. Talanov
2015-07-07 14:56:19 +03:00
parent 155f00578d
commit c313887641
134 changed files with 791 additions and 907 deletions
+1 -1
View File
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1, 1.toByte(), 128.toByte(), 128) class MyClass
// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1.toByte(), b3 = -128.toByte(), b4 = IntegerValueType(128))
// EXPECTED: Ann(b1 = 1.toByte(), b2 = 1.toByte(), b3 = -128.toByte(), b4 = 128)
@@ -4,4 +4,4 @@ annotation class Ann(val c1: Char)
Ann('a' - 'a') class MyClass
// EXPECTED: Ann(c1 = IntegerValueType(0))
// EXPECTED: Ann(c1 = 0)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 / 1, 1 / 1, 1 / 1, 1 / 1) class MyClass
// EXPECTED: Ann(b = IntegerValueType(1), i = IntegerValueType(1), l = IntegerValueType(1), s = IntegerValueType(1))
// EXPECTED: Ann(b = 1.toByte(), i = 1, l = 1.toLong(), s = 1.toShort())
@@ -10,4 +10,4 @@ annotation class Ann(
Ann(1 plus 1, 1 minus 1, 1 times 1, 1 div 1, 1 mod 1) class MyClass
// EXPECTED: Ann(p1 = IntegerValueType(2), p2 = IntegerValueType(0), p3 = IntegerValueType(1), p4 = IntegerValueType(1), p5 = IntegerValueType(0))
// EXPECTED: Ann(p1 = 2, p2 = 0, p3 = 1, p4 = 1, p5 = 0)
@@ -10,4 +10,4 @@ annotation class Ann(p1: Int,
Ann(1 or 1, 1 and 1, 1 xor 1, 1 shl 1, 1 shr 1, 1 ushr 1) class MyClass
// EXPECTED: Ann(p1 = IntegerValueType(1), p2 = IntegerValueType(1), p3 = IntegerValueType(0), p4 = IntegerValueType(2), p5 = IntegerValueType(0), p6 = IntegerValueType(0))
// EXPECTED: Ann(p1 = 1, p2 = 1.toShort(), p3 = 0.toByte(), p4 = 2, p5 = 0, p6 = 0)
@@ -8,4 +8,4 @@ annotation class Ann(
Ann(1 + 1, java.lang.Long.MAX_VALUE + 1 - 1, java.lang.Long.MAX_VALUE - 1) class MyClass
// EXPECTED: Ann(l1 = IntegerValueType(2), l2 = 9223372036854775807.toLong(), l3 = 9223372036854775806.toLong())
// EXPECTED: Ann(l1 = 2.toLong(), l2 = 9223372036854775807.toLong(), l3 = 9223372036854775806.toLong())
@@ -16,4 +16,4 @@ Ann(
p5 = 1.toByte() + 1.toByte()
) class MyClass
// EXPECTED: Ann(p1 = 128, p2 = IntegerValueType(2), p3 = 128, p4 = 2, p5 = 2)
// EXPECTED: Ann(p1 = 128, p2 = 2.toByte(), p3 = 128, p4 = 2, p5 = 2)
@@ -16,4 +16,4 @@ Ann(
p5 = 1.toInt() + 1.toInt()
) class MyClass
// EXPECTED: Ann(p1 = -2147483648, p2 = IntegerValueType(2), p3 = -2147483648, p4 = 2, p5 = 2)
// EXPECTED: Ann(p1 = -2147483648, p2 = 2, p3 = -2147483648, p4 = 2, p5 = 2)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 * 1, 1 * 1, 1 * 1, 1 * 1) class MyClass
// EXPECTED: Ann(b = IntegerValueType(1), i = IntegerValueType(1), l = IntegerValueType(1), s = IntegerValueType(1))
// EXPECTED: Ann(b = 1.toByte(), i = 1, l = 1.toLong(), s = 1.toShort())
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 - 1, 1 - 1, 1 - 1, 1 - 1) class MyClass
// EXPECTED: Ann(b = IntegerValueType(0), i = IntegerValueType(0), l = IntegerValueType(0), s = IntegerValueType(0))
// EXPECTED: Ann(b = 0.toByte(), i = 0, l = 0.toLong(), s = 0.toShort())
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 % 1, 1 % 1, 1 % 1, 1 % 1) class MyClass
// EXPECTED: Ann(b = IntegerValueType(0), i = IntegerValueType(0), l = IntegerValueType(0), s = IntegerValueType(0))
// EXPECTED: Ann(b = 0.toByte(), i = 0, l = 0.toLong(), s = 0.toShort())
@@ -4,4 +4,4 @@ annotation class Ann(i: Int)
Ann((1 + 2) * 2) class MyClass
// EXPECTED: Ann(i = IntegerValueType(6))
// EXPECTED: Ann(i = 6)
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1 + 1, 1 + 1, 1 + 1, 1 + 1) class MyClass
// EXPECTED: Ann(b = IntegerValueType(2), i = IntegerValueType(2), l = IntegerValueType(2), s = IntegerValueType(2))
// EXPECTED: Ann(b = 2.toByte(), i = 2, l = 2.toLong(), s = 2.toShort())
@@ -10,4 +10,4 @@ annotation class Ann(
Ann(1.plus(1), 1.minus(1), 1.times(1), 1.div(1), 1.mod(1)) class MyClass
// EXPECTED: Ann(p1 = IntegerValueType(2), p2 = IntegerValueType(0), p3 = IntegerValueType(1), p4 = IntegerValueType(1), p5 = IntegerValueType(0))
// EXPECTED: Ann(p1 = 2, p2 = 0, p3 = 1, p4 = 1, p5 = 0)
@@ -11,4 +11,4 @@ annotation class Ann(
Ann(-1, -1, -1, -1, -1.0, -1.0.toFloat()) class MyClass
// EXPECTED: Ann(b1 = IntegerValueType(-1), b2 = IntegerValueType(-1), b3 = IntegerValueType(-1), b4 = IntegerValueType(-1), b5 = -1.0.toDouble(), b6 = -1.0.toFloat())
// EXPECTED: Ann(b1 = -1.toByte(), b2 = -1.toShort(), b3 = -1, b4 = -1.toLong(), b5 = -1.0.toDouble(), b6 = -1.0.toFloat())
@@ -11,4 +11,4 @@ annotation class Ann(
Ann(+1, +1, +1, +1, +1.0, +1.0.toFloat()) class MyClass
// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = IntegerValueType(1), b3 = IntegerValueType(1), b4 = IntegerValueType(1), b5 = 1.0.toDouble(), b6 = 1.0.toFloat())
// EXPECTED: Ann(b1 = 1.toByte(), b2 = 1.toShort(), b3 = 1, b4 = 1.toLong(), b5 = 1.0.toDouble(), b6 = 1.0.toFloat())
+1 -1
View File
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1, 1.toInt(), 2147483648.toInt(), 2147483648) class MyClass
// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1, b3 = -2147483648, b4 = IntegerValueType(2147483648))
// EXPECTED: Ann(b1 = 1, b2 = 1, b3 = -2147483648, b4 = 2147483648.toLong())
+1 -1
View File
@@ -7,4 +7,4 @@ annotation class Ann(
Ann(1, 1.toLong()) class MyClass
// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1.toLong())
// EXPECTED: Ann(b1 = 1.toLong(), b2 = 1.toLong())
+1 -1
View File
@@ -9,4 +9,4 @@ annotation class Ann(
Ann(1, 1.toShort(), 32768.toShort(), 32768) class MyClass
// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1.toShort(), b3 = -32768.toShort(), b4 = IntegerValueType(32768))
// EXPECTED: Ann(b1 = 1.toShort(), b2 = 1.toShort(), b3 = -32768.toShort(), b4 = 32768)