Skip to content

Commit 6cdab1e

Browse files
committed
Adapt after rebase
Signed-off-by: Stefan Marr <[email protected]>
1 parent 334d591 commit 6cdab1e

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

src/primitives/Vector.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@ static vm_oop_t vecNew(vm_oop_t clazz) {
1616
}
1717

1818
static vm_oop_t vecNewSize(vm_oop_t clazz, vm_oop_t arg) {
19-
int64_t const size = INT_VAL(arg);
19+
int64_t const size = SMALL_INT_VAL(arg);
2020
return Universe::NewVector(size, static_cast<VMClass*>(clazz));
2121
}
2222

2323
static vm_oop_t vecAt(vm_oop_t obj, vm_oop_t arg) {
2424
auto* self = static_cast<VMVector*>(obj);
25-
int64_t const index = INT_VAL(arg);
25+
int64_t const index = SMALL_INT_VAL(arg);
2626
return self->GetStorage(index);
2727
}
2828

2929
static vm_oop_t vecAtAWFY(vm_oop_t obj, vm_oop_t arg) {
3030
auto* self = static_cast<VMVector*>(obj);
31-
int64_t const index = INT_VAL(arg);
31+
int64_t const index = SMALL_INT_VAL(arg);
3232
return self->AWFYGetStorage(index);
3333
}
3434

3535
static vm_oop_t vecAtPut(vm_oop_t obj, vm_oop_t at, vm_oop_t put) {
3636
auto* self = static_cast<VMVector*>(obj); // Cast itself as a VMVector
37-
int64_t const index = INT_VAL(at); // Set the index looking for
37+
int64_t const index = SMALL_INT_VAL(at); // Set the index looking for
3838
// Call method to set the value at index. That deals with 1to0 indexing
3939
// conversion
4040
return self->SetStorage(index, put);
4141
}
4242

4343
static vm_oop_t vecAtPutAWFY(vm_oop_t obj, vm_oop_t at, vm_oop_t put) {
4444
auto* self = static_cast<VMVector*>(obj); // Cast itself as a VMVector
45-
int64_t const index = INT_VAL(at); // Set the index looking for
45+
int64_t const index = SMALL_INT_VAL(at); // Set the index looking for
4646
// Call method to set the value at index. That does not deal with 1to0
4747
// indexing conversion
4848
self->SetStorageAWFY(index, put);

src/vm/Universe.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ VMArray* Universe::NewExpandedArrayFromArray(size_t size, VMArray* array) {
710710
auto* result = new (GetHeap<HEAP_CLS>(),
711711
additionalBytes ALLOC_OUTSIDE_NURSERY(outsideNursery))
712712
VMArray(size, additionalBytes, currentArraySize);
713+
// NOLINTNEXTLINE(misc-redundant-expression)
713714
if ((GC_TYPE == GENERATIONAL) && outsideNursery) {
714715
result->SetGCField(MASK_OBJECT_IS_OLD);
715716
}

src/vmobjects/VMVector.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ VMVector::VMVector(vm_oop_t first, vm_oop_t last, VMArray* storage)
2626
vm_oop_t VMVector::AWFYGetStorage(int64_t index) {
2727
// This is a method that is used by the AWFY tests, it does not handle
2828
// 1-0 indexing conversion
29-
int64_t const first = INT_VAL(load_ptr(this->first));
29+
int64_t const first = SMALL_INT_VAL(load_ptr(this->first));
3030
VMArray* const storage = load_ptr(this->storage);
3131

3232
if (index > storage->GetNumberOfIndexableFields()) {
@@ -39,8 +39,8 @@ vm_oop_t VMVector::AWFYGetStorage(int64_t index) {
3939
}
4040

4141
vm_oop_t VMVector::GetStorage(int64_t index) {
42-
int64_t const first = INT_VAL(load_ptr(this->first));
43-
int64_t const last = INT_VAL(load_ptr(this->last));
42+
int64_t const first = SMALL_INT_VAL(load_ptr(this->first));
43+
int64_t const last = SMALL_INT_VAL(load_ptr(this->last));
4444
VMArray* const storage = load_ptr(this->storage);
4545

4646
if (index < 1 || index > last - first) {
@@ -53,8 +53,8 @@ vm_oop_t VMVector::GetStorage(int64_t index) {
5353

5454
/* Returns the value currently held at that location */
5555
vm_oop_t VMVector::SetStorage(int64_t index, vm_oop_t value) {
56-
int64_t const first = INT_VAL(load_ptr(this->first));
57-
int64_t const last = INT_VAL(load_ptr(this->last));
56+
int64_t const first = SMALL_INT_VAL(load_ptr(this->first));
57+
int64_t const last = SMALL_INT_VAL(load_ptr(this->last));
5858
VMArray* const storage = load_ptr(this->storage);
5959
if (index < 1 || index > first + last) {
6060
return IndexOutOfBounds(first + last - 1, index);
@@ -66,8 +66,8 @@ vm_oop_t VMVector::SetStorage(int64_t index, vm_oop_t value) {
6666

6767
/* AWFY Vector can expand on at:put: core-lib vector cannot*/
6868
void VMVector::SetStorageAWFY(int64_t index, vm_oop_t value) {
69-
int64_t const first = INT_VAL(load_ptr(this->first));
70-
int64_t last = INT_VAL(load_ptr(this->last));
69+
int64_t const first = SMALL_INT_VAL(load_ptr(this->first));
70+
int64_t last = SMALL_INT_VAL(load_ptr(this->last));
7171
VMArray* storage = load_ptr(this->storage);
7272

7373
if (index > storage->GetNumberOfIndexableFields()) {
@@ -88,7 +88,7 @@ void VMVector::SetStorageAWFY(int64_t index, vm_oop_t value) {
8888
}
8989

9090
void VMVector::Append(vm_oop_t value) {
91-
int64_t last = INT_VAL(load_ptr(this->last));
91+
int64_t last = SMALL_INT_VAL(load_ptr(this->last));
9292
VMArray* storage = load_ptr(this->storage);
9393

9494
if (last >= storage->GetNumberOfIndexableFields()) { // Expand the array
@@ -111,8 +111,8 @@ void VMVector::Append(vm_oop_t value) {
111111
}
112112

113113
vm_oop_t VMVector::RemoveLast() {
114-
const int64_t last = INT_VAL(load_ptr(this->last));
115-
const int64_t first = INT_VAL(load_ptr(this->first));
114+
const int64_t last = SMALL_INT_VAL(load_ptr(this->last));
115+
const int64_t first = SMALL_INT_VAL(load_ptr(this->first));
116116

117117
// Throw an error correctly (error: method in som)
118118
if (last == first) {
@@ -130,10 +130,10 @@ vm_oop_t VMVector::RemoveLast() {
130130

131131
vm_oop_t VMVector::RemoveFirst() {
132132
// This method will just increment the first index
133-
int64_t first = INT_VAL(load_ptr(this->first));
133+
int64_t first = SMALL_INT_VAL(load_ptr(this->first));
134134

135135
// Throw an error correctly (error: method in som)
136-
if (first >= INT_VAL(load_ptr(this->last))) {
136+
if (first >= SMALL_INT_VAL(load_ptr(this->last))) {
137137
// VMSafe*Primitive::Invoke will push it right back to the same frame
138138
VMFrame* frame = Interpreter::GetFrame();
139139
vm_oop_t errorMsg =
@@ -142,16 +142,17 @@ vm_oop_t VMVector::RemoveFirst() {
142142
this->Send("error:", args, 1);
143143
return frame->Pop();
144144
}
145-
vm_oop_t itemToRemove = GetStorage(
146-
1); // This is 1 because GetIndexableField handles 1 to 0 indexing
145+
146+
// This is 1 because GetIndexableField handles 1 to 0 indexing
147+
vm_oop_t itemToRemove = GetStorage(1);
147148
first += 1; // Increment the first index
148149
this->first = store_ptr(this->first, NEW_INT(first));
149150
return itemToRemove;
150151
}
151152

152153
vm_oop_t VMVector::RemoveObj(vm_oop_t other) {
153-
const int64_t first = INT_VAL(load_ptr(this->first));
154-
const int64_t last = INT_VAL(load_ptr(this->last));
154+
const int64_t first = SMALL_INT_VAL(load_ptr(this->first));
155+
const int64_t last = SMALL_INT_VAL(load_ptr(this->last));
155156
VMArray* storage = load_ptr(this->storage);
156157

157158
for (int64_t i = first - 1; i < last - 1; ++i) {
@@ -167,10 +168,10 @@ vm_oop_t VMVector::RemoveObj(vm_oop_t other) {
167168
}
168169

169170
vm_oop_t VMVector::Remove(vm_oop_t inx) {
170-
const int64_t first = INT_VAL(load_ptr(this->first));
171-
int64_t last = INT_VAL(load_ptr(this->last));
171+
const int64_t first = SMALL_INT_VAL(load_ptr(this->first));
172+
int64_t last = SMALL_INT_VAL(load_ptr(this->last));
172173
VMArray* storage = load_ptr(this->storage);
173-
int64_t const index = INT_VAL(inx);
174+
int64_t const index = SMALL_INT_VAL(inx);
174175

175176
if (index < 1 || index > last - first) {
176177
return IndexOutOfBounds(first + last - 1, index);
@@ -200,8 +201,8 @@ void VMVector::RemoveAll() {
200201
}
201202

202203
vm_oop_t VMVector::copyStorageArray() {
203-
const int64_t first = INT_VAL(load_ptr(this->first));
204-
const int64_t last = INT_VAL(load_ptr(this->last));
204+
const int64_t first = SMALL_INT_VAL(load_ptr(this->first));
205+
const int64_t last = SMALL_INT_VAL(load_ptr(this->last));
205206
VMArray* storage = load_ptr(this->storage);
206207

207208
VMArray* result = Universe::NewArray(last - first);

src/vmobjects/VMVector.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "../vm/Symbols.h"
66
#include "../vm/Universe.h"
7+
#include "../vmobjects/VMBigInteger.h"
78
#include "../vmobjects/VMInteger.h"
89
#include "../vmobjects/VMObject.h"
910
#include "ObjectFormats.h"
@@ -29,7 +30,7 @@ class VMVector : public VMObject {
2930

3031
/* Return the last element */
3132
[[nodiscard]] inline vm_oop_t GetLast() {
32-
const int64_t last = INT_VAL(load_ptr(this->last));
33+
const int64_t last = SMALL_INT_VAL(load_ptr(this->last));
3334
vm_oop_t returned = GetStorage(last - 1);
3435
return returned;
3536
}
@@ -59,8 +60,8 @@ class VMVector : public VMObject {
5960

6061
/* Size of the Vector */
6162
[[nodiscard]] inline vm_oop_t Size() {
62-
const int64_t first = INT_VAL(load_ptr(this->first));
63-
const int64_t last = INT_VAL(load_ptr(this->last));
63+
const int64_t first = SMALL_INT_VAL(load_ptr(this->first));
64+
const int64_t last = SMALL_INT_VAL(load_ptr(this->last));
6465
return NEW_INT(last - first);
6566
}
6667

0 commit comments

Comments
 (0)