protected virtual ICode TopLevel(ICode c) { this.seen.Add(c); this.todo.Enqueue(c); ICode ret = null; while (todo.Any()) { var node = todo.Dequeue(); this.BlockStart(node); var transformed = this.Visit(node); this.BlockEnd(node, transformed); if (ret == null) { ret = transformed; } } bool anyChanges = false; foreach (var continuation in this.continuations) { var mapped = this.map.ValueOrDefault(continuation.To); if (mapped != null) { continuation.To = (Stmt)mapped; anyChanges = true; } } if (anyChanges) { // Cloned to make sure the returned object will be different from ICode argument // Other code relies on it being different if this visitor has made changes to the AST ret = (ICode)ret.Clone(); } return(ret); }