refactor compile.cpp to delay code generation until after all byte code has been visited; bugfixes

This commit is contained in:
Joel Dice 2007-12-13 17:27:09 -07:00
parent 74a0ae3493
commit ec8fc80ebe
2 changed files with 717 additions and 526 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,13 +20,24 @@ class Vector {
}
void dispose() {
if (data) {
if (data and minimumCapacity >= 0) {
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) {
if (position + space > capacity) {
assert(s, minimumCapacity >= 0);
unsigned newCapacity = max
(position + space, max(minimumCapacity, capacity * 2));
uint8_t* newData = static_cast<uint8_t*>(s->allocate(newCapacity));
@ -101,7 +112,7 @@ class Vector {
uint8_t* data;
unsigned position;
unsigned capacity;
unsigned minimumCapacity;
int minimumCapacity;
};
} // namespace vm