I've ripped out the deep copying, and flattened the bucket usage, but
this results in no memory being freed or reused for the lifetime of the
program.
This is shown most clearly with this script:
```toy
fn makeCounter() {
var counter: int = 0;
fn increment() {
return ++counter;
}
return increment;
}
var tally = makeCounter();
while (true) {
var result = tally();
if (result >= 10_000_000) {
break;
}
}
```
The number of calls vs amount of memory consumed is:
```
function calls -> memory used in megabytes
1_000 -> 0.138128
10_000 -> 2.235536
100_000 -> 21.7021
1_000_000 -> 216.1712
10_000_000 -> 1520.823
```
Obviously this needs to be fixed, as ballooning to gigabytes of memory
in only a moment isn't practical. That will be the next task - to find
some way to free memory that isn't needed anymore.
See #163, #160
Functions are having issues with being copied around, especially
between buckets, leading to the scopes getting looped. The program gets
stuck in 'incrementRefCount()'.
It's past my time limit, so I'll keep working on it tomorrow with a
fresh mind.
All function stuff is still untested.
See #163
If a string exists in the data, instead of being written, the function
'emitCStringToData()' will instead return the address of the match
within the data section.
Then, I can search the jump table for that address, and use the existing
jump entry or append a new one.
Fixes#168
They're no-ops in compilation for now, and param types aren't parsed.
'return' keyword needs to be implemented.
Was distracted by bugfixes in v2 and v2-docs.
The definition of '&&':
Return the first falsy value, or the last value, skipping the evaluation of other operands.
The definition of '||':
Return the first truthy value, or the last value, skipping the evaluation of other operands.
Toy now follows these definitions.
Fixed#154
The results can be found in
'tests/benchmarks/array_allocation/results.md'
The results are disappointing, as 'malloc()' is simply faster in every
possible situation compared to my custom arena allocator.
Toy now fits into the C spec.
Fixed#158
Addendum: MacOS test caught an error:
error: a function declaration without a prototype is deprecated in all versions of C
That took 3 attempts to fix correctly.
Addendum: 'No new line at the end of file' are you shitting me?
I attempted to add '-Wpedantic' to CFLAGS, but it seems that my usage of
the variable length arrays within unions is causing an error that can't
be selectively disabled:
error: invalid use of structure with flexible array member [-Werror=pedantic]
This is the offending code: /source/toy_string.h#L9-L37
It seems that tagged unions, with VLAs within, is simply not allowed.
Unfortunately, my whole string system depends on it. I'll have to find some way
around it.
I've also updated the debugging output in repl/main.c.
Getting the array's length is still not available yet, so I'm not
marking arrays as done - but everything that is there is tested.
I've also tweaked the assert output callbacks to also print 'assert failure'.
I had intended to solve the Advent of Code puzzles in Toy, but they
don't work without arrays. I wasn't able to enable arrays in time, so
I need to focus on doing things correctly.
The most immediate tasks are marked with 'URGENT', and a lot of tests
need writing.