the protocol-tree-walk to determine friends was broken

This commit is contained in:
Chris Jones 2009-11-10 16:50:59 -06:00
Родитель 83119b405c
Коммит a5761b1f6d
1 изменённых файлов: 10 добавлений и 16 удалений

Просмотреть файл

@ -1958,34 +1958,28 @@ class _FindFriends(ipdl.ast.Visitor):
self.mytype = None # ProtocolType self.mytype = None # ProtocolType
self.vtype = None # ProtocolType self.vtype = None # ProtocolType
self.friends = set() # set<ProtocolType> self.friends = set() # set<ProtocolType>
self.visited = set() # set<ProtocolType>
def findFriends(self, ptype): def findFriends(self, ptype):
self.mytype = ptype self.mytype = ptype
self.walkUpTheProtocolTree(ptype) toplevel = self.findToplevel(ptype)
self.walkDownTheProtocolTree(ptype) self.walkDownTheProtocolTree(toplevel)
return self.friends return self.friends
# TODO could make this into a _iterProtocolTreeHelper ... # TODO could make this into a _iterProtocolTreeHelper ...
def walkUpTheProtocolTree(self, ptype): def findToplevel(self, ptype):
if not ptype.isManaged(): if ptype.isToplevel():
return return ptype
mtype = ptype.manager return self.findToplevel(ptype.manager)
self.visit(mtype)
self.walkUpTheProtocolTree(mtype)
def walkDownTheProtocolTree(self, ptype): def walkDownTheProtocolTree(self, ptype):
if not ptype.isManager(): if ptype != self.mytype:
return # don't want to |friend| ourself!
self.visit(ptype)
for mtype in ptype.manages: for mtype in ptype.manages:
self.visit(mtype)
self.walkDownTheProtocolTree(mtype) self.walkDownTheProtocolTree(mtype)
def visit(self, ptype): def visit(self, ptype):
if ptype in self.visited: # |vtype| is the type currently being visited
return
self.visited.add(ptype)
savedptype = self.vtype savedptype = self.vtype
self.vtype = ptype self.vtype = ptype
ptype._p.accept(self) ptype._p.accept(self)