本文整理汇总了C#中Mono.CSharp.Foreach类的典型用法代码示例。如果您正苦于以下问题:C# Foreach类的具体用法?C# Foreach怎么用?C# Foreach使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Foreach类属于Mono.CSharp命名空间,在下文中一共展示了Foreach类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Visit
public override object Visit (Foreach foreachStatement)
{
var result = new ForeachStatement ();
var location = LocationsBag.GetLocations (foreachStatement);
result.AddChild (new CSharpTokenNode (Convert (foreachStatement.loc), "foreach".Length), ForeachStatement.ForEachKeywordRole);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ForeachStatement.Roles.LPar);
if (foreachStatement.TypeExpr == null)
result.AddChild ((INode)foreachStatement.TypeExpr.Accept (this), ForeachStatement.Roles.ReturnType);
if (foreachStatement.Variable != null)
result.AddChild ((INode)foreachStatement.Variable.Accept (this), ForeachStatement.Roles.Identifier);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), ForeachStatement.InKeywordRole);
if (foreachStatement.Expr != null)
result.AddChild ((INode)foreachStatement.Expr.Accept (this), ForeachStatement.Roles.Initializer);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), ForeachStatement.Roles.RPar);
result.AddChild ((INode)foreachStatement.Statement.Accept (this), ForeachStatement.Roles.EmbeddedStatement);
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:27,代码来源:CSharpParser.cs
示例2: case_888
void case_888()
#line 5933 "cs-parser.jay"
{
Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, null, GetLocation (yyVals[-3+yyTop]));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation (yyVals[-2+yyTop]));
yyVal = f;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs
示例3: Visit
public override object Visit(Foreach foreachStatement)
{
var result = new ForeachStatement();
var location = LocationsBag.GetLocations(foreachStatement);
result.AddChild(new CSharpTokenNode(Convert(foreachStatement.loc), ForeachStatement.ForeachKeywordRole), ForeachStatement.ForeachKeywordRole);
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
if (foreachStatement.TypeExpression != null)
result.AddChild(ConvertToType(foreachStatement.TypeExpression), Roles.Type);
if (foreachStatement.Variable != null)
result.AddChild(Identifier.Create(foreachStatement.Variable.Name, Convert(foreachStatement.Variable.Location)), Roles.Identifier);
if (location != null && location.Count > 1)
result.AddChild(new CSharpTokenNode(Convert(location [1]), ForeachStatement.InKeywordRole), ForeachStatement.InKeywordRole);
if (foreachStatement.Expr != null)
result.AddChild((Expression)foreachStatement.Expr.Accept(this), Roles.Expression);
if (location != null && location.Count > 2)
result.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.RPar), Roles.RPar);
if (foreachStatement.Statement != null)
result.AddChild((Statement)foreachStatement.Statement.Accept(this), Roles.EmbeddedStatement);
return result;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:30,代码来源:CSharpParser.cs
示例4: case_886
void case_886()
#line 5909 "cs-parser.jay"
{
if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
Foreach f = new Foreach ((Expression) yyVals[-6+yyTop], (LocalVariable) yyVals[-1+yyTop], (Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], current_block, GetLocation (yyVals[-8+yyTop]));
lbag.AddStatement (f, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]));
end_block (GetLocation (yyVals[-2+yyTop]));
yyVal = f;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:12,代码来源:cs-parser.cs
示例5: case_887
void case_887()
#line 5920 "cs-parser.jay"
{
start_block (GetLocation (yyVals[-3+yyTop]));
current_block.IsCompilerGenerated = true;
var lt = yyVals[-1+yyTop] as LocatedToken;
var li = lt != null ? new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location) : null;
Foreach f = new Foreach ((Expression) yyVals[-2+yyTop], li, null, null, null, GetLocation (yyVals[-4+yyTop]));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation (yyVals[-3+yyTop]));
yyVal = end_block (GetLocation (yyVals[0+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:14,代码来源:cs-parser.cs
示例6: case_883
void case_883()
#line 5869 "cs-parser.jay"
{
report.Error (230, GetLocation (yyVals[-3+yyTop]), "Type and identifier are both required in a foreach statement");
start_block (GetLocation (yyVals[-2+yyTop]));
current_block.IsCompilerGenerated = true;
Foreach f = new Foreach ((Expression) yyVals[-1+yyTop], null, null, null, null, GetLocation (yyVals[-3+yyTop]));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation (yyVals[-2+yyTop]));
yyVal = end_block (GetLocation (yyVals[0+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:14,代码来源:cs-parser.cs
示例7: case_884
void case_884()
#line 5882 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
start_block (GetLocation (yyVals[-3+yyTop]));
current_block.IsCompilerGenerated = true;
var lt = (LocatedToken) yyVals[-1+yyTop];
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
Foreach f = new Foreach ((Expression) yyVals[-2+yyTop], li, null, null, null, GetLocation (yyVals[-4+yyTop]));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation (yyVals[-3+yyTop]));
yyVal = end_block (GetLocation (yyVals[0+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:18,代码来源:cs-parser.cs
示例8: ArrayForeach
public ArrayForeach (Foreach @foreach, int rank)
{
for_each = @foreach;
statement = for_each.statement;
loc = @foreach.loc;
variable = new LocalVariableReference (for_each.variable, loc);
counter = new StatementExpression[rank];
variables = new TemporaryVariableReference[rank];
length_exprs = new Expression [rank];
//
// Only use temporary length variables when dealing with
// multi-dimensional arrays
//
if (rank > 1)
lengths = new TemporaryVariableReference [rank];
}
开发者ID:alisci01,项目名称:mono,代码行数:18,代码来源:statement.cs
示例9: Visit
public virtual object Visit (Foreach foreachStatement)
{
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs
示例10: ArrayForeach
public ArrayForeach (Foreach @foreach, int rank)
{
for_each = @foreach;
statement = for_each.statement;
loc = @foreach.loc;
counter = new ArrayCounter [rank];
length_exprs = new Expression [rank];
//
// Only use temporary length variables when dealing with
// multi-dimensional arrays
//
if (rank > 1)
lengths = new TemporaryVariable [rank];
}
开发者ID:tgiphil,项目名称:mono,代码行数:16,代码来源:statement.cs
示例11: yyparse
//.........这里部分代码省略.........
Statement s = (Statement) yyVals[0+yyTop];
Block b = new Block (current_block, s.loc, lexer.Location);
b.AddStatement (s);
yyVal = b;
}
break;
case 779:
#line 5006 "cs-parser.jay"
{
Block b = (Block) yyVals[-2+yyTop];
b.AddStatement ((Statement) yyVals[0+yyTop]);
yyVal = yyVals[-2+yyTop];
}
break;
case 780:
#line 5016 "cs-parser.jay"
{
Report.Error (230, GetLocation (yyVals[-5+yyTop]), "Type and identifier are both required in a foreach statement");
yyVal = null;
}
break;
case 781:
#line 5022 "cs-parser.jay"
{
start_block (lexer.Location);
Block foreach_block = current_block;
var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
Location l = lt.Location;
LocalInfo vi = foreach_block.AddVariable ((Expression) yyVals[-4+yyTop], lt.Value, l);
if (vi != null) {
vi.SetReadOnlyContext (LocalInfo.ReadOnlyContext.Foreach);
/* Get a writable reference to this read-only variable.*/
/**/
/* Note that the $$ here refers to the value of _this_ code block,*/
/* not the value of the LHS non-terminal. This can be referred to as $8 below.*/
yyVal = new LocalVariableReference (foreach_block, lt.Value, l, vi, false);
} else {
yyVal = null;
}
}
break;
case 782:
#line 5042 "cs-parser.jay"
{
LocalVariableReference v = (LocalVariableReference) yyVals[-1+yyTop];
Location l = GetLocation (yyVals[-8+yyTop]);
if (v != null) {
Foreach f = new Foreach ((Expression) yyVals[-6+yyTop], v, (Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], l);
current_block.AddStatement (f);
}
yyVal = end_block (lexer.Location);
}
break;
case 789:
#line 5066 "cs-parser.jay"
{
yyVal = new Break (GetLocation (yyVals[-1+yyTop]));
}
break;
case 790:
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs
示例12: Visit
public override object Visit (Foreach foreachStatement)
{
var result = new ForeachStatement ();
var location = LocationsBag.GetLocations (foreachStatement);
result.AddChild (new CSharpTokenNode (Convert (foreachStatement.loc), "foreach".Length), ForeachStatement.Roles.Keyword);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ForeachStatement.Roles.LPar);
if (foreachStatement.TypeExpr == null)
result.AddChild (ConvertToType (foreachStatement.TypeExpr), ForeachStatement.Roles.Type);
if (foreachStatement.Variable != null)
result.AddChild (new Identifier (foreachStatement.Variable.Name, Convert (foreachStatement.Variable.Location)), ForeachStatement.Roles.Identifier);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[1]), "in".Length), ForeachStatement.Roles.InKeyword);
if (foreachStatement.Expr != null)
result.AddChild ((MonoDevelop.CSharp.Ast.Expression)foreachStatement.Expr.Accept (this), ForeachStatement.Roles.Expression);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), ForeachStatement.Roles.RPar);
result.AddChild ((MonoDevelop.CSharp.Ast.Statement)foreachStatement.Statement.Accept (this), ForeachStatement.Roles.EmbeddedStatement);
return result;
}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:27,代码来源:CSharpParser.cs
示例13: yyparse
//.........这里部分代码省略.........
case 835:
#line 5586 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{ yyVal = new EmptyStatement (lexer.Location); }
break;
case 839:
#line 5597 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
var sl = yyVals[-2+yyTop] as StatementList;
if (sl == null) {
sl = new StatementList ((Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop]);
lbag.AddStatement (sl, GetLocation (yyVals[-1+yyTop]));
} else {
sl.Add ((Statement) yyVals[0+yyTop]);
lbag.AppendTo (sl, GetLocation (yyVals[-1+yyTop]));
}
yyVal = sl;
}
break;
case 840:
#line 5613 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
report.Error (230, GetLocation (yyVals[-5+yyTop]), "Type and identifier are both required in a foreach statement");
yyVal = null;
}
break;
case 841:
#line 5618 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
start_block (GetLocation (yyVals[-5+yyTop]));
current_block.IsCompilerGenerated = true;
var lt = (Tokenizer.LocatedToken) yyVals[-3+yyTop];
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
yyVal = li;
}
break;
case 842:
#line 5628 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
Foreach f = new Foreach ((Expression) yyVals[-6+yyTop], (LocalVariable) yyVals[-1+yyTop], (Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-8+yyTop]));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]));
yyVal = end_block (GetLocation (yyVals[-2+yyTop]));
}
break;
case 849:
#line 5651 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new Break (GetLocation (yyVals[-1+yyTop]));
lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop]));
}
break;
case 850:
#line 5659 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new Continue (GetLocation (yyVals[-1+yyTop]));
lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop]));
}
break;
case 851:
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs
示例14: case_812
void case_812()
#line 5146 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
if (yyVals[0+yyTop] is EmptyStatement && lexer.peek_token () == Token.OPEN_BRACE)
Warning_EmptyStatement (GetLocation (yyVals[0+yyTop]));
Foreach f = new Foreach ((Expression) yyVals[-6+yyTop], (LocalVariable) yyVals[-1+yyTop], (Expression) yyVals[-3+yyTop], (Statement) yyVals[0+yyTop], GetLocation (yyVals[-8+yyTop]));
current_block.AddStatement (f);
lbag.AddStatement (f, GetLocation (yyVals[-7+yyTop]), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-2+yyTop]));
yyVal = end_block (GetLocation (yyVals[-2+yyTop]));
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:12,代码来源:cs-parser.cs
注:本文中的Mono.CSharp.Foreach类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论