class_definition.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 EXECUTABLE_SEMANTICS_AST_CLASS_DEFINITION_H_
  5. #define EXECUTABLE_SEMANTICS_AST_CLASS_DEFINITION_H_
  6. #include <string>
  7. #include <vector>
  8. #include "executable_semantics/ast/member.h"
  9. #include "executable_semantics/ast/source_location.h"
  10. #include "executable_semantics/ast/static_scope.h"
  11. namespace Carbon {
  12. class StaticScope;
  13. class ClassDefinition {
  14. public:
  15. ClassDefinition(SourceLocation source_loc, std::string name,
  16. std::vector<Nonnull<Member*>> members)
  17. : source_loc_(source_loc),
  18. name_(std::move(name)),
  19. members_(std::move(members)) {}
  20. auto source_loc() const -> SourceLocation { return source_loc_; }
  21. auto name() const -> const std::string& { return name_; }
  22. auto members() const -> llvm::ArrayRef<Nonnull<Member*>> { return members_; }
  23. // Contains class members.
  24. auto static_scope() const -> const StaticScope& { return static_scope_; }
  25. auto static_scope() -> StaticScope& { return static_scope_; }
  26. private:
  27. SourceLocation source_loc_;
  28. std::string name_;
  29. std::vector<Nonnull<Member*>> members_;
  30. StaticScope static_scope_;
  31. };
  32. } // namespace Carbon
  33. #endif // EXECUTABLE_SEMANTICS_AST_CLASS_DEFINITION_H_