Ejemplo n.º 1
0
 internal void Write(FileImage output)
 {
     // Console.WriteLine("Writing header flags = " + Hex.Short(headerFlags));
     if (tinyFormat)
     {
         // Console.WriteLine("Writing tiny code");
         output.Write((byte)headerFlags);
     }
     else
     {
         // Console.WriteLine("Writing fat code");
         output.Write(headerFlags);
         output.Write((ushort)maxStack);
         output.Write(offset);
         output.Write(localSigIx);
     }
     // Console.WriteLine(Hex.Int(tide) + " CIL instructions");
     // Console.WriteLine("starting instructions at " + output.Seek(0,SeekOrigin.Current));
     for (int i = 0; i < tide; i++)
     {
         buffer[i].Write(output);
     }
     // Console.WriteLine("ending instructions at " + output.Seek(0,SeekOrigin.Current));
     for (int i = 0; i < paddingNeeded; i++)
     {
         output.Write((byte)0);
     }
     if (exceptions != null)
     {
         // Console.WriteLine("Writing exceptions");
         // Console.WriteLine("header = " + Hex.Short(exceptHeader) + " exceptSize = " + Hex.Int(exceptSize));
         output.Write(exceptHeader);
         output.Write3Bytes((uint)exceptSize);
         for (int i = 0; i < exceptions.Count; i++)
         {
             TryBlock tryBlock = (TryBlock)exceptions[i];
             tryBlock.Write(output, fatExceptionFormat);
         }
     }
 }