/// <summary> /// Writes the contents of a binary loyc file to the current output stream. /// </summary> /// <param name="Nodes"></param> public void WriteFileContents(IReadOnlyList <LNode> Nodes) { using (var memStream = new MemoryStream()) using (var childWriter = new LoycBinaryWriter(memStream, this)) { var state = new WriterState(); childWriter.WriteList(Nodes, node => childWriter.WritePrefixedNode(state, node)); memStream.Seek(0, SeekOrigin.Begin); WriteHeader(state); memStream.CopyTo(Writer.BaseStream); } }
/// <summary> /// Writes a reference to the given node template. /// </summary> /// <param name="State"></param> /// <param name="Value"></param> public void WriteReference(WriterState State, NodeTemplate Value) { WriteULeb128((uint)State.GetIndex(Value)); }
/// <summary> /// Writes the given header to the output stream. /// </summary> /// <param name="Header"></param> public void WriteHeader(WriterState Header) { WriteSymbolTable(Header.Symbols); WriteTemplateTable(Header.Templates); }
/// <summary> /// Writes a reference to the given string. /// </summary> /// <param name="State"></param> /// <param name="Value"></param> public void WriteReference(WriterState State, string Value) { WriteULeb128((uint)State.GetIndex(Value)); }