Commit Graph

50 Commits

Author SHA1 Message Date
Christoffer Lerno
e530869aeb Change "cname" to "extname" 2021-06-30 22:36:57 +02:00
Christoffer Lerno
038ed7f9d5 Macro methods added. 2021-06-26 17:42:45 +02:00
Christoffer Lerno
9572c4afc9 Top level $if now uses $if: / $endif; Fix of boolean globals. Fix of $else: clause. Fix of $assert inside of $if 2021-06-24 18:01:59 +02:00
Christoffer Lerno
892c7e8874 Changed generic modules to internal templates. 2021-05-27 08:30:02 +02:00
Christoffer Lerno
dbb067a005 Cleanup. 2021-05-23 21:32:32 +02:00
Christoffer Lerno
1f676c135c Removed func and rewrote typedefs. 2021-05-23 13:16:48 +02:00
Christoffer Lerno
3c4233f4d4 Fixes to failable return from expression and macro blocks. Allow division by float zero. Correct type promotion from compile time float. 2021-05-17 21:17:46 +02:00
Christoffer Lerno
15a65d0c97 Allow use of pthreads to parallelize codegen. 2021-05-09 19:26:05 +02:00
Christoffer Lerno
3bd638bf77 Fixes to debug info in function pointer declarations. Incorrect x64 ABI code for structs by val. Change "Compiler" to "GlobalContext" storage of all types inside. Call debug symbol correct. 2021-05-02 16:42:28 +02:00
Christoffer Lerno
0e076234ca Set stdlib library for testing and profit. Fix bugs when using void* to step. Make constants private linkage. Compare pointers using unsigned comparison without conversion. Use manual ptrdiff code. Fix issue returning "void!". Unify pointers when doing Foo* - void*. Allow comparing for example void* < Foo* 2021-04-29 03:12:25 +02:00
Christoffer Lerno
01f7343945 Parsing of interface. Fix to unpacking arraypointers. Fix accidental unsplat. 2021-04-29 03:12:25 +02:00
Christoffer Lerno
954a90dae3 Fix of arch target. Experimental linker support. 2021-04-09 18:47:41 +02:00
Christoffer Lerno
4210f1ccb2 Some work on vararray. Fix span on post unary. Updated error recovery. Updated return analysis to handle void functions. "while" now disallows error prone next line statement. Working on auto linking. Failable load optimized. Optimization and corrections for call returns + documentation. 2021-04-05 23:34:40 +02:00
Christoffer Lerno
45c4f205bb More correct alignment. Foreach added. Removed dynamic designated array initialization. Use 16 byte alignment on arrays >= 16 for x64 2021-01-27 00:14:16 +01:00
Christoffer Lerno
7fc12192f4 Added "distinct" types. 2021-01-24 21:10:57 +01:00
Christoffer Lerno
3a24fbfa6d Moved examples around. Updated (and corrected) const initialization. Removed "in" keyword. Added "member" attribute domain. Many fixes in struct padding and alignment and tests. Fixed extern global. 2021-01-24 00:55:09 +01:00
Christoffer Lerno
564c93700e Fixed bug that would intermittently arise from multiple contexts having the same pointer (should preferably be fixed in a different way later). Free all the arenas before codegen. Change "next" to "nextcase". Allow missing function parameters. Add "inline" structs. 2021-01-03 00:15:51 +01:00
Christoffer Lerno
4da36dfed9 Optimized and improved aggregate initialization. Compound literal updated to Foo({ 1, 2 })-style. ".name = x" style initialization for named arguments and designated initializers. Added runtime messages on panics. subarrays convert implictly to pointers. len/len() functions. Fix taking slice of pointer. Vararg fixes
Consistent length typedef.

First stab at initializers.

Change compound literal to Foo({ 1, 2 }) style.

Fixed up some tests.

Optimize the zero struct codegen.

Optimize union empty initializer.

Fix issues with unions. Added alignment to globals. Added some union tests.

Use puts to emit error messages during runtime. Fixup of int[] -> int* style conversions.

Fix implicit conversion of int[3]* -> int*

Fix int[] size. Use () to invoke the length of a subarray. Fix taking a slice of a pointer. Limit the number of members in a struct.

Fixes to vararg using debug and cleanups to slices.
2020-12-22 21:55:52 +01:00
Christoffer Lerno
6a5a0f2b94 Moved ABI lowering from codegen to semantic analysis. Fixes for failables in the ABI and the codegen. 2020-12-04 19:19:57 +01:00
Christoffer Lerno
84eea12efe Initial work on RISCV - completely untested. 2020-11-28 19:02:55 +01:00
Christoffer Lerno
31e9ec3d52 Optimize load of return & some parameter types. Fix issue with non-exapanding coerce. Add support for specific arch_os in tests. 2020-11-24 20:31:18 +01:00
Christoffer Lerno
669fd8c9a9 Incorrect index on sret. Explicit fallthrough annotation on type_is_homogenous_base_type. 2020-11-24 11:46:39 +01:00
Christoffer Lerno
162bb9dac8 Add a new "target" command line option to set the target without the need for a full target triple. Add debug command line options. Fix bug with coerce for x64 SysV ABI. 2020-11-23 23:24:27 +01:00
Christoffer Lerno
3c15e495dd Add macro arguments &foo $foo #foo.
C ABI compatibility aarch64, win64, x86, x64
Added debug info
2020-11-22 22:16:19 +01:00
Christoffer Lerno
4222f2731e &&temp operator. Macro evaluation. 2020-10-16 18:11:30 +02:00
Christoffer Lerno
77ccfc1f7c Added CT_SWITCH parsing in top level. Nil changed to null. Parsing more in line with grammar. Parse type as expressions. Zero init by default for locals. Corrected bool/fp conversion. Add memcpy pass to fix issue with value load/stores. 2020-09-21 11:38:12 +02:00
Christoffer Lerno
fb937156fe Work on debug + fix of failable bug. 2020-09-02 10:18:30 +02:00
Christoffer Lerno
ed01616f1e Changed how structs/unions are parsed so that recovery becomes more robust. Allow for more complex error data. Fixed recursive structs/unions. Corrected prefix precedence rules. Begin work on checking initializer constant-ness. Fixed error on failed arithmetic promotion. Added checks on constant overflow of sub/add/mult. Allow "current_module_name::x" to refer to globals. Added many tests. 2020-07-23 18:04:18 +02:00
Christoffer Lerno
b4c661eaad Pre lexing and mmap allocation together with exact exits. 2020-07-15 15:42:54 +02:00
Christoffer Lerno
dc86c21210 New failable based error handling. Labelled break/continue/next. 2020-07-09 13:07:08 +02:00
Christoffer Lerno
50c36789bf Fixes bug handling chained && ||. Work towards more macro functionality. Correctly emit stdcall. Corrected character parsing in escaped string entries. 2020-06-11 15:45:58 +02:00
Christoffer Lerno
3bdfe3e05e Refactored structs. 2020-06-01 21:00:21 +02:00
Christoffer Lerno
b2bfd87a06 Started work on ranges. Added weak/noreturn/inline/cname/stdcall/section/alignment attributes. Some work on subarrays. Fixes to throws. Function pointers work. 2020-05-20 14:22:22 +02:00
Christoffer Lerno
dbce72146f More AST dumps fixed. Throw simplified by removing "DECL_THROW", which also unearthed a bug. 2020-05-07 11:46:16 +02:00
Christoffer Lerno
93bd0fb337 Jumping on else added. 2020-05-05 11:28:49 +02:00
Christoffer Lerno
373001fd12 Error -> errset (temporarily). Catch / throw now works, but it will not yet correctly handle defer. 2020-05-03 02:04:13 +02:00
Christoffer Lerno
78aa49cc0e Work on getting typeof up and running. Try-else now works. 2020-04-22 20:19:55 +02:00
Christoffer Lerno
2c573c8a15 Fixed accidental uses of global context. 2020-04-18 14:29:17 +02:00
Christoffer Lerno
6117a1be7c Lots of fixes and optimizations to structs. Now there are no unnecessary intermediary types. 2020-04-18 14:29:17 +02:00
Christoffer Lerno
1d73338fb0 Order of function resolution is different. Function prototypes resolved first. Same with LLVM gen. Designated initializer and anonymous fields fixed mostly. 2020-04-12 21:35:25 +02:00
Christoffer Lerno
b1aa64cdcc TypeInfo gained a span. Hex lexing fixed. Basic block returns fixed. Removal of Ast.exit. Enum parameter list parses. Enum analysis improved. Exit deduction improved. Switch over a bool allowed. Switch analysis improved. Added -% operator. Updated implicit casts. Use of bigint. Signed-unsigned comparisons. 2020-03-29 17:41:31 +02:00
Christoffer Lerno
f4b4bab947 Restructuring the parser & split parser into parts. Parsing more constructs now, like enums with extended syntax. Corrected handling of function block to be an expression. Added expression block codegen. 2020-03-29 17:40:42 +02:00
Christoffer Lerno
ebbea2ac42 Lookahead cleanup. Start work on throws. Fix try expressions. Beginning work on initializer. Some fixes on LLVM types. Moving more target info into C3. Moving alignment into types Introducing a meta type (incomplete). Start work on macros. Splitting '@' from macro name. 2020-03-29 17:39:33 +02:00
Christoffer Lerno
b437cb545f Improved defer functionality, handling goto, conditional defers, next, break, continue, fixed bugs with module path detection. Improved switch parsing. Better errors on unknown module. 2020-01-28 23:41:10 +01:00
Christoffer Lerno
7b4ed09517 Introduced a Lexer context, comment parsing now actually works properly. Token use in decl/ast/expr is moved to SourceRange instead. And the SourceRange used start/end, which is better than using start + len for many uses. 2020-01-25 17:56:17 +01:00
Christoffer Lerno
cdc1bfe267 Start using UnaryOp/PostUnaryOp ++/-- now works post/pre and also on pointers. Fix ++/-- on any number. Added examples. c3c now compiles files by default. Extended symbol resolution. Addition of 'extern'. Multi-level paths. 2020-01-16 21:28:13 +01:00
Christoffer Lerno
fc3bd57ecf Major type check rewrite. Fixed params to be writable. Conditionals work. Lots of assign operators fixed. Struct access works. 2019-12-08 16:52:29 +01:00
Christoffer Lerno
acf7efded4 Initial work on throws. Cleanup of AST printout (incomplete!). Fixed issues with dead code after return. 2019-11-28 22:24:10 +01:00
Christoffer Lerno
aee3f99ea7 Added some codegen & .o generation and (hopefully correct) optimization. Hacked strings in together with i++/i--. Fixed up parsing of strings supporting \u \U \x => UTF8 2019-11-27 16:16:44 +01:00
Christoffer Lerno
990918b609 LLVM Codegen 2019-11-20 17:09:25 +01:00