[pypy-svn] pypy default: add a way to override which classes are created

antocuni commits-noreply at bitbucket.org
Fri Feb 25 14:58:52 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42279:845d4344fc53
Date: 2011-02-25 13:55 +0100
http://bitbucket.org/pypy/pypy/changeset/845d4344fc53/

Log:	add a way to override which classes are created

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
@@ -48,6 +48,10 @@
         ##                                             for a in self.args]))
 
 class SimpleParser(OpParser):
+
+    # factory method
+    Op = Op
+    
     def parse_args(self, opname, argspec):
         if not argspec.strip():
             return [], None
@@ -67,7 +71,7 @@
         return res
 
     def create_op(self, opnum, args, res, descr):
-        return Op(intern(opname[opnum].lower()), args, res, descr)
+        return self.Op(intern(opname[opnum].lower()), args, res, descr)
 
 class NonCodeError(Exception):
     pass
@@ -132,6 +136,9 @@
     _lineset = None
     is_bytecode = False
     inline_level = None
+
+    # factory method
+    TraceForOpcode = TraceForOpcode
     
     def __init__(self, chunks, path, storage):
         self.path = path
@@ -172,13 +179,13 @@
         for op in operations:
             if op.name == 'debug_merge_point':
                 if so_far:
-                    append_to_res(TraceForOpcode(so_far, storage))
+                    append_to_res(cls.TraceForOpcode(so_far, storage))
                     if limit:
                         break
                     so_far = []
             so_far.append(op)
         if so_far:
-            append_to_res(TraceForOpcode(so_far, storage))
+            append_to_res(cls.TraceForOpcode(so_far, storage))
         # wrap stack back up
         if not stack:
             # no ops whatsoever


More information about the Pypy-commit mailing list