aboutsummaryrefslogtreecommitdiff
path: root/src/builtins.c
Commit message (Collapse)AuthorAgeFilesLines
* [cup] Self-hosting is now possible! Make some tweaks to match C outputMustafa Quraish2022-02-071-2/+2
| | | | | | | | | | | A bit of a chonky commit, but this ports over the remaining (well, almost) everything from the C implementation to the self-hosted compiler. The only things that really remain right now are (1) defer support and (2) support for constants in local scopes. There were used barely enough so for now their uses have been removed, but I'll implement them back later. Not sure how useful (2) is though.
* Add `lseek` and `mmap` syscall infoMustafa Quraish2022-02-051-1/+16
|
* Add `OS_IS_MACOS` and `OS_IS_LINUX` constants as builtinsMustafa Quraish2022-02-051-0/+8
|
* Allow `builtins.c` to inject constants into program, use for syscallsMustafa Quraish2022-02-051-48/+57
| | | | | | We can now directly expose the `syscallN()` APIs to the program and define the `open()`, `write()` etc syscalls in the stdlib. This simplifies the implementation a decent bunch :^)
* Add `exit()` syscall builtinMustafa Quraish2022-02-031-0/+3
|
* Add helper to create builtins for syscalls + implement `read()`Mustafa Quraish2022-02-031-17/+117
| | | | | | | | | | 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).
* Remove `putc` intrinsic and replace with `write(fd, buf, size)`Mustafa Quraish2022-02-031-4/+6
| | | | | `putc`, `puts`, and `putnum` in `std/common.cup` are now implemented in terms of the `write()` syscall.
* Move builtins to a separate fileMustafa Quraish2022-02-031-0/+47
Probably want to add more builtins in the future, so pulling it out of `parser.c` seems like the reasonable thing to do