Feat/real execution runtimes - #1
Open
indexer wants to merge 6 commits into
Open
Conversation
…ctness fixes Extend the line interpreter with user-defined function calls and a call stack, Map/Set/plain-object tracking, and recursion. Fix a class of silent-wrong bugs that made correct algorithms display wrong results: - Python `//` floor division was stripped as a comment - `elif` / `else if` chains ran multiple branches - `+=` to indexed targets (`freq[c] += 1`) was silently dropped - `" in "` split inside string literals; scalar->Map double-render; Infinity/NaN serialization; object-literal shorthand Add Kotlin `when` (statement/expression/compound-assign forms; subject & subjectless; comma/else/in-range conditions; single-line & block bodies), string templates, `for (x in collection)`, `downTo`, `step`, and a clear error for invalid `[...]` list literals.
…backends
Run the genuine language and trace it per line into the existing
visualization panels, instead of the regex line-interpreter:
- Python -> Pyodide (real CPython) under sys.settrace
- TypeScript -> the browser JS engine, Babel-instrumented per statement
(call-stack tracking + a __tick runaway-guard so even `while(true){}`
terminates instead of freezing the tab)
- shared trace->ExecSnapshot adapter; Kotlin stays on the line interpreter
Heavy deps load from CDN in the browser (never bundled; build ~80KB) and
from the npm packages in Node, so both pipelines are unit-testable
(@vitest-environment node). pyodide/@babel/core are devDependencies.
CodeRunnerPage runs async, routes by language, and sanitizes pasted
zero-width/non-breaking characters.
…ained snippets The algorithm-detail walkthroughs replayed hand-authored variable values, often for a different input than the runnable example block. Ground them in reality: - genStepValues runs every TS/Python snippet on the real runtimes and emits truthful per-step variable values into generatedStepValues.ts - withGeneratedStepValues overlays them (titles/descriptions/lines kept); library values now match the playground ~93% (was ~65%) - withSelfContainedSnippets prepends ListNode/TrieNode so the linked-list and trie snippets actually execute (auto-offsetting authored step lines) - fix Jump Search `const`->`let` reassignment libraryExecution.test runs all 210 TS/Python snippets in CI; regenerate values after editing a snippet via `npm run gen:step-values`.
Document the Content-Security-Policy the playground runtimes need (unsafe-eval + wasm-unsafe-eval + jsdelivr in script-src/connect-src; set as a header, not a <meta> which breaks Vite dev), how to self-host the Pyodide/Babel assets instead of using the CDN, first-load UX, and the step-value regeneration workflow. Preconnect to the CDN in index.html.
Behavior-preserving complexity fixes from a hot-path audit: - CodeRunnerPage: memoize `codeLines` so `escapedCodeLines` actually caches (it was re-escaping every source line on every render); replace the O(S^2) executed-line-set rebuild with an O(S) first-execution-step map (O(1) per line at render time). - jsRuntime: serialize call-frame args once at `__enter` instead of on every recorded step (was O(steps * depth * arg-size)). - interpreter: precompute a brace-match table so `matchBraceClose` is O(1) instead of re-scanning the block on every loop iteration / branch re-entry (helps Kotlin if-chains / `when` inside nested loops).
…p config `tsc -b` checks src/ under the browser-only app tsconfig (no node / @babel types), which broke on the runtime loaders' Node fallback paths: - reference `process` via a `globalThis` cast instead of the bare global (no @types/node needed in the app build) - type the Node-only `@babel/core` dynamic import with a minimal local shape instead of `typeof import("@babel/core")` (no declaration in the app build) Behavior unchanged; the Node branches still run only under @vitest-environment node, where the real types are available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.