зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1335886, part 3 - Don't use symtab property to avoid infinite recursion. r=billm
Instead, just stick a "visited" property on them. The symtab property on nodes isn't used for any other purpose. The next patch will eliminate the unused args to enterScope and exitScope. MozReview-Commit-ID: 3WW2NPVB0gM --HG-- extra : rebase_source : 2c2add652e1156a397a155c74015671877af3690
This commit is contained in:
Родитель
4f5c5e3153
Коммит
baf5f306e7
|
@ -445,11 +445,8 @@ class SymbolTable:
|
|||
def enterScope(self, node):
|
||||
assert isinstance(self.scopes[0], dict)
|
||||
assert isinstance(self.currentScope, dict)
|
||||
assert not hasattr(node, 'symtab')
|
||||
|
||||
node.symtab = { }
|
||||
|
||||
self.scopes.append(node.symtab)
|
||||
self.scopes.append({ })
|
||||
self.currentScope = self.scopes[-1]
|
||||
|
||||
def exitScope(self, node):
|
||||
|
@ -554,11 +551,11 @@ class GatherDecls(TcheckVisitor):
|
|||
|
||||
def visitTranslationUnit(self, tu):
|
||||
# all TranslationUnits declare symbols in global scope
|
||||
if hasattr(tu, 'symtab'):
|
||||
if hasattr(tu, 'visited'):
|
||||
return
|
||||
tu.symtab = SymbolTable(self.errors)
|
||||
tu.visited = True
|
||||
savedSymtab = self.symtab
|
||||
self.symtab = tu.symtab
|
||||
self.symtab = SymbolTable(self.errors)
|
||||
|
||||
# pretend like the translation unit "using"-ed these for the
|
||||
# sake of type checking and C++ code generation
|
||||
|
@ -685,12 +682,13 @@ class GatherDecls(TcheckVisitor):
|
|||
|
||||
def visitStructDecl(self, sd):
|
||||
# If we've already processed this struct, don't do it again.
|
||||
if hasattr(sd, 'symtab'):
|
||||
if hasattr(sd, 'visited'):
|
||||
return
|
||||
|
||||
stype = sd.decl.type
|
||||
|
||||
self.symtab.enterScope(sd)
|
||||
sd.visited = True
|
||||
|
||||
for f in sd.fields:
|
||||
ftypedecl = self.symtab.lookup(str(f.typespec))
|
||||
|
|
Загрузка…
Ссылка в новой задаче