scope_index.h 1.1 KB

12345678910111213141516171819202122232425262728293031
  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. using IndexBase::IndexBase;
  19. };
  20. inline constexpr ScopeIndex ScopeIndex::Package = ScopeIndex(0);
  21. } // namespace Carbon::Check
  22. #endif // CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_