本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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]));
}
示例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]));
}
示例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]));
}
示例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];
}
示例9: Visit
public virtual object Visit (Foreach foreachStatement)
{
return null;
}
示例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];
}
示例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:
示例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;
}
示例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:
示例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]));
}