Commit graph

2 commits

Author SHA1 Message Date
Andreas Kling
7f0e59396f LibJS: Add dump_to_string() for AST nodes and bytecode executables
Add the ability to dump AST and bytecode to a String instead of only
to stdout/stderr. This is done by adding an optional StringBuilder
output sink to ASTDumpState, and a new dump_to_string() method on
both ASTNode and Bytecode::Executable.

These will be used for comparing output between compilation pipelines.
2026-02-24 09:39:42 +01:00
Andreas Kling
52ddc15fb3 LibJS: Redesign AST dump with unicode tree drawing
Replace the old indentation-based AST dump with a new tree-drawing
approach using unicode box characters. Each node now also shows its
source position as @line:column, and additional internal state:

- Identifier: [argument:N] vs [variable:N], declaration kind
  (var/let/const), [global], [in-eval-scope]
- FunctionNode: [strict], [arrow], [direct-eval], [uses-this],
  [uses-this-from-environment], [might-need-arguments]
- Program: (script)/(module), [strict], [top-level-await]
- YieldExpression: [yield*] for delegation

Dump code is moved from AST.cpp into a new ASTDump.cpp file.
2026-02-10 02:05:20 +01:00