mirror of
https://github.com/fluencelabs/asmble
synced 2025-04-25 06:42:22 +00:00
Merge fix for late init for logger
This commit is contained in:
commit
317b608048
@ -58,9 +58,9 @@ project(':compiler') {
|
|||||||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||||
compile "org.ow2.asm:asm-tree:$asm_version"
|
compile "org.ow2.asm:asm-tree:$asm_version"
|
||||||
compile "org.ow2.asm:asm-util:$asm_version"
|
compile "org.ow2.asm:asm-util:$asm_version"
|
||||||
compile "org.ow2.asm:asm-commons:$asm_version"
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
||||||
|
testCompile "org.ow2.asm:asm-debug-all:$asm_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
publishSettings(project, 'asmble-compiler', 'Asmble WASM Compiler')
|
publishSettings(project, 'asmble-compiler', 'Asmble WASM Compiler')
|
||||||
|
@ -56,16 +56,20 @@ abstract class ScriptCommand<T> : Command<T>() {
|
|||||||
// if input file is class file
|
// if input file is class file
|
||||||
"class" -> ctx.classLoader.addClass(File(inFile).readBytes()).let { ctx }
|
"class" -> ctx.classLoader.addClass(File(inFile).readBytes()).let { ctx }
|
||||||
// if input file is wasm file
|
// if input file is wasm file
|
||||||
else -> Translate.also { it.logger = logger }.inToAst(inFile, inFile.substringAfterLast('.')).let { inAst ->
|
else -> {
|
||||||
val (mod, name) = (inAst.commands.singleOrNull() as? Script.Cmd.Module) ?:
|
val translateCmd = Translate
|
||||||
|
translateCmd.logger = this.logger
|
||||||
|
translateCmd.inToAst(inFile, inFile.substringAfterLast('.')).let { inAst ->
|
||||||
|
val (mod, name) = (inAst.commands.singleOrNull() as? Script.Cmd.Module) ?:
|
||||||
error("Input file must only contain a single module")
|
error("Input file must only contain a single module")
|
||||||
val className = name?.javaIdent?.capitalize() ?:
|
val className = name?.javaIdent?.capitalize() ?:
|
||||||
"Temp" + UUID.randomUUID().toString().replace("-", "")
|
"Temp" + UUID.randomUUID().toString().replace("-", "")
|
||||||
ctx.withCompiledModule(mod, className, name).let { ctx ->
|
ctx.withCompiledModule(mod, className, name).let { ctx ->
|
||||||
if (name == null && index != args.inFiles.size - 1)
|
if (name == null && index != args.inFiles.size - 1)
|
||||||
logger.warn { "File '$inFile' not last and has no name so will be unused" }
|
logger.warn { "File '$inFile' not last and has no name so will be unused" }
|
||||||
if (name == null || args.disableAutoRegister) ctx
|
if (name == null || args.disableAutoRegister) ctx
|
||||||
else ctx.runCommand(Script.Cmd.Register(name, null))
|
else ctx.runCommand(Script.Cmd.Register(name, null))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ open class Translate : Command<Translate.Args>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"wasm" ->
|
"wasm" ->
|
||||||
Script(listOf(Script.Cmd.Module(BinaryToAst(logger = logger).toModule(
|
Script(listOf(Script.Cmd.Module(BinaryToAst(logger = this.logger).toModule(
|
||||||
ByteReader.InputStream(inBytes.inputStream())), null)))
|
ByteReader.InputStream(inBytes.inputStream())), null)))
|
||||||
else -> error("Unknown in format '$inFormat'")
|
else -> error("Unknown in format '$inFormat'")
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,11 @@ package asmble.io
|
|||||||
|
|
||||||
import asmble.ast.Node
|
import asmble.ast.Node
|
||||||
import asmble.util.*
|
import asmble.util.*
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
|
|
||||||
open class BinaryToAst(
|
open class BinaryToAst(
|
||||||
val version: Long = 1L,
|
val version: Long = 1L,
|
||||||
val logger: Logger = Logger.Print(Logger.Level.OFF),
|
val logger: Logger = Logger.Print(Logger.Level.WARN),
|
||||||
val includeNameSection: Boolean = true
|
val includeNameSection: Boolean = true
|
||||||
) : Logger by logger {
|
) : Logger by logger {
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ rootProject.name = 'asmble'
|
|||||||
include 'annotations',
|
include 'annotations',
|
||||||
'compiler',
|
'compiler',
|
||||||
'examples:c-simple',
|
'examples:c-simple',
|
||||||
'examples:go-simple',
|
// 'examples:go-simple',
|
||||||
'examples:rust-regex',
|
// 'examples:rust-regex', // todo will be enabled when the problem with string max size will be solved
|
||||||
'examples:rust-simple',
|
'examples:rust-simple',
|
||||||
'examples:rust-string'
|
'examples:rust-string'
|
Loading…
x
Reference in New Issue
Block a user