From cf8478e9414d4da2188df690f5fe17857fea2775 Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Wed, 29 Mar 2023 11:42:54 +0200 Subject: [PATCH] polymorphism.core --- examples/polymorphism.core | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/polymorphism.core diff --git a/examples/polymorphism.core b/examples/polymorphism.core new file mode 100644 index 0000000..11e9eb5 --- /dev/null +++ b/examples/polymorphism.core @@ -0,0 +1,29 @@ + +/* +PushStruct :: (a: *MA.Arena, $T: Type): *$T + size := size_of(Type) + result := PushSize(a, size) + return result + +Array :: struct($T: Type) + data: *T + len: int + cap: int + +Array(int) + +QueueAddSLL(list: $List, node: $Node, first: #Identifier = first, last: #Identifier = last, next: #Identifier = next) + +ArrayAdd(array: $Array, item: $Item, data: #Identifier = data, len: #Identifier = len, len: #Identifier = cap) + +QueueAddSLL(list: $List, node: $Node, $first = first, $last = last, $next = next) + if list.first == 0 + list.first = list.last = node + else + list.last = list.last.next = node + +*/ + +main :: (argc: int, argv: **char): int + $i := 10 + return 0 \ No newline at end of file