| Commit message (Collapse) | Author | Age | Files | Lines | |
|---|---|---|---|---|---|
| * | [cup] Add `>>` and `<<` operators, `fork()` buildin and `SYS_execve`HEADmaster | Mustafa Quraish | 2022-02-08 | 11 | -4/+57163 |
| | | |||||
| * | Mark bootstrap files as binary in `.gitattributes` | Mustafa Quraish | 2022-02-08 | 1 | -1/+2 |
| | | |||||
| * | [cup] Remove unnecessary function from codegen, add info to README | Mustafa Quraish | 2022-02-07 | 2 | -12/+16 |
| | | |||||
| * | [cup] Self-hosting is now possible! Make some tweaks to match C output | Mustafa Quraish | 2022-02-07 | 11 | -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 directory | Mustafa Quraish | 2022-02-07 | 4 | -0/+271 |
| | | | | | ... Someone forgot to add them into the repo for a while. | ||||
| * | [cup] Add support for `here` keyword + fix `putu_buffer` bug | Mustafa Quraish | 2022-02-07 | 2 | -3/+19 |
| | | |||||
| * | [cup] Add support for string literals | Mustafa Quraish | 2022-02-07 | 1 | -0/+28 |
| | | |||||
| * | [cup] Port over all the type-checking/pointer arithmetic stuff | Mustafa Quraish | 2022-02-07 | 4 | -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 files | Mustafa Quraish | 2022-02-07 | 3 | -15/+76 |
| | | |||||
| * | [C]: Add `here` keyword that evaluates to a string with it's location | Mustafa Quraish | 2022-02-06 | 5 | -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 README | Mustafa Quraish | 2022-02-06 | 1 | -3/+118 |
| | | |||||
| * | [cup] Flesh out some more boilerplate based on C implementation | Mustafa Quraish | 2022-02-06 | 2 | -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) variables | Mustafa Quraish | 2022-02-06 | 2 | -1/+58 |
| | | |||||
| * | [cup] Add support for builtin functions, add `print()` | Mustafa Quraish | 2022-02-05 | 4 | -2/+24 |
| | | |||||
| * | [cup] Fix error in codegen for `if` | Mustafa Quraish | 2022-02-05 | 1 | -3/+2 |
| | | |||||
| * | [compiler.cup] Support for+while loops | Mustafa Quraish | 2022-02-05 | 2 | -2/+77 |
| | | |||||
| * | Update `run.sh2` to not re-make the C compiler | Mustafa Quraish | 2022-02-05 | 1 | -7/+6 |
| | | |||||
| * | [compiler.cup] Add support for function calls! | Mustafa Quraish | 2022-02-05 | 4 | -12/+130 |
| | | |||||
| * | [compiler.cup] codegen for unary ops, short circuiting &&/|| | Mustafa Quraish | 2022-02-05 | 2 | -1/+66 |
| | | |||||
| * | [compiler.cup] Add codegen for relational + if/conditional support | Mustafa Quraish | 2022-02-05 | 2 | -2/+96 |
| | | |||||
| * | [compiler.cup] Add support for lexically scoped local variables | Mustafa Quraish | 2022-02-05 | 7 | -20/+177 |
| | | |||||
| * | Add implementation of self-hosted compiler so far | Mustafa Quraish | 2022-02-05 | 9 | -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 globals | Mustafa Quraish | 2022-02-05 | 1 | -8/+0 |
| | | |||||
| * | Some very minor fixes (look at message) | Mustafa Quraish | 2022-02-05 | 2 | -1/+3 |
| | | | | | | (1) Add support for escaped single quotes (2) Fix `putu_buffer` in `std/common.cup` | ||||
| * | Allow empty return statements for void functions | Mustafa Quraish | 2022-02-05 | 2 | -4/+15 |
| | | |||||
| * | Fix label counts during code generation for `||` and `&&` | Mustafa Quraish | 2022-02-05 | 1 | -10/+10 |
| | | |||||
| * | Add `lseek` and `mmap` syscall info | Mustafa Quraish | 2022-02-05 | 2 | -1/+24 |
| | | |||||
| * | Allow function declarations without a definition | Mustafa Quraish | 2022-02-05 | 3 | -14/+41 |
| | | |||||
| * | Handle command-line arguments properly on linux | Mustafa Quraish | 2022-02-05 | 1 | -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 builtins | Mustafa Quraish | 2022-02-05 | 1 | -0/+8 |
| | | |||||
| * | Add support for some more binary ops: |, &, ^ | Mustafa Quraish | 2022-02-05 | 8 | -18/+98 |
| | | |||||
| * | Miscellaneous stdlib additions | Mustafa Quraish | 2022-02-05 | 1 | -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 Quraish | 2022-02-05 | 2 | -0/+9 |
| | | |||||
| * | Add ability to initialize global variables | Mustafa Quraish | 2022-02-05 | 3 | -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 types | Mustafa Quraish | 2022-02-05 | 5 | -9/+24 |
| | | |||||
| * | Allow `builtins.c` to inject constants into program, use for syscalls | Mustafa Quraish | 2022-02-05 | 7 | -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.md | Mustafa Quraish | 2022-02-04 | 1 | -2/+2 |
| | | |||||
| * | Add an enum-like-but-not-really structure | Mustafa Quraish | 2022-02-04 | 2 | -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 fixes | Mustafa Quraish | 2022-02-04 | 2 | -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 Quraish | 2022-02-04 | 4 | -25/+28 |
| | | |||||
| * | Don't open/parse a file that's been included more than once | Mustafa Quraish | 2022-02-04 | 1 | -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 expressions | Mustafa Quraish | 2022-02-04 | 4 | -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+strings | Mustafa Quraish | 2022-02-03 | 1 | -0/+131 |
| | | |||||
| * | Add `exit()` syscall builtin | Mustafa Quraish | 2022-02-03 | 1 | -0/+3 |
| | | |||||
| * | Modify implementation of structs to support unions | Mustafa Quraish | 2022-02-03 | 4 | -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 structs | Mustafa Quraish | 2022-02-03 | 8 | -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 declarations | Mustafa Quraish | 2022-02-03 | 1 | -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 Quraish | 2022-02-03 | 2 | -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 init | Mustafa Quraish | 2022-02-03 | 1 | -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 fail | Mustafa Quraish | 2022-02-03 | 1 | -1/+1 |
| | | |||||