mirror of
https://github.com/remko/waforth
synced 2024-12-27 09:59:29 +01:00
shell.key->shell.getc
This commit is contained in:
parent
e6a95d2aa9
commit
06dd7c12e7
4 changed files with 7 additions and 7 deletions
|
@ -8,7 +8,7 @@
|
|||
#include "waforth.gen/waforth_modules.h"
|
||||
|
||||
void (*Z_shellZ_emitZ_vi)(u32);
|
||||
u32 (*Z_shellZ_keyZ_iv)(void);
|
||||
u32 (*Z_shellZ_getcZ_iv)(void);
|
||||
void (*Z_shellZ_loadZ_viii)(u32, u32, u32);
|
||||
void (*Z_shellZ_debugZ_vi)(u32);
|
||||
wasm_rt_table_t (*Z_envZ_table);
|
||||
|
@ -22,7 +22,7 @@ static void shellEmit(u32 c) {
|
|||
static int bufferIndex;
|
||||
char* buffer = "main\n";
|
||||
|
||||
static u32 shellKey() {
|
||||
static u32 shellGetC() {
|
||||
if (bufferIndex >= strlen(buffer)) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ void waforth_init() {
|
|||
}
|
||||
|
||||
Z_shellZ_emitZ_vi = &shellEmit;
|
||||
Z_shellZ_keyZ_iv = &shellKey;
|
||||
Z_shellZ_getcZ_iv = &shellGetC;
|
||||
Z_shellZ_loadZ_viii = &shellLoad;
|
||||
Z_shellZ_debugZ_vi = &shellDebug;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ WebAssembly.instantiate(coreWasm, {
|
|||
process.stdout.write(String.fromCharCode(c));
|
||||
},
|
||||
|
||||
key: () => {
|
||||
getc: () => {
|
||||
if (buffer.length === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class WAForth {
|
|||
|
||||
emit: this.onEmit,
|
||||
|
||||
key: () => {
|
||||
getc: () => {
|
||||
if (buffer.length === 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
|
||||
(module
|
||||
(import "shell" "emit" (func $shell_emit (param i32)))
|
||||
(import "shell" "key" (func $shell_key (result i32)))
|
||||
(import "shell" "getc" (func $shell_getc (result i32)))
|
||||
(import "shell" "load" (func $shell_load (param i32 i32 i32)))
|
||||
(import "shell" "debug" (func $shell_debug (param i32)))
|
||||
|
||||
|
@ -1838,7 +1838,7 @@ EOF
|
|||
(set_global $inputBufferSize (i32.const 0))
|
||||
(block $endLoop
|
||||
(loop $loop
|
||||
(br_if $endLoop (i32.eq (tee_local $char (call $shell_key)) (i32.const -1)))
|
||||
(br_if $endLoop (i32.eq (tee_local $char (call $shell_getc)) (i32.const -1)))
|
||||
(i32.store8 (i32.add (i32.const !inputBufferBase) (get_global $inputBufferSize))
|
||||
(get_local $char))
|
||||
(set_global $inputBufferSize (i32.add (get_global $inputBufferSize) (i32.const 1)))
|
||||
|
|
Loading…
Reference in a new issue