From 02ec291ad0751ab1f399fa3e451e869c36a33281 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Mon, 27 Jun 2022 09:17:53 +0200 Subject: [PATCH] Add file listing --- main.cpp | 16 ++++++++++------ programs/any.kl | 1 - programs/base.kl | 34 ++++++++++------------------------ programs/main.kl | 2 ++ 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/main.cpp b/main.cpp index 8623e2e..4d9f6d4 100644 --- a/main.cpp +++ b/main.cpp @@ -58,7 +58,7 @@ For modules it's a bit different cause they should be distributed as valid. @todo [ ] - Split Bc into builder and interpreter -[ ] - Implement functions +[ ] - 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 @@ -69,13 +69,11 @@ For modules it's a bit different cause they should be distributed as valid. [ ] - Builtin dynamic arrays [ ] - Kilobyte, Megabyte, Gigabyte [ ] - Cast from array to pointer? -[ ] - Mixing loads and imports leads to code duplication, is that what we want??? [ ] - 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 -[ ] - Type as a parameter to a function, alloc :: (size: U64, type: Type) [ ] - Comma notation when declaring variables thing1, thing2: S32 :: probably want to unify it with var unpacking [ ] - Add single line lambda expressions @@ -100,7 +98,9 @@ For modules it's a bit different cause they should be distributed as valid. [ ] - 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 @donzo +[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??? [x] - print those token lines nicely [x] - Improve the python metaprogram [x] - Implementing type Any @@ -175,6 +175,7 @@ For modules it's a bit different cause they should be distributed as valid. #include "base.cpp" #include "base_unicode.cpp" +#include "os_windows.cpp" #include "big_int_c3.cpp" #include "compiler.h" #include "lexing.cpp" @@ -220,6 +221,12 @@ int main(int argument_count, char **arguments){ test_intern_table(); test_bucket_arrays(); + Scratch scratch; + String a = os_get_working_dir(scratch); + String b = os_get_exe_dir(scratch); + Array files = os_list_dir(scratch, ".."_s, LIST_RECURSE_INTO_DIRS); + + emit_line_directives = true; String program_name = "main.kl"_s; if(argument_count > 1){ @@ -252,9 +259,6 @@ int main(int argument_count, char **arguments){ arena_clear(&pctx->stage_arena); - // build_bytecode(); - // compile_to_bc(); - // __debugbreak(); String result = get_compilation_result(); assert(os_write_file("program.c"_s, result)); { diff --git a/programs/any.kl b/programs/any.kl index 6788f54..d95c51e 100644 --- a/programs/any.kl +++ b/programs/any.kl @@ -64,7 +64,6 @@ test_type :: () t51 := get_type_info(t5.base_type) assert(t51.kind == Type_Info_Kind.ARRAY) - t6 := get_type_info(type6) t61 := get_type_info(t6.base_type) t62 := get_type_info(t61.base_type) diff --git a/programs/base.kl b/programs/base.kl index 0509538..83b4968 100644 --- a/programs/base.kl +++ b/programs/base.kl @@ -3,7 +3,6 @@ SizeU :: U64 arena_di: U64 Arena :: struct -// allocator: Allocator di: U64 // @debug_id memory: Os.Memory alignment: U64 @@ -48,32 +47,19 @@ arena_push_size :: (a: *Arena, size: SizeU): *void a.len += size return result +// @todo: Make this compile time thing!!! +// This probably will wait till polymorphism stuff +// something like this: +// arena_push_type :: (a: *Arena, type: $T): *T +// +arena_push_type :: (a: *Arena, type: Type): *void + type_info := get_type_info(type) + assert(type_info != 0) + return arena_push_size(a, type_info.size->SizeU) + arena_release :: (a: *Arena) Os.release(&a.memory) -/* -ALLOCATOR_ACTION :: enum - ALLOCATE - RESIZE - FREE_ALL - -Allocator :: struct - proc: (a: *Allocator, action: ALLOCATOR_ACTION, size: SizeU, old_pointer: *void): *void - -arena_allocator_proc :: (a: *Allocator, action: ALLOCATOR_ACTION, size: SizeU, old_pointer: *void): *void - arena: *Arena = a->*Arena - if action == ALLOCATOR_ACTION.ALLOCATE - return arena_push_size(arena, size) - elif action == ALLOCATOR_ACTION.RESIZE - pass - elif action == ALLOCATOR_ACTION.FREE_ALL - pass - else;; assert(false, "Invalid codepath") - return 0 - -allocate :: (a: *Allocator, size: SizeU): *void - return a.proc(a, ALLOCATOR_ACTION.ALLOCATE, size, 0) -*/ // // Unicode diff --git a/programs/main.kl b/programs/main.kl index 1ed5648..ccd1035 100644 --- a/programs/main.kl +++ b/programs/main.kl @@ -139,6 +139,8 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS good_scheduling = true arena: Arena + + data: *int = arena_push_type(&arena, int) window_name := string_to_string16(&arena, "Have a wonderful day! 豈 更 車 賈 滑 串 句 龜 ") w := WNDCLASSW{ lpfnWndProc = window_procedure,