diff options
| author | Steven Knight <knight@baldmt.com> | 2001-11-20 17:58:56 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2001-11-20 17:58:56 (GMT) |
| commit | fa11b8d2fa2e3adc18588992ff869b1f1457c03f (patch) | |
| tree | 569699b30c9de0106b55352d89b2d03ef8cfe086 /src/engine/SCons/Node/__init__.py | |
| parent | 76166c77f852377b6139a9414cc355fe2661a0e7 (diff) | |
| download | SCons-fa11b8d2fa2e3adc18588992ff869b1f1457c03f.zip SCons-fa11b8d2fa2e3adc18588992ff869b1f1457c03f.tar.gz SCons-fa11b8d2fa2e3adc18588992ff869b1f1457c03f.tar.bz2 | |
Crain: Finish LIBS, LIBPATH, CPPPATH
Diffstat (limited to 'src/engine/SCons/Node/__init__.py')
| -rw-r--r-- | src/engine/SCons/Node/__init__.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 6364bf8..a6606a9 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -192,10 +192,15 @@ class Walker: returns the next node on the descent with each next() call. 'kids_func' is an optional function that will be called to get the children of a node instead of calling 'children'. + + This class does not get caught in node cycles caused, for example, + by C header file include loops. """ def __init__(self, node, kids_func=get_children): self.kids_func = kids_func self.stack = [Wrapper(node, self.kids_func)] + self.history = {} # used to efficiently detect and avoid cycles + self.history[node] = None def next(self): """Return the next node for this walk of the tree. @@ -206,10 +211,14 @@ class Walker: while self.stack: if self.stack[-1].kids: - self.stack.append(Wrapper(self.stack[-1].kids.pop(0), - self.kids_func)) + node = self.stack[-1].kids.pop(0) + if not self.history.has_key(node): + self.stack.append(Wrapper(node, self.kids_func)) + self.history[node] = None else: - return self.stack.pop().node + node = self.stack.pop().node + del self.history[node] + return node def is_done(self): return not self.stack |
