Commit Graph

445 Commits

Author SHA1 Message Date
3d73c52cb4 Fix casting within setters 2025-07-22 19:31:35 +03:00
81ce1dfc2e Fix a bunch of bugs with debug information and stuff 2025-07-22 19:16:45 +03:00
78a1e9f06b Fix typedef issue with modules 2025-07-22 18:03:15 +03:00
f35f1ef701 Repurpose module map and rename old to ErrorModules 2025-07-22 17:34:01 +03:00
fa6b7bdf87 Add temporary line number for for non-local structs 2025-07-22 16:35:15 +03:00
e9bca63f0d Add module id to CustomType, String to std 2025-07-22 16:16:46 +03:00
1224c612c7 Codegen & compile char, change *str to *char 2025-07-22 15:07:33 +03:00
108cf6efa5 Add FCmp to codegen 2025-07-22 15:01:02 +03:00
9b9398ac26 Add lexing of escaped characters, add parsing of characters 2025-07-22 14:57:09 +03:00
e220900ac3 Start adding chars 2025-07-22 14:44:28 +03:00
9c0d373f9d Fix casting to same type 2025-07-22 14:21:17 +03:00
e27aa4b8ab Fix pointer-casting 2025-07-22 14:19:28 +03:00
c03a5188ea Finish casting codegen 2025-07-22 14:12:31 +03:00
104205ee5d Type-infer and check typecasting 2025-07-22 13:24:53 +03:00
3378f556ec Add AST -> MIR for typecasting 2025-07-21 21:28:39 +03:00
c4ab4ac0b3 Add parsing of casting 2025-07-21 21:23:37 +03:00
471c2eaf87 Fix struct-parsing interfering with if-parsing 2025-07-21 20:52:39 +03:00
fe145ad2ef Fix comparisons not working for integers 2025-07-21 20:25:28 +03:00
836a532d8d Fix UserPointer being completely monkeypatched, found the issue 2025-07-21 20:13:15 +03:00
10d62eb1f7 Allow_identifiers_to_have_underscores 2025-07-21 19:36:44 +03:00
069c277516 Update String to be *str 2025-07-21 19:32:40 +03:00
eb99a4c74e Fix range in literals 2025-07-21 19:18:39 +03:00
3d3a9a34f9 Fix binary operators for floats, make library functions extern 2025-07-21 17:32:20 +03:00
feac7163f2 Add a bunch of operations to lib 2025-07-21 17:03:21 +03:00
f0f828d1eb Fix float type coercion and compilation 2025-07-21 16:54:50 +03:00
ec0c7fa194 Fix float coersion rules 2025-07-21 16:53:29 +03:00
a1507e14ca Add flag to ignore no-main-error 2025-07-21 16:47:51 +03:00
7c7dde03f9 Fix error reporting on No-Main-Function and add fp compilation 2025-07-21 16:44:16 +03:00
bcc93dd60c Add parsing to floats 2025-07-21 16:18:14 +03:00
e370e17ffd Only include STD if it is imported 2025-07-21 15:47:02 +03:00
b23577aa18 Check for trivial expressions that they are >0 when unsigned 2025-07-21 15:44:47 +03:00
d65b0153a1 Implement unary operators as syntax sugar 2025-07-21 15:12:49 +03:00
ed9c8638d5 Get pointers working 2025-07-21 14:43:24 +03:00
9db508bd9c Change user-space pointer to different type 2025-07-21 13:52:37 +03:00
a49105b07a Add typecheck/infer for pointers 2025-07-21 13:29:19 +03:00
3b43689650 Add parsing pointer-type 2025-07-21 13:25:01 +03:00
1ba1ae3213 Try add some display for LLIR 2025-07-21 12:07:42 +03:00
f55040ad00 Update how types are formatted 2025-07-21 11:06:42 +03:00
ce645519ce Fix NamedVarRefrence tokenrange 2025-07-21 10:52:33 +03:00
37386db437 Check for mutability when doing a let 2025-07-21 10:43:24 +03:00
5763df948f Check borrow mutability against variable mutability 2025-07-21 10:39:19 +03:00
1fadaa60f2 Add mutability compatibility check to borrows 2025-07-21 10:33:37 +03:00
74ce296a05 Refactor a bit 2025-07-21 10:29:26 +03:00
b9f6f2ba0f Make param mutable based on type 2025-07-21 10:23:30 +03:00
60818842a5 Add borrow mutability 2025-07-21 10:21:25 +03:00
8da32c25c5 Make borrows work as function parameters as well 2025-07-21 10:07:56 +03:00
2e829bc8a9 Fix linker, add e2e tests 2025-07-21 09:59:35 +03:00
09cec9c110 Implement borrowing in codegen 2025-07-21 09:54:55 +03:00
893eaaa865 Clean up and fix some warnings 2025-07-20 22:36:38 +03:00
550fec2827 Fix typeinference and checking for borrows/derefs 2025-07-20 22:33:00 +03:00
47fa5f342f Nearly get typechecking working for deref/borrow 2025-07-20 22:15:16 +03:00
62d73b19a2 Improve error messages for typerefs a bit 2025-07-20 21:51:18 +03:00
c0e375d84c Add typechecking for borrow/deref 2025-07-20 21:48:00 +03:00
cf30f79951 Add type inference for borrow/deref 2025-07-20 21:43:27 +03:00
26818cec96 Add AST->MIR for borrow/deref 2025-07-20 21:34:47 +03:00
ba8ee770fb Parse deref and borrow 2025-07-20 21:25:08 +03:00
d7661cb968 Add metadata location to function calls 2025-07-20 21:08:15 +03:00
33d5ee03f0 Improve LLVM IR SSA names 2025-07-20 20:50:32 +03:00
71a01dad69 Remove name from alloca 2025-07-20 20:24:26 +03:00
848f4118bf Fix params not being pointers 2025-07-20 20:13:47 +03:00
158ddc58c8 Fix structs loading values prematurely 2025-07-20 20:00:34 +03:00
be76331a47 Get recursive structs and arrays working too 2025-07-20 19:59:03 +03:00
d631e80267 At crossroads 2025-07-20 19:54:43 +03:00
c723ba7b4a Get inner arrays working 2025-07-20 19:30:34 +03:00
a62f9db422 Get static arrays actually working alone 2025-07-20 19:23:42 +03:00
b185e2ecc6 Import typedefs from other modules as well 2025-07-20 15:55:47 +03:00
e8e2b4cebd Implement parsing of multiple parameters 2025-07-20 15:32:56 +03:00
575abe8172 Make passes actually return errors well 2025-07-20 15:25:21 +03:00
e4845c4084 Get structs in arrays working, but no luck with arrays in structs 2025-07-20 14:21:37 +03:00
f952651a66 Get structs to work in debug information 2025-07-20 13:52:54 +03:00
c0b02f8a45 Clean up some prints 2025-07-20 05:04:12 +03:00
5f65d3438a Get arrays to work in DI, huzzah 2025-07-19 22:08:23 +03:00
c1cc1d28de Implement array and struct debug info 2025-07-19 20:51:06 +03:00
a511331be2 Fix type-inferrer on arrays 2025-07-19 19:23:24 +03:00
f9f9360efc Update error text 2025-07-19 19:03:31 +03:00
98169af415 Add array and pointer-types to lib 2025-07-19 16:18:29 +03:00
d64cf750b1 Make codegen return StackValues instead of instructions 2025-07-19 15:46:34 +03:00
1ad89de682 Add better coverage for debug types 2025-07-19 14:33:27 +03:00
f2c38d42b9 Add variable debug declarations to all variables 2025-07-19 13:56:51 +03:00
59ce454f91 Store all variables in pointers 2025-07-19 13:54:54 +03:00
94fbd51d35 Commit out adding records for now 2025-07-19 13:29:05 +03:00
e12d0be08b Start adding debug-records 2025-07-19 13:14:53 +03:00
7c8a123945 Add variables to debug info 2025-07-19 12:15:56 +03:00
e75c38ad85 Add debug information to everything (for now) 2025-07-19 00:41:29 +03:00
9749a29680 Upgrade to LLVM 20.1 2025-07-18 23:04:08 +03:00
92f12e90eb Make debug information work 2025-07-18 19:38:01 +03:00
b169e67ca4 Add debug locations to returns 2025-07-18 18:36:04 +03:00
1967cadbc0 Get debug info working very preliminarily 2025-07-18 17:26:11 +03:00
287ab69d32 Remove old useless example 2025-07-18 17:01:10 +03:00
990d8cb448 Fix around in debug information generation, fix subprogram not being set 2025-07-18 16:59:05 +03:00
0c6d9885ec Add debug information compilation for subprograms and their parameters 2025-07-18 15:44:12 +03:00
9bb4f97e6b Start adding debug information 2025-07-18 00:07:11 +03:00
292688a840 Fix some warnings 2025-07-17 20:26:01 +03:00
ce2278ce45 Fix using custom type-labels for e.g. return type 2025-07-17 20:20:07 +03:00
0f782dcb96 Fix parse error returning the token after the error 2025-07-17 20:16:37 +03:00
6dfd98eba3 Use true source for error formatting 2025-07-17 19:34:54 +03:00
df4febf1ef Add formatting of the printed lines to errors 2025-07-17 18:58:05 +03:00
9d1b18f083 Add FullToken array to error raporting 2025-07-17 17:44:18 +03:00
ce7c4bfb52 Improve error raporting futher significantly 2025-07-17 17:15:57 +03:00
f0e47a5d57 Attempt to significantly improve error-raporting 2025-07-17 16:47:10 +03:00
64e34ecf13 Add module_id for modules and metadata 2025-07-17 14:56:41 +03:00
e2dc1a3f85 Fix some warnings 2025-07-17 14:31:40 +03:00
c07e488f48 Update state.load a bit to make a better default for it 2025-07-17 12:36:17 +03:00
8ffb3baa8d Add Any-mutability for StackValues 2025-07-17 00:55:11 +03:00
8abee593f0 Fix value transfer in structs and arrays 2025-07-17 00:33:23 +03:00
9a4f0dc5d8 Allow for cloning inner values 2025-07-17 00:05:37 +03:00
965ad5797f Implement rudamentary borrow 2025-07-16 23:49:28 +03:00
e4ce897f94 Fix expression-indexing 2025-07-16 23:29:15 +03:00
d2cf97af66 Move should_load to separate State 2025-07-16 23:22:06 +03:00
d034754202 Possibly fix array_structs 2025-07-16 23:09:36 +03:00
c41aab33a9 Add optional data to PassState Scope 2025-07-16 22:46:52 +03:00
c19384d77b Refactor a bit 2025-07-16 22:38:19 +03:00
3870b421a9 Refactor indexing/accessing a bit, no mutability 2025-07-16 22:04:11 +03:00
79c98a18f7 Fix some warnings, remove unused code 2025-07-16 21:14:07 +03:00
1eb3e8c095 Refactor IndexedVariableReference being a bit smarter 2025-07-16 21:13:00 +03:00
dbd048c21c Fix struct indexing when setting a field 2025-07-16 20:38:21 +03:00
cd31d7e7cd Nearly fix struct mutability 2025-07-16 20:27:01 +03:00
017b474f0c Fix StructValueIndex never constructed 2025-07-16 19:02:23 +03:00
f2e4b3eff7 Do some cleanup 2025-07-16 18:57:42 +03:00
2a879b5ef4 Implement codegen for structs 2025-07-16 17:08:15 +03:00
d1a37058df Fix warnings 2025-07-16 16:16:58 +03:00
31185d921e Properly implement structs in lib 2025-07-16 16:11:45 +03:00
97fc468d78 Update how struct access is displayed 2025-07-16 00:19:49 +03:00
77439ee34a Implement typechecking for structs 2025-07-16 00:16:53 +03:00
aafab49f82 Fix struct access type inference 2025-07-15 23:30:32 +03:00
7075b6f73f Update order of prints 2025-07-15 23:18:01 +03:00
1d1e574136 Implement type inference for structs 2025-07-15 23:16:37 +03:00
e13b6349f0 Add ScopeTypes to Pass 2025-07-15 22:11:38 +03:00
b012a46e91 Process Struct ASTs into MIR 2025-07-15 22:03:48 +03:00
f139a5ad6c Add MIR support for struct types 2025-07-15 21:48:58 +03:00
d9a1e8456d Add struct indexing parsing 2025-07-15 21:28:02 +03:00
c83d53ae53 Add struct type and expression parsing 2025-07-15 21:19:37 +03:00
5fca72a3f9 Add lexing support for structs 2025-07-15 20:37:41 +03:00
1acaa29a12 Fix module scopes being linked 2025-07-15 20:09:33 +03:00
6788ef1690 Use AvailableExternally-linkage for externs for imports 2025-07-15 20:01:46 +03:00
6f8c02ac04 Add compilation time to cli 2025-07-15 19:45:03 +03:00
19c883ea33 Add e2e tests 2025-07-15 02:55:26 +03:00
28d632d51c Add Makefile by @neon, fix array typechecking during typeinference 2025-07-15 01:17:00 +03:00
bcad9b57fe Make the compiler produce .o/.asm/.ll according to input file name 2025-07-15 00:25:17 +03:00
5b5ec48b8d Put all debug prints behind debug-assertions 2025-07-14 23:43:03 +03:00
0e5f12e0e2 Update README 2025-07-14 22:57:33 +03:00
587aa1d7f2 Fix warnings 2025-07-14 22:56:31 +03:00
1e759d49c7 Fix issue in type-inference pass about function params not registering 2025-07-14 22:55:43 +03:00
5acd1624fd Move test to inside-executable, and add tests that test it compiles 2025-07-14 22:52:30 +03:00
3f90b46dc8 Include stdlib in executable 2025-07-14 22:33:04 +03:00
fa4df50a04 Fix linking so that non-imported functions don't bother main-module 2025-07-14 22:22:55 +03:00
2b47c4efc7 Make linking modules together work, fix printing modules 2025-07-14 21:10:13 +03:00
848347e4a8 Add importer pass, make importer import module properly 2025-07-14 20:35:58 +03:00
a71843dfe9 Implement import-pass 2025-07-14 20:13:30 +03:00
464156b2dc Fix imports in MIR 2025-07-14 19:20:38 +03:00
b82cbcb45c Fix function call not faulting on undefined function 2025-07-14 19:02:21 +03:00
7a2a965cd7 Fix functions being in their own scopes 2025-07-14 18:49:51 +03:00
735c4370aa Add pub keyword 2025-07-14 18:47:02 +03:00
4eaa365674 Add function flags and codegen extern functions 2025-07-14 18:26:57 +03:00
376baa2c9a Remove length param from string, use string pointers instead 2025-07-14 18:22:05 +03:00
1173e17fe6 Update TODO-list 2025-07-14 17:57:34 +03:00
83475b144c Codegen strings 2025-07-14 17:54:56 +03:00
73a3b15fb6 Add AST -> MIR for strings 2025-07-14 17:45:36 +03:00
b9dfa9b1ce Add parsing of string literals 2025-07-14 17:39:48 +03:00
d5b0e3ebf7 Add lexing of strings 2025-07-14 17:38:05 +03:00
e15f77d9de Update libtest and make examples/cli.rs 2025-07-14 17:26:38 +03:00
bc1cc99bcc Update examples 2025-07-14 17:19:10 +03:00
b64cdc4c71 Fix if-statement block return type evaluation 2025-07-14 17:17:48 +03:00
bad4713779 Fix index out of bounds off-by-one error 2025-07-14 02:31:01 +03:00
c2a087785e Update README and lib docs 2025-07-14 02:28:01 +03:00
1b9f3dbca0 Fix warnings 2025-07-14 02:26:55 +03:00
86eab29173 Make nested arrays work 2025-07-14 01:20:50 +03:00
5d06ecb874 Add broken support for nested arrays 2025-07-14 00:05:05 +03:00
d2587df4c9 Add mutability to arrays 2025-07-13 23:58:56 +03:00
d99c450e61 Fix some warnings 2025-07-13 23:14:51 +03:00
cbb1be1161 Implement GEP instead of the weird thing before 2025-07-13 23:14:16 +03:00
312a777203 Get arrays to compile while still not supporting mutability for a bit 2025-07-13 22:04:49 +03:00
515c031f19 Finish type checking and inferrence for arrays 2025-07-13 20:15:03 +03:00
b14a62bc34 Add typechecking for arrays 2025-07-13 19:39:43 +03:00
4f8153643b Perform type inference for array and indexing expressions 2025-07-13 19:26:20 +03:00
64f07002b4 Update how array is displayed when printed 2025-07-13 19:07:31 +03:00
a18a5b4199 Continue progress, make set-statements as todos for later 2025-07-13 19:00:46 +03:00
10cf9341c5 Add return type for index and array expressions 2025-07-13 18:41:14 +03:00
ad20fefabc Add Array Expression to MIR 2025-07-13 18:37:18 +03:00
587ab8afd5 Make mir array implementation halfway, compiling but not working yet 2025-07-13 18:32:27 +03:00
bf8baa7cd4 Add parsing for setting indexed values 2025-07-13 18:02:27 +03:00
df6b5ef34b Add array indexing 2025-07-13 17:46:34 +03:00
8f95d445c0 Add array expression parsing 2025-07-13 17:41:57 +03:00
887071eeb6 Add parsing of array type 2025-07-13 17:33:38 +03:00
4e8228f903 Move binop type resolution to common implementation 2025-07-13 17:05:23 +03:00
a8ed7577a8 Move type checking properly to the typecheck-stage 2025-07-13 16:31:35 +03:00
92736e392e Refactor Type Hints -> Type Refs 2025-07-13 15:58:19 +03:00
f3f47831e9 Split type inference to it's very own pass 2025-07-13 15:55:14 +03:00
7d77e1df32 rename ScopeHint to TypeHint 2025-07-13 15:27:28 +03:00
0d631bfa89 Remove redundant TypeRef, add other optimizations 2025-07-13 15:26:36 +03:00
29e78cf1aa update errors 2025-07-13 13:58:31 +03:00
e79a0fe458 Update where default value is calculated, fix load type 2025-07-12 23:59:16 +03:00
edb2784f4a Remove unused while-loop 2025-07-12 23:40:49 +03:00
51c341450b Fix warnings 2025-07-12 23:37:24 +03:00
557d5f9722 Finish second phase of typechecking, resolve hinted values 2025-07-12 23:35:35 +03:00
61ab5002e4 Split typechecking into two passes, finish first pass 2025-07-12 22:59:23 +03:00
873948a0c4 Move scopehints to own file 2025-07-12 18:40:26 +03:00
be7fa71b53 Add ScopeHints tentatively 2025-07-12 15:32:29 +03:00
04e0c136df Fix warnings 2025-07-12 14:42:43 +03:00
0f424c70d7 Implement mutability part 2 2025-07-12 14:37:10 +03:00
14e0dcbe15 (broken) add part 1 of mutability 2025-07-12 02:38:31 +03:00
85b2ebf04a Add mutability parsing 2025-07-11 21:32:20 +03:00
615fec6e52 Add TODO, remove TODOs 2025-07-09 22:44:33 +03:00
d04a70e464 Remove unused variable 2025-07-09 22:33:56 +03:00
383302c1c2 Fix old fibonacci not working due to last change 2025-07-09 22:32:47 +03:00
b19a32cd8a Make early returns work even without an explicit return 2025-07-09 22:20:08 +03:00
1aa9b3e76c Add RetVoid just in case 2025-07-09 22:01:32 +03:00
94c4ec0613 Add a block garbage-collector that will delete an unused block at end 2025-07-09 21:57:48 +03:00
d757ac4eb3 Fiddle around with if-expression codegen 2025-07-09 21:12:39 +03:00
c50474cc8e Update README.md 2025-07-09 20:27:12 +03:00
50f5f3cc70 Update lib.rs docs 2025-07-09 20:16:52 +03:00
f7fa69fbe2 Add docs to lib.rs 2025-07-09 20:13:16 +03:00
a907fec967 Fix module docs 2025-07-09 20:07:30 +03:00
9710d17e00 Add a bunch of documentation 2025-07-09 20:01:24 +03:00
257496aae2 Rename LogicOperator to CmpOperator 2025-07-09 19:24:07 +03:00
197f0b22f3 Add boolean literals 2025-07-09 19:17:03 +03:00
b84672ef8c Add Mult and And -operators to the whole chain 2025-07-09 19:08:21 +03:00
8afb2c2572 Fix bug in Logic Operator conversion 2025-07-09 19:00:03 +03:00
974647b401 Fix FullToken positions 2025-07-09 18:54:51 +03:00
d5daaa0e87 Improve Debug and Display implementations 2025-07-09 18:47:40 +03:00
49df6c9ed9 Add a bunch of new integer comparison operators 2025-07-09 16:05:08 +03:00
46560d8541 Add all types u8 -> i128 and fix signedness in icmp 2025-07-08 23:47:44 +03:00
14283afe59 Separate pass-common code to pass.rs 2025-07-08 21:44:04 +03:00
2e99ec3a80 Fix warnings 2025-07-08 18:48:18 +03:00
fb876e3ef5 Add type from let through parser to MIR 2025-07-08 18:41:10 +03:00
cdbc4593a8 Move hard_hint to scope 2025-07-08 18:31:04 +03:00
9b9fcd4ec4 Make AST contain only abstract Numbers 2025-07-08 00:48:28 +03:00
22737f022e Fix variable type let inference 2025-07-07 23:40:35 +03:00
a7292f4719 Fix comparison return type in typechecking 2025-07-07 23:31:32 +03:00
9b68ecb614 Add some security checks, typecheck for condition to be a boolean 2025-07-07 23:25:07 +03:00
a366d22470 Add typechecking 2025-07-07 23:03:21 +03:00
12dc457b99 Add mandatory return type for MIR Function 2025-07-07 18:32:37 +03:00
0932af2e3b Simplify transformation from AST to MIR 2025-07-06 23:01:28 +03:00
35efa78a56 Connect all the wires again 2025-07-06 20:49:13 +03:00
454cefafc9 Add middleware PrimaryExpression-struct to make TokenRanges correct 2025-07-05 18:02:06 +03:00
0392c293ba Cleanup 2025-07-05 01:41:03 +03:00
61ba00ea58 Transform AST into MIR successfully, completing the chain 2025-07-05 01:34:57 +03:00
a66fc61c07 Fiddle with names a bit 2025-07-04 21:54:07 +03:00
8a32e66ba8 Refactor a bunch of stuff, produce compiling MIR 2025-07-04 21:30:40 +03:00
5f93b7c9c2 Add rudamentary LLVM lib stuff, make a fully compiling executable 2025-06-24 23:10:44 +03:00
6d3d0fd03e Move reid to subproject 2025-06-24 17:17:15 +03:00
c7f11e5091 Add errors, move compiling to examples 2023-08-02 19:17:57 +03:00
a196857dd6 Add simple codegen from actual AST 2023-08-02 17:03:06 +03:00
dca604a038 Add preliminary codegen, update parsing to require functions 2023-08-02 15:31:33 +03:00
bda4fa4200 Move stuff around, add comment about compiling LLVM 2023-07-31 00:35:46 +03:00