odin progress

This commit is contained in:
2025-06-25 10:13:20 -04:00
parent b84f9ada59
commit 618cfd396b
2 changed files with 165 additions and 26 deletions

View File

@@ -525,12 +525,11 @@ Byte* kt1cx__set (KT1CX_Byte kt, U64 key, Slice_Byte value, AllocatorInfo ba
#pragma region String Operations #pragma region String Operations
inline B32 char_is_upper(U8 c) { return('A' <= c && c <= 'Z'); } inline B32 char_is_upper(U8 c) { return('A' <= c && c <= 'Z'); }
inline U8 char_to_lower(U8 c) { if (char_is_upper(c)) { c += ('a' - 'A'); } return(c); } inline U8 char_to_lower(U8 c) { if (char_is_upper(c)) { c += ('a' - 'A'); } return(c); }
char* str8_to_cstr_capped(Str8 content, Slice_Byte mem);
inline U8 integer_symbols(U8 value) { inline U8 integer_symbols(U8 value) {
local_persist U8 lookup_table[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F', }; return lookup_table[value]; local_persist U8 lookup_table[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F', }; return lookup_table[value];
} }
char* str8_to_cstr_capped(Str8 content, Slice_Byte mem);
Str8 str8_from_u32(AllocatorInfo ainfo, U32 num, U32 radix, U8 min_digits, U8 digit_group_separator); Str8 str8_from_u32(AllocatorInfo ainfo, U32 num, U32 radix, U8 min_digits, U8 digit_group_separator);
typedef def_farray(Str8, 2); typedef def_farray(Str8, 2);
@@ -568,8 +567,6 @@ typedef def_struct(Opts_str8cache_init) {
void str8cache__init(Str8Cache* cache, Opts_str8cache_init* opts); void str8cache__init(Str8Cache* cache, Opts_str8cache_init* opts);
Str8Cache str8cache__make( Opts_str8cache_init* opts); Str8Cache str8cache__make( Opts_str8cache_init* opts);
#define str8gen_slice_byte(gen) (Slice_Byte){ cast(Byte*, (gen).ptr), (gen).cap }
#define str8cache_init(cache, ...) str8cache__init(cache, opt_args(Opts_str8cache_init, __VA_ARGS__)) #define str8cache_init(cache, ...) str8cache__init(cache, opt_args(Opts_str8cache_init, __VA_ARGS__))
#define str8cache_make(...) str8cache__make( opt_args(Opts_str8cache_init, __VA_ARGS__)) #define str8cache_make(...) str8cache__make( opt_args(Opts_str8cache_init, __VA_ARGS__))
@@ -588,6 +585,8 @@ typedef def_struct(Str8Gen) {
void str8gen_init(Str8Gen* gen, AllocatorInfo backing); void str8gen_init(Str8Gen* gen, AllocatorInfo backing);
Str8Gen str8gen_make( AllocatorInfo backing); Str8Gen str8gen_make( AllocatorInfo backing);
#define str8gen_slice_byte(gen) (Slice_Byte){ cast(Byte*, (gen).ptr), (gen).cap }
inline Str8 str8_from_str8gen(Str8Gen gen) { return (Str8){gen.ptr, gen.len}; } inline Str8 str8_from_str8gen(Str8Gen gen) { return (Str8){gen.ptr, gen.len}; }
void str8gen_append_str8(Str8Gen* gen, Str8 str); void str8gen_append_str8(Str8Gen* gen, Str8 str);

View File

@@ -1,6 +1,6 @@
/* /*
WATL Exercise WATL Exercise
Version: 0 (From Scratch, 1-Stage Compilation, MSVC & WinAPI Only, Win CRT Multi-threaded Static Linkage) Version: 0 (From Scratch, 1-Stage Compilation, WinAPI Only, Win CRT Multi-threaded Static Linkage)
Host: Windows 11 (x86-64) Host: Windows 11 (x86-64)
Toolchain: odin-lang/Odin dev-2025-06 Toolchain: odin-lang/Odin dev-2025-06
*/ */
@@ -69,7 +69,7 @@ Raw_Slice :: struct {
len: int, len: int,
} }
slice_assert :: proc "contextless" (s: $Type / []$SliceType) -> Type { slice_assert :: proc "contextless" (s: $Type / []$SliceType) -> Type {
return assert(len(s) > 0) && s != nil return assert(len(s) > 0) && assert(s != nil)
} }
slice_end :: proc "contextless" (s : $Type / []$SliceType) -> Type { slice_end :: proc "contextless" (s : $Type / []$SliceType) -> Type {
return s[len(s) - 1] return s[len(s) - 1]
@@ -78,7 +78,7 @@ size_of_slice_type :: proc "contextless" (slice: $Type / []$SliceType) -> int {
return size_of(E) return size_of(E)
} }
@(require_results) @(require_results)
to_bytes :: proc "contextless" (s: []$Type) -> []byte { slice_to_bytes :: proc "contextless" (s: []$Type) -> []byte {
return ([^]byte)(raw_data(s))[:len(s) * size_of(T)] return ([^]byte)(raw_data(s))[:len(s) * size_of(T)]
} }
slice_zero :: proc "contextless" (data: $Type / []$SliceType) -> Type { slice_zero :: proc "contextless" (data: $Type / []$SliceType) -> Type {
@@ -109,7 +109,8 @@ sll_queue_push_nz :: proc(nil_val: ^$SLL_NodeType, first: ^SLL_NodeType, last: ^
first^ = n first^ = n
last^ = n last^ = n
n.next = nil_val n.next = nil_val
} else { }
else {
last^.next = n last^.next = n
last^ = n last^ = n
n.next = nil_val n.next = nil_val
@@ -347,24 +348,163 @@ KT1L_Meta :: struct {
slot_size: int, slot_size: int,
kt_value_offset: int, kt_value_offset: int,
type_width: int, type_width: int,
type_name: string, type_name: int,
} }
kt1l_populate_slice_a2_Slice_Byte :: proc(kt: ^[]KT1L_Slot(byte), m: KT1L_Meta, backing: AllocatorInfo, values: []byte, num_values: []byte) { kt1l_populate_slice_a2_Slice_Byte :: proc(kt: ^[]KT1L_Slot(byte), m: KT1L_Meta, backing: AllocatorInfo, values: [][2]byte) -> int {
} }
kt1l_populate_slice_a2 :: proc($Type: typeid, kt: ^[]KT1L_Slot(Type), backing: AllocatorInfo, values: [][2]Type) { kt1l_populate_slice_a2 :: proc($Type: typeid, kt: ^[]KT1L_Slot(Type), backing: AllocatorInfo, values: [][2]Type) -> int {
} }
//#endregion("Key Table 1-Layer Linear (KT1L)") //#endregion("Key Table 1-Layer Linear (KT1L)")
//#region("Key Table 1-Layer Chained-Chunked-Cells (KT1CX)") //#region("Key Table 1-Layer Chained-Chunked-Cells (KT1CX)")
KT1CX_Slot :: struct($type: typeid) {
value: type,
key: u64,
occupied: b32,
}
KT1CX_Cell :: struct($type: typeid, $depth: int) {
slots: [depth]KT1CX_Slot(type),
next: ^KT1CX_Cell(type, depth),
}
KT1CX :: struct($type: typeid, $depth: int, $cell: typeid / KT1CX_Cell(type, depth)) {
cell_pool: []cell,
table: []cell,
}
KT1CX_Byte_Slot :: struct {
key: u64,
occupied: b32,
}
KT1CX_Byte_Cell :: struct {
next: ^byte,
}
KT1CX_Byte :: struct {
cell_pool: []byte,
table: []byte,
}
KT1CX_ByteMeta :: struct {
slot_size: int,
slot_key_offset: int,
cell_next_offset: int,
cell_depth: int,
cell_size: int,
type_width: int,
type_name: string,
}
KT1CX_InfoMeta :: struct {
cell_pool_size: int,
table_size: int,
slot_size: int,
slot_key_offset: int,
cell_next_offset: int,
cell_depth: int,
cell_size: int,
type_width: int,
type_name: string,
}
KT1CX_Info :: struct {
backing_table: AllocatorInfo,
backing_cells: AllocatorInfo,
}
kt1cx_init :: proc(info: KT1CX_Info, m: KT1CX_InfoMeta, result: ^KT1CX_Byte) {
}
kt1cx_clear :: proc(kt: KT1CX_Byte, m: KT1CX_ByteMeta) {
}
kt1cx_slot_id :: proc(kt: KT1CX_Byte, key: u64, m: KT1CX_ByteMeta) {
}
kt1cx_get :: proc(kt: KT1CX_Byte, key: u64, m: KT1CX_ByteMeta) {
}
kt1cx_set :: proc(kt: KT1CX_Byte, key: u64, value: []byte, backing_cells: AllocatorInfo, m: KT1CX_ByteMeta) {
}
kt1cx_assert :: proc(kt: $type / KT1CX) {
slice_assert(kt.cell_pool)
slice_assert(kt.table)
}
kt1cx_byte :: proc(kt: $type / KT1CX) -> KT1CX_Byte { return { slice_to_bytes(kt.cell_pool), slice_to_bytes(kt.table) } }
//#endregion("Key Table 1-Layer Chained-Chunked-Cells (KT1CX)") //#endregion("Key Table 1-Layer Chained-Chunked-Cells (KT1CX)")
//#region("String Operations") //#region("String Operations")
char_is_upper :: proc(c: u8) -> b32 { return('A' <= c && c <= 'Z') }
char_to_lower :: proc(c: u8) -> u8 { c:=c; if (char_is_upper(c)) { c += ('a' - 'A') }; return (c) }
integer_symbols :: proc(value: u8) -> u8 {
@static lookup_table: [16]u8 = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F', };
return lookup_table[value];
}
str8_to_cstr_capped :: proc(content: string, mem: []byte) -> cstring {
}
str8_from_u32 :: proc(ainfo: AllocatorInfo, num: u32, radix: u32 = 10, min_digits: u8 = 0, digit_group_separator: u8 = 0) -> string {
}
str8_fmt_backed :: proc(tbl_ainfo, buf_ainfo: AllocatorInfo, fmt_template: string, entries: [][2]string) -> string {
}
str8_fmt_tmp :: proc(fmt_template: string, entries: [][2]string) -> string {
}
Str8Cache_CELL_DEPTH :: 4
KT1CX_Slot_Str8 :: KT1CX_Slot(string)
KT1CX_Cell_Str8 :: KT1CX_Cell(string, Str8Cache_CELL_DEPTH)
KT1CX_Str8 :: KT1CX(string, Str8Cache_CELL_DEPTH, KT1CX_Cell_Str8)
Str8Cache :: struct {
str_reserve: AllocatorInfo,
cell_reserve: AllocatorInfo,
tbl_backing: AllocatorInfo,
kt: KT1CX_Str8,
}
str8cache_init :: proc(cache: ^Str8Cache, str_reserve, cell_reserve, tbl_backing: AllocatorInfo, cell_pool_size, table_size: int) {
}
str8cache_make :: proc(str_reserve, cell_reserve, tbl_backing: AllocatorInfo, cell_pool_size, table_size: int) -> Str8Cache {
cache : Str8Cache; str8cache_init(& cache, str_reserve, cell_reserve, tbl_backing, cell_pool_size, table_size); return cache
}
str8cache_clear :: proc(kt: KT1CX_Str8) {
}
str8cache_get :: proc(kt: KT1CX_Str8, key: u64) -> ^string {
}
str8cache_set :: proc(kt: KT1CX_Str8, key: u64, value: string, str_reserve, cell_reserve: AllocatorInfo) -> ^string {
}
cache_str8 :: proc(cache: ^Str8Cache, str: string) -> ^string {
}
Str8Gen :: struct {
backing: AllocatorInfo,
ptr: ^u8,
len: int,
cap: int,
}
str8gen_init :: proc(gen: ^Str8Gen, ainfo: AllocatorInfo) {
}
str8gen_make :: proc(ainfo: AllocatorInfo) -> Str8Gen { gen: Str8Gen; str8gen_init(& gen, ainfo); return gen }
str8gen_to_bytes :: proc(gen: Str8Gen) -> []byte { return transmute([]byte) Raw_Slice {data = gen.ptr, len = gen.len} }
str8_from_str8gen :: proc(gen: Str8Gen) -> string { return transmute([]string) Raw_Slice {data = gen.ptr, len = gen.len} }
str8gen_append_str8 :: proc(gen: ^Str8Gen, str: string) {
}
str8gen_append_fmt :: proc(gen: ^Str8Gen, fmt_template: string, tokens: [][2]string) {
}
//#endregion("String Operations") //#endregion("String Operations")
//#region("File System") //#region("File System")
//#endregion("File System") //#endregion("File System")
//#region("WATL") //#region("WATL")