Rework bootstrap ASTVisualizer around a generic buildNode + add IASTNode.getCodeLoc#1212
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
- 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
afa0b99 to
449f4cb
Compare
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.
Summary
ASTVisualizerrework (src-bootstrap/visualizer/ast-visualizer.spice): replaces the previous per-node, hand-writtenbuildNode("ASTXxxNode", &node.node…)calls with a single genericbuildNode<T>(const T* node)helper. It derives the node name fromtypename<T>()(stripping the namespace prefix), emits the Graphviz DOT node line (<id> [color="lightgreen",label="<name>"];) and a parent→child edge into a localStringStream, and returns the accumulated text viaAny(output.str()). The struct now keeps a singleString parentNodeIdmember (the oldbool initializedfield and explicitctor()are removed). AllvisitXxxmethods collapse to one-liners that delegate tothis.buildNode(node).IASTNode.getCodeLoc(): adds the method to the interface (ast-node-intf.spice) and implements it onASTNode(ast-nodes.spice), returningconst CodeLoc&.ASTVisualizer.hcleanup: renames the visitor parameterctx→nodeacross allvisitXxxoverrides for consistency.Notes / not yet wired up
Parts of
buildNodeare intentionally stubbed in this change and left as// ...placeholders:getCodeLoc()call (socodeLocStris currently empty and node IDs are not yet unique),parentNodeIdbefore recursing into children,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-bootstrapcompiles with the reworked visualizerBootstrapCompilerTests)