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

ArkScript-lang / Ark / 14574542201

21 Apr 2025 01:44PM UTC coverage: 80.417% (-0.03%) from 80.451%
14574542201

push

github

SuperFola
fix(vm): self referencing values can be printed as such

0 of 3 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

6168 of 7670 relevant lines covered (80.42%)

80721.76 hits per line

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

86.84
/src/arkreactor/VM/Value.cpp
1
#include <Ark/VM/Value.hpp>
2

3
#include <fmt/format.h>
4
#include <fmt/ostream.h>
5

6
namespace Ark
7
{
8
    Value::Value() noexcept :
1,094,013✔
9
        m_type(ValueType::Undefined)
1,094,013✔
10
    {}
2,188,026✔
11

12
    Value::Value(ValueType type) noexcept :
990✔
13
        m_type(type)
990✔
14
    {
990✔
15
        if (type == ValueType::List)
990✔
16
            m_value = std::vector<Value>();
920✔
17
        else if (type == ValueType::String)
70✔
18
            m_value = "";
51✔
19
    }
990✔
20

21
    Value::Value(const int value) noexcept :
18,429✔
22
        m_type(ValueType::Number), m_value(static_cast<double>(value))
18,429✔
23
    {}
36,858✔
24

25
    Value::Value(double value) noexcept :
320,611✔
26
        m_type(ValueType::Number), m_value(value)
320,611✔
27
    {}
641,222✔
28

29
    Value::Value(const std::string& value) noexcept :
19,157✔
30
        m_type(ValueType::String), m_value(value)
19,157✔
31
    {}
38,314✔
32

33
    Value::Value(internal::PageAddr_t value) noexcept :
124,040✔
34
        m_type(ValueType::PageAddr), m_value(value)
124,040✔
35
    {}
248,080✔
36

37
    Value::Value(Value::ProcType value) noexcept :
53✔
38
        m_type(ValueType::CProc), m_value(value)
53✔
39
    {}
106✔
40

41
    Value::Value(std::vector<Value>&& value) noexcept :
57✔
42
        m_type(ValueType::List), m_value(std::move(value))
57✔
43
    {}
57✔
44

45
    Value::Value(internal::Closure&& value) noexcept :
804✔
46
        m_type(ValueType::Closure), m_value(std::move(value))
804✔
47
    {}
804✔
48

49
    Value::Value(UserType&& value) noexcept :
7✔
50
        m_type(ValueType::User), m_value(value)
7✔
51
    {}
7✔
52

53
    Value::Value(Value* ref) noexcept :
17,185✔
54
        m_type(ValueType::Reference), m_value(ref)
17,185✔
55
    {}
34,370✔
56

57
    void Value::push_back(const Value& value)
3,584✔
58
    {
3,584✔
59
        list().emplace_back(value);
3,584✔
60
    }
3,584✔
61

62
    void Value::push_back(Value&& value)
×
63
    {
×
64
        list().emplace_back(std::move(value));
×
65
    }
×
66

67
    std::string Value::toString(VM& vm) const noexcept
439✔
68
    {
439✔
69
        switch (valueType())
439✔
70
        {
129✔
71
            case ValueType::Number:
72
                return fmt::format("{}", number());
421✔
73

74
            case ValueType::String:
75
                return string();
292✔
76

77
            case ValueType::PageAddr:
78
                return fmt::format("Function @ {}", pageAddr());
1✔
79

80
            case ValueType::CProc:
81
                return "CProcedure";
11✔
82

83
            case ValueType::List:
84
            {
85
                std::string out = "[";
10✔
86
                for (auto it = constList().begin(), it_end = constList().end(); it != it_end; ++it)
37✔
87
                {
88
                    if (it->valueType() == ValueType::String)
27✔
89
                        out += "\"" + it->toString(vm) + "\"";
4✔
90
                    else
91
                        out += it->toString(vm);
23✔
92
                    if (it + 1 != it_end)
27✔
93
                        out += " ";
17✔
94
                }
27✔
95
                return out + "]";
10✔
96
            }
11✔
97

98
            case ValueType::Closure:
99
                return closure().toString(vm);
1✔
100

101
            case ValueType::User:
102
                return fmt::format("{}", fmt::streamed(usertype()));
3✔
103

104
            case ValueType::Nil:
105
                return "nil";
5✔
106

107
            case ValueType::True:
108
                return "true";
3✔
109

110
            case ValueType::False:
111
                return "false";
1✔
112

113
            case ValueType::Undefined:
114
                return "undefined";
×
115

116
            case ValueType::Reference:
NEW
117
                if (reference() != this)
×
NEW
118
                    return reference()->toString(vm);
×
NEW
119
                return "Ref(self)";
×
120

121
            case ValueType::InstPtr:
122
                return fmt::format("Instruction @ {}", pageAddr());
×
123

124
            default:
125
                return "~\\._./~";
×
126
        }
127
    }
439✔
128
}
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