optimization of toString for primitive types and "$expr"

- intrinsic toString for promitive types added to stdlib
- utility method added to CodegenUtil
- optimization logic added to generation of interpolating string
This commit is contained in:
Alex Tkachman
2012-09-17 13:00:02 +03:00
parent 7a00dd1551
commit a4e272d7c6
8 changed files with 98 additions and 25 deletions
+55
View File
@@ -9,3 +9,58 @@ public val <out T> T.javaClass : Class<T>
[Intrinsic("kotlin.javaClass.property")] get() = (this as java.lang.Object).getClass() as Class<T>
[Intrinsic("kotlin.javaClass.function")] fun <out T> javaClass() : Class<T> = null as Class<T>
/**
* A helper method for calling hashCode() on Kotlin objects
* TODO remove when Any supports equals() and hashCode()
*/
[Intrinsic("kotlin.hashCode")] public inline fun Any.hashCode(): Int = (this as java.lang.Object).hashCode()
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Boolean.toString(): String = (null as String)
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Byte.toString(): String = (null as String)
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Short.toString(): String = (null as String)
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Char.toString(): String = (null as String)
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Int.toString(): String = (null as String)
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Float.toString(): String = (null as String)
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Long.toString(): String = (null as String)
/**
* A helper method for calling toString() on Kotlin primitives
* TODO remove when Any supports toString()
*/
[Intrinsic("kotlin.toString")] public fun Double.toString(): String = (null as String)
@@ -47,9 +47,3 @@ public inline fun <T> callable(action: ()-> T): Callable<T> {
public override fun call() = action()
}
}
/**
* A helper method for calling hashCode() on Kotlin objects
* TODO remove when Any supports equals() and hashCode()
*/
public inline fun Any.hashCode(): Int = (this as java.lang.Object).hashCode()