Core: Conditional compound to fix Msvc, better assert but printf based, Fix tests
This commit is contained in:
@@ -17,31 +17,31 @@ and make a pointer out of it. Have to be mindful of the lifetime.
|
||||
*/
|
||||
|
||||
|
||||
storage: [32]S64
|
||||
len : S64
|
||||
storage: [32]int
|
||||
len : int
|
||||
|
||||
"+" :: (a: Any, b: Any): Any
|
||||
result: Any = storage[len++]
|
||||
if a.type == S64 && b.type == S64
|
||||
*(result.data->*S64) = *(a.data->*S64) + *(b.data->*S64)
|
||||
if a.type == int && b.type == int
|
||||
*(result.data->*int) = *(a.data->*int) + *(b.data->*int)
|
||||
return result
|
||||
|
||||
"+" :: (a: Any, b: S64): Any
|
||||
"+" :: (a: Any, b: int): Any
|
||||
result: Any = storage[len++]
|
||||
if a.type == S64
|
||||
*(result.data->*S64) = *(a.data->*S64) + b
|
||||
if a.type == int
|
||||
*(result.data->*int) = *(a.data->*int) + b
|
||||
return result
|
||||
|
||||
"==" :: (a: Any, b: S64): bool
|
||||
"==" :: (a: Any, b: int): bool
|
||||
result := false
|
||||
if a.type == S64
|
||||
result = *(a.data->*S64) == b
|
||||
if a.type == int
|
||||
result = *(a.data->*int) == b
|
||||
return result
|
||||
|
||||
"==" :: (a: Any, b: Any): bool
|
||||
result := false
|
||||
if a.type == S64 && b.type == S64
|
||||
result = *(a.data->*S64) == *(b.data->*S64)
|
||||
if a.type == int && b.type == int
|
||||
result = *(a.data->*int) == *(b.data->*int)
|
||||
return result
|
||||
|
||||
main :: (): int
|
||||
@@ -49,7 +49,7 @@ main :: (): int
|
||||
b: Any = 20
|
||||
c := a + b
|
||||
|
||||
Assert(c.type == S64 && c == 30)
|
||||
Assert(c.type == int && c == 30)
|
||||
Assert(a+b+a==c+(5+5))
|
||||
|
||||
return 0
|
||||
@@ -16,6 +16,12 @@ Tuple :: struct($A: Type, $B: Type)
|
||||
a: A
|
||||
b: B
|
||||
|
||||
Triple :: struct($A: Type, $B: Type, $C: Type)
|
||||
a: A
|
||||
b: B
|
||||
c: C
|
||||
|
||||
|
||||
Variant :: union($A: Type, $B: Type, $C: Type)
|
||||
a: A
|
||||
b: B
|
||||
@@ -49,9 +55,6 @@ GetCount :: (a: int): int
|
||||
// @todo: this is allowed, shouldn't be
|
||||
// Test :: (a: int, b: int = 10, c: int???)
|
||||
|
||||
Test :: (a: C.Triple(int, int, int))
|
||||
pass
|
||||
|
||||
// @todo:
|
||||
// Add :: (arr: *Array($T), item: T)
|
||||
// return
|
||||
@@ -74,7 +77,6 @@ main :: (argc: int, argv: **char): int
|
||||
sixth: Array(Array(F32))
|
||||
seventh: Variant(int, F32, S64)
|
||||
|
||||
Test({1,2,3})
|
||||
test_a := int
|
||||
test := *int
|
||||
Assert(test_a != test)
|
||||
|
||||
@@ -10,6 +10,6 @@ main :: (argc: int, argv: **char): int
|
||||
a: *int = PushStruct(&arena, int, int)
|
||||
b: *F32 = PushStruct(&arena, int, F32)
|
||||
padding := sizeof(int)
|
||||
Assert(arena.len->S64 == (sizeof(int) + sizeof(F32) + padding))
|
||||
Assert(arena.len->int == (sizeof(int) + sizeof(F32) + padding))
|
||||
|
||||
return 0
|
||||
@@ -4,8 +4,8 @@ V2 :: #import "MathVec2.core"; Vec2 :: V2.Vec2
|
||||
|
||||
Epsilon :: 0.00001
|
||||
Screen : *U32
|
||||
X : S64
|
||||
Y : S64
|
||||
X : int
|
||||
Y : int
|
||||
TotalTime: F64
|
||||
LightPos := Vec3{2,4,2}
|
||||
|
||||
@@ -143,7 +143,7 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nS
|
||||
|
||||
requested_time_per_frame: F64 = 1.0 / 60.0
|
||||
frame_start_time := Time()
|
||||
frame_number: S64
|
||||
frame_number: int
|
||||
for AppIsRunning
|
||||
msg: MSG
|
||||
for PeekMessageW(&msg, window, 0, 0, PM_REMOVE) > 0
|
||||
|
||||
@@ -34,15 +34,11 @@ main :: (): int
|
||||
value_to_be_wrapped := 10
|
||||
any_value: Any = value_to_be_wrapped
|
||||
|
||||
if any_value.type == S64
|
||||
*(any_value.data->*S64) = 20
|
||||
elif any_value.type == int
|
||||
// Void pointers get implicitly cast
|
||||
value: *int = any_value.data
|
||||
*value = 30
|
||||
elif any_value.type == char;; Assert(false, "No bueno")
|
||||
if any_value.type == int
|
||||
*(any_value.data->*int) = 20
|
||||
else ;; Assert(false, "No bueno")
|
||||
|
||||
Assert(*(any_value.data->*S64) == 20)
|
||||
Assert(*(any_value.data->*int) == 20)
|
||||
|
||||
letter := GetFirstLetterOfType(value_to_be_wrapped)
|
||||
Assert(letter == 'I')
|
||||
|
||||
Reference in New Issue
Block a user