]> granicus.if.org Git - python/commitdiff
revise arguments for addCode method on lnotab. take several numbers
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 6 Mar 2000 18:53:14 +0000 (18:53 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 6 Mar 2000 18:53:14 +0000 (18:53 +0000)
that are internally converted to chars, rather than taking a string.

Lib/compiler/pyassem.py
Tools/compiler/compiler/pyassem.py

index fa42b845ea18e5a4eacf694c2ad22346e8b28e5d..4cb910c3e6ad9951a4b770ec671a8adc6b5c7b6e 100644 (file)
@@ -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
index fa42b845ea18e5a4eacf694c2ad22346e8b28e5d..4cb910c3e6ad9951a4b770ec671a8adc6b5c7b6e 100644 (file)
@@ -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