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

C# FixedStatement类代码示例

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

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



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

示例1: Visit

			public override object Visit (Fixed fixedStatement)
			{
				var result = new FixedStatement ();
				var location = LocationsBag.GetLocations (fixedStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc), "fixed".Length), FixedStatement.FixedKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FixedStatement.Roles.LPar);
				
				if (fixedStatement.Variables != null) {
					result.AddChild ((INode)fixedStatement.Variables.TypeExpression.Accept (this), UsingStatement.Roles.ReturnType);
					result.AddChild (new Identifier (fixedStatement.Variables.Variable.Name, Convert (fixedStatement.Variables.Variable.Location)), UsingStatement.Roles.Identifier);
					var loc = LocationsBag.GetLocations (fixedStatement.Variables);
					if (loc != null)
						result.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), ContinueStatement.Roles.Assign);
					if (fixedStatement.Variables.Initializer != null)
						result.AddChild ((INode)fixedStatement.Variables.Initializer.Accept (this), UsingStatement.Roles.Initializer);
				}
				
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FixedStatement.Roles.RPar);
				result.AddChild ((INode)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement);
				return result;
			}
开发者ID:silk,项目名称:monodevelop,代码行数:24,代码来源:CSharpParser.cs


示例2: Visit

			public override object Visit (Fixed fixedStatement)
			{
				var result = new FixedStatement ();
				var location = LocationsBag.GetLocations (fixedStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (fixedStatement.loc), "fixed".Length), FixedStatement.FixedKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FixedStatement.Roles.LPar);
				
				result.AddChild ((INode)fixedStatement.Type.Accept (this), FixedStatement.PointerDeclarationRole);
				
				foreach (KeyValuePair<LocalInfo, Expression> declarator in fixedStatement.Declarators) {
					result.AddChild ((INode)declarator.Value.Accept (this), FixedStatement.DeclaratorRole);
				}
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), FixedStatement.Roles.RPar);
				result.AddChild ((INode)fixedStatement.Statement.Accept (this), FixedStatement.Roles.EmbeddedStatement);
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:19,代码来源:CSharpParser.cs


示例3: TrackedVisitFixedStatement

		public virtual object TrackedVisitFixedStatement(FixedStatement fixedStatement, object data) {
			return base.VisitFixedStatement(fixedStatement, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NodeTrackingAstVisitor.cs


示例4: 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 = ILRange.OrderAndJoint(node.GetSelfAndChildrenRecursive<ILExpression>().SelectMany(e => e.ILRanges));
				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) {
					if (catchClause.ExceptionVariable == null
					    && (catchClause.ExceptionType == null || catchClause.ExceptionType.MetadataType == MetadataType.Object))
					{
						tryCatchStmt.CatchClauses.Add(new Ast.CatchClause { Body = TransformBlock(catchClause) });
					} else {
						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 ILFixedStatement) {
				ILFixedStatement fixedNode = (ILFixedStatement)node;
				FixedStatement fixedStatement = new FixedStatement();
				foreach (ILExpression initializer in fixedNode.Initializers) {
					Debug.Assert(initializer.Code == ILCode.Stloc);
					ILVariable v = (ILVariable)initializer.Operand;
					fixedStatement.Variables.Add(
						new VariableInitializer {
							Name = v.Name,
							Initializer = (Expression)TransformExpression(initializer.Arguments[0])
						}.WithAnnotation(v));
				}
				fixedStatement.Type = AstBuilder.ConvertType(((ILVariable)fixedNode.Initializers[0].Operand).Type);
				fixedStatement.EmbeddedStatement = TransformBlock(fixedNode.BodyBlock);
				yield return fixedStatement;
			} else if (node is ILBlock) {
				yield return TransformBlock((ILBlock)node);
			} else {
				throw new Exception("Unknown node type");
			}
		}
开发者ID:JustasB,项目名称:cudafy,代码行数:94,代码来源:AstMethodBodyBuilder.cs


示例5: Visit

			public override object Visit(Fixed fixedStatement)
			{
				var result = new FixedStatement();
				var location = LocationsBag.GetLocations(fixedStatement);
				
				result.AddChild(new CSharpTokenNode(Convert(fixedStatement.loc), FixedStatement.FixedKeywordRole), FixedStatement.FixedKeywordRole);
				if (location != null)
					result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
				
				if (fixedStatement.Variables != null) {
					var blockVariableDeclaration = fixedStatement.Variables;
					result.AddChild(ConvertToType(blockVariableDeclaration.TypeExpression), Roles.Type);
					var varInit = new VariableInitializer();
					var initLocation = LocationsBag.GetLocations(blockVariableDeclaration);
					varInit.AddChild(Identifier.Create(blockVariableDeclaration.Variable.Name, Convert(blockVariableDeclaration.Variable.Location)), Roles.Identifier);
					if (blockVariableDeclaration.Initializer != null) {
						if (initLocation != null)
							varInit.AddChild(new CSharpTokenNode(Convert(initLocation [0]), Roles.Assign), Roles.Assign);
						varInit.AddChild((Expression)blockVariableDeclaration.Initializer.Accept(this), Roles.Expression);
					}
					
					result.AddChild(varInit, Roles.Variable);
					
					if (blockVariableDeclaration.Declarators != null) {
						foreach (var decl in blockVariableDeclaration.Declarators) {
							var loc = LocationsBag.GetLocations(decl);
							var init = new VariableInitializer();
							if (loc != null && loc.Count > 0)
								result.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Comma), Roles.Comma);
							init.AddChild(Identifier.Create(decl.Variable.Name, Convert(decl.Variable.Location)), Roles.Identifier);
							if (decl.Initializer != null) {
								if (loc != null && loc.Count > 1)
									init.AddChild(new CSharpTokenNode(Convert(loc [1]), Roles.Assign), Roles.Assign);
								init.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression);
							}
							result.AddChild(init, Roles.Variable);
						}
					}
				}
				
				if (location != null && location.Count > 1)
					result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
				if (fixedStatement.Statement != null)
					result.AddChild((Statement)fixedStatement.Statement.Accept(this), Roles.EmbeddedStatement);
				return result;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:46,代码来源:CSharpParser.cs


示例6: VisitFixedStatement

		public override object VisitFixedStatement(FixedStatement fixedStatement, object data)
		{
			// uses LocalVariableDeclaration, we just have to put the end location on the stack
			if (fixedStatement.EmbeddedStatement.EndLocation.IsEmpty) {
				return base.VisitFixedStatement(fixedStatement, data);
			} else {
				endLocationStack.Push(fixedStatement.EmbeddedStatement.EndLocation);
				base.VisitFixedStatement(fixedStatement, data);
				endLocationStack.Pop();
				return null;
			}
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:12,代码来源:LookupTableVisitor.cs


示例7: VisitFixedStatement

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


示例8: VisitFixedStatement

        public void VisitFixedStatement(FixedStatement fixedStatement)
        {
            JsonObject statement = CreateJsonStatement(fixedStatement);

            AddKeyword(statement, FixedStatement.FixedKeywordRole);
            statement.AddJsonValue("type-info", GenTypeInfo(fixedStatement.Type));
            statement.AddJsonValue("variables", GetCommaSeparatedList(fixedStatement.Variables));
            statement.AddJsonValue("embedded-statement", GenStatement(fixedStatement.EmbeddedStatement));

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


示例9: VisitFixedStatement

		public virtual object VisitFixedStatement(FixedStatement fixedStatement, object data) {
			Debug.Assert((fixedStatement != null));
			Debug.Assert((fixedStatement.PointerDeclaration != null));
			Debug.Assert((fixedStatement.EmbeddedStatement != null));
			fixedStatement.PointerDeclaration.AcceptVisitor(this, data);
			return fixedStatement.EmbeddedStatement.AcceptVisitor(this, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:AbstractASTVisitor.cs


示例10: VisitFixedStatement

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


示例11: VisitFixedStatement

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


示例12: EmbeddedStatement


//.........这里部分代码省略.........
             statement = new YieldStatement(new ReturnStatement(expr));
         }
         else if (this.la.kind == 0x34)
         {
             base.lexer.NextToken();
             statement = new YieldStatement(new BreakStatement());
         }
         else
         {
             base.SynErr(0xab);
         }
         base.Expect(11);
     }
     else if (this.la.kind == 100)
     {
         base.lexer.NextToken();
         if (this.StartOf(5))
         {
             this.Expr(out expr);
         }
         base.Expect(11);
         statement = new ReturnStatement(expr);
     }
     else if (this.la.kind == 0x6f)
     {
         base.lexer.NextToken();
         if (this.StartOf(5))
         {
             this.Expr(out expr);
         }
         base.Expect(11);
         statement = new ThrowStatement(expr);
     }
     else if (this.StartOf(5))
     {
         this.StatementExpr(out statement);
         base.Expect(11);
     }
     else if (this.la.kind == 0x71)
     {
         this.TryStatement(out statement);
     }
     else if (this.la.kind == 0x55)
     {
         base.lexer.NextToken();
         base.Expect(20);
         this.Expr(out expr);
         base.Expect(0x15);
         this.EmbeddedStatement(out statement2);
         statement = new LockStatement(expr, statement2);
     }
     else if (this.la.kind == 120)
     {
         ICSharpCode.NRefactory.Parser.AST.Statement stmt = null;
         base.lexer.NextToken();
         base.Expect(20);
         this.ResourceAcquisition(out stmt);
         base.Expect(0x15);
         this.EmbeddedStatement(out statement2);
         statement = new UsingStatement(stmt, statement2);
     }
     else if (this.la.kind == 0x76)
     {
         base.lexer.NextToken();
         this.Block(out statement2);
         statement = new UnsafeStatement(statement2);
     }
     else if (this.la.kind == 0x49)
     {
         base.lexer.NextToken();
         base.Expect(20);
         this.Type(out type);
         if (type.PointerNestingLevel == 0)
         {
             this.Error("can only fix pointer types");
         }
         List<VariableDeclaration> pointerDeclarators = new List<VariableDeclaration>(1);
         base.Expect(1);
         string name = this.t.val;
         base.Expect(3);
         this.Expr(out expr);
         pointerDeclarators.Add(new VariableDeclaration(name, expr));
         while (this.la.kind == 14)
         {
             base.lexer.NextToken();
             base.Expect(1);
             name = this.t.val;
             base.Expect(3);
             this.Expr(out expr);
             pointerDeclarators.Add(new VariableDeclaration(name, expr));
         }
         base.Expect(0x15);
         this.EmbeddedStatement(out statement2);
         statement = new FixedStatement(type, pointerDeclarators, statement2);
     }
     else
     {
         base.SynErr(0xac);
     }
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:101,代码来源:Parser.cs


示例13: VisitFixedStatement

		public virtual object VisitFixedStatement(FixedStatement fixedStatement, object data) {
			Debug.Assert((fixedStatement != null));
			Debug.Assert((fixedStatement.PointerDeclaration != null));
			Debug.Assert((fixedStatement.EmbeddedStatement != null));
			nodeStack.Push(fixedStatement.PointerDeclaration);
			fixedStatement.PointerDeclaration.AcceptVisitor(this, data);
			fixedStatement.PointerDeclaration = ((Statement)(nodeStack.Pop()));
			nodeStack.Push(fixedStatement.EmbeddedStatement);
			fixedStatement.EmbeddedStatement.AcceptVisitor(this, data);
			fixedStatement.EmbeddedStatement = ((Statement)(nodeStack.Pop()));
			return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:12,代码来源:AbstractAstTransformer.cs


示例14: VisitFixedStatement

		public sealed override object VisitFixedStatement(FixedStatement fixedStatement, object data) {
			BeginVisit(fixedStatement);
			object result = TrackedVisitFixedStatement(fixedStatement, data);
			EndVisit(fixedStatement);
			return result;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:6,代码来源:NodeTrackingAstVisitor.cs


示例15: TransformNode

		IEnumerable<Statement> TransformNode(ILNode node)
		{
			if (node is ILLabel) {
				yield return new LabelStatement { Label = ((ILLabel)node).Name };
			} else if (node is ILExpression) {
				List<ILRange> ilRanges = ILRange.OrderAndJoint(node.GetSelfAndChildrenRecursive<ILExpression>().SelectMany(e => e.ILRanges));
				AstNode codeExpr = TransformExpression((ILExpression)node);
				if (codeExpr != null) {
					codeExpr = codeExpr.WithAnnotation(ilRanges);
					if (codeExpr is Expression) {
						yield return new ExpressionStatement { Expression = (Expression)codeExpr };
					} else if (codeExpr is Statement) {
						yield return (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 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;
				if (TypeAnalysis.IsBoolean(ilSwitch.Condition.InferredType) && (
					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 = typeSystem.Int32;
				}
				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.ExpectedType ?? 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 TryCatchStatement();
				tryCatchStmt.TryBlock = TransformBlock(tryCatchNode.TryBlock);
				foreach (var catchClause in tryCatchNode.CatchBlocks) {
					CatchClause clause = new CatchClause { Body = TransformBlock(catchClause) };
					if (catchClause.ExceptionVariable != null
					    || (catchClause.ExceptionType != null && !catchClause.ExceptionType.IsCorLibType("System", "Object")))
					{
						clause.Type = AstBuilder.ConvertType(catchClause.ExceptionType);
						clause.VariableName = catchClause.ExceptionVariable == null ? null : catchClause.ExceptionVariable.Name;
						clause.AddAnnotation(catchClause.ExceptionVariable);
					}
					if (catchClause.FilterBlock != null) {
						clause.Filter = new FilterClause { 
							Expression = new LambdaExpression { 
								Body = TransformBlock(catchClause.FilterBlock) 
							}.WithAnnotation(new FilterClauseAnnotation())
						};
					}
					tryCatchStmt.CatchClauses.Add(clause);
				}
				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();
				foreach (ILExpression initializer in fixedNode.Initializers) {
					Debug.Assert(initializer.Code == ILCode.Stloc);
					ILVariable v = (ILVariable)initializer.Operand;
					fixedStatement.Variables.Add(
						new VariableInitializer {
							Name = v.Name,
							Initializer = (Expression)TransformExpression(initializer.Arguments[0])
						}.WithAnnotation(v));
				}
				fixedStatement.Type = AstBuilder.ConvertType(((ILVariable)fixedNode.Initializers[0].Operand).Type);
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:101,代码来源:AstMethodBodyBuilder.cs


示例16: EmbeddedStatement


//.........这里部分代码省略.........
				lexer.NextToken();

#line  1585 "cs.ATG" 
				statement = new YieldStatement(new BreakStatement()); 
			} else SynErr(198);
			Expect(11);
		} else if (la.kind == 101) {
			lexer.NextToken();
			if (StartOf(6)) {
				Expr(
#line  1588 "cs.ATG" 
out expr);
			}
			Expect(11);

#line  1588 "cs.ATG" 
			statement = new ReturnStatement(expr); 
		} else if (la.kind == 112) {
			lexer.NextToken();
			if (StartOf(6)) {
				Expr(
#line  1589 "cs.ATG" 
out expr);
			}
			Expect(11);

#line  1589 "cs.ATG" 
			statement = new ThrowStatement(expr); 
		} else if (StartOf(6)) {
			StatementExpr(
#line  1592 "cs.ATG" 
out statement);
			while (!(la.kind == 0 || la.kind == 11)) {SynErr(199); lexer.NextToken(); }
			Expect(11);
		} else if (la.kind == 114) {
			TryStatement(
#line  1595 "cs.ATG" 
out statement);
		} else if (la.kind == 86) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1598 "cs.ATG" 
out expr);
			Expect(21);
			EmbeddedStatement(
#line  1599 "cs.ATG" 
out embeddedStatement);

#line  1599 "cs.ATG" 
			statement = new LockStatement(expr, embeddedStatement); 
		} else if (la.kind == 121) {

#line  1602 "cs.ATG" 
			Statement resourceAcquisitionStmt = null; 
			lexer.NextToken();
			Expect(20);
			ResourceAcquisition(
#line  1604 "cs.ATG" 
out resourceAcquisitionStmt);
			Expect(21);
			EmbeddedStatement(
#line  1605 "cs.ATG" 
out embeddedStatement);

#line  1605 "cs.ATG" 
			statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); 
		} else if (la.kind == 119) {
			lexer.NextToken();
			Block(
#line  1608 "cs.ATG" 
out embeddedStatement);

#line  1608 "cs.ATG" 
			statement = new UnsafeStatement(embeddedStatement); 
		} else if (la.kind == 74) {

#line  1610 "cs.ATG" 
			Statement pointerDeclarationStmt = null; 
			lexer.NextToken();
			Expect(20);
			ResourceAcquisition(
#line  1612 "cs.ATG" 
out pointerDeclarationStmt);
			Expect(21);
			EmbeddedStatement(
#line  1613 "cs.ATG" 
out embeddedStatement);

#line  1613 "cs.ATG" 
			statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); 
		} else SynErr(200);

#line  1615 "cs.ATG" 
		if (statement != null) {
		statement.StartLocation = startLocation;
		statement.EndLocation = t.EndLocation;
		}
		
	}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:101,代码来源:Parser.cs


示例17: 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


示例18: VisitFixedStatement

		public virtual void VisitFixedStatement(FixedStatement fixedStatement)
		{
			StartNode(fixedStatement);
			WriteKeyword(FixedStatement.FixedKeywordRole);
			Space(policy.SpaceBeforeUsingParentheses);
			var braceHelper = BraceHelper.LeftParen(this, CodeBracesRangeFlags.Parentheses);
			Space(policy.SpacesWithinUsingParentheses);
			DebugStart(fixedStatement);
			fixedStatement.Type.AcceptVisitor(this);
			Space();
			WriteCommaSeparatedList(fixedStatement.Variables);
			DebugEnd(fixedStatement);
			Space(policy.SpacesWithinUsingParentheses);
			braceHelper.RightParen();
			WriteEmbeddedStatement(fixedStatement.EmbeddedStatement);
			EndNode(fixedStatement);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:17,代码来源:CSharpOutputVisitor.cs


示例19: VisitFixedStatement

		public override void VisitFixedStatement(FixedStatement fixedStatement)
		{
			FixEmbeddedStatment(policy.StatementBraceStyle, policy.FixedBraceForcement, fixedStatement.EmbeddedStatement);
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:4,代码来源:AstFormattingVisitor.cs


示例20: Process_Fixed_Statement

        private void Process_Fixed_Statement(StringBuilder sb, FixedStatement statement)
        {
            sb.Append("fixed(");
            bool typeAppended = false;

            foreach (IAstNode declNode in statement.Declarators)
            {
                VariableDeclarator decl = (VariableDeclarator)declNode;
                if (typeAppended == false)
                {
                    sb.Append(FormatterUtility.FormatDataType(decl.ReturnType, document, controller)).Append(" ");
                    typeAppended = true;
                }
                else
                    sb.Append(", ");

                Process_Variable_Declarator(sb, decl);
            }

            sb.Append(")");

            sb.Append(ProcessStatement(statement.Statement));
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:23,代码来源:CSharpCodeFormatter.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Fixture类代码示例发布时间:2022-05-24
下一篇:
C# FixedFieldDeclaration类代码示例发布时间: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