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


C# FixedStatement类代码示例

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


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


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