aboutsummaryrefslogtreecommitdiff
path: root/testsuite/compilable
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-10-03 20:51:22 +0200
committerEugen Wissner <belka@caraus.de>2026-10-03 20:51:22 +0200
commite4ce7f658741a7428597da4872435a1b0bae944c (patch)
tree50f65abf6fa4468db7bc93a6ae61d623a2dd8566 /testsuite/compilable
parent5d808dd4c4003968bbdf180e1e1193231db5d43b (diff)
downloadelna-e4ce7f658741a7428597da4872435a1b0bae944c.tar.gz
Rework generics for parameters to be plain types
Diffstat (limited to 'testsuite/compilable')
-rw-r--r--testsuite/compilable/generic_alias.elna10
-rw-r--r--testsuite/compilable/generic_arguments.elna18
-rw-r--r--testsuite/compilable/generic_base_chain.elna14
-rw-r--r--testsuite/compilable/generic_const_inference.elna4
-rw-r--r--testsuite/compilable/generic_inference.elna10
-rw-r--r--testsuite/compilable/generic_pointee.elna17
6 files changed, 45 insertions, 28 deletions
diff --git a/testsuite/compilable/generic_alias.elna b/testsuite/compilable/generic_alias.elna
index 47ac638..da9501a 100644
--- a/testsuite/compilable/generic_alias.elna
+++ b/testsuite/compilable/generic_alias.elna
@@ -6,7 +6,7 @@ type
Node#[T] = record
next: ^Node#[T];
- value: T
+ value: ^T
end
Ref#[T] = ^T
@@ -16,10 +16,10 @@ type
end
var
- chain: Node#[^File]
- aliased: Ref#[^File]
- raw: ^^File
- boxed: Boxed#[^File]
+ chain: Node#[File]
+ aliased: Ref#[File]
+ raw: ^File
+ boxed: Boxed#[File]
begin
chain.next := nil;
diff --git a/testsuite/compilable/generic_arguments.elna b/testsuite/compilable/generic_arguments.elna
index 4d33db5..1cda57f 100644
--- a/testsuite/compilable/generic_arguments.elna
+++ b/testsuite/compilable/generic_arguments.elna
@@ -5,22 +5,22 @@ type
end
Pair#[K, V] = record
- key: K;
- value: V
+ key: ^K;
+ value: ^V
end
var
- entry: Pair#[^File, ^Word8]
+ entry: Pair#[File, Word8]
-proc allocate#[T](size: Word) -> T
+proc allocate#[T](size: Word) -> ^T
extern
-proc first#[K, V](entry_ptr: ^Pair#[K, V]) -> K
+proc first#[K, V](entry_ptr: ^Pair#[K, V]) -> ^K
return entry_ptr^.key
begin
- entry.key := allocate#[^File](#size(File));
- assert(#size(Pair#[^File, ^Word8]) = #size(Pointer) * 2u);
- assert(#offset(Pair#[^File, ^Word8], value) = #size(Pointer));
- assert(first#[^File, ^Word8](@entry) = entry.key)
+ entry.key := allocate#[File](#size(File));
+ assert(#size(Pair#[File, Word8]) = #size(Pointer) * 2u);
+ assert(#offset(Pair#[File, Word8], value) = #size(Pointer));
+ assert(first#[File, Word8](@entry) = entry.key)
end.
diff --git a/testsuite/compilable/generic_base_chain.elna b/testsuite/compilable/generic_base_chain.elna
index c303e6d..1abe199 100644
--- a/testsuite/compilable/generic_base_chain.elna
+++ b/testsuite/compilable/generic_base_chain.elna
@@ -5,20 +5,20 @@ type
end
Map#[K, V] = record
- key: K;
- value: V
+ key: ^K;
+ value: ^V
end
- Cache#[K, V] = record(Map#[^Word8, V])
- newest: K
+ Cache#[K, V] = record(Map#[Word8, V])
+ newest: ^K
end
var
- store: Cache#[^Int, ^File]
+ store: Cache#[Int, File]
byte_key: ^Word8
- upcast: ^Map#[^Word8, ^File]
+ upcast: ^Map#[Word8, File]
-proc put#[K2, V2](target: ^Map#[K2, V2]; key: K2)
+proc put#[K2, V2](target: ^Map#[K2, V2]; key: ^K2)
begin
target^.key := key
return
diff --git a/testsuite/compilable/generic_const_inference.elna b/testsuite/compilable/generic_const_inference.elna
index a9fc41f..7ce197f 100644
--- a/testsuite/compilable/generic_const_inference.elna
+++ b/testsuite/compilable/generic_const_inference.elna
@@ -10,10 +10,10 @@ var
nested: NestedConst := nil
direct_const: const ^Word8 := nil
-proc write#[T](fd: Int; buf: T; count: Int) -> Int
+proc write#[T](fd: Int; buf: ^T; count: Int) -> Int
return 0
-proc write_const#[T](fd: Int; buf: const T; count: Int) -> Int
+proc write_const#[T](fd: Int; buf: ^const T; count: Int) -> Int
return 0
begin
diff --git a/testsuite/compilable/generic_inference.elna b/testsuite/compilable/generic_inference.elna
index 860eab1..9d7fed6 100644
--- a/testsuite/compilable/generic_inference.elna
+++ b/testsuite/compilable/generic_inference.elna
@@ -5,20 +5,20 @@ type
end
Cell#[T] = record
- held: T
+ held: ^T
end
var
- files: Cell#[^File]
- bytes: Cell#[^Word8]
+ files: Cell#[File]
+ bytes: Cell#[Word8]
f: File
b: Word8
-proc store#[T](target: ^Cell#[T]; value: T)
+proc store#[T](target: ^Cell#[T]; value: ^T)
target^.held := value
return
-proc relay#[T](target: ^Cell#[T]; value: T)
+proc relay#[T](target: ^Cell#[T]; value: ^T)
store(target, value)
return
diff --git a/testsuite/compilable/generic_pointee.elna b/testsuite/compilable/generic_pointee.elna
new file mode 100644
index 0000000..5ecaedf
--- /dev/null
+++ b/testsuite/compilable/generic_pointee.elna
@@ -0,0 +1,17 @@
+program()
+
+type
+ File = record
+ fd: Int
+ end
+
+proc allocate#[T](size: Word) -> ^T
+extern
+
+var
+ f: ^File
+
+begin
+ f := allocate#[File](#size(File));
+ assert(f = nil)
+end.