The descriptor for a guarded block (.try)
Inheritance: CodeBlock
Beispiel #1
0
 private void catchEnd()
 {
     PERWAPI.TryBlock lastTry = (PERWAPI.TryBlock)errBlocks.Pop();
     if (dotnetErr != null)
     {
         // use a filter if we need to "dual-check" for native exception
         code.EndFilterBlock(filterStart, lastTry);
         dotnetErr   = null;
         filterStart = null;
     }
     else
     {
         // this is the normal catch block
         code.EndCatchBlock(emitter.findType(exType) as PERWAPI.Class, lastTry);
     }
 }
Beispiel #2
0
        private PERWAPI.TryBlock getLastTryBlock()
        {
            for (int i = 0; i < tryJump.Length; i++)
            {
                if (startPos == tryJump[i])
                {
                    int    start = tryStart[i];
                    int    end   = tryEnd[i];
                    string key   = start + "/" + end;

                    PERWAPI.TryBlock block = (PERWAPI.TryBlock)tryBlocks[key];
                    if (block == null)
                    {
                        block          = code.EndTryBlock();
                        tryBlocks[key] = block;
                    }
                    return(block);
                }
            }

            throw new System.Exception("This is not good");
        }
Beispiel #3
0
 /// <summary>
 /// Mark this position as the end of the last started block and
 /// make it a try block.  This try block is added to the current
 /// instructions (ie do not need to call AddTryBlock)
 /// </summary>
 /// <returns>The try block just ended</returns>
 public TryBlock EndTryBlock()
 {
     TryBlock tBlock = new TryBlock((CILLabel)blockStack.Pop(),NewCodedLabel());
     AddTryBlock(tBlock);
     return tBlock;
 }
Beispiel #4
0
 /// <summary>
 /// Mark this position as the end of the last started block and
 /// make it a finally block.  This finally block is associated with the
 /// specified try block.
 /// </summary>
 /// <param name="tryBlock">the try block associated with this finally block</param>
 public void EndFinallyBlock(TryBlock tryBlock)
 {
     Finally finBlock= new Finally((CILLabel)blockStack.Pop(),NewCodedLabel());
     tryBlock.AddHandler(finBlock);
 }
Beispiel #5
0
 /// <summary>
 /// Mark this position as the end of the last started block and
 /// make it a filter block.  This filter block is associated with the
 /// specified try block.  The format is:
 /// filterLab:   ...
 ///              ...
 /// filterHandler :  ...
 ///                  ...
 /// </summary>
 /// <param name="filterLab">the label where the filter code is</param>
 /// <param name="tryBlock">the try block associated with this filter block</param>
 public void EndFilterBlock(CILLabel filterLab, TryBlock tryBlock)
 {
     Filter filBlock = new Filter(filterLab,(CILLabel)blockStack.Pop(),NewCodedLabel());
     tryBlock.AddHandler(filBlock);
 }
Beispiel #6
0
 /// <summary>
 /// Mark this position as the end of the last started block and
 /// make it a fault block.  This fault block is associated with the
 /// specified try block.
 /// </summary>
 /// <param name="tryBlock">the try block associated with this fault block</param>
 public void EndFaultBlock(TryBlock tryBlock)
 {
     Fault fBlock= new Fault((CILLabel)blockStack.Pop(),NewCodedLabel());
     tryBlock.AddHandler(fBlock);
 }
Beispiel #7
0
 /// <summary>
 /// Mark this position as the end of the last started block and
 /// make it a catch block.  This catch block is associated with the
 /// specified try block.
 /// </summary>
 /// <param name="exceptType">the exception type to be caught</param>
 /// <param name="tryBlock">the try block associated with this catch block</param>
 public void EndCatchBlock(Class exceptType, TryBlock tryBlock)
 {
     Catch catchBlock = new Catch(exceptType,(CILLabel)blockStack.Pop(), NewCodedLabel());
     tryBlock.AddHandler(catchBlock);
 }
Beispiel #8
0
 public void AddTryBlock(TryBlock tryBlock)
 {
     if (exceptions == null)
         exceptions = new ArrayList();
     else if (exceptions.Contains(tryBlock)) return;
     exceptions.Add(tryBlock);
 }
Beispiel #9
0
 internal TryBlock MakeTryBlock(ArrayList labels)
 {
     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;
 }
 internal void EndFinallyBlock(TryBlock tryBlock) {
     System.Diagnostics.Debug.Assert(blocks.Peek() == Clause.Finally);
     blocks.Pop();
     buffer.EndFinallyBlock(tryBlock);
 }
 internal void EndCatchBlock(PERWAPI.Class type, TryBlock tryBlock) {
     System.Diagnostics.Debug.Assert(blocks.Peek() == Clause.Catch);
     blocks.Pop();
     buffer.EndCatchBlock(type, tryBlock);
 }