OpenCoverage

qv4estable.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4estable.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2using namespace QV4;-
3ESTable::ESTable()-
4 : m_capacity(8)-
5{-
6 m_keys = (Value*)malloc(m_capacity * sizeof(Value));-
7 m_values = (Value*)malloc(m_capacity * sizeof(Value));-
8 memset(m_keys, 0, m_capacity);-
9 memset(m_values, 0, m_capacity);-
10}
executed 1188 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1188
11-
12ESTable::~ESTable()-
13{-
14 free(m_keys);-
15 free(m_values);-
16 m_size = 0;-
17 m_capacity = 0;-
18 m_keys = nullptr;-
19 m_values = nullptr;-
20}
executed 1198 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1198
21-
22void ESTable::markObjects(MarkStack *s)-
23{-
24 for (uint i = 0; i < m_size
i < m_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
25 m_keys[i].mark(s);-
26 m_values[i].mark(s);-
27 }
never executed: end of block
0
28}
never executed: end of block
0
29-
30-
31-
32void ESTable::clear()-
33{-
34 m_size = 0;-
35}
executed 52 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
52
36-
37-
38-
39void ESTable::set(const Value &key, const Value &value)-
40{-
41 for (uint i = 0; i < m_size
i < m_sizeDescription
TRUEevaluated 1208 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 901 times by 1 test
Evaluated by:
  • tst_ecmascripttests
; ++i) {
901-1208
42 if (m_keys[i].sameValueZero(key)
m_keys[i].sameValueZero(key)Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 1163 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
44-1163
43 m_values[i] = value;-
44 return;
executed 44 times by 1 test: return;
Executed by:
  • tst_ecmascripttests
44
45 }-
46 }
executed 1163 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
1163
47-
48 if (m_capacity == m_size
m_capacity == m_sizeDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 898 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
4-898
49 uint oldCap = m_capacity;-
50 m_capacity *= 2;-
51 m_keys = (Value*)realloc(m_keys, m_capacity * sizeof(Value));-
52 m_values = (Value*)realloc(m_values, m_capacity * sizeof(Value));-
53 memset(m_keys + oldCap, 0, m_capacity - oldCap);-
54 memset(m_values + oldCap, 0, m_capacity - oldCap);-
55 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
4
56-
57 Value nk = key;-
58 if (nk.isDouble()
nk.isDouble()Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 849 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
56-849
59 if (nk.doubleValue() == 0
nk.doubleValue() == 0Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 32 times by 1 test
Evaluated by:
  • tst_ecmascripttests
&& std::signbit(nk.doubleValue())
std::signbit(nk.doubleValue())Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEnever evaluated
)
0-32
60 nk = Primitive::fromDouble(+0);
executed 24 times by 1 test: nk = Primitive::fromDouble(+0);
Executed by:
  • tst_ecmascripttests
24
61 }
executed 56 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
56
62-
63 m_keys[m_size] = nk;-
64 m_values[m_size] = value;-
65-
66 m_size++;-
67}
executed 904 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
904
68-
69-
70bool ESTable::has(const Value &key) const-
71{-
72 for (uint i = 0; i < m_size
i < m_sizeDescription
TRUEevaluated 276 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 104 times by 1 test
Evaluated by:
  • tst_ecmascripttests
; ++i) {
104-276
73 if (m_keys[i].sameValueZero(key)
m_keys[i].sameValueZero(key)Description
TRUEevaluated 95 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 180 times by 1 test
Evaluated by:
  • tst_ecmascripttests
)
95-180
74 return
executed 95 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
true;
executed 95 times by 1 test: return true;
Executed by:
  • tst_ecmascripttests
95
75 }
executed 180 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
180
76-
77 return
executed 104 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
false;
executed 104 times by 1 test: return false;
Executed by:
  • tst_ecmascripttests
104
78}-
79-
80-
81-
82ReturnedValue ESTable::get(const Value &key, bool *hasValue) const-
83{-
84 for (uint i = 0; i < m_size
i < m_sizeDescription
TRUEevaluated 180 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
; ++i) {
12-180
85 if (m_keys[i].sameValueZero(key)
m_keys[i].sameValueZero(key)Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 116 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
64-116
86 if (hasValue
hasValueDescription
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • tst_ecmascripttests
)
0-64
87 *
never executed: *hasValue = true;
hasValue = true;
never executed: *hasValue = true;
0
88 return
executed 64 times by 1 test: return m_values[i].asReturnedValue();
Executed by:
  • tst_ecmascripttests
m_values[i].asReturnedValue();
executed 64 times by 1 test: return m_values[i].asReturnedValue();
Executed by:
  • tst_ecmascripttests
64
89 }-
90 }
executed 116 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
116
91-
92 if (hasValue
hasValueDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_ecmascripttests
)
0-12
93 *
never executed: *hasValue = false;
hasValue = false;
never executed: *hasValue = false;
0
94 return
executed 12 times by 1 test: return Encode::undefined();
Executed by:
  • tst_ecmascripttests
Encode::undefined();
executed 12 times by 1 test: return Encode::undefined();
Executed by:
  • tst_ecmascripttests
12
95}-
96-
97-
98bool ESTable::remove(const Value &key)-
99{-
100 bool found = false;-
101 uint idx = 0;-
102 for (; idx < m_size
idx < m_sizeDescription
TRUEevaluated 136 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_ecmascripttests
; ++idx) {
28-136
103 if (m_keys[idx].sameValueZero(key)
m_keys[idx].sameValueZero(key)Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
48-88
104 found = true;-
105 break;
executed 88 times by 1 test: break;
Executed by:
  • tst_ecmascripttests
88
106 }-
107 }
executed 48 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
48
108-
109 if (found == true
found == trueDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • tst_ecmascripttests
FALSEevaluated 28 times by 1 test
Evaluated by:
  • tst_ecmascripttests
) {
28-88
110 memmove(m_keys + idx, m_keys + idx + 1, m_size - idx);-
111 memmove(m_values + idx, m_values + idx + 1, m_size - idx);-
112 m_size--;-
113 }
executed 87 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
87
114 return
executed 116 times by 1 test: return found;
Executed by:
  • tst_ecmascripttests
found;
executed 116 times by 1 test: return found;
Executed by:
  • tst_ecmascripttests
116
115}-
116-
117-
118uint ESTable::size() const-
119{-
120 return
executed 836 times by 1 test: return m_size;
Executed by:
  • tst_ecmascripttests
m_size;
executed 836 times by 1 test: return m_size;
Executed by:
  • tst_ecmascripttests
836
121}-
122-
123-
124-
125void ESTable::iterate(uint idx, Value *key, Value *value)-
126{-
127 ((idx < m_size) ? static_cast<void>(0) : qt_assert("idx < m_size", __FILE__, 175));-
128 ((key) ? static_cast<void>(0) : qt_assert("key", __FILE__, 176));-
129 ((value) ? static_cast<void>(0) : qt_assert("value", __FILE__, 177));-
130 *key = m_keys[idx];-
131 *value = m_values[idx];-
132}
executed 400 times by 1 test: end of block
Executed by:
  • tst_ecmascripttests
400
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0