namespace Qrakhen.Qamp.Core.Execution; public class Instructions(IEnumerable instructions) : ISteppable, IPeekable, ISeekable { private readonly T[] _instructions = instructions.ToArray(); public long Position { get; private set; } = 0; public long Length => _instructions.LongLength; public bool Done => Position >= _instructions.Length; public T this[long offset] => offset < Length ? _instructions[offset] : throw new ArgumentOutOfRangeException($"Tried to access offset beyond instruction length {offset}:{Length}"); public T Seek(long position) { Position = position; return _instructions[Position]; } public T Next() { return _instructions[Position++]; } public T Peek(int delta = 0) { return _instructions[Position + delta]; } }