本文整理汇总了C#中Boo.Lang.Compiler.Ast.Block.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# Block.Accept方法的具体用法?C# Block.Accept怎么用?C# Block.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Boo.Lang.Compiler.Ast.Block
的用法示例。
在下文中一共展示了Block.Accept方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenameLocals
public static void RenameLocals(Block block, StringComparer nameComparer)
{
FindVariableDeclarationsVisitor fvdv = new FindVariableDeclarationsVisitor();
block.Accept(fvdv);
List<DeclarationStatement> list = new List<DeclarationStatement>();
foreach (DeclarationStatement decl in fvdv.Declarations) {
DeclarationStatement conflict = null;
int conflictIndex = -1;
for (int i = 0; i < list.Count; i++) {
if (nameComparer.Equals(list[i].Declaration.Name, decl.Declaration.Name)) {
conflict = list[i];
conflictIndex = i;
break;
}
}
if (conflict == null) {
list.Add(decl);
} else {
// Handle conflict: try if "moveup" would be sufficient
if (IsSameType(decl.Declaration.Type, conflict.Declaration.Type, nameComparer)) {
// create declaration at beginning of class and
// replace decl & conflict by assignment
DeclarationStatement newDecl = new DeclarationStatement(conflict.LexicalInfo);
newDecl.Declaration = new Declaration(conflict.Declaration.LexicalInfo, conflict.Declaration.Name, conflict.Declaration.Type);
block.Insert(0, newDecl);
ReplaceWithInitializer(decl);
ReplaceWithInitializer(conflict);
list[conflictIndex] = newDecl;
} else {
string newName = FindFreeName(decl.Declaration.Name, list, fvdv.Declarations, nameComparer);
decl.ParentNode.Accept(new RenameLocalsVisitor(decl.Declaration.Name, newName, nameComparer));
decl.Declaration.Name = newName;
}
}
}
}
示例2: OnLoopBody
public void OnLoopBody(Block block)
{
this._level++;
block.Accept(this);
this._level--;
}