From d244608571b6344f12106370bd773dfff2585d24 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Sat, 22 Apr 2023 09:34:19 +0200 Subject: [PATCH] Core: Cleanup todos --- build/rtsgame/main.core | 4 +- core_ast.cpp | 2 +- core_main.cpp | 113 +++++++++++++++++----------------------- 3 files changed, 51 insertions(+), 68 deletions(-) diff --git a/build/rtsgame/main.core b/build/rtsgame/main.core index bc7c67f..d48b50b 100644 --- a/build/rtsgame/main.core +++ b/build/rtsgame/main.core @@ -1,6 +1,4 @@ -/*@language_todo: make polymorphism checking more robust*/ - -/*@language_todo: labeled block +/*@language_todo: labeled block :LabeledBlock It acts just like a scope in C. BUT it can be turned into a goto label by adding another semicolon diff --git a/core_ast.cpp b/core_ast.cpp index 032318a..b6b1c18 100644 --- a/core_ast.cpp +++ b/core_ast.cpp @@ -572,7 +572,7 @@ void next(Ast_Iter *iter) { case AST_UNION: case AST_ENUM: case AST_LAMBDA: - case AST_TYPE: // @cleanup: what is this used for? + case AST_TYPE: case AST_CONST: case AST_VAR: { Ast_Decl *node = (Ast_Decl *)ast; diff --git a/core_main.cpp b/core_main.cpp index b1d252e..11dfe00 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -1,78 +1,63 @@ /* - @! Dont fully rely on files!!! - @! Language.core shouldnt be a file! - @! Nice way of creating valid declarations programatically - @! Add a token global that implies Ast is in the executable - @! Ast_Module should be Ast_File - @! Stringify Core_Message list +Features +- Labeled blocks / gotos :LabeledBlock +- Add := for default arguments in lambda. (a := false, b := false) +- Add struct default values. +- Add for loop: + - for i: int = 0, i < 10, i+=1 + - for diff: array + - iterator how to do this without function poly ? for it := iter_begin(), iter_valid(), iter_advance() +- Defer +- Expand macros - @! Separate out the codegen stage cause that can change - @! Look into String_Builders in Core_Ctx - @! Look into stage allocator and perhaps - use it more often to reduce scenarios - with 2 allocators, and simplify stuff - @! Cleanup big int allocator +- Using directive to bring symbols into local scope +- Other kinds of casts, a cast from structs of same layout, a cast without conversion +- Inject symbols into a declaration / namespace ?? +- Optionally pass size and alignment calculations to C ? - @! Clean way to free all memory and reset the compiler - @! Bring the Table<> +Cleanup +- Look into unifying lambda expressions and lambda declarations +- Ast_Module shouldn't require Ast_File to hold declarations etc. I think - core_create_namespace("memes", { - core_basic_type( - }, 4); +- Look into a different way of passing arguments in typechecking +- Separate out the codegen stage cause that can change +- Robust c declaration generation +- Nicer / more readable expression generation +- Detecting if return was called -Fix backlog -- [ ] Fix and decide what to do when initializing global variable using not constants C:/AProgramming/cparse/compiler/modules/Language.core:180:28: error: initializer element is not a compile-time constant -- [ ] Test and bulletproof any, slices -- [ ] Test suite that expects test to error out -- [ ] String declaration in Language.core this way we can compound create it and access fields and stuff -- [ ] This error is valid error case when someone creates a compound out of basic type C:/AProgramming/cparse/compiler/examples/arms_race/arms_race.core:137 Internal compiler error: Invalid type was passed to the compound expression, should have been an array, struct or slice +- Look into String_Builders in Core_Ctx +- Look into stage allocator and perhaps +use it more often to reduce scenarios +with 2 allocators, and simplify stuff +- Clean way to free all memory and reset the compiler +- Bring the table? + +- Nice way of creating valid declarations programatically +core_create_namespace("memes", { + core_basic_type( +}, 4); + +Robustness +- Test suite that expects test to error out +- Fix and decide what to do when initializing global variable using not constants C:/AProgramming/cparse/compiler/modules/Language.core:180:28: error: initializer element is not a compile-time constant +- Test and bulletproof any, slices +- This error is valid error case when someone creates a compound out of basic type C:/AProgramming/cparse/compiler/examples/arms_race/arms_race.core:137 Internal compiler error: Invalid type was passed to the compound expression, should have been an array, struct or slice result := String{data, filesize} -- [ ] How to cast from U64 to pointer? -``` -Future features +Bytecode interpreter +- Ir +- Interpreter +- Code generation -- [ ] Other kinds of casts, a cast from structs of same layout, a cast without conversion -- [ ] Inject symbols into a declaration / namespace ?? -- [ ] Using directive to bring symbols into local scope - -### - -- [ ] Way to import and force evaluate #import_lazy #import ? - -Redesign: -- [ ] Casting syntax - -In the future - -- [ ] Cleanup - - [ ] Add ability to do i: int = 0 inside for loops for i: int = 0, i < 10, i+=1 - - [ ] Complicated c declaration generation - -- [ ] Expand macros -- [ ] Defer - -- [ ] Basic - - [ ] Detecting if return was called - -- [ ] Programming constructs - - [ ] Using language construct - - [ ] Named loops and breaking out of them - -- [ ] Bytecode interpreter - - [ ] Ir - - [ ] Interpreter - - [ ] Code generation +Fun +- Inject stack traces into the program +- Inject instrumentation into the program Ideas -- [ ] #test construct that would gather all tests and run them on start of program or something -- [ ] Inject stack traces into the program -- [ ] Constant arrays that evaluate fully at compile time -- [ ] Rust like enum where you associate values(other structs) with key -- [ ] Cast from array to pointer? -- [ ] Ternary operator? -- [ ] Optionally pass size and alignment calculations to C ? +- Constant arrays that evaluate fully at compile time +- Rust like enum where you associate values(other structs) with key + */ #include "core_compiler_includes.cpp"