Finished
defers today (I didn't forbid assignments, only declarations, breaks and continue).
Continuing with the idea of assignments(from `if`s and `while`s),
I've added "initializer" to defer so it's possible to capture values manually:
| mem := malloc(10); defer(p:=mem) {free(p);}
mem = malloc(100); defer(p:=mem) {free(p);}
|
Compare to
| mem := malloc(10); defer {free(mem);}
mem = malloc(100); defer {free(mem);}
|
where program would double free the same pointer
Idea is to have automatic captures someday and it's a scaffold for it which can be used manually for now. (On C side it just creates variable name, based on which p is used).
From other things. I've added a new modifier - @essential. A function is essential, if its return value can't be ignored. It's like __attribute__((warn_unused_result)) in gcc, only not a warning, but an error.
And asserts now work more or less and can print ast(that was used before c codegen) and
values of expressions if something goes wrong or you just ask it to print everything. They support only integers now though, but still now I can test compiler using it itself
which I'll probably do more in a future. Testing from inside of C is pain and suffering.