A project exploring compiler bootstrapping. The first commit is a c-subset compiler that can compile itself. Each commit after adds a new feature, and is compiled by the previous commit.
-
Add correct integer types (i8, i16, i32, i64) and (u8, u16, u32, u64).
-
Add
ascast operator. -
Remove implicit casts.
-
Support multiple file imports.
-
Type safe enums.
enum Foo { A, B }; enum Foo x = Foo::A;
-
Change type syntax to
let foo: typeand func tofunc foo() -> type.let x: i32 = 5;func foo() -> i32 { return 5; }
-
Fix static arrays, and decay from array to pointer.
- Index only for array & future slice types, or pointers to them.
- Pointer to array can be converted to pointer to first elem for C interop.
-
Switch statements that make sense.
-
Struct init and struct expressions.
Foo{x = 1, y = 2}?
-
Avoid aggregates in LLVM registers.
- Aggregates are represented as
ptrto them on stack. - Except for function args, returns, struct members.
a = bfor aggregate creates memcpy.Foo{a = 1}generatesalloca- Function args and ret need to be store/loaded.
- Aggregates are represented as
-
Type safe unions.
-
Rename
NULLtonull -
Let expressions,
if (let a = x as foo)support. -
Auto
&on union -> struct ptr casts? -
Support extern for external functions.
-
Remove function declarations, supporting use before define.
-
Fix relative imports, split source to
src/sema/... -
bool(i1) type. -
Model LLVM IR.
-
Constants
const x = 12; -
Platform specific code:
- Add host machine constants (
__WIN32__,__LINUX__, etc). - Host specific imports
libc.win32.b,libc.linux.b, loaded if exists. - Target command line flag.
- Add host machine constants (
-
Fix windows/mingw builds.
-
Fix
realpath&dprintfusage. -
Move decl, stmt and expr to Unions.
-
typeof(foo)expression to do:sizeof(typeof(foo))let x: typeof(foo) = 12
-
Function types & function pointer support.
-
No semicolons for decls.
-
Add target pointer size, Add iptr and uptr types.
-
Generic functions.
func foo<T>(a: T, b: T) -> T { return a + b; }
-
is[T, U](union: U*) -> boolfunction.is[T, U](union: U*) -> bool { return union as T* != NULL; }
-
Generic types
-
Isolated imports.
-
Methods and method call syntax
a.foo(...)->Foo::foo(a, ...)
-
Add slice type.
-
syntax: slice:
[i8], arrayi8[N]ori8[] = [1, 2] -
stored as
{ ptr: T*, len: isize } -
arrays become
[1, 2, 3] -
array to slice:
array[start:end]start & end are optional -
array or pointer to it? can be converted to slice implicitly
-
-
aarch64 backend
-
Remove intrinsic lists for types, cache types.
-
Add references?
-
Actual constant expressions and decls.
-
Correctly padded structs.
-
continue statement.
-
x86_64 backend
- Report all sema'd files in -sema-lsp
- Send empty list of diagnostics for clean files.
- Add formatter support.
- Don't stop on first sema fail.
- Workspace symbols? Autocomplete? ...
- Add output & in-place argument
- Preserve newlines and comments in unions.
- Preserve char constants.
- Fix trailing comments in block scopes.
- Preserve newline between comments, and comments & code.
- Fix newline bugs
let x = y + zDon't split after=if+is moved to new line. - Auto split based on max line length (88 chars?)