From 0471dbe7d77d20ed8318dbd58ecc3a889a3c6b1e Mon Sep 17 00:00:00 2001 From: Niels Bross Date: Tue, 16 Jul 2024 14:31:54 +0200 Subject: [PATCH] Add nbrutil to modules. Move static array to nbrutil --- .gitmodules | 3 +++ Codegen.jai | 3 +++ Lexing.jai | 1 + Semantic_Analysis.jai | 3 ++- modules/nbrutil | 1 + static_array.jai | 43 ------------------------------------------- 6 files changed, 10 insertions(+), 44 deletions(-) create mode 100644 .gitmodules create mode 160000 modules/nbrutil delete mode 100644 static_array.jai diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3de15ae --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/nbrutil"] + path = modules/nbrutil + url = git@git.nbross.com:nielsbross/nbrutil.git diff --git a/Codegen.jai b/Codegen.jai index 3ff3b9b..a755843 100644 --- a/Codegen.jai +++ b/Codegen.jai @@ -477,3 +477,6 @@ codegen :: (ast_root : *AST_Node, checker_result : Semantic_Check_Result, output init_codegen_state(*codegen_state, ast_root, checker_result, output_language); return codegen(*codegen_state); } + +#scope_module +#import "nbrutil"; diff --git a/Lexing.jai b/Lexing.jai index 9c05158..188a45e 100644 --- a/Lexing.jai +++ b/Lexing.jai @@ -700,3 +700,4 @@ print_from_source_location :: (source_location : Source_Range, allocator := cont #import "Basic"; +#import "File"; diff --git a/Semantic_Analysis.jai b/Semantic_Analysis.jai index 4d6151e..63d4f44 100644 --- a/Semantic_Analysis.jai +++ b/Semantic_Analysis.jai @@ -8,8 +8,9 @@ // [x] Improve error reporting on mismatched overloads when types don't match, but arity does // [x] Improve error reporting for type mismatches in general. It seems like the expect node is not always correct. -#load "static_array.jai"; +#import "nbrutil"; #import "Hash_Table"; +#import "String"; VERTEX_MAIN_FUNCTION_PREFIX :: "vertex"; PIXEL_MAIN_FUNCTION_PREFIX :: "pixel"; diff --git a/modules/nbrutil b/modules/nbrutil new file mode 160000 index 0000000..d827960 --- /dev/null +++ b/modules/nbrutil @@ -0,0 +1 @@ +Subproject commit d82796090a29f454ea2525179725294bed598838 diff --git a/static_array.jai b/static_array.jai deleted file mode 100644 index edfc51e..0000000 --- a/static_array.jai +++ /dev/null @@ -1,43 +0,0 @@ -Static_Array :: struct (T : Type, N : int) { - array : [N] T; - - count : int; -} - -operator *[] :: (sa : *Static_Array, index : int) -> *sa.T { - assert(index < sa.count); - return *sa.array[index]; -} - -array_add :: (sa : *Static_Array, item : sa.T) { - assert(sa.count + 1 < sa.N); - - sa.array[sa.count] = item; - sa.count += 1; -} - -array_add :: (sa : *Static_Array) -> *sa.T { - assert(sa.count + 1 < sa.N); - - ptr := *sa.array[sa.count]; - sa.count += 1; - return ptr; -} - -pop :: (sa : *Static_Array) -> sa.T { - assert(sa.count > 0); - elem := sa.array[sa.count - 1]; - sa.count -= 1; - return elem; -} - -clear :: (sa : *Static_Array) { - sa.count = 0; -} - -to_array :: (sa : *Static_Array) -> []sa.T { - array : []sa.T; - array.count = sa.count; - array.data = sa.array.data; - return array; -}