Refactor ASM generation code #105

Merged
CommanderTvis merged 11 commits from adv-expr-refactor-agc into adv-expr 2020-06-16 10:30:06 +03:00
Showing only changes of commit c3cecc5a16 - Show all commits

View File

@ -5,7 +5,6 @@ import org.objectweb.asm.Label
import org.objectweb.asm.MethodVisitor import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes import org.objectweb.asm.Opcodes
import scientifik.kmath.asm.internal.AsmBuilder.ClassLoader import scientifik.kmath.asm.internal.AsmBuilder.ClassLoader
import scientifik.kmath.ast.MST
import scientifik.kmath.operations.Algebra import scientifik.kmath.operations.Algebra
/** /**
@ -20,7 +19,7 @@ internal class AsmBuilder<T> internal constructor(
private val classOfT: Class<*>, private val classOfT: Class<*>,
private val algebra: Algebra<T>, private val algebra: Algebra<T>,
private val className: String, private val className: String,
private val evaluateMethodVisitor: AsmBuilder<T>.() -> Unit private val invokeLabel0Visitor: AsmBuilder<T>.() -> Unit
) { ) {
private class ClassLoader(parent: java.lang.ClassLoader) : java.lang.ClassLoader(parent) { private class ClassLoader(parent: java.lang.ClassLoader) : java.lang.ClassLoader(parent) {
internal fun defineClass(name: String?, b: ByteArray): Class<*> = defineClass(name, b, 0, b.size) internal fun defineClass(name: String?, b: ByteArray): Class<*> = defineClass(name, b, 0, b.size)
@ -110,7 +109,7 @@ internal class AsmBuilder<T> internal constructor(
visitCode() visitCode()
val l0 = Label() val l0 = Label()
visitLabel(l0) visitLabel(l0)
evaluateMethodVisitor() invokeLabel0Visitor()
visitReturnObject() visitReturnObject()
val l1 = Label() val l1 = Label()
visitLabel(l1) visitLabel(l1)