Got this thing to compile and seem operable at runtime

There was quite a few errors with the hashtable (not suprised). I need to use it more to see if it fails to work properly.

For now it should be fine enough for prototyping
This commit is contained in:
2024-02-22 23:15:29 -05:00
parent 7332644515
commit 9b3bc6fd68
7 changed files with 208 additions and 67 deletions

View File

@ -4,12 +4,14 @@ package sectr
import "base:builtin"
import "base:runtime"
import c "core:c/libc"
import "core:hash"
import "core:mem"
import "core:mem/virtual"
import "core:os"
import "core:path/filepath"
import c "core:c/libc"
Byte :: 1
Kilobyte :: 1024 * Byte
Megabyte :: 1024 * Kilobyte
@ -32,6 +34,7 @@ terabyte :: proc ( tb : $ integer_type ) -> integer_type {
}
copy :: builtin.copy
crc32 :: hash.crc32
Allocator :: mem.Allocator
AllocatorError :: mem.Allocator_Error
alloc :: mem.alloc
@ -53,6 +56,39 @@ get_bounds :: proc {
view_get_bounds,
}
//region Stack - Basic fixed-size stack container
Stack :: struct ( $ Type : typeid, $ Size : i32 ) {
idx : i32,
items : [ Size ] Type,
}
stack_push :: proc( stack : ^ $ StackType / Stack( $ Type, $ Size ), value : Type ) {
using stack
verify( idx < len( items ), "Attempted to push on a full stack" )
items[ idx ] = value
idx += 1
}
stack_pop :: proc( stack : ^ $ StackType / Stack( $ Type, $ Size ) ) {
using stack
verify( idx > 0, "Attempted to pop an empty stack" )
idx -= 1
}
stack_peek :: proc ( stack : ^ Stack( $ Type, $ Size ) ) -> ^ Type {
using stack
return & items[idx]
}
//endregion Stack
// TODO(Ed) : This is extremely jank, Raylib requires a 'heap' allocator with the way it works.