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

ArkScript-lang / Ark / 13344738465

15 Feb 2025 11:50AM UTC coverage: 77.022% (-1.9%) from 78.929%
13344738465

Pull #510

github

web-flow
Merge 70d135e0e into dd2f0e5fc
Pull Request #510: wip

5695 of 7394 relevant lines covered (77.02%)

44192.48 hits per line

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

87.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 :
475,487✔
9
        m_type(ValueType::Undefined)
475,487✔
10
    {}
950,974✔
11

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

21
    Value::Value(const int value) noexcept :
1,128✔
22
        m_type(ValueType::Number), m_value(static_cast<double>(value))
1,128✔
23
    {}
2,256✔
24

25
    Value::Value(double value) noexcept :
299,622✔
26
        m_type(ValueType::Number), m_value(value)
299,622✔
27
    {}
599,244✔
28

29
    Value::Value(const std::string& value) noexcept :
1,730✔
30
        m_type(ValueType::String), m_value(value)
1,730✔
31
    {}
3,460✔
32

33
    Value::Value(internal::PageAddr_t value) noexcept :
115,055✔
34
        m_type(ValueType::PageAddr), m_value(value)
115,055✔
35
    {}
230,110✔
36

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

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

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

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

53
    Value::Value(Value* ref) noexcept :
8,237✔
54
        m_type(ValueType::Reference), m_value(ref)
8,237✔
55
    {}
16,474✔
56

57
    void Value::push_back(const Value& value)
1,356✔
58
    {
1,356✔
59
        list().emplace_back(value);
1,356✔
60
    }
1,356✔
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
210✔
68
    {
210✔
69
        switch (valueType())
210✔
70
        {
74✔
71
            case ValueType::Number:
72
                return fmt::format("{}", number());
193✔
73

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

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

80
            case ValueType::CProc:
81
                return "CProcedure";
10✔
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:
117
                return reference()->toString(vm);
×
118

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

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