scope_index.h 1.0 KB

123456789101112131415161718192021222324252627282930
  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, public Printable<ScopeIndex> {
  16. static const ScopeIndex Package;
  17. using IndexBase::IndexBase;
  18. };
  19. constexpr ScopeIndex ScopeIndex::Package = ScopeIndex(0);
  20. } // namespace Carbon::Check
  21. #endif // CARBON_TOOLCHAIN_CHECK_SCOPE_INDEX_H_