summaryrefslogtreecommitdiffstats
path: root/Tools/compiler
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-03-06 18:53:14 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-03-06 18:53:14 (GMT)
commitabd7ebf70bbb149b3872d26925ebab21b740cd58 (patch)
tree69ee04a844c821a242b66785df431cd21b95fcdc /Tools/compiler
parentfa974a9d06a216ca55bd81985fe75b17bdc3630a (diff)
downloadcpython-abd7ebf70bbb149b3872d26925ebab21b740cd58.zip
cpython-abd7ebf70bbb149b3872d26925ebab21b740cd58.tar.gz
cpython-abd7ebf70bbb149b3872d26925ebab21b740cd58.tar.bz2
revise arguments for addCode method on lnotab. take several numbers
that are internally converted to chars, rather than taking a string.
Diffstat (limited to 'Tools/compiler')
-rw-r--r--Tools/compiler/compiler/pyassem.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/Tools/compiler/compiler/pyassem.py b/Tools/compiler/compiler/pyassem.py
index fa42b84..4cb910c 100644
--- a/Tools/compiler/compiler/pyassem.py
+++ b/Tools/compiler/compiler/pyassem.py
@@ -143,17 +143,19 @@ class PyAssembler:
for t in self.insts:
opname = t[0]
if len(t) == 1:
- lnotab.addCode(chr(self.opnum[opname]))
+ lnotab.addCode(self.opnum[opname])
elif len(t) == 2:
- oparg = self._convertArg(opname, t[1])
if opname == 'SET_LINENO':
+ oparg = t[1]
lnotab.nextLine(oparg)
+ else:
+ oparg = self._convertArg(opname, t[1])
try:
hi, lo = divmod(oparg, 256)
except TypeError:
raise TypeError, "untranslated arg: %s, %s" % (opname, oparg)
- lnotab.addCode(chr(self.opnum[opname]) + chr(lo) +
- chr(hi))
+ lnotab.addCode(self.opnum[opname], lo, hi)
+
# why is a module a special case?
if self.flags == 0:
nlocals = 0
@@ -324,9 +326,10 @@ class LineAddrTable:
self.lastoff = 0
self.lnotab = []
- def addCode(self, code):
- self.code.append(code)
- self.codeOffset = self.codeOffset + len(code)
+ def addCode(self, *args):
+ for arg in args:
+ self.code.append(chr(arg))
+ self.codeOffset = self.codeOffset + len(args)
def nextLine(self, lineno):
if self.firstline == 0:
@@ -451,9 +454,9 @@ class StackDepthTracker:
('LOAD_', 1),
('IMPORT_', 1),
]
- # special cases
-
- #: UNPACK_TUPLE, UNPACK_LIST, BUILD_TUPLE,
+
+ # special cases:
+ # UNPACK_TUPLE, UNPACK_LIST, BUILD_TUPLE,
# BUILD_LIST, CALL_FUNCTION, MAKE_FUNCTION, BUILD_SLICE
def UNPACK_TUPLE(self, count):
return count