using System.Collections.Generic; using Ariadne; namespace Vellum.WasmProbe { public enum Mood { Calm, Angry, } [Saveable] public partial struct Pair { public int A; public string B; } [Saveable] public partial class Animal { public string Name; } [Saveable] public sealed partial class Dog : Animal { public int Tricks; } // Nothing in the normal build constructs a Cat, so only a save can bring one into being. [Saveable] public sealed partial class Cat : Animal { public Mood Mood; } [Saveable] public sealed partial class Zoo { public Animal Star; public Animal Other; public List Pairs; public Dictionary Index; public Mood Mood; } public class Gates { public readonly HashSet Open = new HashSet(); } // Nothing in the normal build constructs a Hidden, so only a save can bring one into being. public partial class Hidden : Arc { public int Count; protected override void Run(Gates gates) { int seen = 0; wait: while (!gates.Open.Contains("go")) { seen++; Yield(); } Count = seen; } } public partial class Widening : Arc { public string Log = ""; private static int Wrapping(System.Type type) { int depth = 0; while (type.IsGenericType) { ++depth; type = type.GetGenericArguments()[0]; } return depth; } private void Wrap(Gates gates, ItemType item, int left) { ItemType kept = item; wait: while (!gates.Open.Contains("wrap" + left)) { Yield(); } Log += Wrapping(typeof(ItemType)) + "@" + left + ";"; if (left > 0) { deeper: Wrap(gates, new List { kept }, left - 1); } Log += "up" + Wrapping(kept.GetType()) + ";"; } protected override void Run(Gates gates) { start: Wrap(gates, 7, 2); } } }