From dd974288c4631ddea389be55d929b2574675eaa4 Mon Sep 17 00:00:00 2001 From: Dennis Ranke Date: Wed, 29 Mar 2023 23:36:10 +0200 Subject: [PATCH] load cart, still missing platform functions to link --- main.c | 16 ++++++++++++++-- never_sleeps.uw8 | Bin 0 -> 246 bytes 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 never_sleeps.uw8 diff --git a/main.c b/main.c index 65390fd..50b77b3 100644 --- a/main.c +++ b/main.c @@ -75,6 +75,7 @@ void* loadUw8(uint32_t* sizeOut, IM3Runtime runtime, IM3Function loadFunc, uint8 verifyM3(runtime, m3_GetResultsV(loadFunc, sizeOut)); void* wasm = malloc(*sizeOut); memcpy(wasm, memory, *sizeOut); + return wasm; } int main() { @@ -93,6 +94,7 @@ int main() { verifyM3(runtime, m3_ParseModule(env, &loaderMod, loaderWasm, loaderSize)); loaderMod->memoryImported = true; verifyM3(runtime, m3_LoadModule(runtime, loaderMod)); + verifyM3(runtime, m3_CompileModule(loaderMod)); verifyM3(runtime, m3_RunStart(loaderMod)); IM3Function loadFunc; @@ -100,15 +102,25 @@ int main() { uint32_t platformSize; void* platformWasm = loadUw8(&platformSize, runtime, loadFunc, memory, "platform.uw8"); - printf("platform size: %u\n", platformSize); - printf("First byte: %u\n", memory[0]); + + uint32_t cartSize; + void* cartWasm = loadUw8(&cartSize, runtime, loadFunc, memory, "never_sleeps.uw8"); IM3Module platformMod; verifyM3(runtime, m3_ParseModule(env, &platformMod, platformWasm, platformSize)); platformMod->memoryImported = true; verifyM3(runtime, m3_LoadModule(runtime, platformMod)); linkSystemFunctions(platformMod); + verifyM3(runtime, m3_CompileModule(platformMod)); verifyM3(runtime, m3_RunStart(platformMod)); + IM3Module cartMod; + verifyM3(runtime, m3_ParseModule(env, &cartMod, cartWasm, cartSize)); + platformMod->memoryImported = true; + verifyM3(runtime, m3_LoadModule(runtime, cartMod)); + linkSystemFunctions(cartMod); + verifyM3(runtime, m3_CompileModule(cartMod)); + verifyM3(runtime, m3_RunStart(cartMod)); + return 0; } diff --git a/never_sleeps.uw8 b/never_sleeps.uw8 new file mode 100644 index 0000000000000000000000000000000000000000..38919a12ba1f0866c8b177454a92dd2fab6b093e GIT binary patch literal 246 zcmVWvw~!FUtCEEL`*)ITa{?Z7rB_tn)Y8c-v>{4{;De z#aZ>ymfDabe=R0E7@#BApMq%<(q{#Mti;R4p8gwALLFLV31Y2fojXDI>N~nx8aJMb wiBk