Polymorphism: Add already resolved decls for identifiers

This commit is contained in:
Krzosa Karol
2023-04-03 11:55:14 +02:00
parent 41d2baa56b
commit b543e1df9d
4 changed files with 43 additions and 26 deletions

View File

@@ -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)