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

ArkScript-lang / Ark / 24356581947

13 Apr 2026 05:12PM UTC coverage: 94.045% (+0.1%) from 93.946%
24356581947

Pull #677

github

web-flow
Merge e28a547be into a3329d309
Pull Request #677: wip

24 of 24 new or added lines in 2 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

9870 of 10495 relevant lines covered (94.04%)

659551.72 hits per line

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

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

3
#include <Ark/Constants.hpp>
4

5
#include <cassert>
6

7
namespace Ark::internal
8
{
9
    ScopeView::ScopeView(pair_t* storage, const std::size_t start) noexcept :
173,771✔
10
        m_storage(storage), m_start(start), m_size(0), m_min_id(MaxValue16Bits), m_max_id(0)
173,771✔
11
    {}
347,542✔
12

13
    void ScopeView::insertFront(const std::vector<pair_t>& values) noexcept
1✔
14
    {
1✔
15
        const std::size_t offset_by = values.size();
1✔
16
        // If there is one day a bug with bad references, this can be caused by this code,
17
        // called when inserting plugins variables in a scope (because we invalidate said
18
        // references by moving them to another slot inside m_storage).
19
        for (std::size_t i = 0; i < m_size; ++i)
2✔
20
        {
21
            // This is a weak attempt to prevent / notice the bug before it goes in production,
22
            // if you hit this assertion read the comments carefully!
23
            assert(m_storage[m_start + m_size - i - 1].second.valueType() != ValueType::Reference && "References can not be moved around!");
1✔
24
            m_storage[m_start + m_size - i + offset_by - 1] = m_storage[m_start + m_size - i - 1];
1✔
25
        }
1✔
26

27
        std::size_t i = 0;
1✔
28
        for (const pair_t& pair : values)
2✔
29
        {
30
            const uint16_t id = pair.first;
1✔
31
            if (id < m_min_id)
1✔
32
                m_min_id = id;
×
33
            if (id > m_max_id)
1✔
34
                m_max_id = id;
1✔
35

36
            m_storage[m_start + i] = pair;
1✔
37
            ++i;
1✔
38
        }
1✔
39

40
        m_size += offset_by;
1✔
41
    }
1✔
42

43
    uint16_t ScopeView::idFromValue(const Value& val) const noexcept
2,096,142✔
44
    {
2,096,142✔
45
        for (std::size_t i = m_start; i < m_start + m_size; ++i)
4,192,281✔
46
        {
47
            const auto& [id, value] = m_storage[i];
2,098,187✔
48
            if (value == val)
2,096,139✔
49
                return id;
2,048✔
50
        }
2,096,139✔
51
        return MaxValue16Bits;
2,094,094✔
52
    }
2,096,142✔
53

UNCOV
54
    bool operator==(const ScopeView& A, const ScopeView& B) noexcept
×
UNCOV
55
    {
×
56
        // if we have two scopes with the same number of elements and starting at the same position,
57
        // they must be identical, as we have a single storage for all scopes
58
        return A.m_size == B.m_size && A.m_start == B.m_start;
×
59
    }
60
}
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