SourceRange.h 509 B

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