Inheritance: ICatchClause
Beispiel #1
0
 /// <summary>
 /// Visits the specified catch clause.
 /// </summary>
 /// <param name="catchClause">The catch clause.</param>
 /// <returns></returns>
 protected virtual ICatchClause DeepCopy(CatchClause catchClause)
 {
     if (catchClause.FilterCondition != null)
     catchClause.FilterCondition = Substitute(catchClause.FilterCondition);
       catchClause.Body = (IBlockStatement)Substitute(catchClause.Body);
       return catchClause;
 }
 /// <summary>
 /// Rewrites the children of the given catch clause.
 /// </summary>
 /// <param name="catchClause"></param>
 public override void RewriteChildren(CatchClause catchClause) {
   if (this.scopesWithCapturedLocals.ContainsKey(catchClause)) {
     var statements = ((BlockStatement)catchClause.Body).Statements;
     this.AllocateClosureFor(catchClause, statements,
       delegate() {
         this.isInsideAnonymousMethod = true;
         var local = catchClause.ExceptionContainer;
         var fieldType = this.Rewrite(this.copier.Copy(local.Type)); //get the type as the anon delegate will see it
         this.isInsideAnonymousMethod = false;
         this.CreateClosureField(local, fieldType, local.Type, local.Name.Value);
         var field = this.fieldReferencesForUseInsideThisMethod[local];
         statements.Insert(0, new ExpressionStatement() {
           Expression = new Assignment() {
             Target = new TargetExpression() { Instance = this.currentClosureObject, Definition = field, Type = field.Type },
             Source = new BoundExpression() { Definition = local, Type = local.Type },
             Type = local.Type,
           }
         });
         base.RewriteChildren(catchClause);
       });
   } else
     base.RewriteChildren(catchClause);
 }
Beispiel #3
0
 /// <summary>
 /// Create a mutable copy of an icatchclause.
 /// </summary>
 /// <param name="catchClause"></param>
 /// <returns></returns>
 protected virtual CatchClause GetMutableCopy(ICatchClause catchClause)
 {
     var copy = new CatchClause(catchClause);
       return copy;
 }
 private static void DecompileHandler(BasicBlock containingBlock, BasicBlock handlerBlock, TryCatchFinallyStatement tryStatement)
 {
     if (handlerBlock.ExceptionInformation.HandlerKind == HandlerKind.Finally) {
     tryStatement.FinallyBody = handlerBlock;
       } else if (handlerBlock.ExceptionInformation.HandlerKind == HandlerKind.Fault) {
     tryStatement.FaultBody = handlerBlock;
       } else {
     CatchClause catchClause = new CatchClause();
     catchClause.Body = handlerBlock;
     catchClause.ExceptionType = handlerBlock.ExceptionInformation.ExceptionType;
     if (handlerBlock.ExceptionInformation.HandlerKind == HandlerKind.Catch) {
       catchClause.ExceptionContainer = ExtractExceptionContainer(handlerBlock);
     } else if (handlerBlock.ExceptionInformation.HandlerKind == HandlerKind.Filter) {
       catchClause.FilterCondition = ExtractFilterCondition(handlerBlock);
     }
     tryStatement.CatchClauses.Add(catchClause);
       }
       //Remove handler from statements in containing block
       containingBlock.Statements[containingBlock.Statements.Count-1] = GetBasicBlockStartingAt(handlerBlock, handlerBlock.ExceptionInformation.HandlerEndOffset);
       RemoveEndFinally(handlerBlock);
 }
Beispiel #5
0
 /// <summary>
 /// Rewrites the children of the given catch clause.
 /// </summary>
 public virtual void RewriteChildren(CatchClause catchClause)
 {
     catchClause.ExceptionType = this.Rewrite(catchClause.ExceptionType);
       if (catchClause.ExceptionContainer != Dummy.LocalVariable)
     catchClause.ExceptionContainer = this.Rewrite((LocalDefinition)catchClause.ExceptionContainer);
       if (catchClause.FilterCondition != null)
     catchClause.FilterCondition = this.Rewrite(catchClause.FilterCondition);
       catchClause.Body = this.Rewrite((BlockStatement)catchClause.Body);
 }
Beispiel #6
0
 /// <summary>
 /// Visits the specified catch clause.
 /// </summary>
 /// <param name="catchClause">The catch clause.</param>
 /// <returns></returns>
 public virtual ICatchClause Visit(ICatchClause catchClause)
 {
     CatchClause mutableCatchClause = catchClause as CatchClause;
       if (!this.copyOnlyIfNotAlreadyMutable || mutableCatchClause == null)
     mutableCatchClause = new CatchClause(catchClause);
       return Visit(mutableCatchClause);
 }
Beispiel #7
0
 /// <summary>
 /// Visits the specified catch clause.
 /// </summary>
 /// <param name="catchClause">The catch clause.</param>
 /// <returns></returns>
 public virtual ICatchClause Visit(CatchClause catchClause)
 {
     if (catchClause.FilterCondition != null)
     catchClause.FilterCondition = Visit(catchClause.FilterCondition);
       catchClause.Body = Visit(catchClause.Body);
       return catchClause;
 }