Add nbrutil to modules. Move static array to nbrutil

This commit is contained in:
2024-07-16 14:31:54 +02:00
parent c5758bd023
commit 0471dbe7d7
6 changed files with 10 additions and 44 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "modules/nbrutil"]
path = modules/nbrutil
url = git@git.nbross.com:nielsbross/nbrutil.git

View File

@@ -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";

View File

@@ -700,3 +700,4 @@ print_from_source_location :: (source_location : Source_Range, allocator := cont
#import "Basic";
#import "File";

View File

@@ -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";

1
modules/nbrutil Submodule

Submodule modules/nbrutil added at d82796090a

View File

@@ -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;
}