fixing compiler bugs
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
Os :: #import "os.kl"
|
||||
SizeU :: #strict U64
|
||||
|
||||
arena_di: U64
|
||||
|
||||
ALLOCATOR_ACTION :: enum
|
||||
ALLOCATE
|
||||
RESIZE
|
||||
FREE_ALL
|
||||
|
||||
Allocator :: struct
|
||||
proc: (a: *Allocator, action: ALLOCATOR_ACTION, size: SizeU, old_pointer: *void): *void
|
||||
|
||||
Arena :: struct
|
||||
allocator: Allocator
|
||||
di: U64 // @debug_id
|
||||
memory: Os.Memory
|
||||
alignment: U64
|
||||
@@ -33,6 +41,7 @@ arena_init :: (a: *Arena)
|
||||
a.memory = Os.reserve(a.DEFAULT_RESERVE_SIZE)
|
||||
a.alignment = a.DEFAULT_ALIGNMENT
|
||||
a.di = arena_di++
|
||||
a.allocator.proc = arena_allocator_proc
|
||||
|
||||
arena_push_size :: (a: *Arena, size: SizeU): *void
|
||||
generous_size := size + a.alignment
|
||||
@@ -47,3 +56,21 @@ arena_push_size :: (a: *Arena, size: SizeU): *void
|
||||
a.len += size
|
||||
return result
|
||||
|
||||
arena_release :: (a: *Arena)
|
||||
Os.release(&a.memory)
|
||||
|
||||
arena_allocator_proc :: (a: *Allocator, action: ALLOCATOR_ACTION, size: SizeU, old_pointer: *void): *void
|
||||
arena: *Arena = a->*Arena
|
||||
if action == ALLOCATOR_ACTION.ALLOCATE
|
||||
return arena_push_size(arena, size)
|
||||
elif action == ALLOCATOR_ACTION.RESIZE
|
||||
pass
|
||||
elif action == ALLOCATOR_ACTION.FREE_ALL
|
||||
pass
|
||||
else;; assert(false, "Invalid codepath")
|
||||
return 0
|
||||
|
||||
allocate :: (a: *Allocator, size: SizeU): *void
|
||||
return a.proc(a, ALLOCATOR_ACTION.ALLOCATE, size, 0)
|
||||
|
||||
|
||||
|
||||
@@ -3,4 +3,7 @@
|
||||
main :: (argc: int, argv: **char): int
|
||||
arena: Arena
|
||||
arena_init(&arena)
|
||||
data: *S64 = arena_push_size(&arena, size_of(S64))
|
||||
data: *S64 = arena_push_size(&arena, size_of(S64))
|
||||
*data = 10
|
||||
|
||||
arena_release(&arena)
|
||||
@@ -1,4 +1,4 @@
|
||||
#load "Windows.kl"
|
||||
#import "Windows.kl"
|
||||
RBGQUAD :: struct;; rgbBlue: BYTE; rgbGreen: BYTE; rgbRed: BYTE; rgbReserved: BYTE
|
||||
BITMAPINFOHEADER :: struct;; biSize: DWORD; biWidth: LONG; biHeight: LONG; biPlanes: WORD; biBitCount: WORD; biCompression: DWORD; biSizeImage: DWORD; biXPelsPerMeter: LONG; biYPelsPerMeter: LONG; biClrUsed: DWORD; biClrImportant: DWORD
|
||||
BITMAPINFO :: struct;; bmiHeader: BITMAPINFOHEADER; bmiColors: [1]RBGQUAD
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// #import "base.kl"
|
||||
#load "gdi32.kl"
|
||||
#load "user32.kl"
|
||||
#load "os.kl"
|
||||
#import "base.kl"
|
||||
#import "gdi32.kl"
|
||||
#import "user32.kl"
|
||||
#import "os.kl"
|
||||
#import "Windows.kl"
|
||||
|
||||
question_mark16 :: 0x003f
|
||||
String32 :: struct;; str: *U32; len: S64
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#load "Windows.kl"
|
||||
#import "Windows.kl"
|
||||
WNDPROC :: (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM): LRESULT
|
||||
WNDCLASSW :: struct;; style: UINT; lpfnWndProc: WNDPROC; cbClsExtra: int; cbWndExtra: int; hInstance: HINSTANCE; hIcon: HICON; hCursor: HCURSOR; hbrBackground: HBRUSH; lpszMenuName: LPCWSTR; lpszClassName: LPCWSTR
|
||||
MSG :: struct;; hwnd: HWND; message: UINT; wParam: WPARAM; lParam: LPARAM; time: DWORD; pt: POINT; lPrivate: DWORD
|
||||
|
||||
Reference in New Issue
Block a user