aboutsummaryrefslogtreecommitdiff
path: root/src/types.c
Commit message (Collapse)AuthorAgeFilesLines
* Add support for some more binary ops: |, &, ^Mustafa Quraish2022-02-051-0/+3
|
* Add `void` type and allow void* to be assigned to other ptr typesMustafa Quraish2022-02-051-1/+9
|
* Some minor bug fixesMustafa Quraish2022-02-041-3/+5
| | | | | | (1) Return correct size for unions (2) Make sure function name identifier doesn't exist (3) Assign `<anonymous>` as display name for nested compound types
* Minor fixes, rearranging, whitespace trimming. No functional changes.Mustafa Quraish2022-02-041-12/+12
|
* Modify implementation of structs to support unionsMustafa Quraish2022-02-031-4/+7
| | | | | | This was simple enough, we just needed to change the part where we were computing the offset for each field, and the total size of the compound structure.
* Add support for basic structsMustafa Quraish2022-02-031-3/+51
| | | | | | | | 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 pre-increment and pre-decrement operators.Mustafa Quraish2022-02-031-0/+1
| | | | | | The implementation is very hacky, maybe there's a better way to go about doing this. Maybe just keep it as single AST node and do the work during codegen?
* Add helper to create builtins for syscalls + implement `read()`Mustafa Quraish2022-02-031-0/+1
| | | | | | | | | | This was possible, but very tedious to do by hand before. Now we automate it based on the number of arguments. Note that currently we can't just add `syscall3()` etc as builtins because the actual numbers for the system calls vary from one system to another, and we want to maintain support for macOS and Linux (at least for now).
* Check for integer-like types in type-checking instead of exact onesMustafa Quraish2022-02-031-7/+7
| | | | Since we allow implicit conversions now the exact type is less relevant.
* Remove `putc` intrinsic and replace with `write(fd, buf, size)`Mustafa Quraish2022-02-031-0/+8
| | | | | `putc`, `puts`, and `putnum` in `std/common.cup` are now implemented in terms of the `write()` syscall.
* Allow implicitly converting between integer-like-typesMustafa Quraish2022-02-031-0/+23
| | | | This design should also be useful for structs down the road.
* Avoid pointer-arithmetic multiplications if we have `char*`Mustafa Quraish2022-02-031-24/+34
| | | | Simple optimization, it was just adding extra overhead anyway.
* Add support for `char` type + string/char literalsMustafa Quraish2022-02-021-7/+21
| | | | | | | | | | | 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.
* Add initial support for arrays (also no testing)Mustafa Quraish2022-02-021-1/+19
| | | | | | 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-0/+186
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.