Exemple #1
0
 internal override void Write(PEWriter output, bool fatFormat)
 {
     if (Diag.DiagOn)
     {
         Console.WriteLine("writing exception details");
     }
     for (int i = 0; i < handlers.Count; i++)
     {
         if (Diag.DiagOn)
         {
             Console.WriteLine("Except block " + i);
         }
         HandlerBlock handler = handlers[i];
         flags = handler.GetFlag();
         if (Diag.DiagOn)
         {
             Console.WriteLine("flags = " + flags);
         }
         if (fatFormat)
         {
             output.Write((uint)flags);
         }
         else
         {
             output.Write(flags);
         }
         base.Write(output, fatFormat);
         handler.Write(output, fatFormat);
     }
 }
Exemple #2
0
        internal TryBlock MakeTryBlock(List <CILLabel> labels)
        {
            Contract.Requires(labels != null);
            Contract.Ensures(Contract.Result <TryBlock>() != null);
            TryBlock tBlock = new TryBlock(CILInstructions.GetLabel(labels, tryOffset),
                                           CILInstructions.GetLabel(labels, tryOffset + tryLength));
            CILLabel     hStart  = CILInstructions.GetLabel(labels, handlerOffset);
            CILLabel     hEnd    = CILInstructions.GetLabel(labels, handlerOffset + handlerLength);
            HandlerBlock handler = null;

            switch (clauseType)
            {
            case (EHClauseType.Exception):
                handler = new Catch((Class)classToken, hStart, hEnd);
                break;

            case (EHClauseType.Filter):
                handler = new Filter(CILInstructions.GetLabel(labels, filterOffset), hStart, hEnd);
                break;

            case (EHClauseType.Finally):
                handler = new Finally(hStart, hEnd);
                break;

            case (EHClauseType.Fault):
                handler = new Fault(hStart, hEnd);
                break;
            }
            tBlock.AddHandler(handler);
            return(tBlock);
        }
Exemple #3
0
 /// <summary>
 /// Add a handler to this try block
 /// </summary>
 /// <param name="handler">a handler to be added to the try block</param>
 public void AddHandler(HandlerBlock handler)
 {
     Contract.Requires(handler != null);
     //flags = handler.GetFlag();
     handlers.Add(handler);
 }
Exemple #4
0
 /// <summary>
 /// Add a handler to this try block
 /// </summary>
 /// <param name="handler">a handler to be added to the try block</param>
 public void AddHandler(HandlerBlock handler)
 {
     Contract.Requires(handler != null);
     //flags = handler.GetFlag();
     handlers.Add(handler);
 }