Serenity Operating System
1/*
2 * Copyright (c) 2020, the SerenityOS developers.
3 * Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#pragma once
9
10#include <AK/NonnullRefPtr.h>
11#include <AK/StringView.h>
12#include <AK/Types.h>
13#include <LibJS/SourceCode.h>
14
15namespace JS {
16
17struct Position {
18 size_t line { 0 };
19 size_t column { 0 };
20 size_t offset { 0 };
21};
22
23struct SourceRange {
24 [[nodiscard]] bool contains(Position const& position) const { return position.offset <= end.offset && position.offset >= start.offset; }
25
26 NonnullRefPtr<SourceCode const> code;
27 Position start;
28 Position end;
29
30 DeprecatedString filename() const;
31};
32
33}