public MatchModule() { AddWordHandler("()", compiler => compiler.Push(Unit.Value)); // TODO: COMPLETE AddWordHandler("match", async compiler => { var value = compiler.Pop(); var patterns = compiler.TryPop <Ir.List>(); if (patterns == null) { throw new CompilerException("Match requires a list of patterns"); } var vtype = value.Type; int size; if (value is Ir.List vlist) { size = vlist.Count; } else if (vtype == typeof(Vec2)) { size = 2; } else if (vtype == typeof(Vec3)) { size = 3; } else if (vtype == typeof(Vec4)) { size = 4; } else { size = -1; } var runtime = false; Ir currentBlock = null; foreach (var(pattern, handler) in patterns.Where((_, i) => i % 2 == 0) .Zip(patterns.Where((_, i) => i % 2 == 1)).Concat(patterns.Count % 2 == 0 ? new (Ir, Ir)[0] : new[] { ((Ir)Unit.Value, patterns.Last()) }).Reverse())
public void Insert(int index, Ir item) => Elements.Insert(index, item);
public int IndexOf(Ir item) => Elements.IndexOf(item);
public bool Remove(Ir item) => Elements.Remove(item);
public bool Contains(Ir item) => Elements.Contains(item);
public void Add(Ir item) => Elements.Add(item);
public ValueToken(Ir value) : base(Location.Generated, Location.Generated, TokenType.Value, null, null) =>