mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Make sure the docstring is always entered as the first element in the
consts, even if it is None. Simplify _lookupName() by removing lots of redundant tests.
This commit is contained in:
parent
ceccc3c037
commit
5af105eec9
2 changed files with 2 additions and 22 deletions
|
@ -254,7 +254,6 @@ class PyFlowGraph(FlowGraph):
|
||||||
|
|
||||||
def setDocstring(self, doc):
|
def setDocstring(self, doc):
|
||||||
self.docstring = doc
|
self.docstring = doc
|
||||||
self.consts.insert(0, doc)
|
|
||||||
|
|
||||||
def setFlag(self, flag):
|
def setFlag(self, flag):
|
||||||
self.flags = self.flags | flag
|
self.flags = self.flags | flag
|
||||||
|
@ -335,6 +334,7 @@ class PyFlowGraph(FlowGraph):
|
||||||
def convertArgs(self):
|
def convertArgs(self):
|
||||||
"""Convert arguments from symbolic to concrete form"""
|
"""Convert arguments from symbolic to concrete form"""
|
||||||
assert self.stage == FLAT
|
assert self.stage == FLAT
|
||||||
|
self.consts.insert(0, self.docstring)
|
||||||
for i in range(len(self.insts)):
|
for i in range(len(self.insts)):
|
||||||
t = self.insts[i]
|
t = self.insts[i]
|
||||||
if len(t) == 2:
|
if len(t) == 2:
|
||||||
|
@ -347,21 +347,11 @@ class PyFlowGraph(FlowGraph):
|
||||||
|
|
||||||
def _lookupName(self, name, list):
|
def _lookupName(self, name, list):
|
||||||
"""Return index of name in list, appending if necessary"""
|
"""Return index of name in list, appending if necessary"""
|
||||||
found = None
|
|
||||||
t = type(name)
|
t = type(name)
|
||||||
for i in range(len(list)):
|
for i in range(len(list)):
|
||||||
# must do a comparison on type first to prevent UnicodeErrors
|
# must do a comparison on type first to prevent UnicodeErrors
|
||||||
if t == type(list[i]) and list[i] == name:
|
if t == type(list[i]) and list[i] == name:
|
||||||
found = 1
|
|
||||||
break
|
|
||||||
if found:
|
|
||||||
# this is cheap, but incorrect in some cases, e.g 2 vs. 2L
|
|
||||||
if type(name) == type(list[i]):
|
|
||||||
return i
|
return i
|
||||||
for i in range(len(list)):
|
|
||||||
elt = list[i]
|
|
||||||
if type(elt) == type(name) and elt == name:
|
|
||||||
return i
|
|
||||||
end = len(list)
|
end = len(list)
|
||||||
list.append(name)
|
list.append(name)
|
||||||
return end
|
return end
|
||||||
|
|
|
@ -254,7 +254,6 @@ class PyFlowGraph(FlowGraph):
|
||||||
|
|
||||||
def setDocstring(self, doc):
|
def setDocstring(self, doc):
|
||||||
self.docstring = doc
|
self.docstring = doc
|
||||||
self.consts.insert(0, doc)
|
|
||||||
|
|
||||||
def setFlag(self, flag):
|
def setFlag(self, flag):
|
||||||
self.flags = self.flags | flag
|
self.flags = self.flags | flag
|
||||||
|
@ -335,6 +334,7 @@ class PyFlowGraph(FlowGraph):
|
||||||
def convertArgs(self):
|
def convertArgs(self):
|
||||||
"""Convert arguments from symbolic to concrete form"""
|
"""Convert arguments from symbolic to concrete form"""
|
||||||
assert self.stage == FLAT
|
assert self.stage == FLAT
|
||||||
|
self.consts.insert(0, self.docstring)
|
||||||
for i in range(len(self.insts)):
|
for i in range(len(self.insts)):
|
||||||
t = self.insts[i]
|
t = self.insts[i]
|
||||||
if len(t) == 2:
|
if len(t) == 2:
|
||||||
|
@ -347,21 +347,11 @@ class PyFlowGraph(FlowGraph):
|
||||||
|
|
||||||
def _lookupName(self, name, list):
|
def _lookupName(self, name, list):
|
||||||
"""Return index of name in list, appending if necessary"""
|
"""Return index of name in list, appending if necessary"""
|
||||||
found = None
|
|
||||||
t = type(name)
|
t = type(name)
|
||||||
for i in range(len(list)):
|
for i in range(len(list)):
|
||||||
# must do a comparison on type first to prevent UnicodeErrors
|
# must do a comparison on type first to prevent UnicodeErrors
|
||||||
if t == type(list[i]) and list[i] == name:
|
if t == type(list[i]) and list[i] == name:
|
||||||
found = 1
|
|
||||||
break
|
|
||||||
if found:
|
|
||||||
# this is cheap, but incorrect in some cases, e.g 2 vs. 2L
|
|
||||||
if type(name) == type(list[i]):
|
|
||||||
return i
|
return i
|
||||||
for i in range(len(list)):
|
|
||||||
elt = list[i]
|
|
||||||
if type(elt) == type(name) and elt == name:
|
|
||||||
return i
|
|
||||||
end = len(list)
|
end = len(list)
|
||||||
list.append(name)
|
list.append(name)
|
||||||
return end
|
return end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue