mirror of
https://github.com/remko/waforth
synced 2025-02-05 20:46:22 +01:00
Implement ABORT + QUIT
This commit is contained in:
parent
2e344baf31
commit
7920432071
3 changed files with 24 additions and 2 deletions
|
@ -112,7 +112,12 @@ class WAForth {
|
|||
|
||||
run(s) {
|
||||
this.read(s);
|
||||
return this.core.exports.interpret();
|
||||
try {
|
||||
return this.core.exports.interpret();
|
||||
} catch (e) {
|
||||
// Exceptions thrown from the core means QUIT or ABORT is called, or an error
|
||||
// has occurred. Assume what has been done has been done, and ignore here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,11 @@ function prompt() {
|
|||
$el.html($el.html().replace(/\n$/, ""));
|
||||
|
||||
forth.run(input);
|
||||
jqconsole.Write(outputBuffer.join(""), "jqconsole-output");
|
||||
let output = outputBuffer.join("");
|
||||
if (output.length === 0) {
|
||||
output = "\n";
|
||||
}
|
||||
jqconsole.Write(output, "jqconsole-output");
|
||||
outputBuffer = [];
|
||||
prompt();
|
||||
});
|
||||
|
|
|
@ -585,6 +585,12 @@
|
|||
(i32.load (i32.load (get_local $btos)))))
|
||||
(!def_word "@" "$@")
|
||||
|
||||
;; 6.1.0670 ABORT
|
||||
(func $ABORT
|
||||
(set_global $tos (i32.const !stackBase))
|
||||
(call $QUIT))
|
||||
(!def_word "ABORT" "$ABORT")
|
||||
|
||||
;; 6.1.0690
|
||||
(func $ABS
|
||||
(local $btos i32)
|
||||
|
@ -1012,6 +1018,13 @@
|
|||
(call $compileCall (get_local $findToken)))
|
||||
(!def_word "POSTPONE" "$POSTPONE" !fImmediate)
|
||||
|
||||
;; 6.1.2050
|
||||
(func $QUIT
|
||||
(set_global $tors (i32.const !returnStackBase))
|
||||
(set_global $sourceID (i32.const 0))
|
||||
(unreachable))
|
||||
(!def_word "QUIT" "$QUIT")
|
||||
|
||||
;; 6.1.2060
|
||||
(func $R>
|
||||
(set_global $tors (i32.sub (get_global $tors) (i32.const 4)))
|
||||
|
|
Loading…
Add table
Reference in a new issue