Any type initially working

This commit is contained in:
Krzosa Karol
2022-06-19 12:34:05 +02:00
parent ade2638255
commit 014ef07b9f
6 changed files with 93 additions and 55 deletions

View File

@@ -41,24 +41,50 @@ create_bitmap :: (size: Vec2I, bottom_up: Bool = true): Windows_Bitmap
result.hdc = CreateCompatibleDC(hdc)
return result
print :: (type: Type)
type_info := get_type_info(type)
_gcvt :: #foreign (value: F64, digits: int, buffer: *char): *char
print_float :: (value: F64)
buff: [100]char
_gcvt(value, 10, &buff[0])
OutputDebugStringA(&buff[0])
print_type :: (t: Type)
type_info := get_type_info(t)
if !type_info
return
switch type_info.kind
S64, S32, S16, S8, int
Type_Info_Kind.S64, Type_Info_Kind.S32, Type_Info_Kind.S16, Type_Info_Kind.S8, Type_Info_Kind.INT
OutputDebugStringA("Integer")
U64, U32, U16, U8
Type_Info_Kind.U64, Type_Info_Kind.U32, Type_Info_Kind.U16, Type_Info_Kind.U8
OutputDebugStringA("Unsigned")
Type_Info_Kind.F64, Type_Info_Kind.F32
OutputDebugStringA("Float")
Type_Info_Kind.POINTER
OutputDebugStringA("*")
print(type_info.base_type)
Type_Info_Kind.SLICE
OutputDebugStringA("[]")
print(type_info.base_type)
print_type(type_info.base_type)
default;; OutputDebugStringA("Unknown")
print :: (a: Any)
type_info := get_type_info(a.type)
if !type_info
return
print_type(a.type)
OutputDebugStringA(" - ")
// @todo check for types here
switch type_info.kind
Type_Info_Kind.S64, Type_Info_Kind.S32, Type_Info_Kind.S16, Type_Info_Kind.S8, Type_Info_Kind.INT
OutputDebugStringA("Integer")
Type_Info_Kind.U64, Type_Info_Kind.U32, Type_Info_Kind.U16, Type_Info_Kind.U8
OutputDebugStringA("Unsigned")
Type_Info_Kind.F64
data := a.data->*F64
print_float(*data)
Type_Info_Kind.POINTER
OutputDebugStringA("Pointer")
default;; OutputDebugStringA("Unknown")
app_is_running := true
window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
if msg == WM_DESTROY
@@ -67,19 +93,15 @@ window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRE
return 0
else;; return DefWindowProcW(hwnd, msg, wparam, lparam)
_gcvt :: #foreign (value: F64, digits: int, buffer: *char): *char
print_float :: (value: F64)
buff: [100]char
_gcvt(value, 10, &buff[0])
OutputDebugStringA("\n")
OutputDebugStringA(&buff[0])
WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nShowCmd: int): int
if good_scheduling := false, timeBeginPeriod(1) == TIMERR_NOERROR
good_scheduling = true
print([]**S64)
char_info := get_type_info(char)
val := 4232.23
thing: Any = val
print(val)
assert(char_info.kind == Type_Info_Kind.CHAR)
#assert(int == int)
#assert(int != char)