Skip to content

Rework bootstrap ASTVisualizer around a generic buildNode + add IASTNode.getCodeLoc#1212

Merged
marcauberer merged 2 commits into
mainfrom
bootstrap/ast-visualizer-impl
Jun 17, 2026
Merged

Rework bootstrap ASTVisualizer around a generic buildNode + add IASTNode.getCodeLoc#1212
marcauberer merged 2 commits into
mainfrom
bootstrap/ast-visualizer-impl

Conversation

@marcauberer

@marcauberer marcauberer commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Bootstrap ASTVisualizer rework (src-bootstrap/visualizer/ast-visualizer.spice): replaces the previous per-node, hand-written buildNode("ASTXxxNode", &node.node…) calls with a single generic buildNode<T>(const T* node) helper. It derives the node name from typename<T>() (stripping the namespace prefix), emits the Graphviz DOT node line (<id> [color="lightgreen",label="<name>"];) and a parent→child edge into a local StringStream, and returns the accumulated text via Any(output.str()). The struct now keeps a single String parentNodeId member (the old bool initialized field and explicit ctor() are removed). All visitXxx methods collapse to one-liners that delegate to this.buildNode(node).
  • IASTNode.getCodeLoc(): adds the method to the interface (ast-node-intf.spice) and implements it on ASTNode (ast-nodes.spice), returning const CodeLoc&.
  • C++ ASTVisualizer.h cleanup: renames the visitor parameter ctxnode across all visitXxx overrides for consistency.

Notes / not yet wired up

Parts of buildNode are intentionally stubbed in this change and left as // ... placeholders:

  • the getCodeLoc() call (so codeLocStr is currently empty and node IDs are not yet unique),
  • setting parentNodeId before recursing into children,
  • the actual child traversal (getChildren() / this.visit(child) are commented out).

So this lays down the structure and the generic helper; full edge/recursion wiring follows in a later change.

Test plan

  • src-bootstrap compiles with the reworked visualizer
  • Bootstrap visualizer unit test runs (BootstrapCompilerTests)

@marcauberer marcauberer requested review from a team as code owners June 15, 2026 19:30
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added std Prs / issues regarding the standard lib bootstrap Change regarding the bootstrap compiler labels Jun 15, 2026
@marcauberer marcauberer added this to the 0.27.0 milestone Jun 15, 2026
marcauberer and others added 2 commits June 17, 2026 20:27
- Add StringStream output member to ASTVisualizer for DOT accumulation
- Implement buildNode() to emit Graphviz DOT node/edge lines, with manual
  save/restore of parentNodeId (no RAII in bootstrap yet)
- Expose getDot() returning const String& to avoid dangling raw pointer
- All visitXxx methods clear output, call buildNode, return Any()
- Add getCodeLoc() to IASTNode interface and ASTNode implementation
- Strengthen unit test: verify node id, lightgreen color, label, edge
  presence/absence, and parentNodeId restoration after each visit call
- C++ ASTVisualizer.h: rename ctx -> node in all visitor overrides and
  remove unused nodeNames member
@marcauberer marcauberer force-pushed the bootstrap/ast-visualizer-impl branch from afa0b99 to 449f4cb Compare June 17, 2026 18:28
@marcauberer marcauberer changed the title Implement ASTVisualizer in bootstrap + Any value constructor Rework bootstrap ASTVisualizer around a generic buildNode + add IASTNode.getCodeLoc Jun 17, 2026
@marcauberer marcauberer merged commit e860ccf into main Jun 17, 2026
9 checks passed
@marcauberer marcauberer deleted the bootstrap/ast-visualizer-impl branch June 17, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bootstrap Change regarding the bootstrap compiler size/L std Prs / issues regarding the standard lib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant