• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CatchClause类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CatchClause的典型用法代码示例。如果您正苦于以下问题:C# CatchClause类的具体用法?C# CatchClause怎么用?C# CatchClause使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CatchClause类属于命名空间,在下文中一共展示了CatchClause类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TryStatement

    public TryStatement(Statement statement, CatchClause catchClause, FinallyClause finallyClause)
    {
      Statement = statement;
      Catch = catchClause;
      Finally = finallyClause;
      SourceOffset = statement.SourceOffset;

      Use(Statement);
      Use(Catch);
      Use(Finally);

      m.Util.Diagnose.Debug.Assert(Catch != null || Finally != null, "SyntaxError: Missing catch or finally after try");
    }
开发者ID:reshadi2,项目名称:mcjs,代码行数:13,代码来源:TryStatement.cs


示例2: VisitCatchClause

			public override void VisitCatchClause(CatchClause catchClause)
			{
				base.VisitCatchClause(catchClause);
				var exceptionResolveResult = ctx.Resolve(catchClause.VariableNameToken) as LocalResolveResult;
				if (exceptionResolveResult == null)
					return;

				var catchVisitor = new CatchClauseVisitor(ctx, exceptionResolveResult.Variable);
				catchClause.Body.AcceptVisitor(catchVisitor);

				foreach (var throwStatement in catchVisitor.OffendingThrows) {
					var localThrowStatement = throwStatement;
					var title = ctx.TranslateString("The exception is rethrown with explicit usage of the variable");
					var action = new CodeAction(ctx.TranslateString("Change to 'throw;'"), script => {
						script.Replace(localThrowStatement, new ThrowStatement());
					});
					AddIssue(localThrowStatement, title, new [] { action });
				}
			}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:19,代码来源:ExceptionRethrowIssue.cs


示例3: VisitCatchClause

		public virtual object VisitCatchClause(CatchClause catchClause, object data) {
			Debug.Assert((catchClause != null));
			Debug.Assert((catchClause.TypeReference != null));
			Debug.Assert((catchClause.StatementBlock != null));
			Debug.Assert((catchClause.Condition != null));
			nodeStack.Push(catchClause.TypeReference);
			catchClause.TypeReference.AcceptVisitor(this, data);
			catchClause.TypeReference = ((TypeReference)(nodeStack.Pop()));
			nodeStack.Push(catchClause.StatementBlock);
			catchClause.StatementBlock.AcceptVisitor(this, data);
			catchClause.StatementBlock = ((Statement)(nodeStack.Pop()));
			nodeStack.Push(catchClause.Condition);
			catchClause.Condition.AcceptVisitor(this, data);
			catchClause.Condition = ((Expression)(nodeStack.Pop()));
			return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:16,代码来源:AbstractAstTransformer.cs


示例4: ConvertCatch

			CatchClause ConvertCatch (Catch ctch) 
			{
				CatchClause result = new CatchClause ();
				var location = LocationsBag.GetLocations (ctch);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), "catch".Length), CatchClause.Roles.Keyword);
				
				if (ctch.Type_expr != null) {
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CatchClause.Roles.LPar);
					
					result.AddChild ((INode)ctch.Type_expr.Accept (this), CatchClause.Roles.ReturnType);
					if (!string.IsNullOrEmpty (ctch.Name))
						result.AddChild (new Identifier (ctch.Name, Convert (location[1])), CatchClause.Roles.Identifier);
					
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), CatchClause.Roles.RPar);
				}
				
				result.AddChild ((INode)ctch.Block.Accept (this), CatchClause.Roles.Body);
				
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:23,代码来源:CSharpParser.cs


示例5: ConvertCatch

			CatchClause ConvertCatch(Catch ctch)
			{
				var result = new CatchClause();
				var location = LocationsBag.GetLocations(ctch);
				result.AddChild(new CSharpTokenNode(Convert(ctch.loc), CatchClause.CatchKeywordRole), CatchClause.CatchKeywordRole);
				if (ctch.TypeExpression != null) {
					if (location != null)
						result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
					
					if (ctch.TypeExpression != null)
						result.AddChild(ConvertToType(ctch.TypeExpression), Roles.Type);
					if (ctch.Variable != null && !string.IsNullOrEmpty(ctch.Variable.Name))
						result.AddChild(Identifier.Create(ctch.Variable.Name, Convert(ctch.Variable.Location)), Roles.Identifier);
					
					if (location != null && location.Count > 1)
						result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
				}

				if (ctch.Block != null)
					result.AddChild((BlockStatement)ctch.Block.Accept(this), Roles.Body);
				
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:23,代码来源:CSharpParser.cs


示例6: CompileCatchClause

		private JsBlockStatement CompileCatchClause(LocalResolveResult catchVariable, CatchClause catchClause, bool isCatchAll, bool isOnly) {
			SetRegion(catchClause.GetRegion());
			JsStatement variableDeclaration = null;
			if (!catchClause.VariableNameToken.IsNull) {
				JsExpression compiledAssignment;
				if (isCatchAll)	// If this is the only handler we need to construct the exception
					compiledAssignment = isOnly ? _runtimeLibrary.MakeException(JsExpression.Identifier(_variables[catchVariable.Variable].Name), this) : JsExpression.Identifier(_variables[catchVariable.Variable].Name);
				else
					compiledAssignment = _runtimeLibrary.Downcast(JsExpression.Identifier(_variables[catchVariable.Variable].Name), _compilation.FindType(KnownTypeCode.Exception), _resolver.Resolve(catchClause.Type).Type, this);

				variableDeclaration = JsStatement.Var(_variables[((LocalResolveResult)_resolver.Resolve(catchClause.VariableNameToken)).Variable].Name, compiledAssignment);
			}

			var result = CreateInnerCompiler().Compile(catchClause.Body);
			if (variableDeclaration != null)
				result = JsStatement.Block(new[] { variableDeclaration }.Concat(result.Statements));
			return result;
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:18,代码来源:StatementCompiler.cs


示例7: VisitCatchClause

 public virtual void VisitCatchClause(CatchClause catchClause)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(catchClause);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs


示例8: VisitCatchClause

		public virtual void VisitCatchClause(CatchClause catchClause)
		{
			StartNode(catchClause);
			WriteKeyword(CatchClause.CatchKeywordRole);
			if (!catchClause.Type.IsNull) {
				Space(policy.SpaceBeforeCatchParentheses);
				LPar();
				Space(policy.SpacesWithinCatchParentheses);
				catchClause.Type.AcceptVisitor(this);
				if (!string.IsNullOrEmpty(catchClause.VariableName)) {
					Space();
					WriteIdentifier(catchClause.VariableNameToken);
				}
				Space(policy.SpacesWithinCatchParentheses);
				RPar();
			}
			if (!catchClause.Condition.IsNull) {
				Space();
				WriteKeyword(CatchClause.WhenKeywordRole);
				Space(policy.SpaceBeforeIfParentheses);
				LPar();
				Space(policy.SpacesWithinIfParentheses);
				catchClause.Condition.AcceptVisitor(this);
				Space(policy.SpacesWithinIfParentheses);
				RPar();
			}
			WriteBlock(catchClause.Body, policy.StatementBraceStyle);
			EndNode(catchClause);
		}
开发者ID:icsharpcode,项目名称:NRefactory,代码行数:29,代码来源:CSharpOutputVisitor.cs


示例9: GetWatchInstrument

	        static Statement GetWatchInstrument (string id, Expression expr)
			{
				var r = new MemberReferenceExpression (
					new MemberReferenceExpression (
						new MemberReferenceExpression (
							new IdentifierExpression ("Continuous"), "Server"), "WatchStore"), "Record");
				var i = new ExpressionStatement (new InvocationExpression (r, new PrimitiveExpression (id), expr));
				var t = new TryCatchStatement ();
				t.TryBlock = new BlockStatement ();
				t.TryBlock.Statements.Add (i);
				var c = new CatchClause ();
				c.Body = new BlockStatement ();
				t.CatchClauses.Add (c);
				return t;
			}
开发者ID:mono,项目名称:Continuous,代码行数:15,代码来源:ContinuousEnv.MonoDevelop.cs


示例10: TransformNode

		IEnumerable<Statement> TransformNode(ILNode node)
		{
			if (node is ILLabel) {
				yield return new Ast.LabelStatement { Label = ((ILLabel)node).Name };
			} else if (node is ILExpression) {
				List<ILRange> ilRanges = ((ILExpression)node).GetILRanges();
				AstNode codeExpr = TransformExpression((ILExpression)node);
				if (codeExpr != null) {
					codeExpr = codeExpr.WithAnnotation(ilRanges);
					if (codeExpr is Ast.Expression) {
						yield return new Ast.ExpressionStatement { Expression = (Ast.Expression)codeExpr };
					} else if (codeExpr is Ast.Statement) {
						yield return (Ast.Statement)codeExpr;
					} else {
						throw new Exception();
					}
				}
			} else if (node is ILWhileLoop) {
				ILWhileLoop ilLoop = (ILWhileLoop)node;
				WhileStatement whileStmt = new WhileStatement() {
					Condition = ilLoop.Condition != null ? (Expression)TransformExpression(ilLoop.Condition) : new PrimitiveExpression(true),
					EmbeddedStatement = TransformBlock(ilLoop.BodyBlock)
				};
				yield return whileStmt;
			} else if (node is ILCondition) {
				ILCondition conditionalNode = (ILCondition)node;
				bool hasFalseBlock = conditionalNode.FalseBlock.EntryGoto != null || conditionalNode.FalseBlock.Body.Count > 0;
				yield return new Ast.IfElseStatement {
					Condition = (Expression)TransformExpression(conditionalNode.Condition),
					TrueStatement = TransformBlock(conditionalNode.TrueBlock),
					FalseStatement = hasFalseBlock ? TransformBlock(conditionalNode.FalseBlock) : null
				};
			} else if (node is ILSwitch) {
				ILSwitch ilSwitch = (ILSwitch)node;
				SwitchStatement switchStmt = new SwitchStatement() { Expression = (Expression)TransformExpression(ilSwitch.Condition) };
				foreach (var caseBlock in ilSwitch.CaseBlocks) {
					SwitchSection section = new SwitchSection();
					if (caseBlock.Values != null) {
						section.CaseLabels.AddRange(caseBlock.Values.Select(i => new CaseLabel() { Expression = AstBuilder.MakePrimitive(i, ilSwitch.Condition.InferredType) }));
					} else {
						section.CaseLabels.Add(new CaseLabel());
					}
					section.Statements.Add(TransformBlock(caseBlock));
					switchStmt.SwitchSections.Add(section);
				}
				yield return switchStmt;
			} else if (node is ILTryCatchBlock) {
				ILTryCatchBlock tryCatchNode = ((ILTryCatchBlock)node);
				var tryCatchStmt = new Ast.TryCatchStatement();
				tryCatchStmt.TryBlock = TransformBlock(tryCatchNode.TryBlock);
				foreach (var catchClause in tryCatchNode.CatchBlocks) {
					tryCatchStmt.CatchClauses.Add(
						new Ast.CatchClause {
							Type = AstBuilder.ConvertType(catchClause.ExceptionType),
							VariableName = catchClause.ExceptionVariable == null ? null : catchClause.ExceptionVariable.Name,
							Body = TransformBlock(catchClause)
						});
				}
				if (tryCatchNode.FinallyBlock != null)
					tryCatchStmt.FinallyBlock = TransformBlock(tryCatchNode.FinallyBlock);
				if (tryCatchNode.FaultBlock != null) {
					CatchClause cc = new CatchClause();
					cc.Body = TransformBlock(tryCatchNode.FaultBlock);
					cc.Body.Add(new ThrowStatement()); // rethrow
					tryCatchStmt.CatchClauses.Add(cc);
				}
				yield return tryCatchStmt;
			} else if (node is ILBlock) {
				yield return TransformBlock((ILBlock)node);
			} else if (node is ILComment) {
				yield return new CommentStatement(((ILComment)node).Text).WithAnnotation(((ILComment)node).ILRanges);
			} else {
				throw new Exception("Unknown node type");
			}
		}
开发者ID:hlesesne,项目名称:ILSpy,代码行数:75,代码来源:AstMethodBodyBuilder.cs


示例11: VisitCatchClause

		public virtual object VisitCatchClause(CatchClause catchClause, object data) {
			Debug.Assert((catchClause != null));
			Debug.Assert((catchClause.TypeReference != null));
			Debug.Assert((catchClause.StatementBlock != null));
			Debug.Assert((catchClause.Condition != null));
			catchClause.TypeReference.AcceptVisitor(this, data);
			catchClause.StatementBlock.AcceptVisitor(this, data);
			return catchClause.Condition.AcceptVisitor(this, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:9,代码来源:AbstractASTVisitor.cs


示例12: VisitCatchClause

        public void VisitCatchClause(CatchClause catchClause)
        {
            JsonObject visitCatch = new JsonObject();
            visitCatch.Comment = "VisitCatchClause";

            AddKeyword(visitCatch, "catch-keyword", CatchClause.CatchKeywordRole);

            if (!catchClause.Type.IsNull)
            {
                visitCatch.AddJsonValue("type-info", GenTypeInfo(catchClause.Type));
                if (!string.IsNullOrEmpty(catchClause.VariableName))
                {
                    visitCatch.AddJsonValue("identifier", GetIdentifier(catchClause.VariableNameToken));
                }
            }

            visitCatch.AddJsonValue("catch-body", GenStatement(catchClause.Body));

            Push(visitCatch);
        }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:20,代码来源:AstCsToJson.cs


示例13: VisitTryCatchStatement

			public override void VisitTryCatchStatement (TryCatchStatement tryCatchStatement)
			{
				base.VisitTryCatchStatement (tryCatchStatement);

				var catches = tryCatchStatement.CatchClauses.ToList ();
				if (catches.Count == 0)
					return;

				var varName = catches.Where (x => !string.IsNullOrEmpty (x.VariableName)).Select (x => x.VariableName).FirstOrDefault ();
				if (varName == null) {
					varName = "_ex";
				}

				//
				// Fix first
				//
				foreach (var c in catches) {
					if (string.IsNullOrEmpty (c.VariableName)) {
						c.VariableName = varName;
					}
				}

				//
				// Merge them
				//
				if (catches.Count > 0) {
					var body = new BlockStatement ();
					var newCatch = new CatchClause {
						VariableName = varName,
						Body = body,
					};

					IfElseStatement lastIf = null;

					foreach (var c in catches) {

						var cbody = c.Body;
						cbody.Remove ();

						var iff = new IfElseStatement (GetNotNullTypeCheck (varName, c.Type), cbody);

						if (lastIf == null)
							body.Add (iff);
						else
							lastIf.FalseStatement = iff;

						lastIf = iff;

						c.Remove ();
					}

					var rethrow = new ThrowStatement (new IdentifierExpression (varName));

					if (lastIf == null)
						body.Add (rethrow);
					else
						lastIf.FalseStatement = rethrow;

					tryCatchStatement.CatchClauses.Add (newCatch);
				}
			}
开发者ID:RReverser,项目名称:Netjs,代码行数:61,代码来源:CsToTs.cs


示例14: VisitCatchClause

 public void VisitCatchClause(CatchClause node)
 {
     VisitChildren(node);
 }
开发者ID:evanw,项目名称:minisharp,代码行数:4,代码来源:Lower.cs


示例15: VisitCatchClause

		public virtual object VisitCatchClause(CatchClause catchClause, object data) {
			throw new global::System.NotImplementedException("CatchClause");
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NotImplementedAstVisitor.cs


示例16: TransformNode

		IEnumerable<Statement> TransformNode(ILNode node)
		{
			if (node is ILLabel) {
				yield return new Ast.LabelStatement { Label = ((ILLabel)node).Name }.WithAnnotation(node.ILRanges);
			} else if (node is ILExpression) {
				AstNode codeExpr = TransformExpression((ILExpression)node);
				if (codeExpr != null) {
					if (codeExpr is Ast.Expression) {
						yield return new Ast.ExpressionStatement { Expression = (Ast.Expression)codeExpr };
					} else if (codeExpr is Ast.Statement) {
						yield return (Ast.Statement)codeExpr;
					} else {
						throw new Exception();
					}
				}
			} else if (node is ILWhileLoop) {
				ILWhileLoop ilLoop = (ILWhileLoop)node;
				Expression expr;
				WhileStatement whileStmt = new WhileStatement() {
					Condition = expr = ilLoop.Condition != null ? (Expression)TransformExpression(ilLoop.Condition) : new PrimitiveExpression(true),
					EmbeddedStatement = TransformBlock(ilLoop.BodyBlock)
				};
				expr.AddAnnotation(ilLoop.ILRanges);
				yield return whileStmt;
			} else if (node is ILCondition) {
				ILCondition conditionalNode = (ILCondition)node;
				bool hasFalseBlock = conditionalNode.FalseBlock.EntryGoto != null || conditionalNode.FalseBlock.Body.Count > 0;
				BlockStatement trueStmt;
				var ifElseStmt = new Ast.IfElseStatement {
					Condition = (Expression)TransformExpression(conditionalNode.Condition),
					TrueStatement = trueStmt = TransformBlock(conditionalNode.TrueBlock),
					FalseStatement = hasFalseBlock ? TransformBlock(conditionalNode.FalseBlock) : null
				};
				ifElseStmt.Condition.AddAnnotation(conditionalNode.ILRanges);
				if (ifElseStmt.FalseStatement == null)
					trueStmt.HiddenEnd = NRefactoryExtensions.CreateHidden(conditionalNode.FalseBlock.GetSelfAndChildrenRecursiveILRanges(), trueStmt.HiddenEnd);
				yield return ifElseStmt;
			} else if (node is ILSwitch) {
				ILSwitch ilSwitch = (ILSwitch)node;
				if (ilSwitch.Condition.InferredType.GetElementType() == ElementType.Boolean && (
					from cb in ilSwitch.CaseBlocks
					where cb.Values != null
					from val in cb.Values
					select val
				).Any(val => val != 0 && val != 1))
				{
					// If switch cases contain values other then 0 and 1, force the condition to be non-boolean
					ilSwitch.Condition.ExpectedType = corLib.Int32;
				}
				SwitchStatement switchStmt = new SwitchStatement() { Expression = (Expression)TransformExpression(ilSwitch.Condition) };
				switchStmt.Expression.AddAnnotation(ilSwitch.ILRanges);
				switchStmt.HiddenEnd = NRefactoryExtensions.CreateHidden(ilSwitch.EndILRanges, switchStmt.HiddenEnd);
				foreach (var caseBlock in ilSwitch.CaseBlocks) {
					SwitchSection section = new SwitchSection();
					if (caseBlock.Values != null) {
						section.CaseLabels.AddRange(caseBlock.Values.Select(i => new CaseLabel() { Expression = AstBuilder.MakePrimitive(i, (ilSwitch.Condition.ExpectedType ?? ilSwitch.Condition.InferredType).ToTypeDefOrRef()) }));
					} else {
						section.CaseLabels.Add(new CaseLabel());
					}
					section.Statements.Add(TransformBlock(caseBlock));
					switchStmt.SwitchSections.Add(section);
				}
				yield return switchStmt;
			} else if (node is ILTryCatchBlock) {
				ILTryCatchBlock tryCatchNode = ((ILTryCatchBlock)node);
				var tryCatchStmt = new Ast.TryCatchStatement();
				tryCatchStmt.TryBlock = TransformBlock(tryCatchNode.TryBlock);
				tryCatchStmt.TryBlock.HiddenStart = NRefactoryExtensions.CreateHidden(tryCatchNode.ILRanges, tryCatchStmt.TryBlock.HiddenStart);
				foreach (var catchClause in tryCatchNode.CatchBlocks) {
					if (catchClause.ExceptionVariable == null
					    && (catchClause.ExceptionType == null || catchClause.ExceptionType.GetElementType() == ElementType.Object))
					{
						tryCatchStmt.CatchClauses.Add(new Ast.CatchClause { Body = TransformBlock(catchClause) }.WithAnnotation(catchClause.StlocILRanges));
					} else {
						tryCatchStmt.CatchClauses.Add(
							new Ast.CatchClause {
								Type = AstBuilder.ConvertType(catchClause.ExceptionType),
								VariableNameToken = catchClause.ExceptionVariable == null ? null : Identifier.Create(catchClause.ExceptionVariable.Name).WithAnnotation(catchClause.ExceptionVariable.IsParameter ? TextTokenType.Parameter : TextTokenType.Local),
								Body = TransformBlock(catchClause)
							}.WithAnnotation(catchClause.ExceptionVariable).WithAnnotation(catchClause.StlocILRanges));
					}
				}
				if (tryCatchNode.FinallyBlock != null)
					tryCatchStmt.FinallyBlock = TransformBlock(tryCatchNode.FinallyBlock);
				if (tryCatchNode.FaultBlock != null) {
					CatchClause cc = new CatchClause();
					cc.Body = TransformBlock(tryCatchNode.FaultBlock);
					cc.Body.Add(new ThrowStatement()); // rethrow
					tryCatchStmt.CatchClauses.Add(cc);
				}
				yield return tryCatchStmt;
			} else if (node is ILFixedStatement) {
				ILFixedStatement fixedNode = (ILFixedStatement)node;
				FixedStatement fixedStatement = new FixedStatement();
				for (int i = 0; i < fixedNode.Initializers.Count; i++) {
					var initializer = fixedNode.Initializers[i];
					Debug.Assert(initializer.Code == ILCode.Stloc);
					ILVariable v = (ILVariable)initializer.Operand;
					VariableInitializer vi;
					fixedStatement.Variables.Add(vi =
//.........这里部分代码省略.........
开发者ID:nakijun,项目名称:dnSpy,代码行数:101,代码来源:AstMethodBodyBuilder.cs


示例17: IsRedundant

			bool IsRedundant(CatchClause catchClause)
			{
				var firstStatement = catchClause.Body.Statements.FirstOrNullObject();
				if (firstStatement.IsNull) {
					return false;
				}
				var throwStatement = firstStatement as ThrowStatement;
				if (throwStatement == null) {
					return false;
				}
				return throwStatement.Expression.IsNull;
			}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:12,代码来源:RedundantCatchIssue.cs


示例18: VisitCatchClause

		public virtual void VisitCatchClause(CatchClause catchClause)
		{
			StartNode(catchClause);
			DebugStart(catchClause);
			WriteKeywordReference(CatchClause.CatchKeywordRole, currentTryReference);
			if (!catchClause.Type.IsNull) {
				Space(policy.SpaceBeforeCatchParentheses);
				var braceHelper = BraceHelper.LeftParen(this, CodeBracesRangeFlags.Parentheses);
				Space(policy.SpacesWithinCatchParentheses);
				catchClause.Type.AcceptVisitor(this);
				if (!string.IsNullOrEmpty(catchClause.VariableName)) {
					Space();
					WriteIdentifier(catchClause.VariableNameToken);
				}
				Space(policy.SpacesWithinCatchParentheses);
				braceHelper.RightParen();
			}
			DebugEnd(catchClause);
			if (!catchClause.Condition.IsNull) {
				Space();
				WriteKeywordReference(CatchClause.WhenKeywordRole, currentTryReference);
				Space(policy.SpaceBeforeIfParentheses);
				var braceHelper = BraceHelper.LeftParen(this, CodeBracesRangeFlags.Parentheses);
				Space(policy.SpacesWithinIfParentheses);
				catchClause.Condition.AcceptVisitor(this);
				Space(policy.SpacesWithinIfParentheses);
				braceHelper.RightParen();
			}
			catchClause.Body.AcceptVisitor(this);
			EndNode(catchClause);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:31,代码来源:CSharpOutputVisitor.cs


示例19: TryStatement

		TryStatement(BlockStatement body, CatchClause[] catchClauses, BlockStatement finallyBlock)
			: super(StatementKind.Try) {
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:2,代码来源:TryStatement.stab.cs


示例20: ParseCatchClause

 private CatchClause ParseCatchClause(TokenSet followers, ref bool seenEmptyCatch)
   //^ requires this.currentToken == Token.Catch;
   //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
 {
   if (seenEmptyCatch) this.HandleError(Error.TooManyCatches);
   SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
   this.GetNextToken();
   TypeExpression exeptionType;
   NameDeclaration/*?*/ name = null;
   if (this.currentToken == Token.LeftParenthesis) {
     this.Skip(Token.LeftParenthesis);
     exeptionType = this.ParseTypeExpression(false, false, followers|Token.Identifier|Token.RightParenthesis);
     if (Parser.IdentifierOrNonReservedKeyword[this.currentToken]) 
       name = this.ParseNameDeclaration();
     this.Skip(Token.RightParenthesis);
   } else {
     exeptionType = this.GetTypeExpressionFor(Token.Object, slb.GetSourceLocation());
   }
   BlockStatement body = this.ParseBlock(followers);
   slb.UpdateToSpan(body.SourceLocation);
   CatchClause result = new CatchClause(exeptionType, null, name, body, slb);
   //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
   return result;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:24,代码来源:Parser.cs



注:本文中的CatchClause类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CatchPos类代码示例发布时间:2022-05-24
下一篇:
C# Catalog类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap