Преглед изворни кода

Minor uses of import_* in import_ref (#6428)

Just refactoring calls to use shorter names.
Jon Ross-Perkins пре 5 месеци
родитељ
комит
44d86e11bb
1 измењених фајлова са 42 додато и 64 уклоњено
  1. 42 64
      toolchain/check/import_ref.cpp

+ 42 - 64
toolchain/check/import_ref.cpp

@@ -229,8 +229,8 @@ class ImportContext {
   // from `InstId`s in the import IR to corresponding `ConstantId`s in the local
   // IR.
   auto local_constant_values_for_import_insts() -> SemIR::ConstantValueStore& {
-    return local_context().import_ir_constant_values()
-        [local_context().sem_ir().import_irs().GetRawIndex(import_ir_id_)];
+    auto index = local_ir().import_irs().GetRawIndex(import_ir_id_);
+    return local_context().import_ir_constant_values()[index];
   }
 
   // Returns the file we are importing into.
@@ -1458,8 +1458,7 @@ struct ResolveResult {
     CARBON_CHECK(!resolver.HasNewWork());
     // AddImportedConstant produces an unattached constant, so its type must
     // be unattached as well.
-    inst.type_id =
-        resolver.local_context().types().GetUnattachedType(inst.type_id);
+    inst.type_id = resolver.local_types().GetUnattachedType(inst.type_id);
     auto const_id = AddImportedConstant(resolver.local_context(), inst);
     CARBON_CHECK(const_id.is_constant(), "{0} is not constant", inst);
     return Done(const_id);
@@ -1520,8 +1519,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver, ParamPatternT inst,
 
   return ResolveResult::Unique<ParamPatternT>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
+      {.type_id =
+           resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
        .subpattern_id = subpattern_id,
        .index = inst.index});
 }
@@ -1586,8 +1585,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
     }
 
     // In the second phase, create the associated constant and its declaration.
-    auto type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-        type_const_id);
+    auto type_id =
+        resolver.local_types().GetTypeIdForTypeConstantId(type_const_id);
     std::tie(assoc_const_id, const_id) =
         MakeAssociatedConstant(resolver, import_assoc_const, type_id);
   } else {
@@ -1630,11 +1629,10 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
   auto decl_id = AddImportRef(resolver, inst.decl_id);
 
   return ResolveResult::Deduplicated<SemIR::AssociatedEntity>(
-      resolver,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
-       .index = inst.index,
-       .decl_id = decl_id});
+      resolver, {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(
+                     type_const_id),
+                 .index = inst.index,
+                 .decl_id = decl_id});
 }
 
 static auto TryResolveTypedInst(ImportRefResolver& resolver,
@@ -1672,8 +1670,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
   // Create a corresponding instruction to represent the declaration.
   return ResolveResult::Unique<SemIR::BaseDecl>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
+      {.type_id =
+           resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
        .base_type_inst_id = base_type_inst_id,
        .index = inst.index});
 }
@@ -1695,8 +1693,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
       GetLocalSymbolicEntityNameId(resolver, inst.entity_name_id);
   return ResolveResult::Deduplicated<SemIR::SymbolicBinding>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .entity_name_id = entity_name_id,
        .value_id = SemIR::InstId::None});
 }
@@ -1724,8 +1721,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
        .is_template = import_entity_name.is_template});
   return ResolveResult::Unique<BindingPatternT>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
+      {.type_id =
+           resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
        .entity_name_id = entity_name_id});
 }
 
@@ -1774,8 +1771,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver, SemIR::Call inst)
 
   return ResolveResult::Deduplicated<SemIR::Call>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .callee_id = callee_id,
        .args_id = GetLocalCanonicalInstBlockId(resolver, inst.args_id, args)});
 }
@@ -1956,8 +1952,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
   new_class.param_patterns_id = GetLocalCanonicalInstBlockId(
       resolver, import_class.param_patterns_id, param_patterns);
   new_class.self_type_id =
-      resolver.local_context().types().GetTypeIdForTypeConstantId(
-          self_const_id);
+      resolver.local_types().GetTypeIdForTypeConstantId(self_const_id);
 
   if (import_class.is_complete()) {
     auto complete_type_witness_id = AddLoadedImportRef(
@@ -2082,8 +2077,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
   }
   return ResolveResult::Unique<SemIR::FieldDecl>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           const_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(const_id),
        .name_id = GetLocalNameId(resolver, inst.name_id),
        .index = inst.index});
 }
@@ -2132,8 +2126,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::FloatValue>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .float_id = float_id});
 }
 
@@ -3088,8 +3081,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::FacetValue>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .type_inst_id = type_inst_id,
        .witnesses_block_id = GetLocalCanonicalInstBlockId(
            resolver, inst.witnesses_block_id, witnesses)});
@@ -3157,8 +3149,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::ImplWitnessAccess>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .witness_id = witness_id,
        .index = inst.index});
 }
@@ -3201,8 +3192,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::IntValue>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .int_id = int_id});
 }
 
@@ -3312,8 +3302,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Unique<SemIR::ReturnSlotPattern>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
+      {.type_id =
+           resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
        .type_inst_id = SemIR::TypeInstId::None});
 }
 
@@ -3326,8 +3316,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
     return ResolveResult::Retry();
   }
 
-  auto type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-      type_const_id);
+  auto type_id =
+      resolver.local_types().GetTypeIdForTypeConstantId(type_const_id);
   auto specific_id =
       GetOrAddLocalSpecific(resolver, inst.specific_id, specific_data);
   return ResolveResult::Deduplicated<SemIR::SpecificFunction>(
@@ -3368,8 +3358,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::StructAccess>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .struct_id = struct_id,
        .index = inst.index});
 }
@@ -3414,8 +3403,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::StructValue>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .elements_id =
            GetLocalCanonicalInstBlockId(resolver, inst.elements_id, elems)});
 }
@@ -3452,8 +3440,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::TupleAccess>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .tuple_id = tuple_id,
        .index = inst.index});
 }
@@ -3469,8 +3456,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Unique<SemIR::TuplePattern>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
+      {.type_id =
+           resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
        .elements_id =
            GetLocalCanonicalInstBlockId(resolver, inst.elements_id, elements)});
 }
@@ -3509,8 +3496,7 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Deduplicated<SemIR::TupleValue>(
       resolver,
-      {.type_id =
-           resolver.local_context().types().GetTypeIdForTypeConstantId(type_id),
+      {.type_id = resolver.local_types().GetTypeIdForTypeConstantId(type_id),
        .elements_id =
            GetLocalCanonicalInstBlockId(resolver, inst.elements_id, elems)});
 }
@@ -3544,8 +3530,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Unique<SemIR::VarPattern>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
+      {.type_id =
+           resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
        .subpattern_id = subpattern_id});
 }
 
@@ -3560,8 +3546,8 @@ static auto TryResolveTypedInst(ImportRefResolver& resolver,
 
   return ResolveResult::Unique<SemIR::VarStorage>(
       resolver, import_inst_id,
-      {.type_id = resolver.local_context().types().GetTypeIdForTypeConstantId(
-           type_const_id),
+      {.type_id =
+           resolver.local_types().GetTypeIdForTypeConstantId(type_const_id),
        .pattern_id = pattern_id});
 }
 
@@ -3994,7 +3980,7 @@ auto ImportRefResolver::ResolveType(SemIR::TypeId import_type_id)
     // Builtins don't require constant resolution; we can use them directly.
     return GetSingletonType(local_context(), import_type_inst_id);
   } else {
-    return local_context().types().GetTypeIdForTypeConstantId(
+    return local_types().GetTypeIdForTypeConstantId(
         ResolveConstant(import_type_id.AsConstantId()));
   }
 }
@@ -4071,8 +4057,7 @@ auto ImportRefResolver::FindResolvedConstId(SemIR::InstId inst_id)
     if (auto const_id =
             local_context()
                 .import_ir_constant_values()
-                    [local_context().sem_ir().import_irs().GetRawIndex(
-                        cursor_ir_id)]
+                    [local_ir().import_irs().GetRawIndex(cursor_ir_id)]
                 .GetAttached(cursor_inst_id);
         const_id.has_value()) {
       SetResolvedConstId(inst_id, result.indirect_insts, const_id);
@@ -4198,21 +4183,14 @@ auto ImportImplsFromApiFile(Context& context) -> void {
 auto ImportImpl(Context& context, SemIR::ImportIRId import_ir_id,
                 SemIR::ImplId impl_id) -> void {
   ImportRefResolver resolver(&context, import_ir_id);
-  resolver.Resolve(context.import_irs()
-                       .Get(import_ir_id)
-                       .sem_ir->impls()
-                       .Get(impl_id)
-                       .first_decl_id());
+  resolver.Resolve(resolver.import_impls().Get(impl_id).first_decl_id());
 }
 
 auto ImportInterface(Context& context, SemIR::ImportIRId import_ir_id,
                      SemIR::InterfaceId interface_id) -> SemIR::InterfaceId {
   ImportRefResolver resolver(&context, import_ir_id);
-  auto local_id = resolver.Resolve(context.import_irs()
-                                       .Get(import_ir_id)
-                                       .sem_ir->interfaces()
-                                       .Get(interface_id)
-                                       .first_decl_id());
+  auto local_id = resolver.Resolve(
+      resolver.import_interfaces().Get(interface_id).first_decl_id());
   auto local_inst =
       context.insts().Get(context.constant_values().GetInstId(local_id));