SourceRange.h 482 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Types.h>
  8. namespace JS {
  9. struct Position {
  10. size_t line { 0 };
  11. size_t column { 0 };
  12. size_t offset { 0 };
  13. };
  14. struct SourceRange {
  15. [[nodiscard]] bool contains(Position const& position) const { return position.offset <= end.offset && position.offset >= start.offset; }
  16. StringView filename;
  17. Position start;
  18. Position end;
  19. };
  20. }