|
@@ -1,3 +1,5 @@
|
|
|
|
+{$mode objfpc}
|
|
|
|
+{$h+}
|
|
program helloworld;
|
|
program helloworld;
|
|
|
|
|
|
uses classes,ctypes, wasmtime;
|
|
uses classes,ctypes, wasmtime;
|
|
@@ -73,14 +75,14 @@ begin
|
|
exit_with_error('failed to parse wat', error, Nil);
|
|
exit_with_error('failed to parse wat', error, Nil);
|
|
wasm_byte_vec_delete(@wat);
|
|
wasm_byte_vec_delete(@wat);
|
|
|
|
|
|
- Writeln('Compiling module...\n');
|
|
|
|
|
|
+ Writeln('Compiling module...');
|
|
|
|
|
|
error:=wasmtime_module_new(engine, Puint8_t(wasm.data), wasm.size, @module);
|
|
error:=wasmtime_module_new(engine, Puint8_t(wasm.data), wasm.size, @module);
|
|
wasm_byte_vec_delete(@wasm);
|
|
wasm_byte_vec_delete(@wasm);
|
|
if (error <> nil) then
|
|
if (error <> nil) then
|
|
exit_with_error('failed to compile module', error, nil);
|
|
exit_with_error('failed to compile module', error, nil);
|
|
|
|
|
|
- Writeln('Creating callback...\n');
|
|
|
|
|
|
+ Writeln('Creating callback...');
|
|
hello_ty:=wasm_functype_new_0_0();
|
|
hello_ty:=wasm_functype_new_0_0();
|
|
wasmtime_func_new(context, hello_ty, @hello_callback, Nil, Nil, @hello);
|
|
wasmtime_func_new(context, hello_ty, @hello_callback, Nil, Nil, @hello);
|
|
|
|
|
|
@@ -91,7 +93,7 @@ begin
|
|
if (error<>nil) or (trap <>Nil) then
|
|
if (error<>nil) or (trap <>Nil) then
|
|
exit_with_error('failed to instantiate', error, trap);
|
|
exit_with_error('failed to instantiate', error, trap);
|
|
|
|
|
|
- Writeln('Extracting export...\n');
|
|
|
|
|
|
+ Writeln('Extracting export...');
|
|
ok:=wasmtime_instance_export_get(context, @instance, PAnsiChar('run'), 3, @run) ;
|
|
ok:=wasmtime_instance_export_get(context, @instance, PAnsiChar('run'), 3, @run) ;
|
|
if OK=0 then
|
|
if OK=0 then
|
|
exit_with_error('failed to get run export', nil, nil);
|
|
exit_with_error('failed to get run export', nil, nil);
|
|
@@ -103,7 +105,7 @@ begin
|
|
if (error<>nil) or (trap<>nil) then
|
|
if (error<>nil) or (trap<>nil) then
|
|
exit_with_error('failed to call function', error, trap);
|
|
exit_with_error('failed to call function', error, trap);
|
|
|
|
|
|
- Writeln('All finished!\n');
|
|
|
|
|
|
+ Writeln('All finished!');
|
|
wasmtime_module_delete(module);
|
|
wasmtime_module_delete(module);
|
|
wasmtime_store_delete(store);
|
|
wasmtime_store_delete(store);
|
|
wasm_engine_delete(engine);
|
|
wasm_engine_delete(engine);
|