-
Notifications
You must be signed in to change notification settings - Fork 354
Refactor CFG node API #4310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThakeeNathees
wants to merge
12
commits into
jaseci-labs:main
Choose a base branch
from
ThakeeNathees:refactor-cfg-node-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor CFG node API #4310
ThakeeNathees
wants to merge
12
commits into
jaseci-labs:main
from
ThakeeNathees:refactor-cfg-node-api
Conversation
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
d1e1a4f to
732baf2
Compare
3 tasks
- 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)
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
- 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)
78d3465 to
e30802e
Compare
for more information, see https://pre-commit.ci
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
for more information, see https://pre-commit.ci
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.
This PR refactors the CFG (Control Flow Graph) node API to use a cleaner interface:
bb_in/bb_outattributes with_nodes_in/_nodes_outinUniCFGNodeget_head()andget_tail()methods, addsset_next()andset_next_conditional()helper methodsCoalesceBBPassclass andcfg_dot_from_filefunctionCFGBuildPassinterface by removing most method implementationsExpr,ElementStmt,ArchBlockStmt,EnumBlockStmt,AstImplNeedingNode,Modulenow inherit fromUniCFGNode