diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-08 20:43:39 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-08 20:43:39 +0200 |
| commit | 47c8f99b6ef812dbc22ca56a39ba21bccad47796 (patch) | |
| tree | 7c057a6d408f9b30801767ed528f7f4c207bfbce /testsuite/compilable/generic_arguments.elna | |
| parent | 8f9ba0c67479d8926edead8aa828458c5b3bc1be (diff) | |
| download | elna-47c8f99b6ef812dbc22ca56a39ba21bccad47796.tar.gz | |
Implement generic pointers
Diffstat (limited to 'testsuite/compilable/generic_arguments.elna')
| -rw-r--r-- | testsuite/compilable/generic_arguments.elna | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testsuite/compilable/generic_arguments.elna b/testsuite/compilable/generic_arguments.elna new file mode 100644 index 0000000..6bc5242 --- /dev/null +++ b/testsuite/compilable/generic_arguments.elna @@ -0,0 +1,28 @@ +type + File = record + fd: Int + end + + Pair#[K, V] = record + key: K; + value: V + end + +var + entry: Pair#[^File, ^Word8] + +proc allocate#[T](size: Word) -> T extern + +proc first#[K, V](entry_ptr: ^Pair#[K, V]) -> K +begin +return entry_ptr^.key + +program() +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) +return 0u8 + +end. |
