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

ArkScript-lang / Ark / 20641844879

01 Jan 2026 04:26PM UTC coverage: 92.744% (+0.5%) from 92.251%
20641844879

push

github

SuperFola
feat(builtin): disassemble can show a file bytecode

14 of 14 new or added lines in 1 file covered. (100.0%)

3 existing lines in 1 file now uncovered.

8487 of 9151 relevant lines covered (92.74%)

281143.99 hits per line

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

96.84
/src/arkreactor/VM/Value.cpp
1
#include <Ark/VM/Value.hpp>
2
#include <Ark/VM/Value/Procedure.hpp>
3
#include <Ark/VM/Value/Dict.hpp>
4

5
#include <fmt/format.h>
6
#include <fmt/ostream.h>
7

8
namespace Ark
9
{
10
    Value::Value() noexcept :
2,832,909✔
11
        m_type(ValueType::Undefined)
2,832,909✔
12
    {}
5,665,818✔
13

14
    Value::Value(ValueType type) noexcept :
2,257✔
15
        m_type(type)
2,257✔
16
    {
2,257✔
17
        if (type == ValueType::List)
2,257✔
18
            m_value = List_t();
2,187✔
19
        else if (type == ValueType::String)
70✔
20
            m_value = std::string();
51✔
21
    }
2,257✔
22

23
    Value::Value(const int value) noexcept :
21,203✔
24
        m_type(ValueType::Number), m_value(static_cast<double>(value))
21,203✔
25
    {}
42,406✔
26

27
    Value::Value(const double value) noexcept :
359,593✔
28
        m_type(ValueType::Number), m_value(value)
359,593✔
29
    {}
719,186✔
30

31
    Value::Value(const String_t& value) noexcept :
24,275✔
32
        m_type(ValueType::String), m_value(value)
24,275✔
33
    {}
48,550✔
34

35
    Value::Value(const char* value) noexcept :
337✔
36
        m_type(ValueType::String), m_value(std::string(value))
337✔
37
    {}
337✔
38

39
    Value::Value(internal::PageAddr_t value) noexcept :
148,029✔
40
        m_type(ValueType::PageAddr), m_value(value)
148,029✔
41
    {}
296,058✔
42

43
    Value::Value(Procedure&& value) noexcept :
67✔
44
        m_type(ValueType::CProc), m_value(std::move(value))
67✔
45
    {}
67✔
46

47
    Value::Value(List_t&& value) noexcept :
97✔
48
        m_type(ValueType::List), m_value(std::move(value))
97✔
49
    {}
97✔
50

51
    Value::Value(internal::Closure&& value) noexcept :
2,763✔
52
        m_type(ValueType::Closure), m_value(std::move(value))
2,763✔
53
    {}
2,763✔
54

55
    Value::Value(UserType&& value) noexcept :
18✔
56
        m_type(ValueType::User), m_value(value)
18✔
57
    {}
18✔
58

59
    Value::Value(Dict_t&& value) noexcept :
39✔
60
        m_type(ValueType::Dict), m_value(std::make_shared<Dict_t>(std::move(value)))
39✔
61
    {}
78✔
62

63
    Value::Value(Ref_t ref) noexcept :
42,597✔
64
        m_type(ValueType::Reference), m_value(ref)
42,597✔
65
    {}
85,194✔
66

67
    void Value::push_back(const Value& value)
5,355✔
68
    {
5,355✔
69
        list().emplace_back(value);
5,355✔
70
    }
5,355✔
71

72
    void Value::push_back(Value&& value)
1✔
73
    {
1✔
74
        list().emplace_back(std::move(value));
1✔
75
    }
1✔
76

77
    std::string Value::toString(VM& vm, const bool show_as_code) const noexcept
980✔
78
    {
980✔
79
        switch (valueType())
980✔
80
        {
410✔
81
            case ValueType::Number:
82
                return fmt::format("{}", number());
929✔
83

84
            case ValueType::String:
85
                if (show_as_code)
519✔
86
                    return fmt::format("\"{}\"", string());
110✔
87
                return string();
421✔
88

89
            case ValueType::PageAddr:
90
                return fmt::format("Function@{}", pageAddr());
13✔
91

92
            case ValueType::CProc:
93
                return "CProcedure";
17✔
94

95
            case ValueType::List:
96
            {
97
                std::string out = "[";
16✔
98
                for (auto it = constList().begin(), it_end = constList().end(); it != it_end; ++it)
52✔
99
                {
100
                    if (it->valueType() == ValueType::String)
36✔
101
                        out += "\"" + it->toString(vm) + "\"";
4✔
102
                    else
103
                        out += it->toString(vm);
32✔
104
                    if (it + 1 != it_end)
36✔
105
                        out += " ";
23✔
106
                }
36✔
107
                return out + "]";
16✔
108
            }
17✔
109

110
            case ValueType::Closure:
111
                return closure().toString(vm);
2✔
112

113
            case ValueType::User:
114
                return fmt::format("{}", fmt::streamed(usertype()));
2✔
115

116
            case ValueType::Dict:
117
                return dict().toString(vm);
7✔
118

119
            case ValueType::Nil:
120
                return "nil";
12✔
121

122
            case ValueType::True:
123
                return "true";
7✔
124

125
            case ValueType::False:
126
                return "false";
1✔
127

128
            case ValueType::Undefined:
129
                return "undefined";
6✔
130

131
            case ValueType::Reference:
132
                if (reference() != this)
6✔
133
                    return reference()->toString(vm);
6✔
UNCOV
134
                return "Ref(self)";
×
135

136
            case ValueType::InstPtr:
UNCOV
137
                return fmt::format("Instruction@{}", pageAddr());
×
138

139
            default:
UNCOV
140
                return "~\\._./~";
×
141
        }
142
    }
980✔
143

144
    bool operator==(const Value& A, const Value& B) noexcept
2,211,154✔
145
    {
2,211,154✔
146
        // values should have the same type
147
        if (A.m_type != B.m_type)
2,211,154✔
148
            return false;
2,096,734✔
149
        // all the types >= Nil are Nil itself, True, False, Undefined
150
        if (A.typeNum() >= static_cast<uint8_t>(ValueType::Nil))
114,420✔
151
            return true;
851✔
152

153
        if (A.valueType() == ValueType::Dict)
113,569✔
154
            return A.dict() == B.dict();
15✔
155

156
        return A.m_value == B.m_value;
113,554✔
157
    }
2,211,154✔
158
}
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