use of org.graalvm.wasm.api.ModuleExportDescriptor in project graal by oracle.
the class WasmJsApiSuite method testCompile.
@Test
public void testCompile() throws IOException {
runTest(context -> {
final WebAssembly wasm = new WebAssembly(context);
final WasmModule module = wasm.moduleDecode(binaryWithExports);
try {
HashMap<String, ModuleExportDescriptor> exports = new HashMap<>();
int i = 0;
while (i < WebAssembly.moduleExports(module).getArraySize()) {
final ModuleExportDescriptor d = (ModuleExportDescriptor) WebAssembly.moduleExports(module).readArrayElement(i);
exports.put(d.name(), d);
i++;
}
Assert.assertEquals("Should export main.", ImportExportKind.function, exports.get("main").kind());
Assert.assertEquals("Should export memory.", ImportExportKind.memory, exports.get("memory").kind());
Assert.assertEquals("Should export global __heap_base.", ImportExportKind.global, exports.get("__heap_base").kind());
Assert.assertEquals("Should export global __data_end.", ImportExportKind.global, exports.get("__data_end").kind());
Assert.assertEquals("Should have empty imports.", 0L, WebAssembly.moduleImports(module).getArraySize());
} catch (InvalidArrayIndexException e) {
throw new RuntimeException(e);
}
});
}
Aggregations