aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* [cup] Add `>>` and `<<` operators, `fork()` buildin and `SYS_execve`HEADmasterMustafa Quraish2022-02-0811-4/+57163
|
* Mark bootstrap files as binary in `.gitattributes`Mustafa Quraish2022-02-081-1/+2
|
* [cup] Remove unnecessary function from codegen, add info to READMEMustafa Quraish2022-02-072-12/+16
|
* [cup] Self-hosting is now possible! Make some tweaks to match C outputMustafa Quraish2022-02-0711-90/+390
| | | | | | | | | | | 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 missing files to self-hosted directoryMustafa Quraish2022-02-074-0/+271
| | | | ... Someone forgot to add them into the repo for a while.
* [cup] Add support for `here` keyword + fix `putu_buffer` bugMustafa Quraish2022-02-072-3/+19
|
* [cup] Add support for string literalsMustafa Quraish2022-02-071-0/+28
|
* [cup] Port over all the type-checking/pointer arithmetic stuffMustafa Quraish2022-02-074-26/+252
| | | | | | | | | There's still some work to be done when checking function call args, etc, but the general mechanism of actually propagating the type back up the AST is now here from the C compiler. ... Not to say that was very good, but it's passable enough for now. More improvements to come in the future!
* [cup] Add ability to import filesMustafa Quraish2022-02-073-15/+76
|
* [C]: Add `here` keyword that evaluates to a string with it's locationMustafa Quraish2022-02-065-18/+28
| | | | | | | | | It's not really a keyword like the other ones, but just handled completely at the lexer level since it already knows the location of the token, so it injects a string literal instead. We also use this in the self-hosted compiler now for better error reporting for where the error happened internally.
* Add some information to the READMEMustafa Quraish2022-02-061-3/+118
|
* [cup] Flesh out some more boilerplate based on C implementationMustafa Quraish2022-02-062-2/+145
| | | | | | No feature has really been fully added here, just fleshing out some more of the global variables / functions / conditions here so it's easier to implement them later on
* [cup] Add support for global (initialized) variablesMustafa Quraish2022-02-062-1/+58
|
* [cup] Add support for builtin functions, add `print()`Mustafa Quraish2022-02-054-2/+24
|
* [cup] Fix error in codegen for `if`Mustafa Quraish2022-02-051-3/+2
|
* [compiler.cup] Support for+while loopsMustafa Quraish2022-02-052-2/+77
|
* Update `run.sh2` to not re-make the C compilerMustafa Quraish2022-02-051-7/+6
|
* [compiler.cup] Add support for function calls!Mustafa Quraish2022-02-054-12/+130
|
* [compiler.cup] codegen for unary ops, short circuiting &&/||Mustafa Quraish2022-02-052-1/+66
|
* [compiler.cup] Add codegen for relational + if/conditional supportMustafa Quraish2022-02-052-2/+96
|
* [compiler.cup] Add support for lexically scoped local variablesMustafa Quraish2022-02-057-20/+177
|
* Add implementation of self-hosted compiler so farMustafa Quraish2022-02-059-0/+1574
| | | | | | | | | There's also a `run.sh2` script which does the following: - Compiles the C compiler `build/cupcc` - Compiles the self-hosted compiler `build/cup.out` (with `cupcc`) - Compiles the specified file on CLI with `build/cup.out` - Runs this exectuable and shows the output
* Remove old test which disallowed initializing globalsMustafa Quraish2022-02-051-8/+0
|
* Some very minor fixes (look at message)Mustafa Quraish2022-02-052-1/+3
| | | | | (1) Add support for escaped single quotes (2) Fix `putu_buffer` in `std/common.cup`
* Allow empty return statements for void functionsMustafa Quraish2022-02-052-4/+15
|
* Fix label counts during code generation for `||` and `&&`Mustafa Quraish2022-02-051-10/+10
|
* Add `lseek` and `mmap` syscall infoMustafa Quraish2022-02-052-1/+24
|
* Allow function declarations without a definitionMustafa Quraish2022-02-053-14/+41
|
* Handle command-line arguments properly on linuxMustafa Quraish2022-02-051-4/+13
| | | | | | | Turns out they're supposed to be accessed on the stack there. For macOS, because 16 byte-alignment is "required", we don't know the exact position of the arguments and that they're also passed in through `rdi` and `rsi`
* Add `OS_IS_MACOS` and `OS_IS_LINUX` constants as builtinsMustafa Quraish2022-02-051-0/+8
|
* Add support for some more binary ops: |, &, ^Mustafa Quraish2022-02-058-18/+98
|
* Miscellaneous stdlib additionsMustafa Quraish2022-02-051-5/+41
| | | | | | - `close()` syscall - `putu_buffer()` - toy `malloc()` which can allocate from a 1gb pool without freeing.
* Add `sizeof(<type>)` operator that can return the size of a type.Mustafa Quraish2022-02-052-0/+9
|
* Add ability to initialize global variablesMustafa Quraish2022-02-053-4/+14
| | | | The code to initialize them is put right before calling `main()`
* Add `void` type and allow void* to be assigned to other ptr typesMustafa Quraish2022-02-055-9/+24
|
* Allow `builtins.c` to inject constants into program, use for syscallsMustafa Quraish2022-02-057-90/+204
| | | | | | 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 :^)
* Update README.mdMustafa Quraish2022-02-041-2/+2
|
* Add an enum-like-but-not-really structureMustafa Quraish2022-02-042-0/+49
| | | | | | Basically, it looks like an enum but it isn't actually a type. It just behaves like a container to number all the (global) constants defined within it.
* Some minor bug fixesMustafa Quraish2022-02-042-4/+12
| | | | | | (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-044-25/+28
|
* Don't open/parse a file that's been included more than onceMustafa Quraish2022-02-041-21/+39
| | | | | We don't use absolute paths or anything fancy right now, but it's a basic prototype which can be extended upon.
* Add support for read-only constant expressionsMustafa Quraish2022-02-044-7/+121
| | | | | | | 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 some simple tests for arrays+stringsMustafa Quraish2022-02-031-0/+131
|
* Add `exit()` syscall builtinMustafa Quraish2022-02-031-0/+3
|
* Modify implementation of structs to support unionsMustafa Quraish2022-02-034-13/+19
| | | | | | 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-038-6/+192
| | | | | | | | 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 automatic type inference for initialized variable declarationsMustafa Quraish2022-02-031-17/+27
| | | | | | If we know the type of the expression on the RHS, and no type is specified, then we can just assume that the variable has the same type.
* Add pre-increment and pre-decrement operators.Mustafa Quraish2022-02-032-2/+34
| | | | | | 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 an implicit block around a `for` loop, allow statement initMustafa Quraish2022-02-031-12/+27
| | | | | Now we can have variable declarations as part of the initialization of the for loop, and it can only be accessed within the loop.
* Make `make test` exit early if any of the tests failMustafa Quraish2022-02-031-1/+1
|