From fec8c7f9d19118f38188d804fd8248aeb8fbafe8 Mon Sep 17 00:00:00 2001 From: Iaroslav Date: Sat, 13 Jun 2020 15:50:21 +0700 Subject: [PATCH] Minor refactor and encapsulation --- .../jvmMain/kotlin/scientifik/kmath/asm/AsmExpressions.kt | 6 ++++-- .../scientifik/kmath/expressions/FunctionalExpressions.kt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/AsmExpressions.kt b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/AsmExpressions.kt index ef579278a..9e6efb66b 100644 --- a/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/AsmExpressions.kt +++ b/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/asm/AsmExpressions.kt @@ -11,7 +11,7 @@ interface AsmExpression { fun invoke(gen: AsmGenerationContext) } -internal val methodNameAdapters = mapOf("+" to "add", "*" to "multiply", "/" to "divide") +private val methodNameAdapters: Map = mapOf("+" to "add", "*" to "multiply", "/" to "divide") internal fun hasSpecific(context: Algebra, name: String, arity: Int): Boolean { val aName = methodNameAdapters[name] ?: name @@ -137,7 +137,9 @@ internal class AsmConstProductExpression( gen.visitAlgebraOperation( owner = AsmGenerationContext.SPACE_OPERATIONS_CLASS, method = "multiply", - descriptor = "(L${AsmGenerationContext.OBJECT_CLASS};L${AsmGenerationContext.NUMBER_CLASS};)L${AsmGenerationContext.OBJECT_CLASS};" + descriptor = "(L${AsmGenerationContext.OBJECT_CLASS};" + + "L${AsmGenerationContext.NUMBER_CLASS};)" + + "L${AsmGenerationContext.OBJECT_CLASS};" ) } } diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/expressions/FunctionalExpressions.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/expressions/FunctionalExpressions.kt index c3f36a814..a441a80c0 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/expressions/FunctionalExpressions.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/expressions/FunctionalExpressions.kt @@ -2,7 +2,7 @@ package scientifik.kmath.expressions import scientifik.kmath.operations.* -internal class FunctionalUnaryOperation(val context: Algebra, val name: String, val expr: Expression) : +internal class FunctionalUnaryOperation(val context: Algebra, val name: String, private val expr: Expression) : Expression { override fun invoke(arguments: Map): T = context.unaryOperation(name, expr.invoke(arguments)) }