Multiple bugfixes, read more

* expand() will only touch the memory once
* fixed missing if-else cascade at toy_routine.c:90
* unary negate will not optimise numbers unless the '-' character is immediately prior
* fixed broken test for unary negation of groups
This commit is contained in:
2024-09-20 21:39:02 +10:00
parent ad6f1c3067
commit 78320e53bb
4 changed files with 50 additions and 30 deletions

View File

@@ -9,10 +9,12 @@
//utils
static void expand(Toy_Bytecode* bc, int amount) {
while (bc->count + amount > bc->capacity) {
if (bc->count + amount > bc->capacity) {
int oldCapacity = bc->capacity;
bc->capacity = TOY_GROW_CAPACITY(oldCapacity);
while (bc->count + amount > bc->capacity) {
bc->capacity = TOY_GROW_CAPACITY(bc->capacity);
}
bc->ptr = TOY_GROW_ARRAY(unsigned char, bc->ptr, oldCapacity, bc->capacity);
}
}