Skip to content

Commit

Permalink
improvement(semantic/cfg): better control flow for ForStatements.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Jun 5, 2024
1 parent 33b9fcc commit 3482d50
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,18 +848,19 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
}

/* cfg */
let body_graph_ix = self.cfg.new_basic_block();
let before_body_graph_ix = self.cfg.new_basic_block();
let statement_state =
self.cfg.preserve_state(self.current_node_id, StatementControlFlowType::UsesContinue);
/* cfg */

self.visit_statement(&stmt.body);

/* cfg */
let after_body_graph_ix = self.cfg.current_node_ix;
let after_for_stmt = self.cfg.new_basic_block();
self.cfg.add_edge(before_for_graph_ix, test_graph_ix, EdgeType::Normal);
self.cfg.add_edge(after_test_graph_ix, body_graph_ix, EdgeType::Normal);
self.cfg.add_edge(body_graph_ix, update_graph_ix, EdgeType::Backedge);
self.cfg.add_edge(after_test_graph_ix, before_body_graph_ix, EdgeType::Normal);
self.cfg.add_edge(after_body_graph_ix, update_graph_ix, EdgeType::Backedge);
self.cfg.add_edge(update_graph_ix, test_graph_ix, EdgeType::Backedge);
self.cfg.add_edge(after_test_graph_ix, after_for_stmt, EdgeType::Normal);

Expand Down

0 comments on commit 3482d50

Please sign in to comment.