コード例 #1
0
ファイル: EHClause.cs プロジェクト: dbremner/perwapi
 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;
 }
コード例 #2
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /// <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);
 }