aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Add support for pointers! (tests missing)Mustafa Quraish2022-02-024-17/+30
| | | | | | | | | | This commit adds initial support for taking pointers / dereferencing. The type system is still a bit of a hot mess, so all type information is actually not looked at, but the functionality still seems to be there. Still need to add some tests for pointers/dereferencing to ensure that it works in some edge cases as well.
* Refactor variable access+assignment in terms of `generate_lvalue()`Mustafa Quraish2022-02-021-20/+21
| | | | This will make it trivial to compute pointers!
* Add `size_for_type()` helper instead of hard-coding variable sizesMustafa Quraish2022-02-023-5/+16
|
* Modify how types are stored.Mustafa Quraish2022-02-024-99/+143
| | | | | | | We now dynamically allocate the type structure, and recursively store a reference to the original type if it's a pointer. For now it's a little bit of a waste but it helps us future-proof stuff for more complex things to come
* Defer: Pop elements off the defer-stack when returningMustafa Quraish2022-02-011-2/+4
| | | | | | | | | | | | | We restore the count later, but this fix makes it so that the compiler doesn't get stuck in an infinite loop when you try to compile the following code: ``` fn main(): int { defer return 5; return 1; } ```
* Add basic `defer` implementation.Mustafa Quraish2022-02-014-0/+27
| | | | | | We don't have any closures yet, so it's essentially the same as just moving the statement after the `defer` keyword to the end of the block/ right before returning from the function.
* Global variables now supported! + some fixes to OP_ASSIGNMustafa Quraish2022-01-314-42/+93
| | | | | | Previously we weren't creating a new assignment node, and this was causing all sorts of funky errors. This commit also fixes that, and we can now use global variables :^)
* Add ability to import other filesMustafa Quraish2022-01-314-3/+62
| | | | | | This still requires a lot of work to avoid duplicate imports, and handle cyclic imports, but it is a good enough for small examples which just want to include some common definitions from std/
* Minor fixes to code generationMustafa Quraish2022-01-311-11/+11
| | | | | | | (1) Prefix function names with `func_` now, to avoid clasing with possible NASM keywords (such as `abs`). (2) Label numbers are now properly handed for conditional expressions.
* Fix offset for local variablesMustafa Quraish2022-01-311-1/+1
| | | | | | The stack actually grows downwards, so we need to account for that. The previous implementation was incorrect and exploded if you tried to use local variables in other functions except main.
* Make `Lexer_new` return a pointer instead of the object.Mustafa Quraish2022-01-313-8/+8
|
* Add basic builtin-function supportMustafa Quraish2022-01-313-35/+158
| | | | | | | This isn't really super extendible for now, but it's a start and gives us the `print` builtin which allows us to finally actually print out values to the screen, so we can move away from testing with exit codes eventually.
* Put tokens in their own macro to allow looping over themMustafa Quraish2022-01-304-30/+36
|
* Rename `cup` directory to `src`Mustafa Quraish2022-01-3014-0/+1781