[pypy-svn] pypy default: rename OpCode to TraceForOpcode once more, to distinguish it from lib_pypy.disassembler.Opcode

antocuni commits-noreply at bitbucket.org
Wed Feb 23 15:34:28 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42226:1e7c2cf4e620
Date: 2011-02-23 14:42 +0100
http://bitbucket.org/pypy/pypy/changeset/1e7c2cf4e620/

Log:	rename OpCode to TraceForOpcode once more, to distinguish it from
	lib_pypy.disassembler.Opcode

diff --git a/pypy/tool/jitlogparser/parser.py b/pypy/tool/jitlogparser/parser.py
--- a/pypy/tool/jitlogparser/parser.py
+++ b/pypy/tool/jitlogparser/parser.py
@@ -68,7 +68,7 @@
 class NonCodeError(Exception):
     pass
 
-class OpCode(object):
+class TraceForOpcode(object):
     filename = None
     startlineno = 0
     name = None
@@ -100,7 +100,7 @@
                                            self.startlineno)
 
     def getcode(self):
-        if self.code is None:
+        if self.code is None and self.filename is not None:
             self.code = dis(self.storage.load_code(self.filename)[self.startlineno])
         return self.code
 
@@ -143,7 +143,7 @@
 
     @classmethod
     def from_operations(cls, operations, storage, limit=None):
-        """ Slice given operation list into a chain of OpCode chunks.
+        """ Slice given operation list into a chain of TraceForOpcode chunks.
         Also detect inlined functions and make them Function
         """
         stack = []
@@ -168,13 +168,13 @@
         for op in operations:
             if op.name == 'debug_merge_point':
                 if so_far:
-                    append_to_res(OpCode(so_far, storage))
+                    append_to_res(TraceForOpcode(so_far, storage))
                     if limit:
                         break
                     so_far = []
             so_far.append(op)
         if so_far:
-            append_to_res(OpCode(so_far, storage))
+            append_to_res(TraceForOpcode(so_far, storage))
         # wrap stack back up
         if not stack:
             # no ops whatsoever

diff --git a/pypy/tool/jitlogparser/test/test_parser.py b/pypy/tool/jitlogparser/test/test_parser.py
--- a/pypy/tool/jitlogparser/test/test_parser.py
+++ b/pypy/tool/jitlogparser/test/test_parser.py
@@ -1,6 +1,6 @@
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.metainterp.history import ConstInt, Const
-from pypy.tool.jitlogparser.parser import parse, OpCode, Function,\
+from pypy.tool.jitlogparser.parser import parse, TraceForOpcode, Function,\
      adjust_bridges
 from pypy.tool.jitlogparser.storage import LoopStorage
 import py
@@ -59,9 +59,9 @@
     """)
     res = Function.from_operations(ops.operations, LoopStorage())
     assert len(res.chunks) == 3 # two chunks + inlined call
-    assert isinstance(res.chunks[0], OpCode)
+    assert isinstance(res.chunks[0], TraceForOpcode)
     assert isinstance(res.chunks[1], Function)
-    assert isinstance(res.chunks[2], OpCode)
+    assert isinstance(res.chunks[2], TraceForOpcode)
     assert res.chunks[1].path == "1"
     assert len(res.chunks[1].chunks) == 3
     


More information about the Pypy-commit mailing list