diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index f93a5453ebe7..b3f69fc19411 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -20,19 +20,19 @@ namespace Carbon { SemanticsContext::SemanticsContext(const TokenizedBuffer& tokens, DiagnosticEmitter& emitter, const ParseTree& parse_tree, - SemanticsIR& semantics, + SemanticsIR& semantics_ir, llvm::raw_ostream* vlog_stream) : tokens_(&tokens), emitter_(&emitter), parse_tree_(&parse_tree), - semantics_(&semantics), + semantics_ir_(&semantics_ir), vlog_stream_(vlog_stream), node_stack_(parse_tree, vlog_stream), - node_block_stack_("node_block_stack_", semantics.node_blocks(), + node_block_stack_("node_block_stack_", semantics_ir.node_blocks(), vlog_stream), - params_or_args_stack_("params_or_args_stack_", semantics.node_blocks(), + params_or_args_stack_("params_or_args_stack_", semantics_ir.node_blocks(), vlog_stream), - args_type_info_stack_("args_type_info_stack_", semantics.node_blocks(), + args_type_info_stack_("args_type_info_stack_", semantics_ir.node_blocks(), vlog_stream) { // Inserts the "Invalid" and "Type" types as "used types" so that // canonicalization can skip them. We don't emit either for lowering. @@ -63,7 +63,7 @@ auto SemanticsContext::VerifyOnFinish() -> void { auto SemanticsContext::AddNode(SemanticsNode node) -> SemanticsNodeId { auto block = node_block_stack_.PeekForAdd(); CARBON_VLOG() << "AddNode " << block << ": " << node << "\n"; - return semantics_->AddNode(block, node); + return semantics_ir_->AddNode(block, node); } auto SemanticsContext::AddNodeAndPush(ParseTree::Node parse_node, @@ -80,9 +80,9 @@ auto SemanticsContext::AddNameToLookup(ParseTree::Node name_node, llvm::StringRef); CARBON_DIAGNOSTIC(PreviousDefinition, Note, "Previous definition is here."); auto prev_def_id = name_lookup_[name_id].back(); - auto prev_def = semantics_->GetNode(prev_def_id); + auto prev_def = semantics_ir_->GetNode(prev_def_id); - emitter_->Build(name_node, NameRedefined, semantics_->GetString(name_id)) + emitter_->Build(name_node, NameRedefined, semantics_ir_->GetString(name_id)) .Note(prev_def.parse_node(), PreviousDefinition) .Emit(); } @@ -105,7 +105,7 @@ auto SemanticsContext::BindName(ParseTree::Node name_node, CARBON_CHECK(parse_tree_->node_kind(name_node) == ParseNodeKind::DeclaredName) << parse_tree_->node_kind(name_node); auto name_str = parse_tree_->GetNodeText(name_node); - auto name_id = semantics_->AddString(name_str); + auto name_id = semantics_ir_->AddString(name_str); AddNode( SemanticsNode::BindName::Make(name_node, type_id, name_id, target_id)); @@ -135,7 +135,7 @@ auto SemanticsContext::LookupName(ParseTree::Node parse_node, llvm::StringRef name) -> SemanticsNodeId { CARBON_DIAGNOSTIC(NameNotFound, Error, "Name {0} not found", llvm::StringRef); - auto name_id = semantics_->GetStringID(name); + auto name_id = semantics_ir_->GetStringID(name); if (!name_id) { emitter_->Emit(parse_node, NameNotFound, name); return SemanticsNodeId::BuiltinInvalidType; @@ -178,8 +178,8 @@ auto SemanticsContext::ImplicitAsForArgs( return true; } - auto arg_refs = semantics_->GetNodeBlock(arg_refs_id); - auto param_refs = semantics_->GetNodeBlock(param_refs_id); + auto arg_refs = semantics_ir_->GetNodeBlock(arg_refs_id); + auto param_refs = semantics_ir_->GetNodeBlock(param_refs_id); // If sizes mismatch, fail early. if (arg_refs.size() != param_refs.size()) { @@ -198,7 +198,7 @@ auto SemanticsContext::ImplicitAsForArgs( // It's currently not supported, but will be needed. for (size_t i = 0; i < arg_refs.size(); ++i) { auto value_id = arg_refs[i]; - auto as_type_id = semantics_->GetNode(param_refs[i]).type_id(); + auto as_type_id = semantics_ir_->GetNode(param_refs[i]).type_id(); if (ImplicitAsImpl(value_id, as_type_id, diagnostic == nullptr ? &value_id : nullptr) == ImplicitAsKind::Incompatible) { @@ -207,10 +207,10 @@ auto SemanticsContext::ImplicitAsForArgs( "Callable cannot be used: Cannot implicityly convert " "argument {0} from `{1}` to `{2}`.", size_t, std::string, std::string); - diagnostic->Note( - param_parse_node, CallArgTypeMismatch, i, - semantics_->StringifyType(semantics_->GetNode(value_id).type_id()), - semantics_->StringifyType(as_type_id)); + diagnostic->Note(param_parse_node, CallArgTypeMismatch, i, + semantics_ir_->StringifyType( + semantics_ir_->GetNode(value_id).type_id()), + semantics_ir_->StringifyType(as_type_id)); return false; } } @@ -230,10 +230,10 @@ auto SemanticsContext::ImplicitAsRequired(ParseTree::Node parse_node, "Cannot implicitly convert from `{0}` to `{1}`.", std::string, std::string); emitter_ - ->Build( - parse_node, ImplicitAsConversionFailure, - semantics_->StringifyType(semantics_->GetNode(value_id).type_id()), - semantics_->StringifyType(as_type_id)) + ->Build(parse_node, ImplicitAsConversionFailure, + semantics_ir_->StringifyType( + semantics_ir_->GetNode(value_id).type_id()), + semantics_ir_->StringifyType(as_type_id)) .Emit(); } return output_value_id; @@ -249,7 +249,7 @@ auto SemanticsContext::ImplicitAsImpl(SemanticsNodeId value_id, // If the value is invalid, we can't do much, but do "succeed". return ImplicitAsKind::Identical; } - auto value = semantics_->GetNode(value_id); + auto value = semantics_ir_->GetNode(value_id); auto value_type_id = value.type_id(); if (value_type_id == SemanticsTypeId::InvalidType) { return ImplicitAsKind::Identical; @@ -276,7 +276,7 @@ auto SemanticsContext::ImplicitAsImpl(SemanticsNodeId value_id, if (value.kind() == SemanticsNodeKind::StructValue && value.GetAsStructValue() == SemanticsNodeBlockId::Empty) { if (output_value_id != nullptr) { - *output_value_id = semantics_->GetType(value_type_id); + *output_value_id = semantics_ir_->GetType(value_type_id); } return ImplicitAsKind::Compatible; } @@ -314,21 +314,21 @@ auto SemanticsContext::ParamOrArgSave(bool for_args) -> void { auto [entry_parse_node, entry_node_id] = node_stack_.PopForParseNodeAndNodeId(); param_or_arg_id = AddNode(SemanticsNode::StubReference::Make( - entry_parse_node, semantics_->GetNode(entry_node_id).type_id(), + entry_parse_node, semantics_ir_->GetNode(entry_node_id).type_id(), entry_node_id)); } else { // For a parameter, there should always be something in the IR. node_stack_.PopAndIgnore(); auto ir_id = node_block_stack_.Peek(); CARBON_CHECK(ir_id.is_valid()); - auto& ir = semantics_->GetNodeBlock(ir_id); + auto& ir = semantics_ir_->GetNodeBlock(ir_id); CARBON_CHECK(!ir.empty()) << "Should have had a param"; param_or_arg_id = ir.back(); } // Save the param or arg ID. auto& params_or_args = - semantics_->GetNodeBlock(params_or_args_stack_.PeekForAdd()); + semantics_ir_->GetNodeBlock(params_or_args_stack_.PeekForAdd()); params_or_args.push_back(param_or_arg_id); } @@ -339,7 +339,7 @@ auto SemanticsContext::CanonicalizeType(SemanticsNodeId node_id) return it->second; } - auto type_id = semantics_->AddType(node_id); + auto type_id = semantics_ir_->AddType(node_id); CARBON_CHECK(canonical_types_.insert({node_id, type_id}).second); return type_id; } @@ -348,10 +348,10 @@ auto SemanticsContext::CanonicalizeStructType(ParseTree::Node parse_node, SemanticsNodeBlockId refs_id) -> SemanticsTypeId { // Construct the field structure for lookup. - auto refs = semantics_->GetNodeBlock(refs_id); + auto refs = semantics_ir_->GetNodeBlock(refs_id); llvm::FoldingSetNodeID canonical_id; for (const auto& ref_id : refs) { - auto ref = semantics_->GetNode(ref_id); + auto ref = semantics_ir_->GetNode(ref_id); canonical_id.AddInteger(ref.GetAsStructTypeField().index); canonical_id.AddInteger(ref.type_id().index); } @@ -367,7 +367,7 @@ auto SemanticsContext::CanonicalizeStructType(ParseTree::Node parse_node, // The struct doesn't already exist, so create and store it as canonical. auto node_id = AddNode(SemanticsNode::StructType::Make( parse_node, SemanticsTypeId::TypeType, refs_id)); - auto type_id = semantics_->AddType(node_id); + auto type_id = semantics_ir_->AddType(node_id); CARBON_CHECK(canonical_types_.insert({node_id, type_id}).second); canonical_struct_types_nodes_.push_back( std::make_unique(canonical_id, type_id)); diff --git a/toolchain/semantics/semantics_context.h b/toolchain/semantics/semantics_context.h index c46ce2d51bae..b45ee71117d4 100644 --- a/toolchain/semantics/semantics_context.h +++ b/toolchain/semantics/semantics_context.h @@ -145,7 +145,7 @@ class SemanticsContext { auto parse_tree() -> const ParseTree& { return *parse_tree_; } - auto semantics() -> SemanticsIR& { return *semantics_; } + auto semantics_ir() -> SemanticsIR& { return *semantics_ir_; } auto node_stack() -> SemanticsNodeStack& { return node_stack_; } @@ -221,7 +221,7 @@ class SemanticsContext { const ParseTree* parse_tree_; // The SemanticsIR being added to. - SemanticsIR* semantics_; + SemanticsIR* semantics_ir_; // Whether to print verbose output. llvm::raw_ostream* vlog_stream_; diff --git a/toolchain/semantics/semantics_handle.cpp b/toolchain/semantics/semantics_handle.cpp index af61604d4f25..98515aa796db 100644 --- a/toolchain/semantics/semantics_handle.cpp +++ b/toolchain/semantics/semantics_handle.cpp @@ -62,7 +62,7 @@ auto SemanticsHandleDeducedParameterListStart(SemanticsContext& context, auto SemanticsHandleDesignatedName(SemanticsContext& context, ParseTree::Node parse_node) -> bool { auto name_str = context.parse_tree().GetNodeText(parse_node); - auto name_id = context.semantics().AddString(name_str); + auto name_id = context.semantics_ir().AddString(name_str); // The parent is responsible for binding the name. context.node_stack().Push(parse_node, name_id); return true; @@ -74,16 +74,17 @@ auto SemanticsHandleDesignatorExpression(SemanticsContext& context, ParseNodeKind::DesignatedName); auto base_id = context.node_stack().PopForNodeId(); - auto base = context.semantics().GetNode(base_id); - auto base_type = - context.semantics().GetNode(context.semantics().GetType(base.type_id())); + auto base = context.semantics_ir().GetNode(base_id); + auto base_type = context.semantics_ir().GetNode( + context.semantics_ir().GetType(base.type_id())); switch (base_type.kind()) { case SemanticsNodeKind::StructType: { - auto refs = context.semantics().GetNodeBlock(base_type.GetAsStructType()); + auto refs = + context.semantics_ir().GetNodeBlock(base_type.GetAsStructType()); // TODO: Do we need to optimize this with a lookup table for O(1)? for (int i = 0; i < static_cast(refs.size()); ++i) { - auto ref = context.semantics().GetNode(refs[i]); + auto ref = context.semantics_ir().GetNode(refs[i]); if (name_id == ref.GetAsStructTypeField()) { context.AddNodeAndPush( parse_node, @@ -95,17 +96,19 @@ auto SemanticsHandleDesignatorExpression(SemanticsContext& context, CARBON_DIAGNOSTIC(DesignatorExpressionNameNotFound, Error, "Type `{0}` does not have a member `{1}`.", std::string, llvm::StringRef); - context.emitter().Emit(parse_node, DesignatorExpressionNameNotFound, - context.semantics().StringifyType(base.type_id()), - context.semantics().GetString(name_id)); + context.emitter().Emit( + parse_node, DesignatorExpressionNameNotFound, + context.semantics_ir().StringifyType(base.type_id()), + context.semantics_ir().GetString(name_id)); break; } default: { CARBON_DIAGNOSTIC(DesignatorExpressionUnsupported, Error, "Type `{0}` does not support designator expressions.", std::string); - context.emitter().Emit(parse_node, DesignatorExpressionUnsupported, - context.semantics().StringifyType(base.type_id())); + context.emitter().Emit( + parse_node, DesignatorExpressionUnsupported, + context.semantics_ir().StringifyType(base.type_id())); break; } } @@ -192,7 +195,7 @@ auto SemanticsHandleInfixOperator(SemanticsContext& context, // TODO: This should search for a compatible interface. For now, it's a very // trivial check of validity on the operation. lhs_id = context.ImplicitAsRequired( - parse_node, lhs_id, context.semantics().GetNode(rhs_id).type_id()); + parse_node, lhs_id, context.semantics_ir().GetNode(rhs_id).type_id()); // Figure out the operator for the token. auto token = context.parse_tree().node_token(parse_node); @@ -201,8 +204,8 @@ auto SemanticsHandleInfixOperator(SemanticsContext& context, context.AddNodeAndPush( parse_node, SemanticsNode::BinaryOperatorAdd::Make( - parse_node, context.semantics().GetNode(lhs_id).type_id(), lhs_id, - rhs_id)); + parse_node, context.semantics_ir().GetNode(lhs_id).type_id(), + lhs_id, rhs_id)); break; default: return context.TODO(parse_node, llvm::formatv("Handle {0}", token_kind)); @@ -221,7 +224,7 @@ auto SemanticsHandleLiteral(SemanticsContext& context, auto token = context.parse_tree().node_token(parse_node); switch (auto token_kind = context.tokens().GetKind(token)) { case TokenKind::IntegerLiteral: { - auto id = context.semantics().AddIntegerLiteral( + auto id = context.semantics_ir().AddIntegerLiteral( context.tokens().GetIntegerLiteral(token)); context.AddNodeAndPush( parse_node, @@ -233,7 +236,7 @@ auto SemanticsHandleLiteral(SemanticsContext& context, } case TokenKind::RealLiteral: { auto token_value = context.tokens().GetRealLiteral(token); - auto id = context.semantics().AddRealLiteral( + auto id = context.semantics_ir().AddRealLiteral( {.mantissa = token_value.Mantissa(), .exponent = token_value.Exponent(), .is_decimal = token_value.IsDecimal()}); @@ -246,7 +249,7 @@ auto SemanticsHandleLiteral(SemanticsContext& context, break; } case TokenKind::StringLiteral: { - auto id = context.semantics().AddString( + auto id = context.semantics_ir().AddString( context.tokens().GetStringLiteral(token)); context.AddNodeAndPush( parse_node, @@ -399,8 +402,8 @@ auto SemanticsHandleReturnStatement(SemanticsContext& context, ParseTree::Node parse_node) -> bool { CARBON_CHECK(!context.return_scope_stack().empty()); const auto& fn_node = - context.semantics().GetNode(context.return_scope_stack().back()); - const auto callable = context.semantics().GetCallable( + context.semantics_ir().GetNode(context.return_scope_stack().back()); + const auto callable = context.semantics_ir().GetCallable( fn_node.GetAsFunctionDeclaration().second); if (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) == @@ -414,7 +417,7 @@ auto SemanticsHandleReturnStatement(SemanticsContext& context, "Must return a {0}.", std::string); context.emitter() .Build(parse_node, ReturnStatementMissingExpression, - context.semantics().StringifyType(callable.return_type_id)) + context.semantics_ir().StringifyType(callable.return_type_id)) .Emit(); } @@ -442,7 +445,7 @@ auto SemanticsHandleReturnStatement(SemanticsContext& context, context.AddNodeAndPush( parse_node, SemanticsNode::ReturnExpression::Make( - parse_node, context.semantics().GetNode(arg).type_id(), arg)); + parse_node, context.semantics_ir().GetNode(arg).type_id(), arg)); } return true; } @@ -507,9 +510,9 @@ auto SemanticsHandleVariableDeclaration(SemanticsContext& context, auto cast_value_id = context.ImplicitAsRequired( parse_node, last_node_id, - context.semantics().GetNode(storage_id).type_id()); + context.semantics_ir().GetNode(storage_id).type_id()); context.AddNode(SemanticsNode::Assign::Make( - parse_node, context.semantics().GetNode(cast_value_id).type_id(), + parse_node, context.semantics_ir().GetNode(cast_value_id).type_id(), storage_id, cast_value_id)); } diff --git a/toolchain/semantics/semantics_handle_call_expression.cpp b/toolchain/semantics/semantics_handle_call_expression.cpp index bfa8a0c2bb8d..0259334d6455 100644 --- a/toolchain/semantics/semantics_handle_call_expression.cpp +++ b/toolchain/semantics/semantics_handle_call_expression.cpp @@ -15,7 +15,7 @@ auto SemanticsHandleCallExpression(SemanticsContext& context, auto [call_expr_parse_node, name_id] = context.node_stack().PopForParseNodeAndNodeId( ParseNodeKind::CallExpressionStart); - auto name_node = context.semantics().GetNode(name_id); + auto name_node = context.semantics_ir().GetNode(name_id); if (name_node.kind() != SemanticsNodeKind::FunctionDeclaration) { // TODO: Work on error. context.TODO(parse_node, "Not a callable name"); @@ -24,7 +24,7 @@ auto SemanticsHandleCallExpression(SemanticsContext& context, } auto [_, callable_id] = name_node.GetAsFunctionDeclaration(); - auto callable = context.semantics().GetCallable(callable_id); + auto callable = context.semantics_ir().GetCallable(callable_id); CARBON_DIAGNOSTIC(NoMatchingCall, Error, "No matching callable was found."); auto diagnostic = diff --git a/toolchain/semantics/semantics_handle_function.cpp b/toolchain/semantics/semantics_handle_function.cpp index e929b1927f91..c2cb29d7f957 100644 --- a/toolchain/semantics/semantics_handle_function.cpp +++ b/toolchain/semantics/semantics_handle_function.cpp @@ -51,9 +51,9 @@ auto SemanticsHandleFunctionDefinitionStart(SemanticsContext& context, ParseNodeKind::FunctionIntroducer); auto name_str = context.parse_tree().GetNodeText(name_node); - auto name_id = context.semantics().AddString(name_str); + auto name_id = context.semantics_ir().AddString(name_str); - auto callable_id = context.semantics().AddCallable( + auto callable_id = context.semantics_ir().AddCallable( {.param_refs_id = param_refs_id, .return_type_id = return_type_id}); auto decl_id = context.AddNode( SemanticsNode::FunctionDeclaration::Make(fn_node, name_id, callable_id)); @@ -61,8 +61,8 @@ auto SemanticsHandleFunctionDefinitionStart(SemanticsContext& context, context.node_block_stack().Push(); context.PushScope(); - for (auto ref_id : context.semantics().GetNodeBlock(param_refs_id)) { - auto ref = context.semantics().GetNode(ref_id); + for (auto ref_id : context.semantics_ir().GetNodeBlock(param_refs_id)) { + auto ref = context.semantics_ir().GetNode(ref_id); auto [name_id, target_id] = ref.GetAsBindName(); context.AddNameToLookupIgnoreConflicts(name_id, target_id); } diff --git a/toolchain/semantics/semantics_handle_struct.cpp b/toolchain/semantics/semantics_handle_struct.cpp index 177d57ec31a9..fbd14a6be708 100644 --- a/toolchain/semantics/semantics_handle_struct.cpp +++ b/toolchain/semantics/semantics_handle_struct.cpp @@ -53,10 +53,10 @@ auto SemanticsHandleStructFieldValue(SemanticsContext& context, // Store the name for the type. auto type_block_id = context.args_type_info_stack().PeekForAdd(); - context.semantics().AddNode( + context.semantics_ir().AddNode( type_block_id, SemanticsNode::StructTypeField::Make( - parse_node, context.semantics().GetNode(value_node_id).type_id(), + parse_node, context.semantics_ir().GetNode(value_node_id).type_id(), name_id)); // Push the value back on the stack as an argument. @@ -109,7 +109,8 @@ auto SemanticsHandleStructTypeLiteral(SemanticsContext& context, << "{} is handled by StructLiteral."; auto type_id = context.CanonicalizeStructType(parse_node, refs_id); - context.node_stack().Push(parse_node, context.semantics().GetType(type_id)); + context.node_stack().Push(parse_node, + context.semantics_ir().GetType(type_id)); return true; } diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index fa239bfb4d3e..bb6a38397d2b 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -14,27 +14,27 @@ namespace Carbon { auto SemanticsIR::MakeBuiltinIR() -> SemanticsIR { - SemanticsIR semantics(/*builtin_ir=*/nullptr); - semantics.nodes_.reserve(SemanticsBuiltinKind::ValidCount); + SemanticsIR semantics_ir(/*builtin_ir=*/nullptr); + semantics_ir.nodes_.reserve(SemanticsBuiltinKind::ValidCount); // InvalidType uses a self-referential type so that it's not accidentally // treated as a normal type. Every other builtin is a type, including the // self-referential TypeType. #define CARBON_SEMANTICS_BUILTIN_KIND(Name, ...) \ - semantics.nodes_.push_back(SemanticsNode::Builtin::Make( \ + semantics_ir.nodes_.push_back(SemanticsNode::Builtin::Make( \ SemanticsBuiltinKind::Name, \ SemanticsBuiltinKind::Name == SemanticsBuiltinKind::InvalidType \ ? SemanticsTypeId::InvalidType \ : SemanticsTypeId::TypeType)); #include "toolchain/semantics/semantics_builtin_kind.def" - CARBON_CHECK(semantics.node_blocks_.size() == 1) + CARBON_CHECK(semantics_ir.node_blocks_.size() == 1) << "BuildBuiltins should only have the empty block, actual: " - << semantics.node_blocks_.size(); - CARBON_CHECK(semantics.nodes_.size() == SemanticsBuiltinKind::ValidCount) + << semantics_ir.node_blocks_.size(); + CARBON_CHECK(semantics_ir.nodes_.size() == SemanticsBuiltinKind::ValidCount) << "BuildBuiltins should produce " << SemanticsBuiltinKind::ValidCount - << " nodes, actual: " << semantics.nodes_.size(); - return semantics; + << " nodes, actual: " << semantics_ir.nodes_.size(); + return semantics_ir; } auto SemanticsIR::MakeFromParseTree(const SemanticsIR& builtin_ir, @@ -43,16 +43,16 @@ auto SemanticsIR::MakeFromParseTree(const SemanticsIR& builtin_ir, DiagnosticConsumer& consumer, llvm::raw_ostream* vlog_stream) -> SemanticsIR { - SemanticsIR semantics(&builtin_ir); + SemanticsIR semantics_ir(&builtin_ir); // Copy builtins over. - semantics.nodes_.resize_for_overwrite(SemanticsBuiltinKind::ValidCount); + semantics_ir.nodes_.resize_for_overwrite(SemanticsBuiltinKind::ValidCount); static constexpr auto BuiltinIR = SemanticsCrossReferenceIRId(0); for (int i = 0; i < SemanticsBuiltinKind::ValidCount; ++i) { // We can reuse the type node ID because the offsets of cross-references // will be the same in this IR. auto type = builtin_ir.nodes_[i].type_id(); - semantics.nodes_[i] = SemanticsNode::CrossReference::Make( + semantics_ir.nodes_[i] = SemanticsNode::CrossReference::Make( type, BuiltinIR, SemanticsNodeId(i)); } @@ -60,7 +60,8 @@ auto SemanticsIR::MakeFromParseTree(const SemanticsIR& builtin_ir, ErrorTrackingDiagnosticConsumer err_tracker(consumer); DiagnosticEmitter emitter(translator, err_tracker); - SemanticsContext context(tokens, emitter, parse_tree, semantics, vlog_stream); + SemanticsContext context(tokens, emitter, parse_tree, semantics_ir, + vlog_stream); PrettyStackTraceFunction context_dumper( [&](llvm::raw_ostream& output) { context.PrintForStackDump(output); }); @@ -75,8 +76,8 @@ auto SemanticsIR::MakeFromParseTree(const SemanticsIR& builtin_ir, #define CARBON_PARSE_NODE_KIND(Name) \ case ParseNodeKind::Name: { \ if (!SemanticsHandle##Name(context, parse_node)) { \ - semantics.has_errors_ = true; \ - return semantics; \ + semantics_ir.has_errors_ = true; \ + return semantics_ir; \ } \ break; \ } @@ -85,13 +86,13 @@ auto SemanticsIR::MakeFromParseTree(const SemanticsIR& builtin_ir, } // Pop information for the file-level scope. - semantics.top_node_block_id_ = context.node_block_stack().Pop(); + semantics_ir.top_node_block_id_ = context.node_block_stack().Pop(); context.PopScope(); context.VerifyOnFinish(); - semantics.has_errors_ = err_tracker.seen_error(); - return semantics; + semantics_ir.has_errors_ = err_tracker.seen_error(); + return semantics_ir; } static constexpr int Indent = 2;