forked from kscience/kmath
Minor refactor and encapsulation
This commit is contained in:
parent
36ad1fcf58
commit
fec8c7f9d1
@ -11,7 +11,7 @@ interface AsmExpression<T> {
|
|||||||
fun invoke(gen: AsmGenerationContext<T>)
|
fun invoke(gen: AsmGenerationContext<T>)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val methodNameAdapters = mapOf("+" to "add", "*" to "multiply", "/" to "divide")
|
private val methodNameAdapters: Map<String, String> = mapOf("+" to "add", "*" to "multiply", "/" to "divide")
|
||||||
|
|
||||||
internal fun <T> hasSpecific(context: Algebra<T>, name: String, arity: Int): Boolean {
|
internal fun <T> hasSpecific(context: Algebra<T>, name: String, arity: Int): Boolean {
|
||||||
val aName = methodNameAdapters[name] ?: name
|
val aName = methodNameAdapters[name] ?: name
|
||||||
@ -137,7 +137,9 @@ internal class AsmConstProductExpression<T>(
|
|||||||
gen.visitAlgebraOperation(
|
gen.visitAlgebraOperation(
|
||||||
owner = AsmGenerationContext.SPACE_OPERATIONS_CLASS,
|
owner = AsmGenerationContext.SPACE_OPERATIONS_CLASS,
|
||||||
method = "multiply",
|
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};"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package scientifik.kmath.expressions
|
|||||||
|
|
||||||
import scientifik.kmath.operations.*
|
import scientifik.kmath.operations.*
|
||||||
|
|
||||||
internal class FunctionalUnaryOperation<T>(val context: Algebra<T>, val name: String, val expr: Expression<T>) :
|
internal class FunctionalUnaryOperation<T>(val context: Algebra<T>, val name: String, private val expr: Expression<T>) :
|
||||||
Expression<T> {
|
Expression<T> {
|
||||||
override fun invoke(arguments: Map<String, T>): T = context.unaryOperation(name, expr.invoke(arguments))
|
override fun invoke(arguments: Map<String, T>): T = context.unaryOperation(name, expr.invoke(arguments))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user