summaryrefslogtreecommitdiff
path: root/test/c/poly_union_rev.sail
diff options
context:
space:
mode:
authorAlasdair2018-08-13 19:55:23 +0100
committerAlasdair2018-08-13 19:55:23 +0100
commit82642087083f6c7c548e7c8b14233fde8198e9c7 (patch)
tree41ca0bf065970e1678af30e16247206cae370e82 /test/c/poly_union_rev.sail
parent01fd68577abfa98a901b220a9928b397047e9fd4 (diff)
Sort ctype_defs in dependency order after specialisation
We now generate anonymous types in the correct order, but post specialisation more dependencies can occur between named types, so an additional sorting step is needed to ensure that these happen in the correct order. In theory we could end up with circular dependencies here that don't exist at the Sail source level, but this shouldn't occur often (or ever) in practice. I think this is fixable but it would require some code generator changes.
Diffstat (limited to 'test/c/poly_union_rev.sail')
-rw-r--r--test/c/poly_union_rev.sail27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/c/poly_union_rev.sail b/test/c/poly_union_rev.sail
new file mode 100644
index 00000000..bc654808
--- /dev/null
+++ b/test/c/poly_union_rev.sail
@@ -0,0 +1,27 @@
+default Order dec
+
+val print = "print_endline" : string -> unit
+
+union option ('a : Type) = {
+ Some : 'a,
+ None : unit
+}
+
+union ast = {
+ HCF : unit
+}
+
+val decode : unit -> option(ast)
+
+function decode() = Some(HCF())
+
+val main : unit -> unit
+
+function main() = {
+ let instr = decode();
+ match instr {
+ Some(HCF()) => print("HCF"),
+ Some(_) => print("Some(_)"),
+ None() => print("None")
+ }
+} \ No newline at end of file