export the memory with the name "memory"

This commit is contained in:
Volker Berlin 2019-11-02 19:20:28 +01:00
parent fac7e68b43
commit 87039232eb
2 changed files with 4 additions and 1 deletions

View File

@ -206,6 +206,9 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
//stream.writeVaruint32( pages ); // maximum length
}
wasm.writeSection( SectionType.Memory, stream );
// export the memory with the name "memory"
exports.add( new ExportEntry( "memory", ExternalKind.Memory, 0 ) );
}
}

View File

@ -150,7 +150,7 @@ public class TextModuleWriter extends ModuleWriter {
int pages = (dataSize + 0xFFFF) / 0x10000;
newline( output );
String pagesStr = Integer.toString( pages );
output.append( "(memory " ).append( pagesStr ).append( ' ' ).append( pagesStr ).append( ')' );
output.append( "(memory (export \"memory\") " ).append( pagesStr ).append( ' ' ).append( pagesStr ).append( ')' );
newline( output );
output.append( "(data (i32.const 0) \"" );
byte[] data = dataStream.toByteArray();