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

C# Ast.ForeachStatement类代码示例

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

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



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

示例1: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			if (nameComparer.Equals(from, foreachStatement.VariableName)) {
				foreachStatement.VariableName = to;
			}
			return base.VisitForeachStatement(foreachStatement, data);
		}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:7,代码来源:RenameIdentifierVisitor.cs


示例2: VisitForeachStatement

            public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
            {
                //Looks convoluted solution not sure this is correct way to detect something of form (foreach(var t in Enum.GetValue/GetNames(...))
                InvocationExpression expr = foreachStatement.Expression as InvocationExpression;

                if (expr != null)
                {
                    MemberReferenceExpression expr2 = expr.TargetObject as MemberReferenceExpression;
                    if (expr2 != null)
                    {
                        IdentifierExpression expr3 = expr2.TargetObject as IdentifierExpression;
                        if (expr3 != null && expr3.Identifier == "Enum")
                        {
                            UnlockWith(foreachStatement);
                        }
                    }
                }
                return base.VisitForeachStatement(foreachStatement, data);
            }
开发者ID:timdams,项目名称:strokes,代码行数:19,代码来源:ForEachWithEnumAchievement.cs


示例3: VisitForeachStatement

 public override object VisitForeachStatement (ForeachStatement node, object data)
 {
     if (node.EmbeddedStatement is EmptyStatement)
         return null;
     
     var iteratorName = GetNextIteratorName ();
     
     Write ("var ", iteratorName, " = ");
     var extType = node.Expression.AcceptVisitor (this, null);
     
     var ctype = extType as Mono.Cecil.TypeReference;
     var itype = extType as ICSharpCode.NRefactory.Ast.TypeReference;
     
     var isArray = false;
     
     if (ctype != null) {
         isArray = ctype.FullName.IndexOf ("[]") > 0;
     } else if (itype != null) {
         isArray = itype.IsArrayType;
     }
     
     //Console.WriteLine ("Node: {0}", name);
     if (isArray) {
         var iName = GetNextIteratorName();
         Write (";");
         NewLine ();
         Write ("for(var ",iName,"=0;", iName, " < ", iteratorName, ".length;", iName, "++)");
         
         NewLine ();
         BeginBlock ();
         PushLocals ();
         Write ("var ", node.VariableName, "=", iteratorName, "[", iName, "];");
         NewLine ();
         Locals.Add (node.VariableName, node.TypeReference);
         
         BlockStatement block = node.EmbeddedStatement as BlockStatement;
         if (block != null) {
             block.AcceptChildren (this, null);
         } else {
             node.EmbeddedStatement.AcceptVisitor (this, null);
         }
         PopLocals ();
         EndBlock ();
         NewLine ();
     } else {
         Write (".", CREATE_ITERATOR_NAME, "();");
         
         NewLine ();
         
         Write ("while(", iteratorName, ".", ITERATOR_HAS_NEXT_NAME, "()", ") ");
         BeginBlock ();
         
         Write ("var ", node.VariableName, " = ", iteratorName, ".", ITERATOR_NEXT_NAME, ";");
         NewLine ();
         
         PushLocals ();
         Locals.Add (node.VariableName, node.TypeReference);
         
         BlockStatement block = node.EmbeddedStatement as BlockStatement;
         if (block != null) {
             block.AcceptChildren (this, null);
         } else {
             node.EmbeddedStatement.AcceptVisitor (this, null);
         }
         
         PopLocals ();
         
         EndBlock ();
         NewLine ();
     }
     return null;
 }
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:72,代码来源:JsEmitter.cs


示例4: TrackedVisitForeachStatement

 public override object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data)
 {
     this.AppendIndented(string.Empty);
     this.CreateInitStatement(foreachStatement);
     this.AppendLine();
     this.AppendIndentedLine("while enumerator.MoveNext():");
     this.IncreaseIndent();
     this.AppendIndentedLine(string.Concat(foreachStatement.VariableName, " = enumerator.Current"));
     foreachStatement.EmbeddedStatement.AcceptVisitor(this, data);
     this.DecreaseIndent();
     return null;
 }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:12,代码来源:NRefactoryToPythonConverter.cs


示例5: AppendForeachVariableName

 private void AppendForeachVariableName(ForeachStatement foreachStatement)
 {
     IdentifierExpression expression = foreachStatement.Expression as IdentifierExpression;
     InvocationExpression invocationExpression = foreachStatement.Expression as InvocationExpression;
     MemberReferenceExpression memberReferenceExpression = foreachStatement.Expression as MemberReferenceExpression;
     if (expression != null)
     {
         this.Append(expression.Identifier);
     }
     else if (invocationExpression != null)
     {
         invocationExpression.AcceptVisitor(this, null);
     }
     else if (memberReferenceExpression != null)
     {
         memberReferenceExpression.AcceptVisitor(this, null);
     }
 }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:18,代码来源:NRefactoryToPythonConverter.cs


示例6: TrackedVisitForeachStatement

		public virtual object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data) {
			return base.VisitForeachStatement(foreachStatement, data);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:3,代码来源:NodeTrackingAstVisitor.cs


示例7: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			if (!foreachStatement.EmbeddedStatement.IsNull) {
				AddVariable(foreachStatement.TypeReference,
				            foreachStatement.VariableName,
				            foreachStatement.EmbeddedStatement.StartLocation,
				            foreachStatement.EndLocation,
				            false, true,
				            foreachStatement.Expression,
				            null,
				            false,
				            foreachStatement.EmbeddedStatement.StartLocation);
			}
			
			if (foreachStatement.Expression != null) {
				foreachStatement.Expression.AcceptVisitor(this, data);
			}
			if (foreachStatement.EmbeddedStatement == null) {
				return data;
			}
			return foreachStatement.EmbeddedStatement.AcceptVisitor(this, data);
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:22,代码来源:LookupTableVisitor.cs


示例8: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			base.VisitForeachStatement(foreachStatement, data);
			
			if (resolver.CompilationUnit == null)
				return null;
			
			if (foreachStatement.TypeReference.IsNull) {
				ResolveResult rr = resolver.ResolveIdentifier(foreachStatement.VariableName, foreachStatement.StartLocation, ExpressionContext.Default);
				if (rr != null && rr.ResolvedType != null) {
					BlockStatement blockStatement = foreachStatement.EmbeddedStatement as BlockStatement;
					if (blockStatement == null) {
						blockStatement = new BlockStatement();
						blockStatement.AddChild(foreachStatement.EmbeddedStatement);
						foreachStatement.EmbeddedStatement = blockStatement;
					}
					
					string newVariableName = foreachStatement.VariableName + "_loopVariable";
					
					ExpressionStatement st = new ExpressionStatement(
						new AssignmentExpression(
							new IdentifierExpression(foreachStatement.VariableName),
							AssignmentOperatorType.Assign,
							new IdentifierExpression(newVariableName)));
					blockStatement.Children.Insert(0, st);
					st.Parent = blockStatement;
					
					foreachStatement.VariableName = newVariableName;
					foreachStatement.TypeReference = ConvertType(rr.ResolvedType);
				}
			}
			return null;
		}
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:33,代码来源:VBNetToCSharpConvertVisitor.cs


示例9: VisitStatement

			public void VisitStatement (ForeachStatement statement, MethodProperties meth)
			{
				meth.CyclometricComplexity++;
				VisitExpression(((ForeachStatement)(statement)).Expression, meth);
				
				VisitExpression(statement.NextExpression, meth);						
				
				foreach(var innerStatement in ((ForeachStatement)statement).EmbeddedStatement.Children)
					VisitStatement((Statement)innerStatement, meth);
			}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:10,代码来源:ASTVisitor.cs


示例10: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			return base.VisitForeachStatement(foreachStatement, true);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:4,代码来源:FindJumpInstructionsVisitor.cs


示例11: VisitForeachStatement

 public virtual bool VisitForeachStatement(ForeachStatement foreachStatement, object d)
 {
     if ((foreachStatement == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if ((foreachStatement.TypeReference == null)) {
         return SetFailure();
     }
     if ((foreachStatement.Expression == null)) {
         return SetFailure();
     }
     if ((foreachStatement.NextExpression == null)) {
         return SetFailure();
     }
     if ((foreachStatement.EmbeddedStatement == null)) {
         return SetFailure();
     }
     if(foreachStatement.GetType() != d.GetType()) {return SetFailure();}
     var data = (ForeachStatement)d;
     if (!IsMatch(foreachStatement, data)) {
         return SetFailure();
     }
     foreachStatement.TypeReference.AcceptVisitor(this, data.TypeReference);
     foreachStatement.Expression.AcceptVisitor(this, data.Expression);
     foreachStatement.NextExpression.AcceptVisitor(this, data.NextExpression);
     return foreachStatement.EmbeddedStatement.AcceptVisitor(this, data.EmbeddedStatement);
 }
开发者ID:jbuedel,项目名称:AgentRalphPlugin,代码行数:30,代码来源:AstComparisonVisitor.Generated.cs


示例12: IsMatch

 private bool IsMatch(ForeachStatement left, ForeachStatement right)
 {
     return left.VariableName == right.VariableName;
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:4,代码来源:AstComparisonVisitor.cs


示例13: VisitForeachStatement

 public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
 {
     foreachStatement.Expression.Parent = foreachStatement;
     foreachStatement.TypeReference.Parent = foreachStatement;
     return base.VisitForeachStatement(foreachStatement, data);
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:6,代码来源:ParentVisitor.cs


示例14: VisitForeachStatement

		public object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			B.ForStatement fs = new B.ForStatement(GetLexicalInfo(foreachStatement));
			fs.EndSourceLocation = GetLocation(foreachStatement.EndLocation);
			fs.Iterator = ConvertExpression(foreachStatement.Expression);
			fs.Declarations.Add(new B.Declaration(foreachStatement.VariableName, ConvertTypeReference(foreachStatement.TypeReference)));
			fs.Block = ConvertBlock(foreachStatement.EmbeddedStatement);
			return fs;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:ConvertVisitorStatements.cs


示例15: VisitForeachStatement

		public override object VisitForeachStatement(ForeachStatement foreachStatement, object data)
		{
			curBlock.Add(foreachStatement.VariableName);
			return base.VisitForeachStatement(foreachStatement, data);
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:5,代码来源:PrefixFieldsVisitor.cs


示例16: VisitForeachStatement

 public object VisitForeachStatement(ForeachStatement foreachStatement, object data)
 {
     throw new NotImplementedException ();
 }
开发者ID:Monobjc,项目名称:monobjc-tools,代码行数:4,代码来源:CodeDomExpressionPrinter.cs


示例17: EmbeddedStatement


//.........这里部分代码省略.........
			} else SynErr(256);
			break;
		}
		case 98: {
			lexer.NextToken();

#line  2382 "VBNET.ATG" 
			Expression group = null;
			TypeReference typeReference;
			string        typeName;
			Location startLocation = t.Location;
			
			if (la.kind == 85) {
				lexer.NextToken();
				LoopControlVariable(
#line  2389 "VBNET.ATG" 
out typeReference, out typeName);
				Expect(109);
				Expr(
#line  2390 "VBNET.ATG" 
out group);
				EndOfStmt();
				Block(
#line  2391 "VBNET.ATG" 
out embeddedStatement);
				Expect(128);
				if (StartOf(27)) {
					Expr(
#line  2392 "VBNET.ATG" 
out expr);
				}

#line  2394 "VBNET.ATG" 
				statement = new ForeachStatement(typeReference, 
				                                typeName,
				                                group, 
				                                embeddedStatement, 
				                                expr);
				statement.StartLocation = startLocation;
				statement.EndLocation   = t.EndLocation;
				
				
			} else if (StartOf(13)) {

#line  2405 "VBNET.ATG" 
				Expression start = null;
				Expression end = null;
				Expression step = null;
				Expression nextExpr = null;List<Expression> nextExpressions = null;
				
				LoopControlVariable(
#line  2410 "VBNET.ATG" 
out typeReference, out typeName);
				Expect(11);
				Expr(
#line  2411 "VBNET.ATG" 
out start);
				Expect(172);
				Expr(
#line  2411 "VBNET.ATG" 
out end);
				if (la.kind == 162) {
					lexer.NextToken();
					Expr(
#line  2411 "VBNET.ATG" 
out step);
开发者ID:almazik,项目名称:ILSpy,代码行数:67,代码来源:Parser.cs


示例18: VisitForeachStatement

 public virtual object VisitForeachStatement(ForeachStatement foreachStatement, object data)
 {
     Debug.Assert((foreachStatement != null));
     Debug.Assert((foreachStatement.TypeReference != null));
     Debug.Assert((foreachStatement.Expression != null));
     Debug.Assert((foreachStatement.NextExpression != null));
     Debug.Assert((foreachStatement.EmbeddedStatement != null));
     foreachStatement.TypeReference.AcceptVisitor(this, data);
     foreachStatement.Expression.AcceptVisitor(this, data);
     foreachStatement.NextExpression.AcceptVisitor(this, data);
     return foreachStatement.EmbeddedStatement.AcceptVisitor(this, data);
 }
开发者ID:pusp,项目名称:o2platform,代码行数:12,代码来源:AbstractASTVisitor.cs


示例19: EmbeddedStatement


//.........这里部分代码省略.........
			Expect(11);
			if (StartOf(6)) {
				ForIterator(
#line  1597 "cs.ATG" 
out iterator);
			}
			Expect(21);
			EmbeddedStatement(
#line  1598 "cs.ATG" 
out embeddedStatement);

#line  1599 "cs.ATG" 
			statement = new ForStatement(initializer, expr, iterator, embeddedStatement); 
		} else if (la.kind == 77) {
			lexer.NextToken();
			Expect(20);
			Type(
#line  1601 "cs.ATG" 
out type);
			Identifier();

#line  1601 "cs.ATG" 
			string varName = t.val; 
			Expect(81);
			Expr(
#line  1602 "cs.ATG" 
out expr);
			Expect(21);
			EmbeddedStatement(
#line  1603 "cs.ATG" 
out embeddedStatement);

#line  1604 "cs.ATG" 
			statement = new ForeachStatement(type, varName , expr, embeddedStatement); 
		} else if (la.kind == 53) {
			lexer.NextToken();
			Expect(11);

#line  1607 "cs.ATG" 
			statement = new BreakStatement(); 
		} else if (la.kind == 61) {
			lexer.NextToken();
			Expect(11);

#line  1608 "cs.ATG" 
			statement = new ContinueStatement(); 
		} else if (la.kind == 78) {
			GotoStatement(
#line  1609 "cs.ATG" 
out statement);
		} else if (
#line  1611 "cs.ATG" 
IsYieldStatement()) {
			Expect(132);
			if (la.kind == 101) {
				lexer.NextToken();
				Expr(
#line  1612 "cs.ATG" 
out expr);

#line  1612 "cs.ATG" 
				statement = new YieldStatement(new ReturnStatement(expr)); 
			} else if (la.kind == 53) {
				lexer.NextToken();

#line  1613 "cs.ATG" 
开发者ID:pluraldj,项目名称:SharpDevelop,代码行数:67,代码来源:Parser.cs


示例20: VisitForeachStatement

		public virtual object VisitForeachStatement(ForeachStatement foreachStatement, object data) {
			Debug.Assert((foreachStatement != null));
			Debug.Assert((foreachStatement.TypeReference != null));
			Debug.Assert((foreachStatement.Expression != null));
			Debug.Assert((foreachStatement.NextExpression != null));
			Debug.Assert((foreachStatement.EmbeddedStatement != null));
			nodeStack.Push(foreachStatement.TypeReference);
			foreachStatement.TypeReference.AcceptVisitor(this, data);
			foreachStatement.TypeReference = ((TypeReference)(nodeStack.Pop()));
			nodeStack.Push(foreachStatement.Expression);
			foreachStatement.Expression.AcceptVisitor(this, data);
			foreachStatement.Expression = ((Expression)(nodeStack.Pop()));
			nodeStack.Push(foreachStatement.NextExpression);
			foreachStatement.NextExpression.AcceptVisitor(this, data);
			foreachStatement.NextExpression = ((Expression)(nodeStack.Pop()));
			nodeStack.Push(foreachStatement.EmbeddedStatement);
			foreachStatement.EmbeddedStatement.AcceptVisitor(this, data);
			foreachStatement.EmbeddedStatement = ((Statement)(nodeStack.Pop()));
			return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:20,代码来源:AbstractAstTransformer.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Ast.IdentifierExpression类代码示例发布时间:2022-05-26
下一篇:
C# Ast.FieldDeclaration类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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