mirror of
https://github.com/fluencelabs/asmble
synced 2025-04-24 22:32:19 +00:00
Fix memory builder (#10)
* fix memory instance creation * change version
This commit is contained in:
parent
ad2b7c071f
commit
1d6002624f
@ -21,7 +21,7 @@ buildscript {
|
||||
allprojects {
|
||||
apply plugin: 'java'
|
||||
group 'com.github.cretz.asmble'
|
||||
version '0.4.5-fl'
|
||||
version '0.4.7-fl'
|
||||
|
||||
// skips building and running for the specified examples
|
||||
ext.skipExamples = ['c-simple', 'go-simple', 'rust-regex']
|
||||
|
@ -76,6 +76,8 @@ interface Module {
|
||||
|
||||
// If there is a memory import, we have to get the one with the mem class as the first
|
||||
val memImport = mod.imports.find { it.kind is Node.Import.Kind.Memory }
|
||||
val builder = ctx.memoryBuilder
|
||||
|
||||
val memLimit = if (memImport != null) {
|
||||
constructor = cls.declaredConstructors.find { it.parameterTypes.firstOrNull()?.ref == mem.memType }
|
||||
val memImportKind = memImport.kind as Node.Import.Kind.Memory
|
||||
@ -89,6 +91,13 @@ interface Module {
|
||||
throw RunErr.ImportMemoryCapacityTooLarge(it * Mem.PAGE_SIZE, memCap)
|
||||
}
|
||||
memLimit
|
||||
} else if (builder != null) {
|
||||
constructor = cls.declaredConstructors.find { it.parameterTypes.firstOrNull()?.ref == mem.memType }
|
||||
|
||||
val memLimit = ctx.defaultMaxMemPages * Mem.PAGE_SIZE
|
||||
val memInst = builder.build(memLimit)
|
||||
constructorParams += memInst
|
||||
memLimit
|
||||
} else {
|
||||
// Find the constructor with no max mem amount (i.e. not int and not memory)
|
||||
constructor = cls.declaredConstructors.find {
|
||||
|
Loading…
x
Reference in New Issue
Block a user