diff --git a/core_main.cpp b/core_main.cpp index 964f0cd..27c0b64 100644 --- a/core_main.cpp +++ b/core_main.cpp @@ -57,50 +57,50 @@ For modules it's a bit different cause they should be distributed as valid. ------------------------------------------------------------------------------- @todo -[ ] - Fix language_basics.kl string index error -[ ] - Split Bc into builder and interpreter -[ ] - Implement functions in the bytecode +- [ ] Split Bc into builder and interpreter +- [ ] Implement functions in the bytecode -[ ] - Probably need to give Ast_Expr a Value field, then I can express Type nicely -[ ] - I would love for String, slice, Any etc. to have their struct declarations in source files, I also would want for stuff like string.str to work without weird special cases -[ ] - Var args with Any +- [ ] Probably need to give Ast_Expr a Value field, then I can express Type nicely +- [ ] I would love for String, slice, Any etc. to have their struct declarations in source files, I also would want for stuff like string.str to work without weird special cases +- [ ] Var args with Any -[ ] - #test construct that would gather all tests and run them on start of program or something -[ ] - Foreign import that would link library -[ ] - Builtin dynamic arrays -[ ] - Kilobyte, Megabyte, Gigabyte -[ ] - Cast from array to pointer? -[ ] - Fix field access, cant cast, cant index -[ ] - Add parent_scope to Ast_Type, Add name to Ast_Type? -[ ] - Some way to take slice of data -[ ] - Optional function renaming in codegen -[ ] - Using in structs to embed members, then casting offsets to that embedded member +- [ ] #test construct that would gather all tests and run them on start of program or something +- [ ] Foreign import that would link library +- [ ] Builtin dynamic arrays +- [ ] Kilobyte, Megabyte, Gigabyte +- [ ] Cast from array to pointer? +- [ ] Fix field access, cant cast, cant index +- [ ] Add parent_scope to Ast_Type, Add name to Ast_Type? +- [ ] Some way to take slice of data +- [ ] Optional function renaming in codegen +- [ ] Using in structs to embed members, then casting offsets to that embedded member -[ ] - Comma notation when declaring variables thing1, thing2: S32 :: probably want to unify it with var unpacking -[ ] - Add single line lambda expressions -[ ] - Ternary operator -[ ] - Disable ability to parse inner structs, functions, constants etc. ? -[ ] - Write up on order independent declarations +- [ ] Comma notation when declaring variables thing1, thing2: S32 :: probably want to unify it with var unpacking +- [ ] Add single line lambda expressions +- [ ] Ternary operator +- [ ] Disable ability to parse inner structs, functions, constants etc. ? +- [ ] Write up on order independent declarations -[ ] - Consider changing syntax of scopes to use braces { } -[ ] - Order independent declarations in structs ? -[ ] - constructor => thing :: (i: S32) -> {i = i, thing = 10} -[ ] - Casting to basic types by call S64(x) -[ ] - Default values in structs??? Should compound stmts bring values from default values?? Maybe not? Whats the alternative +- [ ] Consider changing syntax of scopes to use braces { } +- [ ] Order independent declarations in structs ? +- [ ] constructor => thing :: (i: S32) -> {i = i, thing = 10} +- [ ] Casting to basic types by call S64(x) +- [ ] Default values in structs??? Should compound stmts bring values from default values?? Maybe not? Whats the alternative @ideas -[ ] - Var args using Any array - args: []Any - delete vargs -[ ] - [Using] keyword that brings in the struct enviroment into current scope etc. -[ ] - Constant arrays that evaluate fully at compile time -[ ] - Rust like enum where you associate values(other structs) with keys -[ ] - Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {} -[ ] - Inject stack traces into the program -[ ] - Conditional compilation #if -[ ] - Polymorphism - create declaration of a polymorphic thing, when it's called just copy it, replace types and typecheck normally, when someone calls again you just search for the instantiation again +- [ ] Var args using Any array - args: []Any - delete vargs +- [ ] [Using] keyword that brings in the struct enviroment into current scope etc. +- [ ] Constant arrays that evaluate fully at compile time +- [ ] Rust like enum where you associate values(other structs) with keys +- [ ] Compound that zeros values - .{} , Compound that assumes defaults from struct definition - {} +- [ ] Inject stack traces into the program +- [ ] Conditional compilation #if +- [ ] Polymorphism - create declaration of a polymorphic thing, when it's called just copy it, replace types and typecheck normally, when someone calls again you just search for the instantiation again ## Done +- [x] Fix language_basics.kl string index error - [x] Type as a parameter to a function, alloc :: (size: U64, type: Type) - [x] Add token information to instructions - [-] Mixing loads and imports leads to code duplication, is that what we want??? diff --git a/core_parsing.cpp b/core_parsing.cpp index 5635e02..b92c7b7 100644 --- a/core_parsing.cpp +++ b/core_parsing.cpp @@ -659,12 +659,13 @@ parse_struct(Token *pos){ token_match(OPEN_SCOPE); Ast_Scope *scope = begin_decl_scope(scratch, token_get()); do{ - Token *token = token_get(); - - Ast_Decl *decl = parse_decl(false); - if(!decl) compiler_error(token, "Failed to parse struct member"); + Token *token = token_expect(TK_Identifier); + token_expect(TK_Colon); + Ast_Expr *typespec = parse_expr(); + Ast_Decl *decl = ast_var(token, typespec, token->intern_val, 0); decl->flags = set_flag(decl->flags, AST_AGGREGATE_CHILD); + scope->decls.add(decl); }while(token_match(SAME_SCOPE)); diff --git a/modules/base.kl b/modules/base.kl index a73f592..6a2cb5f 100644 --- a/modules/base.kl +++ b/modules/base.kl @@ -2,16 +2,16 @@ Os :: #import "os_windows.kl" SizeU :: U64 arena_di: U64 +ADDITIONAL_COMMIT_SIZE :: 1024*1024 +DEFAULT_RESERVE_SIZE :: 1024*1024*1024 +DEFAULT_ALIGNMENT :: 8 + Arena :: struct di: U64 // @debug_id memory: Os.Memory alignment: U64 len: U64 - ADDITIONAL_COMMIT_SIZE :: 1024*1024 - DEFAULT_RESERVE_SIZE :: 1024*1024*1024 - DEFAULT_ALIGNMENT :: 8 - clamp_top_sizeu :: (val: SizeU, max: SizeU): SizeU if val > max return max @@ -29,8 +29,8 @@ align_up :: (size: SizeU, align: SizeU): SizeU return result arena_init :: (a: *Arena) - a.memory = Os.reserve(a.DEFAULT_RESERVE_SIZE) - a.alignment = a.DEFAULT_ALIGNMENT + a.memory = Os.reserve(DEFAULT_RESERVE_SIZE) + a.alignment = DEFAULT_ALIGNMENT a.di = arena_di++ // a.allocator.proc = arena_allocator_proc @@ -39,7 +39,7 @@ arena_push_size :: (a: *Arena, size: SizeU): *void if a.len + generous_size > a.memory.commit if a.memory.reserve == 0 arena_init(a) - result := Os.commit(&a.memory, generous_size + a.ADDITIONAL_COMMIT_SIZE) + result := Os.commit(&a.memory, generous_size + ADDITIONAL_COMMIT_SIZE) assert(result == true) a.len = align_up(a.len, a.alignment) assert(a.memory.reserve > a.len + a.memory.commit)