scope_index.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_
  5. #define CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_
  6. #include "toolchain/base/index_base.h"
  7. namespace Carbon::Check {
  8. // An index for a pushed scope. This may correspond to a permanent scope with a
  9. // corresponding `NameScope`, in which case a different index will be assigned
  10. // each time the scope is entered. Alternatively, it may be a temporary scope
  11. // such as is created for a block, and will only be entered once.
  12. //
  13. // `ScopeIndex` values are comparable. Lower `ScopeIndex` values correspond to
  14. // scopes entered earlier in the file.
  15. struct ScopeIndex : public IndexBase<ScopeIndex> {
  16. static constexpr llvm::StringLiteral Label = "scope";
  17. static const ScopeIndex Package;
  18. static const ScopeIndex None;
  19. using IndexBase::IndexBase;
  20. };
  21. constexpr ScopeIndex ScopeIndex::Package = ScopeIndex(0);
  22. constexpr ScopeIndex ScopeIndex::None = ScopeIndex(NoneIndex);
  23. } // namespace Carbon::Check
  24. #endif // CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_