aboutsummaryrefslogtreecommitdiff
path: root/src/ast.h
Commit message (Collapse)AuthorAgeFilesLines
* Allow function declarations without a definitionMustafa Quraish2022-02-051-0/+2
|
* Add support for some more binary ops: |, &, ^Mustafa Quraish2022-02-051-0/+2
|
* Add support for read-only constant expressionsMustafa Quraish2022-02-041-1/+7
| | | | | | | We can now have constant definitions that are read-only, evaluated at compile time and just behave like integer literals when accessed. These are nice because we can now potentially inject syscall numbers/ etc through the compiler.
* Add support for basic structsMustafa Quraish2022-02-031-0/+7
| | | | | | | | Structs for now (and probably for the near future) are not allowed to be passed by value, and instead you just pass a pointer to it. Nested structs can also be defined, and they can be either anonymous, or named (in which case only the members can access the type).
* Add support for `char` type + string/char literalsMustafa Quraish2022-02-021-0/+2
| | | | | | | | | | | This commit does a few things in one go: - Add support for a `char` type + some changes to support the new size - Add support for character literals. We need some escaping here to be able to use `\n` and `\0`, etc. - Add support for string literals. These are all stored in the `.data` section. Fortunately NASM already handles the escape characters. - Fix some bugs with code generation, specifically using `movsx` to sign extend the smaller types into 64-bit registers.
* Move type-related stuff to a separate fileMustafa Quraish2022-02-021-20/+1
| | | | | | It was getting a bit unwieldy in `parser.c`, and this will potentially help when we start dealing with more complex type-stuff such as casting / conversions / etc.
* Type checking of expressions / functions!Mustafa Quraish2022-02-021-0/+5
| | | | | | | | | | | | | | | | | This is a bit of a chonky commit, but it adds in the basics of checking the types of expressions / function calls / return types. There's still a lot of work to be done, including: (1) Adding new core types, and casting between allowed types automatically (2) Picking the corrent output type based on input types (for instance float+int == float) (3) We need much better error reporting, the error messages are really vague and unhelpful as-is (4) We also need to work to ensure that a function with a return type actually returns (5) Possible re-factoring to make stuff less hacky when we have more types / structs / arrays / etc.
* Add support for pointers! (tests missing)Mustafa Quraish2022-02-021-1/+2
| | | | | | | | | | 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.
* Add `size_for_type()` helper instead of hard-coding variable sizesMustafa Quraish2022-02-021-0/+1
|
* Modify how types are stored.Mustafa Quraish2022-02-021-6/+17
| | | | | | | 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
* Add basic `defer` implementation.Mustafa Quraish2022-02-011-0/+1
| | | | | | 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-311-2/+3
| | | | | | 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 basic builtin-function supportMustafa Quraish2022-01-311-0/+1
| | | | | | | 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.
* Rename `cup` directory to `src`Mustafa Quraish2022-01-301-0/+150