Update to use new API

extensions
Volodymyr Shymanskyy 5 years ago
parent f8594e7d92
commit 288e2003e4

@ -3,10 +3,11 @@
#include <time.h>
#include "m3.h"
#include "m3_env.h"
#include "extra/fib32.wasm.h"
#define FATAL(msg, ...) { printf("Fatal: " msg "\n", __VA_ARGS__); return; }
#define FATAL(msg, ...) { printf("Fatal: " msg "\n", ##__VA_ARGS__); return; }
void run_wasm()
{
@ -17,24 +18,28 @@ void run_wasm()
printf("Loading WebAssembly...\n");
IM3Environment env = m3_NewEnvironment ();
if (!env) FATAL("m3_NewEnvironment failed");
IM3Runtime runtime = m3_NewRuntime (env, 8*1024);
if (!runtime) FATAL("m3_NewRuntime failed");
IM3Module module;
result = m3_ParseModule (& module, wasm, fsize);
result = m3_ParseModule (env, &module, wasm, fsize);
if (result) FATAL("m3_ParseModule: %s", result);
IM3Runtime env = m3_NewRuntime (8192);
result = m3_LoadModule (env, module);
result = m3_LoadModule (runtime, module);
if (result) FATAL("m3_LoadModule: %s", result);
IM3Function f;
result = m3_FindFunction (&f, env, "__post_instantiate");
result = m3_FindFunction (&f, runtime, "__post_instantiate");
if (! result)
{
result = m3_Call (f);
if (result) FATAL("__post_instantiate: %s", result);
}
result = m3_FindFunction (&f, env, "fib");
result = m3_FindFunction (&f, runtime, "fib");
if (result) FATAL("m3_FindFunction: %s", result);
printf("Running...\n");

Loading…
Cancel
Save