| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // 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
- #ifndef CARBON_TOOLCHAIN_SEM_IR_ASSOCIATED_CONSTANT_H_
- #define CARBON_TOOLCHAIN_SEM_IR_ASSOCIATED_CONSTANT_H_
- #include "common/ostream.h"
- #include "toolchain/base/value_store.h"
- #include "toolchain/sem_ir/ids.h"
- namespace Carbon::SemIR {
- // An associated constant entity. For example:
- //
- // interface I {
- // let AssocConst:! type;
- // }
- //
- // TODO: This overlaps a lot with EntityName and EntityWithParamsBase.
- // Investigate ways of factoring out the common parts.
- struct AssociatedConstant : public Printable<AssociatedConstant> {
- auto Print(llvm::raw_ostream& out) const -> void {
- out << "{"
- << "name: " << name_id << ", parent_scope: " << parent_scope_id
- << ", decl_id: " << decl_id
- << ", default_value_id: " << default_value_id << "}";
- }
- // The following fields are set at the `:!` binding, when the
- // `AssociatedConstant` is created.
- // The entity's name.
- NameId name_id;
- // The parent scope.
- NameScopeId parent_scope_id;
- // The declaration of this associated constant.
- InstId decl_id;
- // The following fields are set at the `;`.
- // The default value of the constant.
- InstId default_value_id = InstId::None;
- };
- using AssociatedConstantStore =
- ValueStore<AssociatedConstantId, AssociatedConstant, Tag<CheckIRId>>;
- } // namespace Carbon::SemIR
- #endif // CARBON_TOOLCHAIN_SEM_IR_ASSOCIATED_CONSTANT_H_
|