SourceCode.h 578 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/String.h>
  8. #include <LibJS/Forward.h>
  9. namespace JS {
  10. class SourceCode : public RefCounted<SourceCode> {
  11. public:
  12. static NonnullRefPtr<SourceCode> create(String filename, String code);
  13. String const& filename() const;
  14. String const& code() const;
  15. SourceRange range_from_offsets(u32 start_offset, u32 end_offset) const;
  16. private:
  17. SourceCode(String filename, String code);
  18. String m_filename;
  19. String m_code;
  20. };
  21. }