Coverage Report

Created: 2026-09-14 07:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibJS/Runtime/PrivateEnvironment.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2021, David Tuin <davidot@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/DeprecatedFlyString.h>
10
#include <AK/StringView.h>
11
#include <AK/Vector.h>
12
#include <LibJS/Heap/Cell.h>
13
#include <LibJS/Heap/CellAllocator.h>
14
15
namespace JS {
16
17
struct PrivateName {
18
0
    PrivateName() = default;
19
    PrivateName(u64 unique_id, DeprecatedFlyString description)
20
0
        : unique_id(unique_id)
21
0
        , description(move(description))
22
0
    {
23
0
    }
24
25
    u64 unique_id { 0 };
26
    DeprecatedFlyString description;
27
28
    bool operator==(PrivateName const& rhs) const;
29
};
30
31
class PrivateEnvironment : public Cell {
32
    JS_CELL(PrivateEnvironment, Cell);
33
    JS_DECLARE_ALLOCATOR(PrivateEnvironment);
34
35
public:
36
    PrivateName resolve_private_identifier(DeprecatedFlyString const& identifier) const;
37
38
    void add_private_name(DeprecatedFlyString description);
39
40
0
    PrivateEnvironment* outer_environment() { return m_outer_environment; }
41
0
    PrivateEnvironment const* outer_environment() const { return m_outer_environment; }
42
43
private:
44
    explicit PrivateEnvironment(PrivateEnvironment* parent);
45
46
    virtual void visit_edges(Visitor&) override;
47
48
    auto find_private_name(DeprecatedFlyString const& description) const
49
0
    {
50
0
        return m_private_names.find_if([&](PrivateName const& private_name) {
51
0
            return private_name.description == description;
52
0
        });
53
0
    }
54
55
    static u64 s_next_id;
56
57
    GCPtr<PrivateEnvironment> m_outer_environment; // [[OuterEnv]]
58
    Vector<PrivateName> m_private_names;           // [[Names]]
59
    u64 m_unique_id;
60
};
61
62
}