wasm-idle 0.7.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +760 -81
- package/dist/index.d.ts +4 -9
- package/dist/index.js +2 -4
- package/dist/playground/applicationAssets.d.ts +4 -0
- package/dist/playground/applicationAssets.js +277 -0
- package/dist/playground/assemblyscript.d.ts +41 -0
- package/dist/playground/assemblyscript.js +630 -0
- package/dist/playground/assetBridge.d.ts +18 -7
- package/dist/playground/assetBridge.js +824 -100
- package/dist/playground/assets.d.ts +813 -19
- package/dist/playground/assets.js +2096 -156
- package/dist/playground/awk.d.ts +5 -0
- package/dist/playground/awk.js +60 -0
- package/dist/playground/bash.d.ts +53 -0
- package/dist/playground/bash.js +1096 -0
- package/dist/playground/bashWorkerProtocol.d.ts +88 -0
- package/dist/playground/bashWorkerProtocol.js +135 -0
- package/dist/playground/bqn.d.ts +5 -0
- package/dist/playground/bqn.js +57 -0
- package/dist/playground/bqnPreflight.d.ts +26 -0
- package/dist/playground/bqnPreflight.js +399 -0
- package/dist/playground/c3.d.ts +15 -0
- package/dist/playground/c3.js +154 -0
- package/dist/playground/clang.d.ts +35 -19
- package/dist/playground/clang.js +241 -52
- package/dist/playground/clangAssetIntegrity.d.ts +32 -0
- package/dist/playground/clangAssetIntegrity.js +8 -0
- package/dist/playground/clojurescript.d.ts +5 -0
- package/dist/playground/clojurescript.js +59 -0
- package/dist/playground/clojurescriptPreflight.d.ts +26 -0
- package/dist/playground/clojurescriptPreflight.js +383 -0
- package/dist/playground/cobol.d.ts +46 -0
- package/dist/playground/cobol.js +703 -0
- package/dist/playground/d.d.ts +47 -0
- package/dist/playground/d.js +644 -0
- package/dist/playground/dOuterAssets.d.ts +16 -0
- package/dist/playground/dOuterAssets.js +163 -0
- package/dist/playground/dotnet.d.ts +99 -0
- package/dist/playground/dotnet.js +1131 -0
- package/dist/playground/duckdb.d.ts +36 -0
- package/dist/playground/duckdb.js +542 -0
- package/dist/playground/elixir.d.ts +18 -10
- package/dist/playground/elixir.js +630 -96
- package/dist/playground/elixirAssets.d.ts +6 -0
- package/dist/playground/elixirAssets.js +33 -0
- package/dist/playground/executionObservation.d.ts +22 -0
- package/dist/playground/executionObservation.js +65 -0
- package/dist/playground/forth.d.ts +5 -0
- package/dist/playground/forth.js +53 -0
- package/dist/playground/forthPreflight.d.ts +24 -0
- package/dist/playground/forthPreflight.js +198 -0
- package/dist/playground/fortran.d.ts +47 -0
- package/dist/playground/fortran.js +651 -0
- package/dist/playground/fortranAssets.d.ts +6 -0
- package/dist/playground/fortranAssets.js +27 -0
- package/dist/playground/gleam.d.ts +6 -0
- package/dist/playground/gleam.js +33 -0
- package/dist/playground/go.d.ts +17 -11
- package/dist/playground/go.js +376 -72
- package/dist/playground/goDebugInstrumentation.d.ts +1 -0
- package/dist/playground/goDebugInstrumentation.js +229 -0
- package/dist/playground/haskell.d.ts +44 -0
- package/dist/playground/haskell.js +678 -0
- package/dist/playground/haskellAssets.d.ts +24 -0
- package/dist/playground/haskellAssets.js +93 -0
- package/dist/playground/index.d.ts +1 -1
- package/dist/playground/index.js +360 -111
- package/dist/playground/j.d.ts +5 -0
- package/dist/playground/j.js +60 -0
- package/dist/playground/jPreflight.d.ts +26 -0
- package/dist/playground/jPreflight.js +372 -0
- package/dist/playground/janet.d.ts +5 -0
- package/dist/playground/janet.js +64 -0
- package/dist/playground/java.d.ts +24 -10
- package/dist/playground/java.js +706 -84
- package/dist/playground/javaSource.d.ts +5 -0
- package/dist/playground/javaSource.js +16 -0
- package/dist/playground/javaStdin.d.ts +1 -1
- package/dist/playground/javaStdin.js +13 -4
- package/dist/playground/julia.d.ts +5 -0
- package/dist/playground/julia.js +64 -0
- package/dist/playground/lfortran.d.ts +8 -0
- package/dist/playground/lfortran.js +30 -0
- package/dist/playground/lfortranAssets.d.ts +21 -0
- package/dist/playground/lfortranAssets.js +118 -0
- package/dist/playground/lisp.d.ts +45 -0
- package/dist/playground/lisp.js +640 -0
- package/dist/playground/lispAssets.d.ts +9 -0
- package/dist/playground/lispAssets.js +74 -0
- package/dist/playground/lldbManifest.d.ts +3 -0
- package/dist/playground/lldbManifest.js +155 -0
- package/dist/playground/lldbSession.d.ts +115 -0
- package/dist/playground/lldbSession.js +1347 -0
- package/dist/playground/loadingProgress.d.ts +16 -0
- package/dist/playground/loadingProgress.js +166 -0
- package/dist/playground/lua.d.ts +44 -0
- package/dist/playground/lua.js +630 -0
- package/dist/playground/nim.d.ts +5 -0
- package/dist/playground/nim.js +76 -0
- package/dist/playground/objectivec.d.ts +39 -0
- package/dist/playground/objectivec.js +288 -0
- package/dist/playground/ocaml.d.ts +28 -10
- package/dist/playground/ocaml.js +815 -253
- package/dist/playground/octave.d.ts +43 -0
- package/dist/playground/octave.js +783 -0
- package/dist/playground/options.d.ts +19 -40
- package/dist/playground/options.js +2 -1
- package/dist/playground/pascal.d.ts +5 -0
- package/dist/playground/pascal.js +60 -0
- package/dist/playground/perl.d.ts +5 -0
- package/dist/playground/perl.js +61 -0
- package/dist/playground/php.d.ts +44 -0
- package/dist/playground/php.js +665 -0
- package/dist/playground/prolog.d.ts +6 -0
- package/dist/playground/prolog.js +75 -0
- package/dist/playground/python.d.ts +20 -14
- package/dist/playground/python.js +445 -101
- package/dist/playground/pythonPackageLock.d.ts +6 -0
- package/dist/playground/pythonPackageLock.js +56 -0
- package/dist/playground/r.d.ts +44 -0
- package/dist/playground/r.js +637 -0
- package/dist/playground/ruby.d.ts +46 -0
- package/dist/playground/ruby.js +732 -0
- package/dist/playground/rubyAssets.d.ts +23 -0
- package/dist/playground/rubyAssets.js +68 -0
- package/dist/playground/rubyTestPreflight.d.ts +2 -0
- package/dist/playground/rubyTestPreflight.js +18 -0
- package/dist/playground/runtimeModule.d.ts +1 -0
- package/dist/playground/runtimeModule.js +5 -0
- package/dist/playground/rust.d.ts +44 -13
- package/dist/playground/rust.js +714 -76
- package/dist/playground/rustExecutableGraph.d.ts +85 -0
- package/dist/playground/rustExecutableGraph.js +946 -0
- package/dist/playground/rustWorkerLimits.d.ts +17 -0
- package/dist/playground/rustWorkerLimits.js +34 -0
- package/dist/playground/sandbox.d.ts +16 -10
- package/dist/playground/sharedBuffer.d.ts +6 -0
- package/dist/playground/sharedBuffer.js +12 -0
- package/dist/playground/sqlite.d.ts +38 -0
- package/dist/playground/sqlite.js +550 -0
- package/dist/playground/staticRuntimeModuleVersion.d.ts +1 -0
- package/dist/playground/staticRuntimeModuleVersion.js +2 -0
- package/dist/playground/staticRuntimePreflight.d.ts +13 -0
- package/dist/playground/staticRuntimePreflight.js +231 -0
- package/dist/playground/staticRuntimePreflightExecute.d.ts +8 -0
- package/dist/playground/staticRuntimePreflightExecute.js +66 -0
- package/dist/playground/staticRuntimePreflightProtocol.d.ts +68 -0
- package/dist/playground/staticRuntimePreflightProtocol.js +339 -0
- package/dist/playground/staticStdinRing.d.ts +45 -0
- package/dist/playground/staticStdinRing.js +158 -0
- package/dist/playground/staticWorkerRuntime.d.ts +154 -0
- package/dist/playground/staticWorkerRuntime.js +1917 -0
- package/dist/playground/stdinBuffer.d.ts +9 -7
- package/dist/playground/stdinBuffer.js +9 -18
- package/dist/playground/swift.d.ts +5 -0
- package/dist/playground/swift.js +17 -0
- package/dist/playground/tcl.d.ts +5 -0
- package/dist/playground/tcl.js +62 -0
- package/dist/playground/teavmConfig.d.ts +1 -1
- package/dist/playground/teavmConfig.js +2 -2
- package/dist/playground/tinygo.d.ts +48 -18
- package/dist/playground/tinygo.js +1202 -329
- package/dist/playground/tinygoExecutableGraph.d.ts +44 -0
- package/dist/playground/tinygoExecutableGraph.js +449 -0
- package/dist/playground/typescript.d.ts +55 -0
- package/dist/playground/typescript.js +924 -0
- package/dist/playground/wasm.d.ts +43 -0
- package/dist/playground/wasm.js +608 -0
- package/dist/playground/wasmAwkVersion.d.ts +59 -0
- package/dist/playground/wasmAwkVersion.js +31 -0
- package/dist/playground/wasmBashVersion.d.ts +63 -0
- package/dist/playground/wasmBashVersion.js +36 -0
- package/dist/playground/wasmBqnVersion.d.ts +24 -0
- package/dist/playground/wasmBqnVersion.js +24 -0
- package/dist/playground/wasmC3Version.d.ts +20 -0
- package/dist/playground/wasmC3Version.js +21 -0
- package/dist/playground/wasmClojureScriptVersion.d.ts +21 -0
- package/dist/playground/wasmClojureScriptVersion.js +21 -0
- package/dist/playground/wasmDIntegrity.d.ts +15 -0
- package/dist/playground/wasmDIntegrity.js +15 -0
- package/dist/playground/wasmDVersion.d.ts +1 -0
- package/dist/playground/wasmDVersion.js +1 -0
- package/dist/playground/wasmDebugVersion.d.ts +6 -0
- package/dist/playground/wasmDebugVersion.js +6 -0
- package/dist/playground/wasmDotnetVersion.d.ts +1 -0
- package/dist/playground/wasmDotnetVersion.js +1 -0
- package/dist/playground/wasmElixirVersion.d.ts +21 -1
- package/dist/playground/wasmElixirVersion.js +21 -1
- package/dist/playground/wasmForthVersion.d.ts +18 -0
- package/dist/playground/wasmForthVersion.js +18 -0
- package/dist/playground/wasmFortranExecutionAssets.d.ts +15 -0
- package/dist/playground/wasmFortranExecutionAssets.js +15 -0
- package/dist/playground/wasmFortranVersion.d.ts +1 -0
- package/dist/playground/wasmFortranVersion.js +1 -0
- package/dist/playground/wasmGleamVersion.d.ts +5 -0
- package/dist/playground/wasmGleamVersion.js +5 -0
- package/dist/playground/wasmGoVersion.d.ts +1 -1
- package/dist/playground/wasmGoVersion.js +1 -1
- package/dist/playground/wasmHaskellVersion.d.ts +1 -0
- package/dist/playground/wasmHaskellVersion.js +1 -0
- package/dist/playground/wasmJVersion.d.ts +24 -0
- package/dist/playground/wasmJVersion.js +24 -0
- package/dist/playground/wasmJanetVersion.d.ts +53 -0
- package/dist/playground/wasmJanetVersion.js +30 -0
- package/dist/playground/wasmJuliaVersion.d.ts +71 -0
- package/dist/playground/wasmJuliaVersion.js +39 -0
- package/dist/playground/wasmLfortranVersion.d.ts +28 -0
- package/dist/playground/wasmLfortranVersion.js +29 -0
- package/dist/playground/wasmLispVersion.d.ts +1 -0
- package/dist/playground/wasmLispVersion.js +1 -0
- package/dist/playground/wasmLuaVersion.d.ts +1 -0
- package/dist/playground/wasmLuaVersion.js +1 -0
- package/dist/playground/wasmNimVersion.d.ts +125 -0
- package/dist/playground/wasmNimVersion.js +66 -0
- package/dist/playground/wasmObjectiveCVersion.d.ts +27 -0
- package/dist/playground/wasmObjectiveCVersion.js +27 -0
- package/dist/playground/wasmOcamlVersion.d.ts +12 -1
- package/dist/playground/wasmOcamlVersion.js +12 -1
- package/dist/playground/wasmOctaveVersion.d.ts +1 -0
- package/dist/playground/wasmOctaveVersion.js +1 -0
- package/dist/playground/wasmPascalVersion.d.ts +61 -0
- package/dist/playground/wasmPascalVersion.js +34 -0
- package/dist/playground/wasmPerlVersion.d.ts +71 -0
- package/dist/playground/wasmPerlVersion.js +39 -0
- package/dist/playground/wasmPrologVersion.d.ts +31 -0
- package/dist/playground/wasmPrologVersion.js +31 -0
- package/dist/playground/wasmRVersion.d.ts +1 -0
- package/dist/playground/wasmRVersion.js +1 -0
- package/dist/playground/wasmRustVersion.d.ts +1306 -1
- package/dist/playground/wasmRustVersion.js +1458 -1
- package/dist/playground/wasmSwiftVersion.d.ts +1 -0
- package/dist/playground/wasmSwiftVersion.js +1 -0
- package/dist/playground/wasmTclVersion.d.ts +85 -0
- package/dist/playground/wasmTclVersion.js +46 -0
- package/dist/playground/wasmTinyGoVersion.d.ts +98 -1
- package/dist/playground/wasmTinyGoVersion.js +107 -1
- package/dist/playground/wasmTypeScriptVersion.d.ts +5 -0
- package/dist/playground/wasmTypeScriptVersion.js +5 -0
- package/dist/playground/wasmWatVersion.d.ts +1 -0
- package/dist/playground/wasmWatVersion.js +1 -0
- package/dist/playground/wasmZigVersion.d.ts +13 -0
- package/dist/playground/wasmZigVersion.js +13 -0
- package/dist/playground/wat.d.ts +44 -0
- package/dist/playground/wat.js +622 -0
- package/dist/playground/worker/assemblyscript.js +339 -0
- package/dist/playground/worker/assets.d.ts +7 -0
- package/dist/playground/worker/assets.js +288 -39
- package/dist/playground/worker/bash.js +338 -0
- package/dist/playground/worker/bashNestedBootstrap.d.ts +6 -0
- package/dist/playground/worker/bashNestedBootstrap.js +59 -0
- package/dist/playground/worker/bashRuntime.d.ts +89 -0
- package/dist/playground/worker/bashRuntime.js +982 -0
- package/dist/playground/worker/clang.js +92 -13
- package/dist/playground/worker/cobol.js +107 -0
- package/dist/playground/worker/d.js +199 -0
- package/dist/playground/worker/dotnet.js +141 -0
- package/dist/playground/worker/duckdb.d.ts +1 -0
- package/dist/playground/worker/duckdb.js +136 -0
- package/dist/playground/worker/elixir.js +307 -41
- package/dist/playground/worker/fortran.d.ts +1 -0
- package/dist/playground/worker/fortran.js +295 -0
- package/dist/playground/worker/go.js +246 -40
- package/dist/playground/worker/haskell.d.ts +7 -0
- package/dist/playground/worker/haskell.js +465 -0
- package/dist/playground/worker/java.js +59 -20
- package/dist/playground/worker/lisp.d.ts +1 -0
- package/dist/playground/worker/lisp.js +195 -0
- package/dist/playground/worker/lua.d.ts +1 -0
- package/dist/playground/worker/lua.js +163 -0
- package/dist/playground/worker/objectivec.d.ts +1 -0
- package/dist/playground/worker/objectivec.js +10 -0
- package/dist/playground/worker/ocaml.js +206 -58
- package/dist/playground/worker/php.d.ts +1 -0
- package/dist/playground/worker/php.js +261 -0
- package/dist/playground/worker/python.js +201 -44
- package/dist/playground/worker/r.d.ts +1 -0
- package/dist/playground/worker/r.js +192 -0
- package/dist/playground/worker/ruby.d.ts +1 -0
- package/dist/playground/worker/ruby.js +248 -0
- package/dist/playground/worker/runtimeAssetFetch.d.ts +15 -0
- package/dist/playground/worker/runtimeAssetFetch.js +375 -0
- package/dist/playground/worker/rust.js +546 -20
- package/dist/playground/worker/sqlite.d.ts +1 -0
- package/dist/playground/worker/sqlite.js +112 -0
- package/dist/playground/worker/staticRuntimePreflight.d.ts +1 -0
- package/dist/playground/worker/staticRuntimePreflight.js +56 -0
- package/dist/playground/worker/tinygo.js +34 -9
- package/dist/playground/worker/typescript.d.ts +1 -0
- package/dist/playground/worker/typescript.js +251 -0
- package/dist/playground/worker/wasm.d.ts +1 -0
- package/dist/playground/worker/wasm.js +273 -0
- package/dist/playground/worker/wat.d.ts +1 -0
- package/dist/playground/worker/wat.js +188 -0
- package/dist/playground/worker/zig.d.ts +8 -0
- package/dist/playground/worker/zig.js +578 -0
- package/dist/playground/workerProgress.d.ts +15 -0
- package/dist/playground/workerProgress.js +72 -0
- package/dist/playground/workerSession.d.ts +28 -0
- package/dist/playground/workerSession.js +164 -0
- package/dist/playground/zig.d.ts +46 -0
- package/dist/playground/zig.js +690 -0
- package/dist/playground/zigAssets.d.ts +6 -0
- package/dist/playground/zigAssets.js +49 -0
- package/package.json +234 -105
- package/dist/clang/app.d.ts +0 -75
- package/dist/clang/app.js +0 -744
- package/dist/clang/apply.d.ts +0 -2
- package/dist/clang/apply.js +0 -11
- package/dist/clang/color.d.ts +0 -3
- package/dist/clang/color.js +0 -3
- package/dist/clang/encode.d.ts +0 -4
- package/dist/clang/encode.js +0 -20
- package/dist/clang/error.d.ts +0 -14
- package/dist/clang/error.js +0 -27
- package/dist/clang/gccCompat.d.ts +0 -15
- package/dist/clang/gccCompat.js +0 -767
- package/dist/clang/index.d.ts +0 -85
- package/dist/clang/index.js +0 -1077
- package/dist/clang/memory/index.d.ts +0 -4
- package/dist/clang/memory/index.js +0 -4
- package/dist/clang/memory/memFs.d.ts +0 -35
- package/dist/clang/memory/memFs.js +0 -132
- package/dist/clang/memory/memory.d.ts +0 -22
- package/dist/clang/memory/memory.js +0 -73
- package/dist/clang/memory/tar.d.ts +0 -2
- package/dist/clang/memory/tar.js +0 -59
- package/dist/clang/url.d.ts +0 -4
- package/dist/clang/url.js +0 -5
- package/dist/clang/wasm.d.ts +0 -4
- package/dist/clang/wasm.js +0 -50
- package/dist/clangd/config.d.ts +0 -18
- package/dist/clangd/config.js +0 -14
- package/dist/clangd/jsonStream.d.ts +0 -9
- package/dist/clangd/jsonStream.js +0 -48
- package/dist/clangd/session.d.ts +0 -18
- package/dist/clangd/session.js +0 -112
- package/dist/clangd/worker.js +0 -131
- package/dist/debug/controller.svelte.d.ts +0 -43
- package/dist/debug/controller.svelte.js +0 -268
- package/dist/debug/editor/index.d.ts +0 -2
- package/dist/debug/editor/index.js +0 -1
- package/dist/debug/editor/monaco.d.ts +0 -26
- package/dist/debug/editor/monaco.js +0 -128
- package/dist/debug/expression.d.ts +0 -26
- package/dist/debug/expression.js +0 -547
- package/dist/debug/index.d.ts +0 -8
- package/dist/debug/index.js +0 -5
- package/dist/debug/language/cpp.d.ts +0 -2
- package/dist/debug/language/cpp.js +0 -7
- package/dist/debug/language/index.d.ts +0 -3
- package/dist/debug/language/index.js +0 -2
- package/dist/debug/language/python.d.ts +0 -2
- package/dist/debug/language/python.js +0 -14
- package/dist/debug/language/types.d.ts +0 -6
- package/dist/debug/locals.d.ts +0 -2
- package/dist/debug/locals.js +0 -8
- package/dist/lsp/cpp/server.d.ts +0 -2
- package/dist/lsp/cpp/server.js +0 -68
- package/dist/lsp/index.d.ts +0 -5
- package/dist/lsp/index.js +0 -4
- package/dist/lsp/python/main.worker.js +0 -92
- package/dist/lsp/python/package/arcturus_python_lsp/__init__.py +0 -3
- package/dist/lsp/python/package/arcturus_python_lsp/server.py +0 -462
- package/dist/lsp/python/server.d.ts +0 -2
- package/dist/lsp/python/server.js +0 -54
- package/dist/lsp/registry.d.ts +0 -2
- package/dist/lsp/registry.js +0 -12
- package/dist/lsp/runtime.d.ts +0 -5
- package/dist/lsp/runtime.js +0 -31
- package/dist/lsp/types.d.ts +0 -17
- package/dist/terminal/Terminal.svelte +0 -422
- package/dist/terminal/Terminal.svelte.d.ts +0 -26
- package/dist/terminal/index.d.ts +0 -7
- package/dist/terminal/index.js +0 -5
- package/dist/terminal/plugin/index.d.ts +0 -9
- package/dist/terminal/plugin/index.js +0 -19
- package/dist/terminal/theme.d.ts +0 -49
- package/dist/terminal/theme.js +0 -49
- package/dist/terminal/types.d.ts +0 -18
- package/dist/utils/vscodeJsonrpcBrowser.d.ts +0 -5
- package/dist/utils/vscodeJsonrpcBrowser.js +0 -4
- /package/dist/{clangd/worker.d.ts → playground/worker/assemblyscript.d.ts} +0 -0
- /package/dist/{debug/language/types.js → playground/worker/bash.d.ts} +0 -0
- /package/dist/{lsp/python/main.worker.d.ts → playground/worker/cobol.d.ts} +0 -0
- /package/dist/{lsp/types.js → playground/worker/d.d.ts} +0 -0
- /package/dist/{terminal/types.js → playground/worker/dotnet.d.ts} +0 -0
package/dist/clang/app.js
DELETED
|
@@ -1,744 +0,0 @@
|
|
|
1
|
-
import { bindNew } from './apply';
|
|
2
|
-
import { Memory } from './memory';
|
|
3
|
-
import { getInstance } from './wasm';
|
|
4
|
-
import { AbortError, NotImplemented, ProcExit } from './error';
|
|
5
|
-
import { evaluateDebugExpressionWithResolver, parseStoredDebugValue } from '../debug/expression';
|
|
6
|
-
import { flushQueuedStdin, readBufferedStdin } from '../playground/stdinBuffer';
|
|
7
|
-
const ESUCCESS = 0;
|
|
8
|
-
const RAF_PROC_EXIT_CODE = 0xc0c0a;
|
|
9
|
-
export default class App {
|
|
10
|
-
ready;
|
|
11
|
-
mem = null;
|
|
12
|
-
memfs;
|
|
13
|
-
instance = null;
|
|
14
|
-
exports;
|
|
15
|
-
trace = () => { };
|
|
16
|
-
debugSession;
|
|
17
|
-
argv;
|
|
18
|
-
environ;
|
|
19
|
-
handles = new Map();
|
|
20
|
-
nextHandle = 0;
|
|
21
|
-
constructor(module, memfs, name, ...args) {
|
|
22
|
-
this.argv = [name, ...args];
|
|
23
|
-
this.environ = { USER: 'jungol' };
|
|
24
|
-
this.memfs = memfs;
|
|
25
|
-
const env = bindNew(this, '__wasm_idle_debug_enter', '__wasm_idle_debug_leave', '__wasm_idle_debug_line', '__wasm_idle_debug_value_num', '__wasm_idle_debug_value_bool', '__wasm_idle_debug_value_addr', '__wasm_idle_debug_value_text');
|
|
26
|
-
const wasi = {
|
|
27
|
-
...bindNew(this, 'proc_exit', 'environ_sizes_get', 'environ_get', 'args_sizes_get', 'args_get', 'random_get', 'clock_time_get', 'poll_oneoff'),
|
|
28
|
-
...this.memfs.exports
|
|
29
|
-
};
|
|
30
|
-
// Rust/WASI modules import `wasi_snapshot_preview1`, while older toolchains here still use
|
|
31
|
-
// `wasi_unstable`. Expose the same host under both names so either artifact shape runs.
|
|
32
|
-
this.ready = getInstance(module, {
|
|
33
|
-
wasi_unstable: wasi,
|
|
34
|
-
wasi_snapshot_preview1: wasi,
|
|
35
|
-
env
|
|
36
|
-
}).then((instance) => {
|
|
37
|
-
this.instance = instance;
|
|
38
|
-
this.exports = this.instance.exports;
|
|
39
|
-
this.mem = new Memory(this.exports.memory);
|
|
40
|
-
this.memfs.hostMem = this.mem;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
async run() {
|
|
44
|
-
await this.ready;
|
|
45
|
-
this.trace(`start(argv=${JSON.stringify(this.argv)}, exports=${JSON.stringify(Object.keys(this.exports || {}))})`);
|
|
46
|
-
try {
|
|
47
|
-
this.exports._start();
|
|
48
|
-
}
|
|
49
|
-
catch (exn) {
|
|
50
|
-
let writeStack = true;
|
|
51
|
-
if (exn instanceof ProcExit) {
|
|
52
|
-
this.trace(`proc_exit(code=${exn.code})`);
|
|
53
|
-
if (exn.code === RAF_PROC_EXIT_CODE) {
|
|
54
|
-
console.log('Allowing rAF after exit.');
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
// Don't allow rAF unless you return the right code.
|
|
58
|
-
console.log(`Disallowing rAF since exit code is ${exn.code}.`);
|
|
59
|
-
if (exn.code == 0)
|
|
60
|
-
return false;
|
|
61
|
-
writeStack = false;
|
|
62
|
-
}
|
|
63
|
-
if (exn instanceof NotImplemented)
|
|
64
|
-
this.trace(`not_implemented(${exn.message})`);
|
|
65
|
-
// Write error message.
|
|
66
|
-
let msg = `\x1b[91mError: ${exn.message}`;
|
|
67
|
-
if (writeStack)
|
|
68
|
-
msg = msg + `\n${exn.stack}`;
|
|
69
|
-
msg += '\x1b[0m\n';
|
|
70
|
-
this.memfs.stdout(msg);
|
|
71
|
-
// Propagate error.
|
|
72
|
-
throw exn;
|
|
73
|
-
}
|
|
74
|
-
this.trace('start() returned without proc_exit');
|
|
75
|
-
}
|
|
76
|
-
proc_exit(code) {
|
|
77
|
-
this.trace(`proc_exit_throw(code=${code})`);
|
|
78
|
-
throw new ProcExit(code);
|
|
79
|
-
}
|
|
80
|
-
debugEvaluate(expression) {
|
|
81
|
-
const session = this.debugSession;
|
|
82
|
-
if (!session)
|
|
83
|
-
throw new Error('unavailable');
|
|
84
|
-
const frame = [...session.frames]
|
|
85
|
-
.reverse()
|
|
86
|
-
.find((candidate) => candidate.functionId === session.currentFunctionId);
|
|
87
|
-
const activeLine = session.currentLine;
|
|
88
|
-
const activeLocals = [...(session.variableMetadata[session.currentFunctionId] || [])]
|
|
89
|
-
.reverse()
|
|
90
|
-
.filter((variable) => activeLine >= variable.fromLine && activeLine <= variable.toLine);
|
|
91
|
-
const activeGlobals = [...(session.globalVariableMetadata || [])]
|
|
92
|
-
.reverse()
|
|
93
|
-
.filter((variable) => activeLine >= variable.fromLine && activeLine <= variable.toLine);
|
|
94
|
-
return evaluateDebugExpressionWithResolver(expression, (name) => {
|
|
95
|
-
const resolveArrayValue = (variable, addressValue) => {
|
|
96
|
-
const dimensions = variable.dimensions?.length
|
|
97
|
-
? variable.dimensions
|
|
98
|
-
: variable.length
|
|
99
|
-
? [variable.length]
|
|
100
|
-
: [];
|
|
101
|
-
const address = Number(addressValue);
|
|
102
|
-
if (!Number.isFinite(address) ||
|
|
103
|
-
address <= 0 ||
|
|
104
|
-
!dimensions.length ||
|
|
105
|
-
(!variable.elementKind && !variable.structFields?.length)) {
|
|
106
|
-
throw new Error('unavailable');
|
|
107
|
-
}
|
|
108
|
-
this.mem?.check?.();
|
|
109
|
-
const scalarSize = variable.structFields?.length && variable.structSize
|
|
110
|
-
? variable.structSize
|
|
111
|
-
: variable.elementKind === 'double'
|
|
112
|
-
? 8
|
|
113
|
-
: variable.elementKind === 'bool' || variable.elementKind === 'char'
|
|
114
|
-
? 1
|
|
115
|
-
: 4;
|
|
116
|
-
const readScalar = (kind, offset) => {
|
|
117
|
-
if (kind === 'bool')
|
|
118
|
-
return !!this.mem.read8(offset);
|
|
119
|
-
if (kind === 'char') {
|
|
120
|
-
const charCode = this.mem.read8(offset);
|
|
121
|
-
return charCode >= 0x20 && charCode <= 0x7e
|
|
122
|
-
? String.fromCharCode(charCode)
|
|
123
|
-
: charCode;
|
|
124
|
-
}
|
|
125
|
-
if (kind === 'float')
|
|
126
|
-
return this.mem.readFloat32(offset);
|
|
127
|
-
if (kind === 'double')
|
|
128
|
-
return this.mem.readFloat64(offset);
|
|
129
|
-
return this.mem.readInt32(offset);
|
|
130
|
-
};
|
|
131
|
-
const buildStructValue = (baseAddress) => ({
|
|
132
|
-
__debugExpressionKind: 'object',
|
|
133
|
-
has: (fieldName) => !!variable.structFields?.some((field) => field.name === fieldName),
|
|
134
|
-
get: (fieldName) => {
|
|
135
|
-
const field = variable.structFields?.find((candidate) => candidate.name === fieldName);
|
|
136
|
-
if (!field)
|
|
137
|
-
throw new Error('unavailable');
|
|
138
|
-
return readScalar(field.kind, baseAddress + field.offset);
|
|
139
|
-
},
|
|
140
|
-
keys: () => variable.structFields?.map((field) => field.name) || []
|
|
141
|
-
});
|
|
142
|
-
const buildArrayValue = (baseAddress, remainingDimensions) => ({
|
|
143
|
-
__debugExpressionKind: 'array',
|
|
144
|
-
length: remainingDimensions[0],
|
|
145
|
-
truncated: remainingDimensions[0] > 8,
|
|
146
|
-
get: (index) => {
|
|
147
|
-
if (!Number.isInteger(index) ||
|
|
148
|
-
index < 0 ||
|
|
149
|
-
index >= remainingDimensions[0]) {
|
|
150
|
-
throw new Error('unavailable');
|
|
151
|
-
}
|
|
152
|
-
if (remainingDimensions.length > 1) {
|
|
153
|
-
const nestedStride = remainingDimensions
|
|
154
|
-
.slice(1)
|
|
155
|
-
.reduce((total, size) => total * size, 1) * scalarSize;
|
|
156
|
-
return buildArrayValue(baseAddress + index * nestedStride, remainingDimensions.slice(1));
|
|
157
|
-
}
|
|
158
|
-
if (variable.structFields?.length && variable.structSize) {
|
|
159
|
-
return buildStructValue(baseAddress + index * variable.structSize);
|
|
160
|
-
}
|
|
161
|
-
if (!variable.elementKind)
|
|
162
|
-
throw new Error('unavailable');
|
|
163
|
-
return readScalar(variable.elementKind, baseAddress + index * scalarSize);
|
|
164
|
-
},
|
|
165
|
-
keys: () => Array.from({ length: Math.min(remainingDimensions[0], 8) }, (_, index) => index)
|
|
166
|
-
});
|
|
167
|
-
return buildArrayValue(address, dimensions);
|
|
168
|
-
};
|
|
169
|
-
const resolveVariableValue = (variable, storedValue) => {
|
|
170
|
-
if (storedValue == null || storedValue === '?')
|
|
171
|
-
throw new Error('unavailable');
|
|
172
|
-
if (variable.kind === 'array')
|
|
173
|
-
return resolveArrayValue(variable, storedValue);
|
|
174
|
-
return parseStoredDebugValue(storedValue);
|
|
175
|
-
};
|
|
176
|
-
const localVariable = activeLocals.find((variable) => variable.name === name);
|
|
177
|
-
if (localVariable) {
|
|
178
|
-
return resolveVariableValue(localVariable, frame?.values.get(localVariable.slot));
|
|
179
|
-
}
|
|
180
|
-
const globalVariable = activeGlobals.find((variable) => variable.name === name);
|
|
181
|
-
if (globalVariable) {
|
|
182
|
-
return resolveVariableValue(globalVariable, session.globalValues.get(globalVariable.slot));
|
|
183
|
-
}
|
|
184
|
-
throw new Error('unavailable');
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
pauseDebugSession(session, functionId, line, reason) {
|
|
188
|
-
const buffer = session.buffer;
|
|
189
|
-
if (!buffer)
|
|
190
|
-
return ESUCCESS;
|
|
191
|
-
session.currentFunctionId = functionId;
|
|
192
|
-
session.currentLine = line;
|
|
193
|
-
const frame = [...session.frames]
|
|
194
|
-
.reverse()
|
|
195
|
-
.find((candidate) => candidate.functionId === functionId);
|
|
196
|
-
if (frame)
|
|
197
|
-
frame.line = line;
|
|
198
|
-
session.pauseOnEntry = false;
|
|
199
|
-
session.stepArmed = false;
|
|
200
|
-
session.nextLineArmed = false;
|
|
201
|
-
session.stepOutArmed = false;
|
|
202
|
-
this.trace(`pause(function=${functionId}, line=${line}, reason=${reason})`);
|
|
203
|
-
const locals = session.variableMetadata[functionId]?.flatMap((variable) => {
|
|
204
|
-
if (line < variable.fromLine || line > variable.toLine)
|
|
205
|
-
return [];
|
|
206
|
-
if (variable.kind === 'array') {
|
|
207
|
-
this.mem?.check?.();
|
|
208
|
-
const address = Number(frame?.values.get(variable.slot) ?? Number.NaN);
|
|
209
|
-
const dimensions = variable.dimensions?.length
|
|
210
|
-
? variable.dimensions
|
|
211
|
-
: variable.length
|
|
212
|
-
? [variable.length]
|
|
213
|
-
: [];
|
|
214
|
-
if (!Number.isFinite(address) ||
|
|
215
|
-
address <= 0 ||
|
|
216
|
-
!dimensions.length ||
|
|
217
|
-
(!variable.elementKind && !variable.structFields?.length)) {
|
|
218
|
-
return [{ name: variable.name, value: '?' }];
|
|
219
|
-
}
|
|
220
|
-
if (variable.structFields?.length && variable.structSize) {
|
|
221
|
-
const previewLength = Math.min(dimensions[0], 8);
|
|
222
|
-
const values = [];
|
|
223
|
-
for (let index = 0; index < previewLength; index += 1) {
|
|
224
|
-
const fieldValues = [];
|
|
225
|
-
for (const field of variable.structFields) {
|
|
226
|
-
const offset = address + index * variable.structSize + field.offset;
|
|
227
|
-
if (field.kind === 'bool') {
|
|
228
|
-
fieldValues.push(`${field.name}: ${this.mem.read8(offset) ? 'true' : 'false'}`);
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
if (field.kind === 'char') {
|
|
232
|
-
const charCode = this.mem.read8(offset);
|
|
233
|
-
fieldValues.push(`${field.name}: ${charCode >= 0x20 && charCode <= 0x7e ? `'${String.fromCharCode(charCode)}'` : `${charCode}`}`);
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
if (field.kind === 'float') {
|
|
237
|
-
fieldValues.push(`${field.name}: ${this.mem.readFloat32(offset)}`);
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
if (field.kind === 'double') {
|
|
241
|
-
fieldValues.push(`${field.name}: ${this.mem.readFloat64(offset)}`);
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
fieldValues.push(`${field.name}: ${this.mem.readInt32(offset)}`);
|
|
245
|
-
}
|
|
246
|
-
values.push(`{${fieldValues.join(', ')}}`);
|
|
247
|
-
}
|
|
248
|
-
return [
|
|
249
|
-
{
|
|
250
|
-
name: variable.name,
|
|
251
|
-
value: `[${values.join(', ')}${dimensions[0] > previewLength ? ', ...' : ''}]`
|
|
252
|
-
}
|
|
253
|
-
];
|
|
254
|
-
}
|
|
255
|
-
if (!variable.elementKind)
|
|
256
|
-
return [{ name: variable.name, value: '?' }];
|
|
257
|
-
const elementStride = variable.elementKind === 'double'
|
|
258
|
-
? 8
|
|
259
|
-
: variable.elementKind === 'bool' || variable.elementKind === 'char'
|
|
260
|
-
? 1
|
|
261
|
-
: 4;
|
|
262
|
-
if (dimensions.length === 2) {
|
|
263
|
-
const previewRows = Math.min(dimensions[0], 4);
|
|
264
|
-
const previewCols = Math.min(dimensions[1], 8);
|
|
265
|
-
const rows = [];
|
|
266
|
-
for (let row = 0; row < previewRows; row += 1) {
|
|
267
|
-
const values = [];
|
|
268
|
-
for (let col = 0; col < previewCols; col += 1) {
|
|
269
|
-
const offset = address + (row * dimensions[1] + col) * elementStride;
|
|
270
|
-
if (variable.elementKind === 'bool') {
|
|
271
|
-
values.push(this.mem.read8(offset) ? 'true' : 'false');
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
if (variable.elementKind === 'char') {
|
|
275
|
-
const charCode = this.mem.read8(offset);
|
|
276
|
-
values.push(charCode >= 0x20 && charCode <= 0x7e
|
|
277
|
-
? `'${String.fromCharCode(charCode)}'`
|
|
278
|
-
: `${charCode}`);
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
if (variable.elementKind === 'float') {
|
|
282
|
-
values.push(`${this.mem.readFloat32(offset)}`);
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
if (variable.elementKind === 'double') {
|
|
286
|
-
values.push(`${this.mem.readFloat64(offset)}`);
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
values.push(`${this.mem.readInt32(offset)}`);
|
|
290
|
-
}
|
|
291
|
-
rows.push(`[${values.join(', ')}${dimensions[1] > previewCols ? ', ...' : ''}]`);
|
|
292
|
-
}
|
|
293
|
-
return [
|
|
294
|
-
{
|
|
295
|
-
name: variable.name,
|
|
296
|
-
value: `[${rows.join(', ')}${dimensions[0] > previewRows ? ', ...' : ''}]`
|
|
297
|
-
}
|
|
298
|
-
];
|
|
299
|
-
}
|
|
300
|
-
const previewLength = Math.min(dimensions[0], 8);
|
|
301
|
-
const values = [];
|
|
302
|
-
for (let index = 0; index < previewLength; index += 1) {
|
|
303
|
-
const offset = address + index * elementStride;
|
|
304
|
-
if (variable.elementKind === 'bool') {
|
|
305
|
-
values.push(this.mem.read8(offset) ? 'true' : 'false');
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
if (variable.elementKind === 'char') {
|
|
309
|
-
const charCode = this.mem.read8(offset);
|
|
310
|
-
values.push(charCode >= 0x20 && charCode <= 0x7e
|
|
311
|
-
? `'${String.fromCharCode(charCode)}'`
|
|
312
|
-
: `${charCode}`);
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
if (variable.elementKind === 'float') {
|
|
316
|
-
values.push(`${this.mem.readFloat32(offset)}`);
|
|
317
|
-
continue;
|
|
318
|
-
}
|
|
319
|
-
if (variable.elementKind === 'double') {
|
|
320
|
-
values.push(`${this.mem.readFloat64(offset)}`);
|
|
321
|
-
continue;
|
|
322
|
-
}
|
|
323
|
-
values.push(`${this.mem.readInt32(offset)}`);
|
|
324
|
-
}
|
|
325
|
-
return [
|
|
326
|
-
{
|
|
327
|
-
name: variable.name,
|
|
328
|
-
value: `[${values.join(', ')}${dimensions[0] > previewLength ? ', ...' : ''}]`
|
|
329
|
-
}
|
|
330
|
-
];
|
|
331
|
-
}
|
|
332
|
-
const value = frame?.values.get(variable.slot) ?? '?';
|
|
333
|
-
return [{ name: variable.name, value }];
|
|
334
|
-
}) || [];
|
|
335
|
-
const localNames = new Set(locals.map((variable) => variable.name));
|
|
336
|
-
const globals = (session.globalVariableMetadata || []).flatMap((variable) => {
|
|
337
|
-
if (localNames.has(variable.name))
|
|
338
|
-
return [];
|
|
339
|
-
if (line < variable.fromLine || line > variable.toLine)
|
|
340
|
-
return [];
|
|
341
|
-
if (variable.kind === 'array') {
|
|
342
|
-
this.mem?.check?.();
|
|
343
|
-
const address = Number(session.globalValues?.get(variable.slot) ?? Number.NaN);
|
|
344
|
-
const dimensions = variable.dimensions?.length
|
|
345
|
-
? variable.dimensions
|
|
346
|
-
: variable.length
|
|
347
|
-
? [variable.length]
|
|
348
|
-
: [];
|
|
349
|
-
if (!Number.isFinite(address) ||
|
|
350
|
-
address <= 0 ||
|
|
351
|
-
!dimensions.length ||
|
|
352
|
-
(!variable.elementKind && !variable.structFields?.length)) {
|
|
353
|
-
return [{ name: variable.name, value: '?' }];
|
|
354
|
-
}
|
|
355
|
-
if (variable.structFields?.length && variable.structSize) {
|
|
356
|
-
const previewLength = Math.min(dimensions[0], 8);
|
|
357
|
-
const values = [];
|
|
358
|
-
for (let index = 0; index < previewLength; index += 1) {
|
|
359
|
-
const fieldValues = [];
|
|
360
|
-
for (const field of variable.structFields) {
|
|
361
|
-
const offset = address + index * variable.structSize + field.offset;
|
|
362
|
-
if (field.kind === 'bool') {
|
|
363
|
-
fieldValues.push(`${field.name}: ${this.mem.read8(offset) ? 'true' : 'false'}`);
|
|
364
|
-
continue;
|
|
365
|
-
}
|
|
366
|
-
if (field.kind === 'char') {
|
|
367
|
-
const charCode = this.mem.read8(offset);
|
|
368
|
-
fieldValues.push(`${field.name}: ${charCode >= 0x20 && charCode <= 0x7e ? `'${String.fromCharCode(charCode)}'` : `${charCode}`}`);
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
if (field.kind === 'float') {
|
|
372
|
-
fieldValues.push(`${field.name}: ${this.mem.readFloat32(offset)}`);
|
|
373
|
-
continue;
|
|
374
|
-
}
|
|
375
|
-
if (field.kind === 'double') {
|
|
376
|
-
fieldValues.push(`${field.name}: ${this.mem.readFloat64(offset)}`);
|
|
377
|
-
continue;
|
|
378
|
-
}
|
|
379
|
-
fieldValues.push(`${field.name}: ${this.mem.readInt32(offset)}`);
|
|
380
|
-
}
|
|
381
|
-
values.push(`{${fieldValues.join(', ')}}`);
|
|
382
|
-
}
|
|
383
|
-
return [
|
|
384
|
-
{
|
|
385
|
-
name: variable.name,
|
|
386
|
-
value: `[${values.join(', ')}${dimensions[0] > previewLength ? ', ...' : ''}]`
|
|
387
|
-
}
|
|
388
|
-
];
|
|
389
|
-
}
|
|
390
|
-
if (!variable.elementKind)
|
|
391
|
-
return [{ name: variable.name, value: '?' }];
|
|
392
|
-
const elementStride = variable.elementKind === 'double'
|
|
393
|
-
? 8
|
|
394
|
-
: variable.elementKind === 'bool' || variable.elementKind === 'char'
|
|
395
|
-
? 1
|
|
396
|
-
: 4;
|
|
397
|
-
if (dimensions.length === 2) {
|
|
398
|
-
const previewRows = Math.min(dimensions[0], 4);
|
|
399
|
-
const previewCols = Math.min(dimensions[1], 8);
|
|
400
|
-
const rows = [];
|
|
401
|
-
for (let row = 0; row < previewRows; row += 1) {
|
|
402
|
-
const values = [];
|
|
403
|
-
for (let col = 0; col < previewCols; col += 1) {
|
|
404
|
-
const offset = address + (row * dimensions[1] + col) * elementStride;
|
|
405
|
-
if (variable.elementKind === 'bool') {
|
|
406
|
-
values.push(this.mem.read8(offset) ? 'true' : 'false');
|
|
407
|
-
continue;
|
|
408
|
-
}
|
|
409
|
-
if (variable.elementKind === 'char') {
|
|
410
|
-
const charCode = this.mem.read8(offset);
|
|
411
|
-
values.push(charCode >= 0x20 && charCode <= 0x7e
|
|
412
|
-
? `'${String.fromCharCode(charCode)}'`
|
|
413
|
-
: `${charCode}`);
|
|
414
|
-
continue;
|
|
415
|
-
}
|
|
416
|
-
if (variable.elementKind === 'float') {
|
|
417
|
-
values.push(`${this.mem.readFloat32(offset)}`);
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
|
-
if (variable.elementKind === 'double') {
|
|
421
|
-
values.push(`${this.mem.readFloat64(offset)}`);
|
|
422
|
-
continue;
|
|
423
|
-
}
|
|
424
|
-
values.push(`${this.mem.readInt32(offset)}`);
|
|
425
|
-
}
|
|
426
|
-
rows.push(`[${values.join(', ')}${dimensions[1] > previewCols ? ', ...' : ''}]`);
|
|
427
|
-
}
|
|
428
|
-
return [
|
|
429
|
-
{
|
|
430
|
-
name: variable.name,
|
|
431
|
-
value: `[${rows.join(', ')}${dimensions[0] > previewRows ? ', ...' : ''}]`
|
|
432
|
-
}
|
|
433
|
-
];
|
|
434
|
-
}
|
|
435
|
-
const previewLength = Math.min(dimensions[0], 8);
|
|
436
|
-
const values = [];
|
|
437
|
-
for (let index = 0; index < previewLength; index += 1) {
|
|
438
|
-
const offset = address + index * elementStride;
|
|
439
|
-
if (variable.elementKind === 'bool') {
|
|
440
|
-
values.push(this.mem.read8(offset) ? 'true' : 'false');
|
|
441
|
-
continue;
|
|
442
|
-
}
|
|
443
|
-
if (variable.elementKind === 'char') {
|
|
444
|
-
const charCode = this.mem.read8(offset);
|
|
445
|
-
values.push(charCode >= 0x20 && charCode <= 0x7e
|
|
446
|
-
? `'${String.fromCharCode(charCode)}'`
|
|
447
|
-
: `${charCode}`);
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
if (variable.elementKind === 'float') {
|
|
451
|
-
values.push(`${this.mem.readFloat32(offset)}`);
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
if (variable.elementKind === 'double') {
|
|
455
|
-
values.push(`${this.mem.readFloat64(offset)}`);
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
values.push(`${this.mem.readInt32(offset)}`);
|
|
459
|
-
}
|
|
460
|
-
return [
|
|
461
|
-
{
|
|
462
|
-
name: variable.name,
|
|
463
|
-
value: `[${values.join(', ')}${dimensions[0] > previewLength ? ', ...' : ''}]`
|
|
464
|
-
}
|
|
465
|
-
];
|
|
466
|
-
}
|
|
467
|
-
const value = session.globalValues?.get(variable.slot) ?? '?';
|
|
468
|
-
return [{ name: variable.name, value }];
|
|
469
|
-
}) || [];
|
|
470
|
-
session.onPause?.({
|
|
471
|
-
type: 'pause',
|
|
472
|
-
line,
|
|
473
|
-
reason,
|
|
474
|
-
locals: [...locals, ...globals],
|
|
475
|
-
callStack: [...session.frames].reverse().map((stackFrame) => ({
|
|
476
|
-
functionName: stackFrame.functionName,
|
|
477
|
-
line: stackFrame.line
|
|
478
|
-
}))
|
|
479
|
-
});
|
|
480
|
-
const sequence = Atomics.load(buffer, 0);
|
|
481
|
-
while (true) {
|
|
482
|
-
if (session.interruptBuffer?.[0] === 2)
|
|
483
|
-
throw new AbortError();
|
|
484
|
-
Atomics.wait(buffer, 0, sequence, 100);
|
|
485
|
-
if (session.interruptBuffer?.[0] === 2)
|
|
486
|
-
throw new AbortError();
|
|
487
|
-
const command = Atomics.exchange(buffer, 1, 0);
|
|
488
|
-
if (command === 1) {
|
|
489
|
-
session.resumeSkipActive = true;
|
|
490
|
-
session.resumeSkipFunctionId = session.currentFunctionId;
|
|
491
|
-
session.resumeSkipLine = session.currentLine;
|
|
492
|
-
return ESUCCESS;
|
|
493
|
-
}
|
|
494
|
-
if (command === 2) {
|
|
495
|
-
session.stepArmed = true;
|
|
496
|
-
session.resumeSkipActive = true;
|
|
497
|
-
session.resumeSkipFunctionId = session.currentFunctionId;
|
|
498
|
-
session.resumeSkipLine = session.currentLine;
|
|
499
|
-
return ESUCCESS;
|
|
500
|
-
}
|
|
501
|
-
if (command === 3) {
|
|
502
|
-
session.nextLineArmed = true;
|
|
503
|
-
session.nextLineFunctionId = session.currentFunctionId;
|
|
504
|
-
session.nextLineLine = session.currentLine;
|
|
505
|
-
session.resumeSkipActive = true;
|
|
506
|
-
session.resumeSkipFunctionId = session.currentFunctionId;
|
|
507
|
-
session.resumeSkipLine = session.currentLine;
|
|
508
|
-
return ESUCCESS;
|
|
509
|
-
}
|
|
510
|
-
if (command === 4) {
|
|
511
|
-
session.stepOutArmed = true;
|
|
512
|
-
session.stepOutDepth = Math.max(0, session.callDepth - 1);
|
|
513
|
-
session.resumeSkipActive = true;
|
|
514
|
-
session.resumeSkipFunctionId = session.currentFunctionId;
|
|
515
|
-
session.resumeSkipLine = session.currentLine;
|
|
516
|
-
return ESUCCESS;
|
|
517
|
-
}
|
|
518
|
-
if (command === 5) {
|
|
519
|
-
const expression = session.watchBuffer ? readBufferedStdin(session.watchBuffer) : '';
|
|
520
|
-
let result = '?';
|
|
521
|
-
try {
|
|
522
|
-
result = expression ? this.debugEvaluate(expression) : '?';
|
|
523
|
-
}
|
|
524
|
-
catch (error) {
|
|
525
|
-
result = error instanceof Error && error.message === 'unavailable' ? '?' : 'error';
|
|
526
|
-
}
|
|
527
|
-
if (session.watchResultBuffer)
|
|
528
|
-
flushQueuedStdin([result], session.watchResultBuffer);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
__wasm_idle_debug_enter(functionId, line) {
|
|
533
|
-
const session = this.debugSession;
|
|
534
|
-
if (!session?.buffer)
|
|
535
|
-
return ESUCCESS;
|
|
536
|
-
session.callDepth += 1;
|
|
537
|
-
session.currentFunctionId = functionId;
|
|
538
|
-
session.currentLine = line;
|
|
539
|
-
session.frames.push({
|
|
540
|
-
functionId,
|
|
541
|
-
functionName: session.functionMetadata[functionId] || `fn_${functionId}`,
|
|
542
|
-
line,
|
|
543
|
-
values: new Map()
|
|
544
|
-
});
|
|
545
|
-
this.trace(`enter(function=${functionId}, line=${line}, depth=${session.callDepth})`);
|
|
546
|
-
if (session.pauseOnEntry) {
|
|
547
|
-
return this.pauseDebugSession(session, functionId, line, 'entry');
|
|
548
|
-
}
|
|
549
|
-
if (session.stepArmed) {
|
|
550
|
-
return this.pauseDebugSession(session, functionId, line, 'step');
|
|
551
|
-
}
|
|
552
|
-
return ESUCCESS;
|
|
553
|
-
}
|
|
554
|
-
__wasm_idle_debug_leave(functionId) {
|
|
555
|
-
const session = this.debugSession;
|
|
556
|
-
if (!session?.buffer)
|
|
557
|
-
return ESUCCESS;
|
|
558
|
-
this.trace(`leave(function=${functionId}, depth=${session.callDepth})`);
|
|
559
|
-
if (session.nextLineArmed && functionId === session.nextLineFunctionId) {
|
|
560
|
-
session.nextLineArmed = false;
|
|
561
|
-
session.stepArmed = true;
|
|
562
|
-
}
|
|
563
|
-
session.callDepth = Math.max(0, session.callDepth - 1);
|
|
564
|
-
if (session.currentFunctionId === functionId)
|
|
565
|
-
session.currentFunctionId = 0;
|
|
566
|
-
for (let index = session.frames.length - 1; index >= 0; index -= 1) {
|
|
567
|
-
if (session.frames[index]?.functionId === functionId) {
|
|
568
|
-
session.frames.splice(index, 1);
|
|
569
|
-
break;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
return ESUCCESS;
|
|
573
|
-
}
|
|
574
|
-
__wasm_idle_debug_value_num(functionId, slot, value) {
|
|
575
|
-
const session = this.debugSession;
|
|
576
|
-
if (!session?.buffer)
|
|
577
|
-
return ESUCCESS;
|
|
578
|
-
if (functionId === 0) {
|
|
579
|
-
session.globalValues.set(slot, Number.isInteger(value) ? String(value) : `${value}`);
|
|
580
|
-
return ESUCCESS;
|
|
581
|
-
}
|
|
582
|
-
for (let index = session.frames.length - 1; index >= 0; index -= 1) {
|
|
583
|
-
const frame = session.frames[index];
|
|
584
|
-
if (frame?.functionId !== functionId)
|
|
585
|
-
continue;
|
|
586
|
-
frame.values.set(slot, Number.isInteger(value) ? String(value) : `${value}`);
|
|
587
|
-
break;
|
|
588
|
-
}
|
|
589
|
-
return ESUCCESS;
|
|
590
|
-
}
|
|
591
|
-
__wasm_idle_debug_value_bool(functionId, slot, value) {
|
|
592
|
-
const session = this.debugSession;
|
|
593
|
-
if (!session?.buffer)
|
|
594
|
-
return ESUCCESS;
|
|
595
|
-
if (functionId === 0) {
|
|
596
|
-
session.globalValues.set(slot, value ? 'true' : 'false');
|
|
597
|
-
return ESUCCESS;
|
|
598
|
-
}
|
|
599
|
-
for (let index = session.frames.length - 1; index >= 0; index -= 1) {
|
|
600
|
-
const frame = session.frames[index];
|
|
601
|
-
if (frame?.functionId !== functionId)
|
|
602
|
-
continue;
|
|
603
|
-
frame.values.set(slot, value ? 'true' : 'false');
|
|
604
|
-
break;
|
|
605
|
-
}
|
|
606
|
-
return ESUCCESS;
|
|
607
|
-
}
|
|
608
|
-
__wasm_idle_debug_value_addr(functionId, slot, value) {
|
|
609
|
-
const session = this.debugSession;
|
|
610
|
-
if (!session?.buffer)
|
|
611
|
-
return ESUCCESS;
|
|
612
|
-
if (functionId === 0) {
|
|
613
|
-
session.globalValues.set(slot, String(value >>> 0));
|
|
614
|
-
return ESUCCESS;
|
|
615
|
-
}
|
|
616
|
-
for (let index = session.frames.length - 1; index >= 0; index -= 1) {
|
|
617
|
-
const frame = session.frames[index];
|
|
618
|
-
if (frame?.functionId !== functionId)
|
|
619
|
-
continue;
|
|
620
|
-
frame.values.set(slot, String(value >>> 0));
|
|
621
|
-
break;
|
|
622
|
-
}
|
|
623
|
-
return ESUCCESS;
|
|
624
|
-
}
|
|
625
|
-
__wasm_idle_debug_value_text(functionId, slot, ptr, len) {
|
|
626
|
-
const session = this.debugSession;
|
|
627
|
-
if (!session?.buffer)
|
|
628
|
-
return ESUCCESS;
|
|
629
|
-
this.mem?.check?.();
|
|
630
|
-
const text = this.mem?.readStr ? this.mem.readStr(ptr, len) : '?';
|
|
631
|
-
if (functionId === 0) {
|
|
632
|
-
session.globalValues.set(slot, text);
|
|
633
|
-
return ESUCCESS;
|
|
634
|
-
}
|
|
635
|
-
for (let index = session.frames.length - 1; index >= 0; index -= 1) {
|
|
636
|
-
const frame = session.frames[index];
|
|
637
|
-
if (frame?.functionId !== functionId)
|
|
638
|
-
continue;
|
|
639
|
-
frame.values.set(slot, text);
|
|
640
|
-
break;
|
|
641
|
-
}
|
|
642
|
-
return ESUCCESS;
|
|
643
|
-
}
|
|
644
|
-
__wasm_idle_debug_line(functionId, line) {
|
|
645
|
-
const session = this.debugSession;
|
|
646
|
-
if (!session?.buffer)
|
|
647
|
-
return ESUCCESS;
|
|
648
|
-
const sharedBreakpointVersion = Atomics.load(session.buffer, 2);
|
|
649
|
-
if (sharedBreakpointVersion !== session.breakpointVersion) {
|
|
650
|
-
const count = Math.max(0, Atomics.load(session.buffer, 3));
|
|
651
|
-
const nextBreakpoints = new Set();
|
|
652
|
-
for (let index = 0; index < count && index + 4 < session.buffer.length; index += 1) {
|
|
653
|
-
const breakpoint = Atomics.load(session.buffer, index + 4);
|
|
654
|
-
if (breakpoint > 0)
|
|
655
|
-
nextBreakpoints.add(breakpoint);
|
|
656
|
-
}
|
|
657
|
-
session.breakpoints = nextBreakpoints;
|
|
658
|
-
session.breakpointVersion = sharedBreakpointVersion;
|
|
659
|
-
}
|
|
660
|
-
if (session.resumeSkipActive) {
|
|
661
|
-
if (functionId === session.resumeSkipFunctionId && line === session.resumeSkipLine) {
|
|
662
|
-
return ESUCCESS;
|
|
663
|
-
}
|
|
664
|
-
session.resumeSkipActive = false;
|
|
665
|
-
session.resumeSkipFunctionId = 0;
|
|
666
|
-
session.resumeSkipLine = 0;
|
|
667
|
-
}
|
|
668
|
-
let reason = '';
|
|
669
|
-
if (session.pauseOnEntry)
|
|
670
|
-
reason = 'entry';
|
|
671
|
-
else if (session.breakpoints.has(line))
|
|
672
|
-
reason = 'breakpoint';
|
|
673
|
-
else if (session.stepArmed)
|
|
674
|
-
reason = 'step';
|
|
675
|
-
else if (session.nextLineArmed &&
|
|
676
|
-
functionId === session.nextLineFunctionId &&
|
|
677
|
-
line !== session.nextLineLine) {
|
|
678
|
-
reason = 'nextLine';
|
|
679
|
-
}
|
|
680
|
-
else if (session.stepOutArmed && session.callDepth <= session.stepOutDepth) {
|
|
681
|
-
reason = 'stepOut';
|
|
682
|
-
}
|
|
683
|
-
if (!reason)
|
|
684
|
-
return ESUCCESS;
|
|
685
|
-
return this.pauseDebugSession(session, functionId, line, reason);
|
|
686
|
-
}
|
|
687
|
-
environ_sizes_get(environ_count_out, environ_buf_size_out) {
|
|
688
|
-
this.mem.check();
|
|
689
|
-
let size = 0;
|
|
690
|
-
const names = Object.getOwnPropertyNames(this.environ);
|
|
691
|
-
for (const name of names) {
|
|
692
|
-
const value = this.environ[name];
|
|
693
|
-
// +2 to account for = and \0 in "name=value\0".
|
|
694
|
-
size += name.length + value.length + 2;
|
|
695
|
-
}
|
|
696
|
-
this.mem.write32(environ_count_out, names.length);
|
|
697
|
-
this.mem.write32(environ_buf_size_out, size);
|
|
698
|
-
this.trace(`environ_sizes_get(count=${names.length}, bytes=${size})`);
|
|
699
|
-
return ESUCCESS;
|
|
700
|
-
}
|
|
701
|
-
environ_get(environ_ptrs, environ_buf) {
|
|
702
|
-
this.mem.check();
|
|
703
|
-
const names = Object.getOwnPropertyNames(this.environ);
|
|
704
|
-
this.trace(`environ_get(entries=${JSON.stringify(names)})`);
|
|
705
|
-
for (const name of names) {
|
|
706
|
-
this.mem.write32(environ_ptrs, environ_buf);
|
|
707
|
-
environ_ptrs += 4;
|
|
708
|
-
environ_buf += this.mem.writeStr(environ_buf, `${name}=${this.environ[name]}`);
|
|
709
|
-
}
|
|
710
|
-
return ESUCCESS;
|
|
711
|
-
}
|
|
712
|
-
args_sizes_get(argc_out, argv_buf_size_out) {
|
|
713
|
-
this.mem.check();
|
|
714
|
-
let size = 0;
|
|
715
|
-
for (let arg of this.argv) {
|
|
716
|
-
size += arg.length + 1; // "arg\0".
|
|
717
|
-
}
|
|
718
|
-
this.mem.write32(argc_out, this.argv.length);
|
|
719
|
-
this.mem.write32(argv_buf_size_out, size);
|
|
720
|
-
this.trace(`args_sizes_get(count=${this.argv.length}, bytes=${size})`);
|
|
721
|
-
return ESUCCESS;
|
|
722
|
-
}
|
|
723
|
-
args_get(argv_ptrs, argv_buf) {
|
|
724
|
-
this.mem.check();
|
|
725
|
-
this.trace(`args_get(argv=${JSON.stringify(this.argv)})`);
|
|
726
|
-
for (let arg of this.argv) {
|
|
727
|
-
this.mem.write32(argv_ptrs, argv_buf);
|
|
728
|
-
argv_ptrs += 4;
|
|
729
|
-
argv_buf += this.mem.writeStr(argv_buf, arg);
|
|
730
|
-
}
|
|
731
|
-
return ESUCCESS;
|
|
732
|
-
}
|
|
733
|
-
random_get(buf, buf_len) {
|
|
734
|
-
const data = new Uint8Array(this.mem.buffer, buf, buf_len);
|
|
735
|
-
for (let i = 0; i < buf_len; ++i)
|
|
736
|
-
data[i] = (Math.random() * 256) | 0;
|
|
737
|
-
}
|
|
738
|
-
clock_time_get() {
|
|
739
|
-
throw new NotImplemented('wasi_unstable', 'clock_time_get');
|
|
740
|
-
}
|
|
741
|
-
poll_oneoff() {
|
|
742
|
-
throw new NotImplemented('wasi_unstable', 'poll_oneoff');
|
|
743
|
-
}
|
|
744
|
-
}
|