mirror of
https://github.com/remko/waforth
synced 2025-01-30 08:34:58 +01:00
waforth2c: Improve table initialization
This commit is contained in:
parent
93e3591205
commit
d42b6d578c
2 changed files with 12 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
CFLAGS=
|
CFLAGS=
|
||||||
CPPFLAGS=-I. -Iwaforth.gen -Iwasm2c
|
CPPFLAGS=-I. -Iwaforth.gen -Iwasm2c
|
||||||
|
LINKFLAGS=-g
|
||||||
|
|
||||||
.DEFAULT_GOAL := all
|
.DEFAULT_GOAL := all
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ example:
|
||||||
./main
|
./main
|
||||||
|
|
||||||
main: $(OBJECTS)
|
main: $(OBJECTS)
|
||||||
$(CC) -o $@ $(OBJECTS)
|
$(CC) $(LINKFLAGS) -o $@ $(OBJECTS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf $(OBJECTS) waforth_core.c waforth_core.h main $(WAFORTH_MODULE_HEADERS) $(WAFORTH_MODULE_SOURCES)
|
-rm -rf $(OBJECTS) waforth_core.c waforth_core.h main $(WAFORTH_MODULE_HEADERS) $(WAFORTH_MODULE_SOURCES)
|
||||||
|
|
|
@ -113,12 +113,18 @@ WebAssembly.instantiate(coreWasm, {
|
||||||
"#undef WASM_RT_MODULE_PREFIX"
|
"#undef WASM_RT_MODULE_PREFIX"
|
||||||
];
|
];
|
||||||
const init = [
|
const init = [
|
||||||
|
"#include <memory.h>",
|
||||||
'#include "waforth_modules.h"',
|
'#include "waforth_modules.h"',
|
||||||
"void waforth_modules_init() {"
|
"static const u8 dictionary[] = { " +
|
||||||
|
Array.from(memory8.slice(dictionaryStart, savedHere)).join(", ") +
|
||||||
|
" };",
|
||||||
|
"void waforth_modules_init() {",
|
||||||
|
"memcpy(&Z_envZ_memory->data[" +
|
||||||
|
dictionaryStart +
|
||||||
|
"], dictionary, " +
|
||||||
|
(savedHere - dictionaryStart) +
|
||||||
|
");"
|
||||||
];
|
];
|
||||||
for (let i = dictionaryStart; i < savedHere; ++i) {
|
|
||||||
init.push("Z_envZ_memory->data[" + i + "] = " + memory8[i] + ";\n");
|
|
||||||
}
|
|
||||||
const objects = ["waforth.gen/waforth_modules.o"];
|
const objects = ["waforth.gen/waforth_modules.o"];
|
||||||
const moduleHeaders = [];
|
const moduleHeaders = [];
|
||||||
const moduleSources = [];
|
const moduleSources = [];
|
||||||
|
|
Loading…
Add table
Reference in a new issue