本文整理汇总了C#中Boo.Lang.Compiler.Ast.ForStatement类的典型用法代码示例。如果您正苦于以下问题:C# ForStatement类的具体用法?C# ForStatement怎么用?C# ForStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ForStatement类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了ForStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnForStatement
public override void OnForStatement(ForStatement node)
{
if (node.LexicalInfo.Line <= resolver.CaretLine && GetEndSourceLocation(node).Line >= resolver.CaretLine - 1) {
foreach (Declaration decl in node.Declarations) {
IterationDeclarationFound(decl.Name, decl.Type, node.Iterator, node.LexicalInfo);
}
}
base.OnForStatement(node);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:VariableLookupVisitor.cs
示例2: LeaveForStatement
public override void LeaveForStatement(ForStatement node)
{
//do not optimize local-reusing loops (BOO-1111)
//TODO: optimize anyway (modify end value to match generator model vs optimized model)
if (node.Declarations.Count == 1
&& null != AstUtil.GetLocalByName(_currentMethod, node.Declarations[0].Name))
return;
CheckForItemInRangeLoop(node);
CheckForItemInArrayLoop(node);
}
开发者ID:Bombadil77,项目名称:boo,代码行数:11,代码来源:OptimizeIterationStatements.cs
示例3: CreateUpdateLabel
private LabelStatement CreateUpdateLabel(ForStatement node)
{
return new LabelStatement(LexicalInfo.Empty, "$label$" + _context.AllocIndex());
}
开发者ID:w4x,项目名称:boolangstudio,代码行数:4,代码来源:OptimizeIterationStatements.cs
示例4: TransformIteration
public void TransformIteration(ForStatement node)
{
string[] textArray1 = new string[] { "iterator" };
InternalLocal iteratorVariable = this.get_CodeBuilder().DeclareLocal(this.get_CurrentMethod(), base._context.GetUniqueName(textArray1), this.get_TypeSystemServices().IEnumeratorType);
iteratorVariable.set_IsUsed(true);
Block block = new Block(node.get_LexicalInfo());
block.Add(this.get_CodeBuilder().CreateAssignment(node.get_LexicalInfo(), this.get_CodeBuilder().CreateReference(iteratorVariable), node.get_Iterator()));
WhileStatement statement = new WhileStatement(node.get_LexicalInfo());
statement.set_Condition(this.get_CodeBuilder().CreateMethodInvocation(this.get_CodeBuilder().CreateReference(iteratorVariable), this.IEnumerator_MoveNext));
MethodInvocationExpression expression = this.get_CodeBuilder().CreateMethodInvocation(this.get_CodeBuilder().CreateReference(iteratorVariable), this.IEnumerator_get_Current);
InternalLocal entity = TypeSystemServices.GetEntity(node.get_Declarations().get_Item(0));
statement.get_Block().Add(this.get_CodeBuilder().CreateAssignment(node.get_LexicalInfo(), this.get_CodeBuilder().CreateReference(entity), expression));
statement.get_Block().Add(node.get_Block());
new LoopVariableUpdater(this, base._context, iteratorVariable, entity).Visit(node);
block.Add(statement);
node.get_ParentNode().Replace(node, block);
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:17,代码来源:ProcessUnityScriptMethods.cs
示例5: OnForStatement
public override void OnForStatement(ForStatement node)
{
base.OnForStatement(node);
}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:4,代码来源:DslMacro.cs
示例6: VisitForStatementBlock
protected void VisitForStatementBlock(ForStatement node)
{
EnterForNamespace(node);
Visit(node.Block);
Visit(node.OrBlock);
Visit(node.ThenBlock);
LeaveNamespace();
}
开发者ID:stuman08,项目名称:boo,代码行数:8,代码来源:ProcessMethodBodies.cs
示例7: OnExtendedGeneratorExpression
public override void OnExtendedGeneratorExpression(ExtendedGeneratorExpression node)
{
BlockExpression block = new BlockExpression(node.LexicalInfo);
Block body = block.Body;
Expression e = node.Items[0].Expression;
foreach (GeneratorExpression ge in node.Items)
{
ForStatement fs = new ForStatement(ge.LexicalInfo);
fs.Iterator = ge.Iterator;
fs.Declarations = ge.Declarations;
body.Add(fs);
if (null == ge.Filter)
{
body = fs.Block;
}
else
{
fs.Block.Add(
NormalizeStatementModifiers.MapStatementModifier(ge.Filter, out body));
}
}
body.Add(new YieldStatement(e.LexicalInfo, e));
MethodInvocationExpression mie = new MethodInvocationExpression(node.LexicalInfo);
mie.Target = block;
Node parentNode = node.ParentNode;
bool isGenerator = AstUtil.IsListMultiGenerator(parentNode);
parentNode.Replace(node, mie);
mie.Accept(this);
if (isGenerator)
{
parentNode.ParentNode.Replace(
parentNode,
CodeBuilder.CreateConstructorInvocation(
TypeSystemServices.Map(ProcessGenerators.List_IEnumerableConstructor),
mie));
}
}
开发者ID:stuman08,项目名称:boo,代码行数:44,代码来源:ProcessMethodBodies.cs
示例8: OnForStatement
public override void OnForStatement(ForStatement node)
{
VisitLoop(node.Block);
}
开发者ID:boo,项目名称:boo-lang,代码行数:4,代码来源:BranchChecking.cs
示例9: OnForStatement
public override void OnForStatement(ForStatement node)
{
NotImplemented("ForStatement");
}
开发者ID:Bombadil77,项目名称:boo,代码行数:4,代码来源:EmitAssembly.cs
示例10: OnForStatement
override public void OnForStatement(ForStatement node)
{
VisitLoop(node.Block);
Visit(node.OrBlock);
Visit(node.ThenBlock);
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:6,代码来源:BranchChecking.cs
示例11: Clone
override public object Clone()
{
ForStatement clone = new ForStatement();
clone._lexicalInfo = _lexicalInfo;
clone._endSourceLocation = _endSourceLocation;
clone._documentation = _documentation;
clone._isSynthetic = _isSynthetic;
clone._entity = _entity;
if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
if (null != _modifier)
{
clone._modifier = _modifier.Clone() as StatementModifier;
clone._modifier.InitializeParent(clone);
}
if (null != _declarations)
{
clone._declarations = _declarations.Clone() as DeclarationCollection;
clone._declarations.InitializeParent(clone);
}
if (null != _iterator)
{
clone._iterator = _iterator.Clone() as Expression;
clone._iterator.InitializeParent(clone);
}
if (null != _block)
{
clone._block = _block.Clone() as Block;
clone._block.InitializeParent(clone);
}
if (null != _orBlock)
{
clone._orBlock = _orBlock.Clone() as Block;
clone._orBlock.InitializeParent(clone);
}
if (null != _thenBlock)
{
clone._thenBlock = _thenBlock.Clone() as Block;
clone._thenBlock.InitializeParent(clone);
}
return clone;
}
开发者ID:Rfvgyhn,项目名称:boo,代码行数:44,代码来源:ForStatementImpl.cs
示例12: ExpandImpl
//.........这里部分代码省略.........
MacroStatement afterall_macro = findmacro("afterall");
;
MacroStatement onempty_macro = findmacro("onempty");
;
MacroStatement beforeeach_macro = findmacro("beforeeach");
;
MacroStatement aftereach_macro = findmacro("aftereach");
MacroStatement prepare_macro = findmacro("prepare");
;
Block beforeall = extract(beforeall_macro);
Block onitem = extractMainItemBlock(macro, extract, onitem_macro, item, prefix, suffix);
Block onerror = extract(onerror_macro);
Block between = extract(between_macro);
Block afterall = extract(afterall_macro);
Block onempty = null;
bool proceed_on_empty = false;
if (onempty_macro != null && onempty_macro.Arguments.Count != 0 &&
onempty_macro.Arguments[0].ToCodeString() == "proceed"){
proceed_on_empty = true;
}
else{
onempty = extract(onempty_macro);
}
Block beforeeach = extract(beforeeach_macro);
Block aftereach = extract(aftereach_macro);
// _idx = 0
Statement betweener = getBetweener(idx, between);
result.Add(col.assign(new MethodInvocationExpression(new ReferenceExpression("_wrapcollection"), src)));
result.Add(new ReferenceExpression("___proceed").assign(new BoolLiteralExpression(proceed_on_empty)));
var mainblock = new Block();
mainblock.Add(idx.assign(0));
mainblock.Add(new IfStatement(
new BinaryExpression(BinaryOperatorType.Equality, new NullLiteralExpression(), col),
new Block().add(new BinaryExpression(BinaryOperatorType.Assign, col,
new MethodInvocationExpression(
new ReferenceExpression("_wrapcollection"),
new ArrayLiteralExpression()))),
null
));
if (beforeall != null){
mainblock.Add(beforeall);
}
var maincycle = new ForStatement();
maincycle.Iterator = col;
string declname = item.ToCodeString();
TypeReference decltype = null;
if (item is TryCastExpression){
declname = ((TryCastExpression) item).Target.ToCodeString();
decltype = ((TryCastExpression) item).Type;
}
maincycle.Declarations.Add(new Declaration(maincycle.LexicalInfo, declname, decltype));
maincycle.Block = new Block();
maincycle.ThenBlock = afterall;
if (betweener != null){
maincycle.Block.Add(betweener);
}
if (null != prepare_macro){
maincycle.Block.Add(prepare_macro.Body);
}
if (null != beforeeach){
maincycle.Block.Add(beforeeach);
}
if (onerror == null){
maincycle.Block.Add(onitem);
}
else{
var trycatch = new TryStatement();
var exchandler = new ExceptionHandler();
exchandler.Block = onerror;
exchandler.Declaration = new Declaration("_ex", new SimpleTypeReference("System.Exception"));
trycatch.ProtectedBlock = onitem;
trycatch.ExceptionHandlers.Add(exchandler);
maincycle.Block.Add(trycatch);
}
if (null != aftereach){
maincycle.Block.Add(aftereach);
}
maincycle.Block.Add(new UnaryExpression(UnaryOperatorType.Increment, idx));
mainblock.Add(maincycle);
result.Add(
new IfStatement(
getMainCondition(col),
mainblock,
onempty
)
);
// if null!=items and (items as IEnumerable).Cast[of System.Object]().Count() != 0:
return result;
}
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:101,代码来源:ForeachMacro.cs
示例13: LeaveForStatement
override public void LeaveForStatement(ForStatement node)
{
_iteratorNode = node.Iterator;
CurrentEnumeratorType = GetExpressionType(node.Iterator);
if (null == CurrentBestEnumeratorType)
return; //error
DeclarationCollection declarations = node.Declarations;
Block body = new Block(node.LexicalInfo);
InternalLocal iterator = CodeBuilder.DeclareLocal(_current,
Context.GetUniqueName("iterator"),
CurrentBestEnumeratorType);
if (CurrentBestEnumeratorType == CurrentEnumeratorType)
{
//$iterator = <node.Iterator>
body.Add(
CodeBuilder.CreateAssignment(
node.LexicalInfo,
CodeBuilder.CreateReference(iterator),
node.Iterator));
}
else
{
//$iterator = <node.Iterator>.GetEnumerator()
body.Add(
CodeBuilder.CreateAssignment(
node.LexicalInfo,
CodeBuilder.CreateReference(iterator),
CodeBuilder.CreateMethodInvocation(node.Iterator, CurrentBestGetEnumerator)));
}
// while __iterator.MoveNext():
if (null == CurrentBestMoveNext)
return; //error
WhileStatement ws = new WhileStatement(node.LexicalInfo);
ws.Condition = CodeBuilder.CreateMethodInvocation(
CodeBuilder.CreateReference(iterator),
CurrentBestMoveNext);
if (null == CurrentBestGetCurrent)
return; //error
Expression current = CodeBuilder.CreateMethodInvocation(
CodeBuilder.CreateReference(iterator),
CurrentBestGetCurrent);
if (1 == declarations.Count)
{
// item = __iterator.Current
ws.Block.Add(
CodeBuilder.CreateAssignment(
node.LexicalInfo,
CodeBuilder.CreateReference((InternalLocal)declarations[0].Entity),
current));
}
else
{
UnpackExpression(ws.Block,
CodeBuilder.CreateCast(
CurrentEnumeratorItemType,
current),
node.Declarations);
}
ws.Block.Add(node.Block);
ws.OrBlock = node.OrBlock;
ws.ThenBlock = node.ThenBlock;
// try:
// while...
// ensure:
// d = iterator as IDisposable
// d.Dispose() unless d is null
if (IsAssignableFrom(TypeSystemServices.IDisposableType, CurrentBestEnumeratorType))
{
TryStatement tryStatement = new TryStatement();
tryStatement.ProtectedBlock.Add(ws);
tryStatement.EnsureBlock = new Block();
CastExpression castExpression = new CastExpression();
castExpression.Type = CodeBuilder.CreateTypeReference(TypeSystemServices.IDisposableType);
castExpression.Target = CodeBuilder.CreateReference(iterator);
castExpression.ExpressionType = TypeSystemServices.IDisposableType;
tryStatement.EnsureBlock.Add(
CodeBuilder.CreateMethodInvocation(castExpression, IDisposable_Dispose));
body.Add(tryStatement);
}
else
{
body.Add(ws);
}
ReplaceCurrentNode(body);
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:97,代码来源:NormalizeIterationStatements.cs
示例14: for_stmt
//throws RecognitionException, TokenStreamException
protected ForStatement for_stmt()
{
ForStatement fs;
IToken f = null;
IToken or = null;
IToken et = null;
fs = null;
Expression iterator = null;
DeclarationCollection declarations = null;
Block body = null;
try { // for error handling
f = LT(1);
match(FOR);
if (0==inputState.guessing)
{
fs = new ForStatement(ToLexicalInfo(f));
declarations = fs.Declarations;
body = fs.Block;
}
declaration_list(declarations);
match(IN);
iterator=array_or_expression();
if (0==inputState.guessing)
{
fs.Iterator = iterator;
}
compound_stmt(body);
{
switch ( LA(1) )
{
case OR:
{
or = LT(1);
match(OR);
if (0==inputState.guessing)
{
fs.OrBlock = new Block(ToLexicalInfo(or));
}
compound_stmt(fs.OrBlock);
break;
}
case EOF:
case DEDENT:
case ESEPARATOR:
case BREAK:
case CONTINUE:
case CAST:
case CHAR:
case DEF:
case FOR:
case FALSE:
case GOTO:
case IF:
case NULL:
case RAISE:
case RETURN:
case SELF:
case SUPER:
case THEN:
case TRY:
case TRUE:
case TYPEOF:
case UNLESS:
case WHILE:
case YIELD:
case ID:
case TRIPLE_QUOTED_STRING:
case DOUBLE_QUOTED_STRING:
case SINGLE_QUOTED_STRING:
case LBRACK:
case LPAREN:
case ASSEMBLY_ATTRIBUTE_BEGIN:
case SPLICE_BEGIN:
case DOT:
case COLON:
case MULTIPLY:
case LBRACE:
case QQ_BEGIN:
case SUBTRACT:
case LONG:
case INCREMENT:
case DECREMENT:
case ONES_COMPLEMENT:
case INT:
case RE_LITERAL:
case DOUBLE:
case FLOAT:
case TIMESPAN:
{
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
//.........这里部分代码省略.........
开发者ID:Bombadil77,项目名称:boo,代码行数:101,代码来源:BooParserBase.cs
示例15: OnForStatement
public override void OnForStatement(ForStatement fs)
{
WriteIndented();
WriteKeyword("for ");
for (int i=0; i<fs.Declarations.Count; ++i)
{
if (i > 0) { Write(", "); }
Visit(fs.Declarations[i]);
}
WriteKeyword(" in ");
Visit(fs.Iterator);
WriteLine(":");
WriteBlock(fs.Block);
if(fs.OrBlock != null)
{
WriteIndented();
WriteKeyword("or:");
WriteLine();
WriteBlock(fs.OrBlock);
}
if(fs.ThenBlock != null)
{
WriteIndented();
WriteKeyword("then:");
WriteLine();
WriteBlock(fs.ThenBlock);
}
}
开发者ID:w4x,项目名称:boolangstudio,代码行数:28,代码来源:BooPrinterVisitor.cs
示例16: 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
示例17: VisitForNextStatement
public object VisitForNextStatement(ForNextStatement forNextStatement, object data)
{
if (forNextStatement.TypeReference.IsNull)
return MakeManualLoop(forNextStatement);
B.ForStatement fs = new B.ForStatement(GetLexicalInfo(forNextStatement));
fs.Block = ConvertBlock(forNextStatement.EmbeddedStatement);
fs.Declarations.Add(new B.Declaration(forNextStatement.VariableName, null));
B.Expression start = ConvertExpression(forNextStatement.Start);
Expression end = forNextStatement.End;
if (forNextStatement.Step == null || forNextStatement.Step.IsNull) {
// range only goes to end - 1, so increment end
end = Expression.AddInteger(end, 1);
fs.Iterator = MakeMethodCall("range", start, ConvertExpression(end));
} else {
PrimitiveExpression stepPE = forNextStatement.Step as PrimitiveExpression;
if (stepPE == null || !(stepPE.Value is int)) {
AddError(forNextStatement, "Step must be an integer literal");
} else {
if ((int)stepPE.Value < 0)
end = Expression.AddInteger(end, -1);
else
end = Expression.AddInteger(end, 1);
}
fs.Iterator = MakeMethodCall("range", start, ConvertExpression(end), ConvertExpression(forNextStatement.Step));
}
return fs;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:27,代码来源:ConvertVisitorStatements.cs
示例18: for_in
public Statement for_in(Block container)
{
Statement stmt = null;
try
{
Declaration declaration2;
Block block;
int num = this.LA(1);
switch (num)
{
case 12:
case 0x10:
case 0x21:
case 0x3b:
{
IToken token = this.identifier();
if (base.inputState.guessing == 0)
{
Declaration declaration;
Declaration declaration1 = declaration = new Declaration(ToLexicalInfo(token));
declaration.set_Name(token.getText());
declaration2 = declaration;
}
break;
}
default:
if (num != 0x2d)
{
throw new NoViableAltException(this.LT(1), this.getFilename());
}
declaration2 = this.declaration();
if (base.inputState.guessing == 0)
{
DeclarationAnnotations.ForceNewVariable(declaration2);
}
break;
}
this.match(0x18);
Expression expression = this.expression();
if (base.inputState.guessing == 0)
{
ForStatement statement2;
ForStatement statement1 = statement2 = new ForStatement();
statement2.set_Iterator(expression);
ForStatement statement3 = statement2;
statement3.get_Declarations().Add(declaration2);
block = statement3.get_Block();
stmt = statement3;
container.Add(stmt);
this.EnterLoop(stmt);
}
this.match(0x40);
this.compound_or_single_stmt(block);
if (base.inputState.guessing == 0)
{
this.LeaveLoop(stmt);
}
}
catch (RecognitionException exception)
{
if (base.inputState.guessing != 0)
{
throw;
}
this.reportError(exception);
this.recover(exception, tokenSet_15_);
return stmt;
}
return stmt;
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:70,代码来源:UnityScriptParser.cs
示例19: OnForStatement
public override void OnForStatement(ForStatement node)
{
}
开发者ID:w4x,项目名称:boolangstudio,代码行数:3,代码来源:GotoOnTopLevelContinue.cs
示例20: LeaveForStatement
public override void LeaveForStatement(ForStatement node)
{
CheckForItemInRangeLoop(node);
CheckForItemInArrayLoop(node);
}
开发者ID:w4x,项目名称:boolangstudio,代码行数:5,代码来源:OptimizeIterationStatements.cs
注:本文中的Boo.Lang.Compiler.Ast.ForStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论