Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectFileAssembler"/> class.
 /// </summary>
 /// <param name="objectFile">The <see cref="ObjectFile"/> that will be assembled.</param>
 protected ObjectFileAssembler(ObjectFile objectFile)
 {
     #region Contract
     Contract.Requires <ArgumentNullException>(objectFile != null);
     #endregion
     this.objectFile = objectFile;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectFileAssembler"/> class.
 /// </summary>
 /// <param name="objectFile">The <see cref="ObjectFile"/> that will be assembled.</param>
 protected ObjectFileAssembler(ObjectFile objectFile)
 {
     #region Contract
     Contract.Requires<ArgumentNullException>(objectFile != null);
     #endregion
     this.objectFile = objectFile;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SectionCollection"/> class.
        /// </summary>
        /// <param name="owner">The owner of the collection.</param>
        internal SectionCollection(ObjectFile owner)
        {
            #region Contract
            Contract.Requires <ArgumentNullException>(owner != null);
            #endregion

            this.owner = owner;
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Context"/> class.
        /// </summary>
        /// <param name="representation">The representation being assembled.</param>
        public Context(ObjectFile representation)
        {
            #region Contract
            Contract.Requires <ArgumentNullException>(representation != null);
            #endregion

            this.representation  = representation;
            this.symbolTable     = new SymbolTable();
            this.relocationTable = new Collection <Relocation>();
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Context"/> class.
        /// </summary>
        /// <param name="representation">The representation being assembled.</param>
        public Context(ObjectFile representation)
        {
            #region Contract
            Contract.Requires<ArgumentNullException>(representation != null);
            #endregion

            this.representation = representation;
            this.symbolTable = new SymbolTable();
            this.relocationTable = new Collection<Relocation>();
        }
Esempio n. 6
0
 /// <summary>
 /// Assembles the specified <see cref="ObjectFile"/>.
 /// </summary>
 /// <param name="objectFile">The <see cref="ObjectFile"/> to assemble.</param>
 /// <param name="filename">The name of the file to assemble to.</param>
 protected void AssembleToFile(ObjectFile objectFile, string filename)
 {
     using (FileStream fs = File.Create(filename))
     {
         using (BinaryWriter writer = new BinaryWriter(fs))
         {
             objectFile.Format.CreateAssembler(objectFile).Assemble(writer);
             writer.Flush();
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Assembles the specified <see cref="ObjectFile"/> and returns the resulting object file as an array of
 /// bytes.
 /// </summary>
 /// <param name="objectFile">The <see cref="ObjectFile"/> to assemble.</param>
 /// <returns>The resulting object file as an array of bytes.</returns>
 protected byte[] Assemble(ObjectFile objectFile)
 {
     byte[] result = null;
     using(MemoryStream ms = new MemoryStream())
     {
         using (BinaryWriter writer = new BinaryWriter(ms))
         {
             objectFile.Format.CreateAssembler(objectFile).Assemble(writer);
             writer.Flush();
             result = ms.ToArray();
         }
     }
     return result;
 }