public override ICatchClause Rewrite(ICatchClause catchClause) { _log.Info("Rewriting ITryCatchFinallyStatement: " + catchClause + " Pass: "******".ctor")); expression = new CreateObjectInstance() { MethodToCall = ctor, Type = catchClause.ExceptionContainer.Type }; } return new CatchClause(catchClause) { Body = new BlockStatement() { Statements = new ThrowStatement() { Exception = expression }.InList<IStatement>() } }; }
public override void Visit(ICatchClause catchClause) { // _log.Info("Visit ICatchClause: " + catchClause); if (catchClause.ExceptionContainer != Dummy.LocalVariable) //if local variable is declared { if(catchClause.Body.Statements.Any()) { var throwStatement = catchClause.Body.Statements.First() as ThrowStatement; if(throwStatement == null || throwStatement.Exception.Type != catchClause.ExceptionType) { //if doesnt already have the same throw MarkMutationTarget(catchClause); } } else // Empty block { MarkMutationTarget(catchClause); } } else if (TypeHelper.GetMethod(catchClause.ExceptionType.ResolvedType, Host.NameTable.GetNameFor(".ctor")) != Dummy.MethodDefinition) { MarkMutationTarget(catchClause); } }
public override void TraverseChildren(ICatchClause catchClause) { this.exceptionsThrown.RemoveWhere(t => TypeHelper.Type1DerivesFromOrIsTheSameAsType2(t.ResolvedType, catchClause.ExceptionType, true)); // no need to save the current value: catch clauses cannot be nested. this.currentCatchClauseExceptionType = catchClause.ExceptionType; base.TraverseChildren(catchClause); this.currentCatchClauseExceptionType = null; }
public void Visit(ICatchClause catchClause) { this.traverser.Traverse(catchClause); }
public void Visit(ICatchClause catchClause) { Contract.Requires(catchClause != null); throw new NotImplementedException(); }
public virtual void onASTElement(ICatchClause catchClause) { }
/// <summary> /// Traverses the catch clause. /// </summary> public void Traverse(ICatchClause catchClause) { Contract.Requires(catchClause != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(catchClause); if (this.StopTraversal) return; this.TraverseChildren(catchClause); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(catchClause); }
public override void Visit(ICatchClause catchClause) { if(Process(catchClause)){visitor.Visit(catchClause);} base.Visit(catchClause); }
public override void TraverseChildren(ICatchClause catchClause) { MethodEnter(catchClause); base.TraverseChildren(catchClause); MethodExit(); }
public override void VisitCatch(ICatchClause operation) { _seenEmptyThrowInCatchClauses.Push(false); Visit(operation.Filter); Visit(operation.Handler); bool seenEmptyThrow = _seenEmptyThrowInCatchClauses.Pop(); if (IsCaughtTypeTooGeneral(operation.CaughtType) && !seenEmptyThrow) { CatchAllCatchClausesWithoutEmptyThrow.Add(operation); } }
public override void Visit(ICatchClause catchClause) { allElements.Add(new InvokInfo(Traverser, "ICatchClause", catchClause)); }
public override void TraverseChildren(ICatchClause catchClause) { var savedExceptionContainer = this.exceptionContainer; this.exceptionContainer = catchClause.ExceptionContainer; base.TraverseChildren(catchClause); this.exceptionContainer = savedExceptionContainer; }
public void EnterCatchClause(ICatchClause catchClauseNode) { }
/// <summary> /// Generates IL for the specified catch clause. /// </summary> /// <param name="catchClause">The catch clause.</param> public override void TraverseChildren(ICatchClause catchClause) { this.generator.BeginScope(0); if (catchClause.FilterCondition != null) { this.generator.BeginFilterBlock(); this.Traverse(catchClause.FilterCondition); this.generator.BeginFilterBody(); } else { this.generator.BeginCatchBlock(catchClause.ExceptionType); } this.StackSize++; if (catchClause.ExceptionContainer != Dummy.LocalVariable) { this.generator.AddVariableToCurrentScope(catchClause.ExceptionContainer); this.VisitAssignmentTo(catchClause.ExceptionContainer); } else this.generator.Emit(OperationCode.Pop); this.lastStatementWasUnconditionalTransfer = false; this.Traverse(catchClause.Body); if (!this.lastStatementWasUnconditionalTransfer) this.generator.Emit(OperationCode.Leave, this.currentTryCatchFinallyEnd); this.generator.EndScope(); this.lastStatementWasUnconditionalTransfer = false; }
/// <inheritdoc /> public override Expression VisitCatch(ICatchClause operation, LocalBinder argument) { throw Unexpected(operation, nameof(VisitTryStatement)); }
public void Visit(ICatchClause catchClause) { throw new NotImplementedException(); }
/// <summary> /// Rewrites the given catch clause. /// </summary> /// <param name="catchClause"></param> public virtual ICatchClause Rewrite(ICatchClause catchClause) { return catchClause; }
// https://github.com/dotnet/roslyn/issues/22008 internal virtual void VisitCatchClause(ICatchClause operation) { DefaultVisit(operation); }
/// <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; }
public override void TraverseChildren(ICatchClause catchClause) { if (this.captures.ContainsKey(catchClause.ExceptionContainer)) this.scopesWithCapturedLocals[catchClause] = true; base.TraverseChildren(catchClause); }
/// <summary> /// Returns a shallow copy of the given catch clause. /// </summary> /// <param name="catchClause"></param> public CatchClause Copy(ICatchClause catchClause) { return new CatchClause(catchClause); }
public override void VisitCatch(ICatchClause operation) { var caughtType = operation.CaughtType; var exceptionLocal = operation.ExceptionLocal; base.VisitCatch(operation); }
private static void WriteTryCatchFinally_catch(LanguageWriter w, ICatchClause clause) { w.Write(" "); w.WriteKeyword("catch"); // 特別な場合 catch(...) を検出 // → clauseBody を改変 // clauseBody は StatementAnalyze の時点で改変する様にした bool catchAll = clause.Condition is StatementAnalyze.IsCatchAll; IStatementCollection clause_body = clause.Body == null?null:clause.Body.Statements; TypeRef var_type = new TypeRef(clause.Variable.VariableType); /* * if(var_type.IsObject&&clause.Condition!=null) { * ISnippetExpression iSnippent=clause.Condition as ISnippetExpression; * if(iSnippent!=null&&iSnippent.Value=="?"&&StatementAnalyze.IsCatchAllClause(ref clause_body)){ * catchAll=true; * } * } * //*/ if (catchAll) { w.Write(" (...)"); } else { if (clause.Variable.Name.Length != 0 || !var_type.IsObject) { w.scope.RegisterVariable(clause.Variable, false); w.Write(" ("); var_type.WriteNameWithRef(w); w.Write(" "); w.WriteDeclaration(clause.Variable.Name); w.Write(")"); } if (clause.Condition != null) { w.Write(" "); w.WriteKeyword("when"); w.Write(" "); w.Write("("); w.WriteExpression(clause.Condition); w.Write(")"); } } w.Write(" {"); w.WriteLine(); w.WriteIndent(); if (clause_body != null) { for (int num = 0; num < clause_body.Count; num++) { IStatement statement3 = clause_body[num]; #if EXTRA_TEMP #warning catch: "コンストラクタの中で、最後の一行で、throw" の場合は書き込まない? // →之は、恐らく、 constructor に function-try-statement を適用した時の話である // よって無視する if (w.SomeConstructor && num + 1 >= clause_body.Count && statement3 is IThrowExceptionStatement) { break; } #endif WriteStatement(w, statement3); } } w.WriteOutdent(); w.Write("}"); }
/// <summary> /// Returns a deep copy of the given catch clause. /// </summary> /// <param name="catchClause"></param> public CatchClause Copy(ICatchClause catchClause) { var mutableCopy = this.shallowCopier.Copy(catchClause); mutableCopy.ExceptionType = this.Copy(mutableCopy.ExceptionType); if (mutableCopy.ExceptionContainer != Dummy.LocalVariable) { var copy = this.GetExistingCopyIfInsideCone(mutableCopy.ExceptionContainer); //allow catch clauses to share the same local if (copy == mutableCopy.ExceptionContainer) { mutableCopy.ExceptionContainer = this.Copy(mutableCopy.ExceptionContainer); this.LocalsInsideCone.Add(catchClause.ExceptionContainer, mutableCopy.ExceptionContainer); } } if (mutableCopy.FilterCondition != null) mutableCopy.FilterCondition = this.Copy(mutableCopy.FilterCondition); mutableCopy.Body = this.Copy(mutableCopy.Body); return mutableCopy; }
internal override IOperation VisitCatchClause(ICatchClause operation, object argument) { return(new CatchClause(Visit(operation.Handler), operation.CaughtType, Visit(operation.Filter), operation.ExceptionLocal, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit)); }
public void Visit(ICatchClause catchClause) { this.result = this.copier.Copy(catchClause); }
public override IOperation VisitCatchClause(ICatchClause operation, object argument) { return(new CatchClause(Visit(operation.ExceptionDeclarationOrExpression), operation.ExceptionType, operation.Locals, Visit(operation.Filter), Visit(operation.Handler), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit)); }
/// <summary> /// Returns a deep copy of the given catch clause. /// </summary> /// <param name="catchClause"></param> public CatchClause Copy(ICatchClause catchClause) { Contract.Requires(catchClause != null); Contract.Ensures(Contract.Result<CatchClause>() != null); var mutableCopy = this.shallowCopier.Copy(catchClause); mutableCopy.ExceptionType = this.Copy(mutableCopy.ExceptionType); if (!(mutableCopy.ExceptionContainer is Dummy)) { var copy = this.GetExistingCopyIfInsideCone(mutableCopy.ExceptionContainer); //allow catch clauses to share the same local if (copy == mutableCopy.ExceptionContainer) { mutableCopy.ExceptionContainer = this.Copy(mutableCopy.ExceptionContainer); this.LocalsInsideCone.Add(catchClause.ExceptionContainer, mutableCopy.ExceptionContainer); } else { mutableCopy.ExceptionContainer = copy; } } if (mutableCopy.FilterCondition != null) mutableCopy.FilterCondition = this.Copy(mutableCopy.FilterCondition); mutableCopy.Body = this.Copy(mutableCopy.Body); return mutableCopy; }
/// <summary> /// Traverses the children of the catch clause. /// </summary> public virtual void TraverseChildren(ICatchClause catchClause) { Contract.Requires(catchClause != null); this.Traverse(catchClause.ExceptionType); if (this.StopTraversal) return; if (!(catchClause.ExceptionContainer is Dummy)) { this.Traverse(catchClause.ExceptionContainer); if (this.StopTraversal) return; } if (catchClause.FilterCondition != null) { this.Traverse(catchClause.FilterCondition); if (this.StopTraversal) return; } this.Traverse(catchClause.Body); }
/// <summary> /// Returns a shallow copy of the given catch clause. /// </summary> /// <param name="catchClause"></param> public CatchClause Copy(ICatchClause catchClause) { Contract.Requires(catchClause != null); Contract.Ensures(Contract.Result<CatchClause>() != null); return new CatchClause(catchClause); }
/// <summary> /// Performs some computation with the given catch clause. /// </summary> /// <param name="catchClause"></param> public virtual void Visit(ICatchClause catchClause) { }
public virtual void VisitCatchClause(ICatchClause value) { VisitVariableDeclaration(value.Variable); VisitExpression(value.Condition); VisitStatement(value.Body); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given catch clause. /// </summary> /// <param name="catchClause"></param> public virtual void Visit(ICatchClause catchClause) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(catchClause); if (catchClause.FilterCondition != null) this.Visit(catchClause.FilterCondition); this.Visit(catchClause.Body); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
public virtual void VisitCatch(ICatchClause operation) { DefaultVisit(operation); }
public override void VisitCatchClause(ICatchClause operation) { Visit(operation.Filter); Visit(operation.Handler); }
public override void TraverseChildren(ICatchClause catchClause) { base.TraverseChildren(catchClause); }
/// <summary> /// /// </summary> /// <param name="catchClause"></param> public CatchClause(ICatchClause catchClause) { this.body = catchClause.Body; this.exceptionContainer = catchClause.ExceptionContainer; this.exceptionType = catchClause.ExceptionType; this.filterCondition = catchClause.FilterCondition; this.locations = new List<ILocation>(catchClause.Locations); }
/// <inheritdoc /> public override IOperation VisitCatch(ICatchClause operation, object argument) { return(base.VisitCatch(operation, argument)); }
public override void TraverseChildren(ICatchClause catchClause) { if (this.currentAnonymousDelegate != null) this.definitionsToIgnore[catchClause.ExceptionContainer] = true; base.TraverseChildren(catchClause); }
public override void TraverseChildren(ICatchClause catchClause) { if (catchClause.ExceptionContainer != Dummy.LocalVariable) this.declaredLocals[catchClause.ExceptionContainer] = true; base.TraverseChildren(catchClause); }
public override void VisitCatchClause(ICatchClause value) { WriteUnsupported(value.ToString()); }