Update operations map, remove TODO

This commit is contained in:
Mikhail Zarechenskiy
2016-12-19 14:59:07 +03:00
parent c076ad5a8d
commit 1baf719cb4
2 changed files with 39 additions and 41 deletions
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.generators.util.GeneratorsFileUtil
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.kotlin.utils.Printer
import java.io.File
@@ -105,15 +104,13 @@ fun generate(): String {
val binaryOperationsMapIterator = binaryOperationsMap.iterator()
while (binaryOperationsMapIterator.hasNext()) {
val (funcName, parameters) = binaryOperationsMapIterator.next()
// TODO: remove this when 'rem' will be added into the stdlib
val funcCall = if (OperatorNameConventions.REM.asString() == funcName) OperatorNameConventions.MOD.asString() else funcName
p.println(
"binaryOperation(",
parameters.map { it.asString() }.joinToString(", "),
", ",
"\"$funcName\"",
", { a, b -> a.${funcCall}(b) }, ",
renderCheckBinaryOperation(funcCall, parameters),
", { a, b -> a.$funcName(b) }, ",
renderCheckBinaryOperation(funcName, parameters),
")",
if (binaryOperationsMapIterator.hasNext()) "," else ""
)
@@ -148,6 +145,7 @@ fun renderCheckBinaryOperation(name: String, params: List<KotlinType>): String {
"div" -> "{ a, b -> a.divide(b) }"
"times" -> "{ a, b -> a.multiply(b) }"
"mod",
"rem",
"xor",
"or",
"and" -> "{ a, b -> a.$name(b) }"