• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArkScript-lang / Ark / 16852602262

09 Aug 2025 06:49PM UTC coverage: 86.842% (-0.03%) from 86.869%
16852602262

Pull #568

github

web-flow
Merge c5673fd08 into c65ea7e5b
Pull Request #568: feat(closures): captures are no longer fully qualified

92 of 113 new or added lines in 13 files covered. (81.42%)

6 existing lines in 2 files now uncovered.

7537 of 8679 relevant lines covered (86.84%)

125769.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.13
/src/arkreactor/VM/ScopeView.cpp
1
#include <Ark/VM/ScopeView.hpp>
2

3
#include <limits>
4

5
namespace Ark::internal
6
{
7
    ScopeView::ScopeView(pair_t* storage, const std::size_t start) noexcept :
141,518✔
8
        m_storage(storage), m_start(start), m_size(0), m_min_id(std::numeric_limits<uint16_t>::max()), m_max_id(0)
141,518✔
9
    {}
283,036✔
10

11
    void ScopeView::push_back(uint16_t id, Value&& val) noexcept
31,617✔
12
    {
31,617✔
13
        if (id < m_min_id)
31,617✔
14
            m_min_id = id;
5,403✔
15
        if (id > m_max_id)
31,617✔
16
            m_max_id = id;
25,048✔
17

18
        m_storage[m_start + m_size] = std::make_pair(id, std::move(val));
31,617✔
19
        ++m_size;
31,617✔
20
    }
31,617✔
21

22
    void ScopeView::push_back(uint16_t id, const Value& val) noexcept
238,927✔
23
    {
238,927✔
24
        if (id < m_min_id)
238,927✔
25
            m_min_id = id;
133,607✔
26
        if (id > m_max_id)
238,927✔
27
            m_max_id = id;
220,132✔
28

29
        m_storage[m_start + m_size] = std::make_pair(id, val);
238,927✔
30
        ++m_size;
238,927✔
31
    }
238,927✔
32

33
    bool ScopeView::maybeHas(const uint16_t id) const noexcept
1,101,359✔
34
    {
1,101,359✔
35
        return m_min_id <= id && id <= m_max_id;
1,101,359✔
36
    }
37

38
    Value* ScopeView::operator[](const uint16_t id_to_look_for) noexcept
1,101,361✔
39
    {
1,101,361✔
40
        if (!maybeHas(id_to_look_for))
1,101,361✔
41
            return nullptr;
602,578✔
42

43
        for (std::size_t i = m_start; i < m_start + m_size; ++i)
2,960,200✔
44
        {
45
            auto& [id, value] = m_storage[i];
2,461,417✔
46
            if (id == id_to_look_for)
2,461,417✔
47
                return &value;
475,807✔
48
        }
2,461,417✔
49
        return nullptr;
22,976✔
50
    }
1,101,361✔
51

NEW
52
    const Value* ScopeView::operator[](const uint16_t id_to_look_for) const noexcept
×
NEW
53
    {
×
NEW
54
        if (!maybeHas(id_to_look_for))
×
NEW
55
            return nullptr;
×
56

NEW
57
        for (std::size_t i = m_start; i < m_start + m_size; ++i)
×
58
        {
NEW
59
            auto& [id, value] = m_storage[i];
×
NEW
60
            if (id == id_to_look_for)
×
NEW
61
                return &value;
×
NEW
62
        }
×
NEW
63
        return nullptr;
×
NEW
64
    }
×
65

66
    uint16_t ScopeView::idFromValue(const Value& val) const noexcept
2,096,130✔
67
    {
2,096,130✔
68
        for (std::size_t i = m_start; i < m_start + m_size; ++i)
4,192,262✔
69
        {
70
            const auto& [id, value] = m_storage[i];
2,098,180✔
71
            if (value == val)
2,096,132✔
72
                return id;
2,048✔
73
        }
2,096,132✔
74
        return std::numeric_limits<uint16_t>::max();
2,094,082✔
75
    }
2,096,130✔
76

77
    void ScopeView::reset() noexcept
31,125✔
78
    {
31,125✔
79
        m_size = 0;
31,125✔
80
        m_min_id = std::numeric_limits<uint16_t>::max();
31,125✔
81
        m_max_id = 0;
31,125✔
82
    }
31,125✔
83

84
    bool operator==(const ScopeView& A, const ScopeView& B) noexcept
×
85
    {
×
86
        // if we have two scopes with the same number of elements and starting at the same position,
87
        // they must be identical, as we have a single storage for all scopes
88
        return A.m_size == B.m_size && A.m_start == B.m_start;
×
89
    }
90
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc