Skip to content

The great frame refactor#2

Open
masak wants to merge 34 commits into
mainfrom
masak/frame
Open

The great frame refactor#2
masak wants to merge 34 commits into
mainfrom
masak/frame

Conversation

@masak
Copy link
Copy Markdown
Owner

@masak masak commented Apr 25, 2026

Old evaluator: Uses a Kont hierarchy to represent internal continuations. Evaluation always starts at a syntax node (and in some mode), but recursive evaluation is managed by delegating to a Kont object, in zero or more steps.

New evaluator: Uses a single Frame class to unify the cases of "handling a node for the first time" and "continuing the node after a subtask finishes".

Advantages:

  • Half the evaluator code. (1.4 kLoC, down from 3.0 kLoC.)
    • Specific evaluator code for infix and prefix ops has been separated out into infix.ts (~300 LoC) and preifx.ts (~100 LoC); these have their own handler maps.
  • The code for evaluating each syntax node type is localized to a single handler, instead of spread over initial code for the syntax node and code for each Kont type.

The properties of Frame are divided into immutable and mutable. Here are the immutable ones:

  • mode: Mode
  • node: SyntaxNode
  • state: number
  • env: Env
  • staticEnvs: Map<SyntaxNode, Env>
  • value: Value
  • cell: Cell | null
  • jumpMap: JumpMap
  • tail: Frame

Here are the mutable properties:

  • datum1: number
  • datum2: number | Value
  • datum3: Array<SyntaxNode>
  • datum4: Array<Value>

They will be added back, gradually.
masak added 28 commits May 22, 2026 23:20
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.

1 participant