public RuntimeMemoryModel(NanCodeWriter writer, Scope parentScope) { Variables = new Scope(parentScope); var ms = new MemoryStream((int)writer.OpCodeCount() * 16); writer.WriteToStream(ms); ms.Seek(0, SeekOrigin.Begin); encodedTokens = new List <double>((int)(ms.Length / 8)); var raw = ms.ToArray(); for (int i = 0; i < raw.Length; i += 8) { encodedTokens.Add(BitConverter.ToDouble(raw, i)); } }