mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:51:16 +01:00
This does a few things: * Replaces the single `TypeId` in the `FacetTypeInfo` struct with a vector of `InterfaceId`, `SpecificId` pairs (sorted in id order) representing the set of interface requirements of the facet type. This will later be used to support facet types with multiple interface requirements (as in `I & J` or `I where .Self impls J`). * Replace `InterfaceType` instructions (used as the type of an `InterfaceDecl` instruction) with `FacetType` instructions (introduced in #4460) with a (newly introduced) `FacetTypeFromInterface()` function. * Replace code that consumed `InterfaceType` values with code that consumed `FaceType` values. I've generally left the assumption in the code that it is dealing with a single interface, using the (newly introduced) `FacetTypeInfo::TryAsSingleInterface`, and producing an error otherwise. There isn't yet support for the `&` operator or `where .Self impls`, so this is generally a good assumption for now, except you can get a facet type with no associated interfaces from a `type where`... expression. In some cases, the facet type value is pulled from the evaluation of an `InterfaceDecl` instruction, where the single interface assumption will hold permanently. * Some related cleans up: nicer stringification and formatting of facet types, suppression of some errors when there already was an error. There is still a lot left to do, including: * Type `type` should be a facet type with a reserved id, replacing the built-in instruction. * Code using `TryAsSingleInterface` should generally be upgraded to handle more than (or less than) one interface. Name lookup should be particularly exciting. * Operator `&` should be defined on facet types, unioning their interface and other requirements. * Requirements from a `where` clause don't do anything yet. * Impls and impl lookup need to resolve facet types, and do things like determine if all the associated constants are given values. --------- Co-authored-by: Josh L <josh11b@users.noreply.github.com> Co-authored-by: Geoff Romer <gromer@google.com>
112 lines
4.1 KiB
C++
112 lines
4.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// This is an X-macro header. It does not use `#include` guards, and instead is
|
|
// designed to be `#include`ed after the x-macro is defined in order for its
|
|
// inclusion to expand to the desired output. Macro definitions are cleaned up
|
|
// at the end of this file.
|
|
//
|
|
// This macro should be defined before including this header:
|
|
// - CARBON_SEM_IR_INST_KIND(Name)
|
|
// Invoked for each kind of semantic instruction.
|
|
|
|
#ifndef CARBON_SEM_IR_INST_KIND
|
|
#error "Must define the x-macro to use this file."
|
|
#endif
|
|
|
|
// For each instruction kind declared here there is a matching definition in
|
|
// `typed_insts.h`.
|
|
CARBON_SEM_IR_INST_KIND(AdaptDecl)
|
|
CARBON_SEM_IR_INST_KIND(AddrOf)
|
|
CARBON_SEM_IR_INST_KIND(AddrPattern)
|
|
CARBON_SEM_IR_INST_KIND(ArrayIndex)
|
|
CARBON_SEM_IR_INST_KIND(ArrayInit)
|
|
CARBON_SEM_IR_INST_KIND(ArrayType)
|
|
CARBON_SEM_IR_INST_KIND(AsCompatible)
|
|
CARBON_SEM_IR_INST_KIND(Assign)
|
|
CARBON_SEM_IR_INST_KIND(AssociatedConstantDecl)
|
|
CARBON_SEM_IR_INST_KIND(AssociatedEntity)
|
|
CARBON_SEM_IR_INST_KIND(AssociatedEntityType)
|
|
CARBON_SEM_IR_INST_KIND(BaseDecl)
|
|
CARBON_SEM_IR_INST_KIND(BindAlias)
|
|
CARBON_SEM_IR_INST_KIND(ExportDecl)
|
|
CARBON_SEM_IR_INST_KIND(BindingPattern)
|
|
CARBON_SEM_IR_INST_KIND(BindName)
|
|
CARBON_SEM_IR_INST_KIND(BindSymbolicName)
|
|
CARBON_SEM_IR_INST_KIND(BindValue)
|
|
CARBON_SEM_IR_INST_KIND(BlockArg)
|
|
CARBON_SEM_IR_INST_KIND(BoolLiteral)
|
|
CARBON_SEM_IR_INST_KIND(BoundMethod)
|
|
CARBON_SEM_IR_INST_KIND(Branch)
|
|
CARBON_SEM_IR_INST_KIND(BranchIf)
|
|
CARBON_SEM_IR_INST_KIND(BranchWithArg)
|
|
CARBON_SEM_IR_INST_KIND(BuiltinInst)
|
|
CARBON_SEM_IR_INST_KIND(Call)
|
|
CARBON_SEM_IR_INST_KIND(ClassDecl)
|
|
CARBON_SEM_IR_INST_KIND(ClassElementAccess)
|
|
CARBON_SEM_IR_INST_KIND(ClassInit)
|
|
CARBON_SEM_IR_INST_KIND(ClassType)
|
|
CARBON_SEM_IR_INST_KIND(CompleteTypeWitness)
|
|
CARBON_SEM_IR_INST_KIND(ConstType)
|
|
CARBON_SEM_IR_INST_KIND(Converted)
|
|
CARBON_SEM_IR_INST_KIND(Deref)
|
|
CARBON_SEM_IR_INST_KIND(FacetType)
|
|
CARBON_SEM_IR_INST_KIND(FacetTypeAccess)
|
|
CARBON_SEM_IR_INST_KIND(FieldDecl)
|
|
CARBON_SEM_IR_INST_KIND(FloatLiteral)
|
|
CARBON_SEM_IR_INST_KIND(FloatType)
|
|
CARBON_SEM_IR_INST_KIND(FunctionDecl)
|
|
CARBON_SEM_IR_INST_KIND(FunctionType)
|
|
CARBON_SEM_IR_INST_KIND(GenericClassType)
|
|
CARBON_SEM_IR_INST_KIND(GenericInterfaceType)
|
|
CARBON_SEM_IR_INST_KIND(ImplDecl)
|
|
CARBON_SEM_IR_INST_KIND(ImportDecl)
|
|
CARBON_SEM_IR_INST_KIND(ImportRefUnloaded)
|
|
CARBON_SEM_IR_INST_KIND(ImportRefLoaded)
|
|
CARBON_SEM_IR_INST_KIND(InitializeFrom)
|
|
CARBON_SEM_IR_INST_KIND(InterfaceDecl)
|
|
CARBON_SEM_IR_INST_KIND(InterfaceWitness)
|
|
CARBON_SEM_IR_INST_KIND(InterfaceWitnessAccess)
|
|
CARBON_SEM_IR_INST_KIND(IntValue)
|
|
CARBON_SEM_IR_INST_KIND(IntType)
|
|
CARBON_SEM_IR_INST_KIND(NameRef)
|
|
CARBON_SEM_IR_INST_KIND(Namespace)
|
|
CARBON_SEM_IR_INST_KIND(OutParam)
|
|
CARBON_SEM_IR_INST_KIND(OutParamPattern)
|
|
CARBON_SEM_IR_INST_KIND(PointerType)
|
|
CARBON_SEM_IR_INST_KIND(RequirementRewrite)
|
|
CARBON_SEM_IR_INST_KIND(RequirementEquivalent)
|
|
CARBON_SEM_IR_INST_KIND(RequirementImpls)
|
|
CARBON_SEM_IR_INST_KIND(Return)
|
|
CARBON_SEM_IR_INST_KIND(ReturnExpr)
|
|
CARBON_SEM_IR_INST_KIND(ReturnSlot)
|
|
CARBON_SEM_IR_INST_KIND(ReturnSlotPattern)
|
|
CARBON_SEM_IR_INST_KIND(SpecificConstant)
|
|
CARBON_SEM_IR_INST_KIND(SpecificFunction)
|
|
CARBON_SEM_IR_INST_KIND(SpliceBlock)
|
|
CARBON_SEM_IR_INST_KIND(StringLiteral)
|
|
CARBON_SEM_IR_INST_KIND(StructAccess)
|
|
CARBON_SEM_IR_INST_KIND(StructInit)
|
|
CARBON_SEM_IR_INST_KIND(StructLiteral)
|
|
CARBON_SEM_IR_INST_KIND(StructType)
|
|
CARBON_SEM_IR_INST_KIND(StructValue)
|
|
CARBON_SEM_IR_INST_KIND(SymbolicBindingPattern)
|
|
CARBON_SEM_IR_INST_KIND(TemporaryStorage)
|
|
CARBON_SEM_IR_INST_KIND(Temporary)
|
|
CARBON_SEM_IR_INST_KIND(TupleAccess)
|
|
CARBON_SEM_IR_INST_KIND(TupleInit)
|
|
CARBON_SEM_IR_INST_KIND(TupleLiteral)
|
|
CARBON_SEM_IR_INST_KIND(TupleType)
|
|
CARBON_SEM_IR_INST_KIND(TupleValue)
|
|
CARBON_SEM_IR_INST_KIND(UnaryOperatorNot)
|
|
CARBON_SEM_IR_INST_KIND(UnboundElementType)
|
|
CARBON_SEM_IR_INST_KIND(ValueAsRef)
|
|
CARBON_SEM_IR_INST_KIND(ValueOfInitializer)
|
|
CARBON_SEM_IR_INST_KIND(ValueParam)
|
|
CARBON_SEM_IR_INST_KIND(ValueParamPattern)
|
|
CARBON_SEM_IR_INST_KIND(VarStorage)
|
|
CARBON_SEM_IR_INST_KIND(WhereExpr)
|
|
|
|
#undef CARBON_SEM_IR_INST_KIND
|