mirror of
https://github.com/corda/corda.git
synced 2025-06-09 19:01:44 +00:00
refactor compile.cpp to delay code generation until after all byte code has been visited; bugfixes
This commit is contained in:
parent
74a0ae3493
commit
ec8fc80ebe
1224
src/compiler.cpp
1224
src/compiler.cpp
File diff suppressed because it is too large
Load Diff
15
src/vector.h
15
src/vector.h
@ -20,13 +20,24 @@ class Vector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
if (data) {
|
if (data and minimumCapacity >= 0) {
|
||||||
s->free(data);
|
s->free(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wrap(uint8_t* data, unsigned capacity) {
|
||||||
|
dispose();
|
||||||
|
|
||||||
|
this->data = data;
|
||||||
|
this->position = 0;
|
||||||
|
this->capacity = capacity;
|
||||||
|
this->minimumCapacity = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void ensure(unsigned space) {
|
void ensure(unsigned space) {
|
||||||
if (position + space > capacity) {
|
if (position + space > capacity) {
|
||||||
|
assert(s, minimumCapacity >= 0);
|
||||||
|
|
||||||
unsigned newCapacity = max
|
unsigned newCapacity = max
|
||||||
(position + space, max(minimumCapacity, capacity * 2));
|
(position + space, max(minimumCapacity, capacity * 2));
|
||||||
uint8_t* newData = static_cast<uint8_t*>(s->allocate(newCapacity));
|
uint8_t* newData = static_cast<uint8_t*>(s->allocate(newCapacity));
|
||||||
@ -101,7 +112,7 @@ class Vector {
|
|||||||
uint8_t* data;
|
uint8_t* data;
|
||||||
unsigned position;
|
unsigned position;
|
||||||
unsigned capacity;
|
unsigned capacity;
|
||||||
unsigned minimumCapacity;
|
int minimumCapacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace vm
|
} // namespace vm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user