aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
Commit message (Collapse)AuthorAgeFilesLines
* Add support for some more binary ops: |, &, ^Mustafa Quraish2022-02-051-16/+19
|
* Add ability to initialize global variablesMustafa Quraish2022-02-051-1/+1
| | | | The code to initialize them is put right before calling `main()`
* Add support for basic structsMustafa Quraish2022-02-031-0/+1
| | | | | | | | 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).
* Handle OP_ASSIGN in `print_ast()`Mustafa Quraish2022-02-021-0/+6
|
* Add initial support for arrays (also no testing)Mustafa Quraish2022-02-021-0/+6
| | | | | | Usual disclaimer at this point: Quick&Dirty implementation, hasn't been tested other than basic sanity checks. Arrays are automatically decayed into pointers when the identifier is accessed.
* Move type-related stuff to a separate fileMustafa Quraish2022-02-021-56/+3
| | | | | | 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-4/+25
| | | | | | | | | | | | | | | | | 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-0/+1
| | | | | | | | | | 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/+10
|
* Modify how types are stored.Mustafa Quraish2022-02-021-7/+67
| | | | | | | 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
* Global variables now supported! + some fixes to OP_ASSIGNMustafa Quraish2022-01-311-1/+1
| | | | | | 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 :^)
* Rename `cup` directory to `src`Mustafa Quraish2022-01-301-0/+161