mirror of
https://github.com/remko/waforth
synced 2025-01-29 08:34:33 +01:00
parent
e49e8439ea
commit
df64428f77
3 changed files with 12 additions and 3 deletions
|
@ -16,6 +16,7 @@ class WAForth {
|
|||
start(options = {}) {
|
||||
const { skipPrelude } = options;
|
||||
let table;
|
||||
let memory;
|
||||
const buffer = (this.buffer = []);
|
||||
|
||||
// TODO: Try to bundle this. See https://github.com/parcel-bundler/parcel/issues/647
|
||||
|
@ -79,7 +80,7 @@ class WAForth {
|
|||
// );
|
||||
var module = new WebAssembly.Module(data);
|
||||
new WebAssembly.Instance(module, {
|
||||
env: { table, tableBase: index }
|
||||
env: { table, tableBase: index, memory, tos: -1 }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +89,7 @@ class WAForth {
|
|||
.then(instance => {
|
||||
this.core = instance.instance;
|
||||
table = this.core.exports.table;
|
||||
memory = this.core.exports.memory;
|
||||
if (!skipPrelude) {
|
||||
this.core.exports.loadPrelude();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
(module
|
||||
(import "env" "table" (table 4 anyfunc))
|
||||
(import "env" "tableBase" (global $tableBase i32))
|
||||
(import "env" "memory" (memory 1))
|
||||
(import "env" "tos" (global $tos i32))
|
||||
|
||||
(type $void (func))
|
||||
(type $push (func (param i32)))
|
||||
|
|
|
@ -46,12 +46,17 @@
|
|||
"\u0060\u0000\u0001\u007F" ;; (func (result i32))
|
||||
"\u0060\u0001\u007f\u0001\u007F" ;; (func (param i32) (result i32))
|
||||
|
||||
"\u0002" "\u0020" ;; Import section
|
||||
"\u0002" ;; #Entries
|
||||
"\u0002" "\u0039" ;; Import section
|
||||
"\u0004" ;; #Entries
|
||||
"\u0003\u0065\u006E\u0076" "\u0005\u0074\u0061\u0062\u006C\u0065" ;; 'env' . 'table'
|
||||
"\u0001" "\u0070" "\u0000" "\u0004" ;; table, anyfunc, flags, initial size
|
||||
"\u0003\u0065\u006E\u0076" "\u0009\u0074\u0061\u0062\u006C\u0065\u0042\u0061\u0073\u0065" ;; 'env' . 'tableBase
|
||||
"\u0003" "\u007F" "\u0000" ;; global, i32, immutable
|
||||
"\u0003\u0065\u006E\u0076" "\u0006\u006d\u0065\u006d\u006f\u0072\u0079" ;; 'env' . 'memory'
|
||||
"\u0002" "\u0000" "\u0001" ;; memory
|
||||
"\u0003\u0065\u006E\u0076" "\u0003\u0074\u006f\u0073" ;; 'env' . 'tos'
|
||||
"\u0003" "\u007F" "\u0000" ;; global, i32, immutable
|
||||
|
||||
|
||||
"\u0003" "\u0002" ;; Function section
|
||||
"\u0001" ;; #Entries
|
||||
|
|
Loading…
Add table
Reference in a new issue