Skip to content

Wasm compiler conductor integration and cleanup#149

Open
jonasongg wants to merge 200 commits into
source-academy:mainfrom
jonasongg:wasm-compiler-conductor-integration
Open

Wasm compiler conductor integration and cleanup#149
jonasongg wants to merge 200 commits into
source-academy:mainfrom
jonasongg:wasm-compiler-conductor-integration

Conversation

@jonasongg

@jonasongg jonasongg commented Apr 20, 2026

Copy link
Copy Markdown
Contributor
  • Adds the 4 Wasm evaluators to build.
  • Split up the giant constants.ts into the runtime folder
  • Split up the giant wasm-compiler.spec.ts into the wasm folder
  • Split up index.ts
  • Ban for loop without the range syntax even for Chapter 4 (modified analysis.ts)
  • Remove BreakContinueError as it's not used (the validation is done elsewhere, and the error is defined elsewhere; see BreakContinueOutsideLoopError

Work that still needs to be done for wasm compiler:

  • Finish up misc & math libraries, which are not done (especially repr function: it's wrong at the moment)
  • Potentially move certain validations out of builderGenerator into validators, since they should apply to all python implementations
    • Perhaps give a more specific error if a name is used before its nonlocal declaration in the same scope (right now, validator gives generic NameNotFoundError)
    • Give a more specific error if parameters are used as nonlocal also
    • Error when more than one starred parameter is used
    • Error when starred parameter is not the last one

@jonasongg jonasongg marked this pull request as draft April 20, 2026 17:19

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a shadow stack and a copying garbage collector within the WASM engine to manage complex types like lists and closures. It refactors the evaluator into chapter-specific classes and introduces a modular library system. Key updates include new WASM runtime helpers for memory management and type checking, alongside a refactored metacircular generator. Feedback points to a potential regression in error diagnostics due to the removal of BreakContinueError and questions the new restriction of for loops to range() in Python §4.

I am having trouble creating individual review comments. Click here to see my feedback.

src/resolver/errors.ts (74-86)

medium

The BreakContinueError class has been removed. This could potentially lead to less specific error messages for misplaced break or continue statements. If the corresponding validator now throws a generic Error, it would be a regression in error reporting quality. Consider restoring a specific error class for this case to maintain detailed diagnostics.

src/validator/sublanguages.ts (62)

medium

Adding ForRangeOnlyValidator to Python §4 seems to be a significant functional change, as it restricts for loops to only work with range(). Was this intentional? Python §4 is described as 'unrestricted', so this new restriction might be surprising.

References
  1. When referring to Python chapters, use the section symbol (§) for consistency with existing documentation (e.g., "Python §2" instead of "Python 2").

@jonasongg jonasongg marked this pull request as ready for review April 21, 2026 07:36
@jonasongg jonasongg changed the title Wasm compiler conductor integration Wasm compiler conductor integration and cleanup Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants