mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Start using typed parse node ids in the check stage (#3547)
Goal is to increase type safety, though more work needs to be done (see added TODOs). Note that, after this change, check handlers corresponding to deleted parse node kinds will no longer compile. --------- Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
co-authored by
Chandler Carruth
parent
a602be89e2
commit
48c986f52d
@@ -7,12 +7,13 @@
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
auto HandleBreakStatement(Context& /*context*/, Parse::NodeId /*parse_node*/)
|
||||
-> bool {
|
||||
auto HandleBreakStatement(Context& /*context*/,
|
||||
Parse::BreakStatementId /*parse_node*/) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleBreakStatementStart(Context& context, Parse::NodeId parse_node)
|
||||
auto HandleBreakStatementStart(Context& context,
|
||||
Parse::BreakStatementStartId parse_node)
|
||||
-> bool {
|
||||
auto& stack = context.break_continue_stack();
|
||||
if (stack.empty()) {
|
||||
@@ -28,12 +29,14 @@ auto HandleBreakStatementStart(Context& context, Parse::NodeId parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleContinueStatement(Context& /*context*/, Parse::NodeId /*parse_node*/)
|
||||
auto HandleContinueStatement(Context& /*context*/,
|
||||
Parse::ContinueStatementId /*parse_node*/)
|
||||
-> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleContinueStatementStart(Context& context, Parse::NodeId parse_node)
|
||||
auto HandleContinueStatementStart(Context& context,
|
||||
Parse::ContinueStatementStartId parse_node)
|
||||
-> bool {
|
||||
auto& stack = context.break_continue_stack();
|
||||
if (stack.empty()) {
|
||||
@@ -49,24 +52,27 @@ auto HandleContinueStatementStart(Context& context, Parse::NodeId parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleForHeader(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
auto HandleForHeader(Context& context, Parse::ForHeaderId parse_node) -> bool {
|
||||
return context.TODO(parse_node, "HandleForHeader");
|
||||
}
|
||||
|
||||
auto HandleForHeaderStart(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
auto HandleForHeaderStart(Context& context, Parse::ForHeaderStartId parse_node)
|
||||
-> bool {
|
||||
return context.TODO(parse_node, "HandleForHeaderStart");
|
||||
}
|
||||
|
||||
auto HandleForIn(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
auto HandleForIn(Context& context, Parse::ForInId parse_node) -> bool {
|
||||
context.decl_state_stack().Pop(DeclState::Var);
|
||||
return context.TODO(parse_node, "HandleForIn");
|
||||
}
|
||||
|
||||
auto HandleForStatement(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
auto HandleForStatement(Context& context, Parse::ForStatementId parse_node)
|
||||
-> bool {
|
||||
return context.TODO(parse_node, "HandleForStatement");
|
||||
}
|
||||
|
||||
auto HandleWhileConditionStart(Context& context, Parse::NodeId parse_node)
|
||||
auto HandleWhileConditionStart(Context& context,
|
||||
Parse::WhileConditionStartId parse_node)
|
||||
-> bool {
|
||||
// Branch to the loop header block. Note that we create a new block here even
|
||||
// if the current block is empty; this ensures that the loop always has a
|
||||
@@ -82,7 +88,8 @@ auto HandleWhileConditionStart(Context& context, Parse::NodeId parse_node)
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleWhileCondition(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
auto HandleWhileCondition(Context& context, Parse::WhileConditionId parse_node)
|
||||
-> bool {
|
||||
auto cond_value_id = context.node_stack().PopExpr();
|
||||
auto loop_header_id =
|
||||
context.node_stack().Peek<Parse::NodeKind::WhileConditionStart>();
|
||||
@@ -104,7 +111,8 @@ auto HandleWhileCondition(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleWhileStatement(Context& context, Parse::NodeId parse_node) -> bool {
|
||||
auto HandleWhileStatement(Context& context, Parse::WhileStatementId parse_node)
|
||||
-> bool {
|
||||
auto loop_exit_id =
|
||||
context.node_stack().Pop<Parse::NodeKind::WhileCondition>();
|
||||
auto loop_header_id =
|
||||
|
||||
Reference in New Issue
Block a user