Add nbrutil to modules. Move static array to nbrutil
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "modules/nbrutil"]
|
||||||
|
path = modules/nbrutil
|
||||||
|
url = git@git.nbross.com:nielsbross/nbrutil.git
|
||||||
@@ -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);
|
init_codegen_state(*codegen_state, ast_root, checker_result, output_language);
|
||||||
return codegen(*codegen_state);
|
return codegen(*codegen_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#scope_module
|
||||||
|
#import "nbrutil";
|
||||||
|
|||||||
@@ -700,3 +700,4 @@ print_from_source_location :: (source_location : Source_Range, allocator := cont
|
|||||||
|
|
||||||
|
|
||||||
#import "Basic";
|
#import "Basic";
|
||||||
|
#import "File";
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
// [x] Improve error reporting on mismatched overloads when types don't match, but arity does
|
// [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.
|
// [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 "Hash_Table";
|
||||||
|
#import "String";
|
||||||
|
|
||||||
VERTEX_MAIN_FUNCTION_PREFIX :: "vertex";
|
VERTEX_MAIN_FUNCTION_PREFIX :: "vertex";
|
||||||
PIXEL_MAIN_FUNCTION_PREFIX :: "pixel";
|
PIXEL_MAIN_FUNCTION_PREFIX :: "pixel";
|
||||||
|
|||||||
1
modules/nbrutil
Submodule
1
modules/nbrutil
Submodule
Submodule modules/nbrutil added at d82796090a
@@ -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;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user