Boo.Lang.Compiler.Ast.Block.Insert C# (CSharp) Метод

Insert() публичный Метод

public Insert ( int index, Expression expression ) : void
index int
expression Expression
Результат void
        public void Insert(int index, Expression expression)
        {
            this.Statements.Insert(index, new ExpressionStatement(expression));
        }

Same methods

Block::Insert ( int index, Statement stmt ) : void

Usage Example

		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;
					}
				}
			}
		}
All Usage Examples Of Boo.Lang.Compiler.Ast.Block::Insert