Polymorphism: Add already resolved decls for identifiers
This commit is contained in:
@@ -26,10 +26,7 @@ Array :: struct($T: Type)
|
||||
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
|
||||
@@ -63,12 +60,24 @@ GetCount :: (a: int): int
|
||||
// @todo: this is allowed, shouldn't be
|
||||
// Test :: (a: int, b: int = 10, c: int???)
|
||||
|
||||
Test :: (a: int, b: int = 10, c: int = 20)
|
||||
Test :: (a: C.Triple(int, int, int))
|
||||
pass
|
||||
|
||||
// @todo:
|
||||
// Add :: (arr: *Array($T), item: T)
|
||||
// return
|
||||
|
||||
C :: #import "LibC.core"
|
||||
|
||||
Add :: (arr: *Array(T), val: $T)
|
||||
if arr.cap == 0
|
||||
arr.cap = 16
|
||||
arr.data = C.malloc(SizeOf(T)->U64 * arr.cap->U64)
|
||||
arr.data[arr.len++] = val
|
||||
|
||||
main :: (argc: int, argv: **char): int
|
||||
buff: *int
|
||||
array: Array(int) = {len = 10, cap = 10, data = buff}
|
||||
array: Array(S64)
|
||||
second_array: Array(int)
|
||||
third_array: Array(int)
|
||||
fourth: Array(F32)
|
||||
@@ -76,6 +85,7 @@ 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)
|
||||
@@ -85,12 +95,7 @@ main :: (argc: int, argv: **char): int
|
||||
|
||||
a := MultipleArgs()
|
||||
|
||||
Test(10)
|
||||
Test(10, 20)
|
||||
Test(10, 20, 30)
|
||||
Test(10, b = 10)
|
||||
Test(10, b = 10, c = 20)
|
||||
Test(a = 10, b = 10, c = 20)
|
||||
Add(&array, 32)
|
||||
|
||||
// value := PolyLambda(**int)
|
||||
// PolyType_r1 := PolyType(10)
|
||||
|
||||
@@ -15,3 +15,8 @@ fread :: #foreign (buffer: *void, element_size: size_t, element_count: size_t, s
|
||||
SEEK_CUR :: 1
|
||||
SEEK_END :: 2
|
||||
SEEK_SET :: 0
|
||||
|
||||
Triple :: struct($A: Type, $B: Type, $C: Type)
|
||||
a: A
|
||||
b: B
|
||||
c: C
|
||||
Reference in New Issue
Block a user