当前位置: 首页>>代码示例>>C#>>正文


C# BlockStatement类代码示例

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


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

示例1: VisitBlockWithoutFixingBraces

		void VisitBlockWithoutFixingBraces(BlockStatement blockStatement, bool indent)
		{
			if (indent) {
				curIndent.Push(IndentType.Block);
			}

			VisitChildrenToFormat (blockStatement, child => {
				if (child.Role == Roles.LBrace || child.Role == Roles.RBrace) {
					return;
				}

				if (child is Statement) {
					FixStatementIndentation(child.StartLocation);
					child.AcceptVisitor(this);
				} else if (child is Comment) {
					child.AcceptVisitor(this);
				} else if (child is NewLineNode) {
					// ignore
				} else {
					// pre processor directives at line start, if they are there.
					if (child.StartLocation.Column > 1)
						FixStatementIndentation(child.StartLocation);
				}
			});

			if (indent) {
				curIndent.Pop ();
			}
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:29,代码来源:FormattingVisitor_Statements.cs

示例2: VisitBlockStatement

        public override void VisitBlockStatement(BlockStatement blockStatement)
        {
            base.VisitBlockStatement (blockStatement);

            List<Statement> statements = new List<Statement>();

            foreach (Statement statement in blockStatement.Statements)
            {
                bool loop = GetIsLoopStatement (statement);
                if (loop)
                {
                    int nodeId = this.blockIds.Dequeue();
                    this.lineMap[nodeId] = statement.StartLocation.Line;
                }

                if (this.loopLevel > 0)
                {
                    if (statement is ContinueStatement || statement is BreakStatement)
                        this.id++;
                }

                statements.Add (statement.Clone());

                if (loop)
                    this.id++;
            }

            blockStatement.Statements.Clear();
            blockStatement.Statements.AddRange (statements);
        }
开发者ID:ermau,项目名称:Instant,代码行数:30,代码来源:IdentifyingVisitor.cs

示例3: ActionFromUsingStatement

		CodeAction ActionFromUsingStatement(RefactoringContext context)
		{
			var initializer = context.GetNode<VariableInitializer>();
			if (initializer == null)
				return null;
			var initializerRR = context.Resolve(initializer) as LocalResolveResult;
			if (initializerRR == null)
				return null;
			var elementType = GetElementType(initializerRR, context);
			if (elementType == null)
				return null;
			var usingStatement = initializer.Parent.Parent as UsingStatement;
			if (usingStatement == null)
				return null;
			return new CodeAction(context.TranslateString("Iterate via foreach"), script => {
				var iterator = MakeForeach(new IdentifierExpression(initializer.Name), elementType, context);
				if (usingStatement.EmbeddedStatement is EmptyStatement) {
					var blockStatement = new BlockStatement();
					blockStatement.Statements.Add(iterator);
					script.Replace(usingStatement.EmbeddedStatement, blockStatement);
					script.FormatText(blockStatement);
				} else if (usingStatement.EmbeddedStatement is BlockStatement) {
					var anchorNode = usingStatement.EmbeddedStatement.FirstChild;
					script.InsertAfter(anchorNode, iterator);
					script.FormatText(usingStatement.EmbeddedStatement);
				}
			});
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:28,代码来源:IterateViaForeachAction.cs

示例4: VisitBlockStatement

		public override object VisitBlockStatement(BlockStatement blockStatement, object data)
		{
			Push();
			object result = base.VisitBlockStatement(blockStatement, data);
			Pop();
			return result;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:PrefixFieldsVisitor.cs

示例5: SmallBasicSimpleName

 private SmallBasicSimpleName(BlockStatement containingBlock, SmallBasicSimpleName template)
   : base(containingBlock, template) {
   if (template.rootClass != null)
     this.rootClass = (RootClassDeclaration)template.rootClass.MakeShallowCopyFor(containingBlock.ContainingNamespaceDeclaration);
   if (template.expressionToInferTargetTypeFrom != null)
     this.expressionToInferTargetTypeFrom = template.expressionToInferTargetTypeFrom.MakeCopyFor(containingBlock);
 }
开发者ID:mestriga,项目名称:Microsoft.CciSamples,代码行数:7,代码来源:Expressions.cs

示例6: Visit

 public virtual void Visit(BlockStatement blockStatement)
 {
     foreach (var xStatement in blockStatement.Statements)
     {
         xStatement.Dispatch(this);
     }
 }
开发者ID:Sullux,项目名称:tws,代码行数:7,代码来源:BaseVisitor.cs

示例7: CheckedStatement

        /// <summary>
        /// Initializes a new instance of the CheckedStatement class.
        /// </summary>
        /// <param name="tokens">
        /// The list of tokens that form the statement.
        /// </param>
        /// <param name="embeddedStatement">
        /// The block statement embedded within this checked statement, if any.
        /// </param>
        internal CheckedStatement(CsTokenList tokens, BlockStatement embeddedStatement)
            : base(StatementType.Checked, tokens)
        {
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(embeddedStatement, "embeddedStatement");

            this.embeddedStatement = embeddedStatement;
            this.AddStatement(embeddedStatement);
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:18,代码来源:CheckedStatement.cs

示例8: TransformBlock

		Ast.BlockStatement TransformBlock(ILBlock block)
		{
			Ast.BlockStatement astBlock = new BlockStatement();
			if (block != null) {
				foreach(ILNode node in block.GetChildren()) {
					astBlock.AddRange(TransformNode(node));
				}
			}
			return astBlock;
		}
开发者ID:hlesesne,项目名称:ILSpy,代码行数:10,代码来源:AstMethodBodyBuilder.cs

示例9: VisitBlockStatement

        public override void VisitBlockStatement(BlockStatement node)
        {
            VisitChildren(node);

            var statements = node.Statements;
            for (AstNode child = node.FirstChild, next = null; child != null; child = next) {
                next = child.NextSibling;
                MangleStatement(statements, child);
            }
        }
开发者ID:evanw,项目名称:minisharp,代码行数:10,代码来源:Mangle.cs

示例10: MethodBodyMetadata

		/// <summary>
		///     Initializes a new instance.
		/// </summary>
		/// <param name="parameters">The metadata of the parameters declared by the method.</param>
		/// <param name="localVariables">The metadata of the local variables declared by the method.</param>
		/// <param name="body">The block statement representing the method's body.</param>
		public MethodBodyMetadata(IEnumerable<VariableMetadata> parameters, IEnumerable<VariableMetadata> localVariables, BlockStatement body)
		{
			Requires.NotNull(parameters, () => parameters);
			Requires.NotNull(localVariables, () => localVariables);
			Requires.NotNull(body, () => body);

			Parameters = parameters;
			LocalVariables = localVariables;
			Body = body;
		}
开发者ID:cubeme,项目名称:safety-sharp,代码行数:16,代码来源:MethodBodyMetadata.cs

示例11: TryFinally

		public void TryFinally()
		{
			BlockStatement block = new BlockStatement {
				new TryCatchStatement {
					TryBlock = new BlockStatement {
						new GotoStatement("LABEL"),
						new AssignmentExpression(new IdentifierExpression("i"), new PrimitiveExpression(1))
					},
					CatchClauses = {
						new CatchClause {
							Body = new BlockStatement {
								new AssignmentExpression(new IdentifierExpression("i"), new PrimitiveExpression(3))
							}
						}
					},
					FinallyBlock = new BlockStatement {
						new AssignmentExpression(new IdentifierExpression("j"), new PrimitiveExpression(5))
					}
				},
				new LabelStatement { Label = "LABEL" },
				new EmptyStatement()
			};
			TryCatchStatement tryCatchStatement = (TryCatchStatement)block.Statements.First();
			Statement stmt1 = tryCatchStatement.TryBlock.Statements.ElementAt(1);
			Statement stmt3 = tryCatchStatement.CatchClauses.Single().Body.Statements.Single();
			Statement stmt5 = tryCatchStatement.FinallyBlock.Statements.Single();
			LabelStatement label = (LabelStatement)block.Statements.ElementAt(1);
			
			DefiniteAssignmentAnalysis da = CreateDefiniteAssignmentAnalysis(block);
			da.Analyze("i");
			Assert.AreEqual(0, da.UnassignedVariableUses.Count);
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(tryCatchStatement));
			Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusBefore(stmt1));
			Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusAfter(stmt1));
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt3));
			Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(stmt3));
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt5));
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusAfter(stmt5));
			Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(tryCatchStatement));
			Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusBefore(label));
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusAfter(label));
			
			da.Analyze("j");
			Assert.AreEqual(0, da.UnassignedVariableUses.Count);
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(tryCatchStatement));
			Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusBefore(stmt1));
			Assert.AreEqual(DefiniteAssignmentStatus.CodeUnreachable, da.GetStatusAfter(stmt1));
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt3));
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusAfter(stmt3));
			Assert.AreEqual(DefiniteAssignmentStatus.PotentiallyAssigned, da.GetStatusBefore(stmt5));
			Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(stmt5));
			Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(tryCatchStatement));
			Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusBefore(label));
			Assert.AreEqual(DefiniteAssignmentStatus.DefinitelyAssigned, da.GetStatusAfter(label));
		}
开发者ID:mono-soc-2012,项目名称:NRefactory,代码行数:55,代码来源:DefiniteAssignmentTests.cs

示例12: FinallyStatement

        /// <summary>
        /// Initializes a new instance of the FinallyStatement class.
        /// </summary>
        /// <param name="tokens">
        /// The list of tokens that form the statement.
        /// </param>
        /// <param name="tryStatement">
        /// The try-statement that this finally-statement is embedded to.
        /// </param>
        /// <param name="embeddedStatement">
        /// The statement embedded within the finally-statement.
        /// </param>
        internal FinallyStatement(CsTokenList tokens, TryStatement tryStatement, BlockStatement embeddedStatement)
            : base(StatementType.Finally, tokens)
        {
            Param.AssertNotNull(tokens, "tokens");
            Param.AssertNotNull(tryStatement, "tryStatement");
            Param.AssertNotNull(embeddedStatement, "embeddedStatement");

            this.tryStatement = tryStatement;
            this.embeddedStatement = embeddedStatement;

            this.AddStatement(embeddedStatement);
        }
开发者ID:kopelli,项目名称:Visual-StyleCop,代码行数:24,代码来源:FinallyStatement.cs

示例13: IsNotImplemented

		bool IsNotImplemented(RefactoringContext context, BlockStatement body)
		{
			if (body.IsNull)
				return true;
			if (body.Statements.Count == 1) {
				var throwStmt = body.Statements.First () as ThrowStatement;
				if (throwStmt != null) {
					return context.Resolve (throwStmt.Expression).Type.FullName == "System.NotImplementedException";
				}
			}
			return false;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:12,代码来源:ImplementNotImplementedProperty.cs

示例14: TransformBlock

		Ast.BlockStatement TransformBlock(ILBlock block)
		{
			Ast.BlockStatement astBlock = new BlockStatement();
			if (block != null) {
				if (block.EntryGoto != null)
					astBlock.Add((Statement)TransformExpression(block.EntryGoto));
				foreach(ILNode node in block.Body) {
					astBlock.AddRange(TransformNode(node));
				}
			}
			return astBlock;
		}
开发者ID:stgwilli,项目名称:ILSpy,代码行数:12,代码来源:AstMethodBodyBuilder.cs

示例15: GlslVisitor

        public GlslVisitor(BlockStatement block, CustomAttribute attr, DecompilerContext ctx)
            : this()
        {
            _attr = attr;

            var trans1 = new ReplaceMethodCallsWithOperators(ctx);
            var trans2 = new RenameLocals();
            ((IAstTransform)trans1).Run(block);
            trans2.Run(block);

            Result = block.AcceptVisitor(this, 0).ToString();
            Result += Environment.NewLine;
        }
开发者ID:mono-soc-2011,项目名称:SLSharp,代码行数:13,代码来源:GlslVisitor.cs


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