Rename unary plus/minus in builtins and stdlib

This commit is contained in:
Yan Zhulanow
2015-10-12 19:19:22 +03:00
parent f7ce0c2d20
commit d52f245cf7
23 changed files with 432 additions and 82 deletions
@@ -31,8 +31,8 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
private val unaryOperators: Map<String, String> = mapOf(
"inc" to "Increments this value.",
"dec" to "Decrements this value.",
"plus" to "Returns this value.",
"minus" to "Returns the negative of this value.")
"unaryPlus" to "Returns this value.",
"unaryMinus" to "Returns the negative of this value.")
private val shiftOperators: Map<String, String> = mapOf(
"shl" to "Shifts this value left by [bits].",
"shr" to "Shifts this value right by [bits], filling the leftmost bits with copies of the sign bit.",
@@ -131,7 +131,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
private fun generateUnaryOperators(kind: PrimitiveType) {
for ((name, doc) in unaryOperators) {
val returnType = if (kind in listOf(PrimitiveType.SHORT, PrimitiveType.BYTE, PrimitiveType.CHAR) &&
name in listOf("plus", "minus")) "Int" else kind.capitalized
name in listOf("unaryPlus", "unaryMinus")) "Int" else kind.capitalized
out.println(" /** $doc */")
out.println(" public operator fun $name(): $returnType")
}