diff options
| author | 2026-10-15 21:44:40 +0330 | |
|---|---|---|
| committer | 2026-10-15 21:44:40 +0330 | |
| commit | f3dcfd9805e1bd23b002f648d4391ec397122d9c (patch) | |
| tree | 91acab7da09c9225a2d838791d70e5c2e7db54b9 /src/js | |
| parent | merge work/small-oob: bytes test out-of-bounds read (diff) | |
| parent | examples/actors_demo: print the fan-out replies in worker order, not arrival ... (diff) | |
merge work/known-bugs: constant-expression precedence, local const in constant expressions, duplicate case labels, unterminated strings, droppable cycles in one collection, js vm exit, docs, actors_demo orderHEADmain
Diffstat (limited to 'src/js')
| -rw-r--r-- | src/js/tinyvm.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/js/tinyvm.ts b/src/js/tinyvm.ts index 51b390b..5ee29c7 100644 --- a/src/js/tinyvm.ts +++ b/src/js/tinyvm.ts @@ -179,6 +179,7 @@ export class TinyVM { should resume it after its event loop has run, whether or not input came. */ public polling: boolean = false; private outputBuffer: number[] = []; + private exitCode: number | null = null; private onOutput?: (byte: number) => void; private onMessage?: (msg: string) => void; @@ -439,7 +440,8 @@ export class TinyVM { return -1n; case 6: // time return BigInt(Math.floor(Date.now() / 1000)); - case 7: // exit + case 7: // exit: the run stops here with this status, as the native core's exit() does + this.exitCode = Number(BigInt.asIntN(32, a)) & 255; return 0n; case 8: // rand return BigInt(Math.floor(Math.random() * 0x7FFFFFFF)); @@ -781,6 +783,7 @@ export class TinyVM { mem = this.mem; bytes = this.bytes; view = this.view; mw = this.mw; // a grow may have moved them mem[Number(a)] = result; s = this.rs; r = this.rr; + if (this.exitCode !== null) { const code = this.exitCode; this.exitCode = null; return code; } break; } else if (Number(a) >= 0 && Number(a) < mw) { mem[Number(a)] = b; |
