refactor(semantic): rename cfg macro to control_flow. (#3742)

As requested here https://github.com/oxc-project/oxc/pull/3737#discussion_r1644713121
This commit is contained in:
rzvxa 2024-06-18 17:01:48 +00:00
parent 4e9d8a5585
commit 7ec44f84a5

View file

@ -31,7 +31,7 @@ use crate::{
Semantic,
};
macro_rules! cfg {
macro_rules! control_flow {
(|$self:ident, $cfg:tt| $body:expr) => {
if let Some(ref mut $cfg) = $self.cfg {
$body
@ -214,8 +214,12 @@ impl<'a> SemanticBuilder<'a> {
flags |= NodeFlags::JSDoc;
}
let ast_node =
AstNode::new(kind, self.current_scope_id, cfg!(|self, cfg| cfg.current_node_ix), flags);
let ast_node = AstNode::new(
kind,
self.current_scope_id,
control_flow!(|self, cfg| cfg.current_node_ix),
flags,
);
self.current_node_id = if matches!(kind, AstKind::Program(_)) {
let id = self.nodes.add_node(ast_node, None);
#[allow(unsafe_code)]
@ -484,7 +488,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
program.scope_id.set(Some(self.current_scope_id));
/* cfg */
let error_harness = cfg!(|self, cfg| {
let error_harness = control_flow!(|self, cfg| {
let error_harness = cfg.attach_error_harness(ErrorEdgeKind::Implicit);
let _program_basic_block = cfg.new_basic_block_normal();
error_harness
@ -500,7 +504,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statements(&program.body);
/* cfg */
cfg!(|self, cfg| cfg.release_error_harness(error_harness));
control_flow!(|self, cfg| cfg.release_error_harness(error_harness));
/* cfg */
self.leave_node(kind);
@ -532,7 +536,9 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
}
/* cfg */
cfg!(|self, cfg| cfg.append_break(node_id, stmt.label.as_ref().map(|it| it.name.as_str())));
control_flow!(
|self, cfg| cfg.append_break(node_id, stmt.label.as_ref().map(|it| it.name.as_str()))
);
/* cfg */
self.leave_node(kind);
@ -551,7 +557,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
}
/* cfg */
cfg!(|self, cfg| cfg
control_flow!(|self, cfg| cfg
.append_continue(node_id, stmt.label.as_ref().map(|it| it.name.as_str())));
/* cfg */
@ -569,7 +575,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.enter_node(kind);
/* cfg */
let (before_do_while_stmt_graph_ix, start_body_graph_ix) = cfg!(|self, cfg| {
let (before_do_while_stmt_graph_ix, start_body_graph_ix) = control_flow!(|self, cfg| {
let before_do_while_stmt_graph_ix = cfg.current_node_ix;
let start_body_graph_ix = cfg.new_basic_block_normal();
cfg.ctx(None).default().allow_break().allow_continue();
@ -580,7 +586,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statement(&stmt.body);
/* cfg - condition basic block */
let (after_body_graph_ix, start_of_condition_graph_ix) = cfg!(|self, cfg| {
let (after_body_graph_ix, start_of_condition_graph_ix) = control_flow!(|self, cfg| {
let after_body_graph_ix = cfg.current_node_ix;
let start_of_condition_graph_ix = cfg.new_basic_block_normal();
(after_body_graph_ix, start_of_condition_graph_ix)
@ -592,7 +598,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
let test_node = self.retrieve_recorded_ast_nodes().into_iter().next();
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
cfg.append_condition_to(start_of_condition_graph_ix, test_node);
let end_of_condition_graph_ix = cfg.current_node_ix;
@ -638,7 +644,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_expression(&expr.left);
/* cfg */
let (left_expr_end_ix, right_expr_start_ix) = cfg!(|self, cfg| {
let (left_expr_end_ix, right_expr_start_ix) = control_flow!(|self, cfg| {
let left_expr_end_ix = cfg.current_node_ix;
let right_expr_start_ix = cfg.new_basic_block_normal();
(left_expr_end_ix, right_expr_start_ix)
@ -648,7 +654,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_expression(&expr.right);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let right_expr_end_ix = cfg.current_node_ix;
let after_logical_expr_ix = cfg.new_basic_block_normal();
@ -673,7 +679,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_assignment_target(&expr.left);
/* cfg */
let cfg_ixs = cfg!(|self, cfg| {
let cfg_ixs = control_flow!(|self, cfg| {
if expr.operator.is_logical() {
let target_end_ix = cfg.current_node_ix;
let expr_start_ix = cfg.new_basic_block_normal();
@ -687,7 +693,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_expression(&expr.right);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
if let Some((target_end_ix, expr_start_ix)) = cfg_ixs {
let expr_end_ix = cfg.current_node_ix;
let after_assignment_ix = cfg.new_basic_block_normal();
@ -707,11 +713,12 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.enter_node(kind);
/* cfg - condition basic block */
let (before_conditional_graph_ix, start_of_condition_graph_ix) = cfg!(|self, cfg| {
let before_conditional_graph_ix = cfg.current_node_ix;
let start_of_condition_graph_ix = cfg.new_basic_block_normal();
(before_conditional_graph_ix, start_of_condition_graph_ix)
});
let (before_conditional_graph_ix, start_of_condition_graph_ix) =
control_flow!(|self, cfg| {
let before_conditional_graph_ix = cfg.current_node_ix;
let start_of_condition_graph_ix = cfg.new_basic_block_normal();
(before_conditional_graph_ix, start_of_condition_graph_ix)
});
/* cfg */
self.record_ast_nodes();
@ -719,29 +726,31 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
let test_node = self.retrieve_recorded_ast_nodes().into_iter().next();
/* cfg */
let (after_condition_graph_ix, before_consequent_expr_graph_ix) = cfg!(|self, cfg| {
cfg.append_condition_to(start_of_condition_graph_ix, test_node);
let after_condition_graph_ix = cfg.current_node_ix;
// conditional expression basic block
let before_consequent_expr_graph_ix = cfg.new_basic_block_normal();
(after_condition_graph_ix, before_consequent_expr_graph_ix)
});
let (after_condition_graph_ix, before_consequent_expr_graph_ix) =
control_flow!(|self, cfg| {
cfg.append_condition_to(start_of_condition_graph_ix, test_node);
let after_condition_graph_ix = cfg.current_node_ix;
// conditional expression basic block
let before_consequent_expr_graph_ix = cfg.new_basic_block_normal();
(after_condition_graph_ix, before_consequent_expr_graph_ix)
});
/* cfg */
self.visit_expression(&expr.consequent);
/* cfg */
let (after_consequent_expr_graph_ix, start_alternate_graph_ix) = cfg!(|self, cfg| {
let after_consequent_expr_graph_ix = cfg.current_node_ix;
let start_alternate_graph_ix = cfg.new_basic_block_normal();
(after_consequent_expr_graph_ix, start_alternate_graph_ix)
});
let (after_consequent_expr_graph_ix, start_alternate_graph_ix) =
control_flow!(|self, cfg| {
let after_consequent_expr_graph_ix = cfg.current_node_ix;
let start_alternate_graph_ix = cfg.new_basic_block_normal();
(after_consequent_expr_graph_ix, start_alternate_graph_ix)
});
/* cfg */
self.visit_expression(&expr.alternate);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_alternate_graph_ix = cfg.current_node_ix;
/* bb after conditional expression joins consequent and alternate */
let after_conditional_graph_ix = cfg.new_basic_block_normal();
@ -780,7 +789,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_for_statement_init(init);
}
/* cfg */
let (before_for_graph_ix, test_graph_ix) = cfg!(|self, cfg| {
let (before_for_graph_ix, test_graph_ix) = control_flow!(|self, cfg| {
let before_for_graph_ix = cfg.current_node_ix;
let test_graph_ix = cfg.new_basic_block_normal();
(before_for_graph_ix, test_graph_ix)
@ -793,13 +802,13 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
let test_node = self.retrieve_recorded_ast_nodes().into_iter().next();
/* cfg */
cfg!(|self, cfg| cfg.append_condition_to(test_graph_ix, test_node));
control_flow!(|self, cfg| cfg.append_condition_to(test_graph_ix, test_node));
/* cfg */
}
/* cfg */
let (after_test_graph_ix, update_graph_ix) =
cfg!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
control_flow!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
/* cfg */
if let Some(update) = &stmt.update {
@ -807,7 +816,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
}
/* cfg */
let before_body_graph_ix = cfg!(|self, cfg| {
let before_body_graph_ix = control_flow!(|self, cfg| {
let before_body_graph_ix = cfg.new_basic_block_normal();
cfg.ctx(None).default().allow_break().allow_continue();
before_body_graph_ix
@ -817,7 +826,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statement(&stmt.body);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_body_graph_ix = cfg.current_node_ix;
let after_for_stmt = cfg.new_basic_block_normal();
cfg.add_edge(before_for_graph_ix, test_graph_ix, EdgeType::Normal);
@ -867,7 +876,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
let (before_for_stmt_graph_ix, start_prepare_cond_graph_ix) =
cfg!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal(),));
control_flow!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal(),));
/* cfg */
self.record_ast_nodes();
@ -876,7 +885,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
let (end_of_prepare_cond_graph_ix, iteration_graph_ix, body_graph_ix) =
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let end_of_prepare_cond_graph_ix = cfg.current_node_ix;
let iteration_graph_ix = cfg.new_basic_block_normal();
cfg.append_iteration(right_node, IterationInstructionKind::In);
@ -890,7 +899,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statement(&stmt.body);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let end_of_body_graph_ix = cfg.current_node_ix;
let after_for_graph_ix = cfg.new_basic_block_normal();
// connect before for statement to the iterable expression
@ -932,7 +941,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
let (before_for_stmt_graph_ix, start_prepare_cond_graph_ix) =
cfg!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
control_flow!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
/* cfg */
self.record_ast_nodes();
@ -941,7 +950,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
let (end_of_prepare_cond_graph_ix, iteration_graph_ix, body_graph_ix) =
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let end_of_prepare_cond_graph_ix = cfg.current_node_ix;
let iteration_graph_ix = cfg.new_basic_block_normal();
cfg.append_iteration(right_node, IterationInstructionKind::Of);
@ -954,7 +963,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statement(&stmt.body);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let end_of_body_graph_ix = cfg.current_node_ix;
let after_for_graph_ix = cfg.new_basic_block_normal();
// connect before for statement to the iterable expression
@ -989,7 +998,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg - condition basic block */
let (before_if_stmt_graph_ix, start_of_condition_graph_ix) =
cfg!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal(),));
control_flow!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal(),));
/* cfg */
self.record_ast_nodes();
@ -997,7 +1006,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
let test_node = self.retrieve_recorded_ast_nodes().into_iter().next();
/* cfg */
let (after_test_graph_ix, before_consequent_stmt_graph_ix) = cfg!(|self, cfg| {
let (after_test_graph_ix, before_consequent_stmt_graph_ix) = control_flow!(|self, cfg| {
cfg.append_condition_to(start_of_condition_graph_ix, test_node);
(cfg.current_node_ix, cfg.new_basic_block_normal())
});
@ -1006,23 +1015,23 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statement(&stmt.consequent);
/* cfg */
let after_consequent_stmt_graph_ix = cfg!(|self, cfg| cfg.current_node_ix);
let after_consequent_stmt_graph_ix = control_flow!(|self, cfg| cfg.current_node_ix);
/* cfg */
let else_graph_ix = if let Some(alternate) = &stmt.alternate {
/* cfg */
let else_graph_ix = cfg!(|self, cfg| cfg.new_basic_block_normal());
let else_graph_ix = control_flow!(|self, cfg| cfg.new_basic_block_normal());
/* cfg */
self.visit_statement(alternate);
cfg!(|self, cfg| Some((else_graph_ix, cfg.current_node_ix)))
control_flow!(|self, cfg| Some((else_graph_ix, cfg.current_node_ix)))
} else {
None
};
/* cfg - bb after if statement joins consequent and alternate */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_if_graph_ix = cfg.new_basic_block_normal();
cfg.add_edge(before_if_stmt_graph_ix, start_of_condition_graph_ix, EdgeType::Normal);
@ -1055,7 +1064,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
let label = &stmt.label.name;
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let ctx = cfg.ctx(Some(label.as_str())).default().allow_break();
if stmt.body.is_iteration_statement() {
ctx.allow_continue();
@ -1068,7 +1077,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statement(&stmt.body);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_body_graph_ix = cfg.current_node_ix;
let after_labeled_stmt_graph_ix = cfg.new_basic_block_normal();
cfg.add_edge(after_body_graph_ix, after_labeled_stmt_graph_ix, EdgeType::Normal);
@ -1096,7 +1105,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
};
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
cfg.push_return(ret_kind, node_id);
cfg.append_unreachable();
});
@ -1113,7 +1122,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
stmt.scope_id.set(Some(self.current_scope_id));
/* cfg */
let discriminant_graph_ix = cfg!(|self, cfg| {
let discriminant_graph_ix = control_flow!(|self, cfg| {
let discriminant_graph_ix = cfg.current_node_ix;
cfg.ctx(None).default().allow_break();
discriminant_graph_ix
@ -1123,18 +1132,18 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
for case in &stmt.cases {
let before_case_graph_ix = cfg!(|self, cfg| cfg.new_basic_block_normal());
let before_case_graph_ix = control_flow!(|self, cfg| cfg.new_basic_block_normal());
self.visit_switch_case(case);
if case.is_default_case() {
have_default_case = true;
}
cfg!(|self, cfg| switch_case_graph_spans
control_flow!(|self, cfg| switch_case_graph_spans
.push((before_case_graph_ix, cfg.current_node_ix)));
}
/* cfg */
// for each switch case
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
for i in 0..switch_case_graph_spans.len() {
let case_graph_span = switch_case_graph_spans[i];
@ -1188,11 +1197,11 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.record_ast_nodes();
self.visit_expression(expr);
let test_node = self.retrieve_recorded_ast_nodes().into_iter().next();
cfg!(|self, cfg| cfg.append_condition_to(cfg.current_node_ix, test_node));
control_flow!(|self, cfg| cfg.append_condition_to(cfg.current_node_ix, test_node));
}
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_test_graph_ix = cfg.current_node_ix;
let statements_in_switch_graph_ix = cfg.new_basic_block_normal();
cfg.add_edge(after_test_graph_ix, statements_in_switch_graph_ix, EdgeType::Jump);
@ -1215,7 +1224,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_expression(&stmt.argument);
/* cfg */
cfg!(|self, cfg| cfg.append_throw(node_id));
control_flow!(|self, cfg| cfg.append_throw(node_id));
/* cfg */
self.leave_node(kind);
@ -1232,7 +1241,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
error_harness,
before_finalizer_graph_ix,
before_try_block_graph_ix,
) = cfg!(|self, cfg| {
) = control_flow!(|self, cfg| {
let before_try_statement_graph_ix = cfg.current_node_ix;
let error_harness =
stmt.handler.as_ref().map(|_| cfg.attach_error_harness(ErrorEdgeKind::Explicit));
@ -1251,12 +1260,12 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_block_statement(&stmt.block);
/* cfg */
let after_try_block_graph_ix = cfg!(|self, cfg| cfg.current_node_ix);
let after_try_block_graph_ix = control_flow!(|self, cfg| cfg.current_node_ix);
/* cfg */
let catch_block_end_ix = if let Some(handler) = &stmt.handler {
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let Some(error_harness) = error_harness else {
unreachable!("we always create an error harness if we have a catch block.");
};
@ -1269,7 +1278,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_catch_clause(handler);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let catch_block_end_ix = cfg.current_node_ix;
// TODO: we shouldn't directly change the current node index.
cfg.current_node_ix = after_try_block_graph_ix;
@ -1282,7 +1291,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
let finally_block_end_ix = if let Some(finalizer) = &stmt.finalizer {
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let Some(before_finalizer_graph_ix) = before_finalizer_graph_ix else {
unreachable!("we always create a finalizer when there is a finally block.");
};
@ -1295,7 +1304,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_finally_clause(finalizer);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let finally_block_end_ix = cfg.current_node_ix;
// TODO: we shouldn't directly change the current node index.
cfg.current_node_ix = after_try_block_graph_ix;
@ -1307,7 +1316,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
};
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_try_statement_block_ix = cfg.new_basic_block_normal();
cfg.add_edge(
before_try_statement_graph_ix,
@ -1383,7 +1392,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg - condition basic block */
let (before_while_stmt_graph_ix, condition_graph_ix) =
cfg!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
control_flow!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
/* cfg */
self.record_ast_nodes();
@ -1391,7 +1400,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
let test_node = self.retrieve_recorded_ast_nodes().into_iter().next();
/* cfg - body basic block */
let body_graph_ix = cfg!(|self, cfg| {
let body_graph_ix = control_flow!(|self, cfg| {
cfg.append_condition_to(condition_graph_ix, test_node);
let body_graph_ix = cfg.new_basic_block_normal();
@ -1403,7 +1412,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_statement(&stmt.body);
/* cfg - after body basic block */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_body_graph_ix = cfg.current_node_ix;
let after_while_graph_ix = cfg.new_basic_block_normal();
@ -1427,19 +1436,19 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg - condition basic block */
let (before_with_stmt_graph_ix, condition_graph_ix) =
cfg!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
control_flow!(|self, cfg| (cfg.current_node_ix, cfg.new_basic_block_normal()));
/* cfg */
self.visit_expression(&stmt.object);
/* cfg - body basic block */
let body_graph_ix = cfg!(|self, cfg| cfg.new_basic_block_normal());
let body_graph_ix = control_flow!(|self, cfg| cfg.new_basic_block_normal());
/* cfg */
self.visit_statement(&stmt.body);
/* cfg - after body basic block */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
let after_body_graph_ix = cfg.new_basic_block_normal();
cfg.add_edge(before_with_stmt_graph_ix, condition_graph_ix, EdgeType::Normal);
@ -1464,14 +1473,15 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
func.scope_id.set(Some(self.current_scope_id));
/* cfg */
let (before_function_graph_ix, error_harness, function_graph_ix) = cfg!(|self, cfg| {
let before_function_graph_ix = cfg.current_node_ix;
cfg.push_finalization_stack();
let error_harness = cfg.attach_error_harness(ErrorEdgeKind::Implicit);
let function_graph_ix = cfg.new_basic_block_function();
cfg.ctx(None).new_function();
(before_function_graph_ix, error_harness, function_graph_ix)
});
let (before_function_graph_ix, error_harness, function_graph_ix) =
control_flow!(|self, cfg| {
let before_function_graph_ix = cfg.current_node_ix;
cfg.push_finalization_stack();
let error_harness = cfg.attach_error_harness(ErrorEdgeKind::Implicit);
let function_graph_ix = cfg.new_basic_block_function();
cfg.ctx(None).new_function();
(before_function_graph_ix, error_harness, function_graph_ix)
});
/* cfg */
// We add a new basic block to the cfg before entering the node
@ -1479,7 +1489,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.enter_node(kind);
/* cfg */
cfg!(|self, cfg| cfg.add_edge(
control_flow!(|self, cfg| cfg.add_edge(
before_function_graph_ix,
function_graph_ix,
EdgeType::NewFunction
@ -1495,7 +1505,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
}
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
cfg.ctx(None).resolve_expect(CtxFlags::FUNCTION);
cfg.release_error_harness(error_harness);
cfg.pop_finalization_stack();
@ -1571,7 +1581,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
expr.scope_id.set(Some(self.current_scope_id));
/* cfg */
let (current_node_ix, error_harness, function_graph_ix) = cfg!(|self, cfg| {
let (current_node_ix, error_harness, function_graph_ix) = control_flow!(|self, cfg| {
let current_node_ix = cfg.current_node_ix;
cfg.push_finalization_stack();
let error_harness = cfg.attach_error_harness(ErrorEdgeKind::Implicit);
@ -1588,13 +1598,17 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
self.visit_formal_parameters(&expr.params);
/* cfg */
cfg!(|self, cfg| cfg.add_edge(current_node_ix, function_graph_ix, EdgeType::NewFunction));
control_flow!(|self, cfg| cfg.add_edge(
current_node_ix,
function_graph_ix,
EdgeType::NewFunction
));
/* cfg */
self.visit_function_body(&expr.body);
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
cfg.ctx(None).resolve_expect(CtxFlags::FUNCTION);
cfg.release_error_harness(error_harness);
cfg.pop_finalization_stack();
@ -1664,7 +1678,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
impl<'a> SemanticBuilder<'a> {
fn enter_kind(&mut self, kind: AstKind<'a>) {
/* cfg */
cfg!(|self, cfg| {
control_flow!(|self, cfg| {
match kind {
AstKind::ReturnStatement(_)
| AstKind::BreakStatement(_)