Skip to content

Conversation

@ThakeeNathees
Copy link
Collaborator

This PR refactors the CFG (Control Flow Graph) node API to use a cleaner interface:

  • Replaces bb_in/bb_out attributes with _nodes_in/_nodes_out in UniCFGNode
  • Removes get_head() and get_tail() methods, adds set_next() and set_next_conditional() helper methods
  • Removes CoalesceBBPass class and cfg_dot_from_file function
  • Simplifies CFGBuildPass interface by removing most method implementations
  • Updates inheritance hierarchy: Expr, ElementStmt, ArchBlockStmt, EnumBlockStmt, AstImplNeedingNode, Module now inherit from UniCFGNode
  • Removes CFG build pass tests (to be reimplemented with new API)

@ThakeeNathees ThakeeNathees reopened this Jan 26, 2026
@RandiJay96 RandiJay96 linked an issue Jan 26, 2026 that may be closed by this pull request
3 tasks
@ThakeeNathees ThakeeNathees changed the title Refactor CFG node API: replace bb_in/bb_out with _nodes_in/_nodes_out Refactor CFG node API Jan 29, 2026
ThakeeNathees and others added 8 commits January 30, 2026 01:13
- Replace bb_in/bb_out attributes with _nodes_in/_nodes_out in UniCFGNode
- Remove get_head() and get_tail() methods, add set_next() and set_next_conditional()
- Remove CoalesceBBPass class and cfg_dot_from_file function
- Simplify CFGBuildPass interface by removing most method implementations
- Update inheritance: Expr, ElementStmt, ArchBlockStmt, EnumBlockStmt, AstImplNeedingNode, Module now inherit from UniCFGNode
- Remove CFG build pass tests (to be reimplemented with new API)
- Refactor CFGBuildPass from obj to class with proper type annotations
- Remove init method, update before_pass to call super.before_pass()
- Add exit_module_code method for ModuleCode handling
- Update exit_if_stmt to use conditional next nodes with CFGPatchNode
- Add _get_first_cfg_node_of_list_of_statements helper method
- Update _connect_list_of_stments to handle patch nodes, return/break statements, and return exit nodes
- Add conditional node support to UniCFGNode with _is_conditional flag
- Add CFGPatchNode class for placeholder nodes that need patching
- Make Module inherit from UniCFGNode for CFG support
- Add helper methods to CtrlStmt (is_break_stmt, is_continue_stmt, is_skip_stmt)
pre-commit-ci bot and others added 4 commits January 29, 2026 18:17
Classes that inherit from UniCFGNode directly or indirectly but had
their own __init__ methods were not calling UniCFGNode.__init__, which
caused AttributeError when accessing _nodes_in, _nodes_out, or
_is_conditional attributes.

Added UniCFGNode.__init__(self) to:
- Expr (direct inheritor)
- EnumBlockStmt (direct inheritor)
- Module (multiple inheritance)
- GlobalVars (inherits ElementStmt)
- Test (inherits ElementStmt)
- ClientBlock (inherits ElementStmt)
- ServerBlock (inherits ElementStmt)
- NativeBlock (inherits ElementStmt)
- SemDef (inherits ElementStmt)
- Enum (inherits ArchBlockStmt)
- Add AstDocNode to inheritance for GlobalVars, Test, ModuleCode,
  PyInlineCode, Import, Archetype, Enum, and Ability classes
- Fix AstImplNeedingNode.body type from generic T to proper Union type
- Add explicit body type annotations in Archetype, Enum, and Ability
- Update resolve_stmt_block signature to accept Sequence[ArchBlockStmt]
- Add type guards in test_parser.py for iterating over walker.body
- Add isinstance check in jac_parser.py before setting doc attribute
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.

Improve CFG build pass

1 participant