[pypy-commit] pypy oparser-mock-model: move get_const_ptr_for_* to the model

antocuni noreply at buildbot.pypy.org
Thu Jun 9 13:37:34 CEST 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: oparser-mock-model
Changeset: r44862:0ec0b2dbc358
Date: 2011-06-09 12:23 +0200
http://bitbucket.org/pypy/pypy/changeset/0ec0b2dbc358/

Log:	move get_const_ptr_for_* to the model

diff --git a/pypy/jit/tool/oparser.py b/pypy/jit/tool/oparser.py
--- a/pypy/jit/tool/oparser.py
+++ b/pypy/jit/tool/oparser.py
@@ -5,8 +5,6 @@
 
 from pypy.jit.tool.oparser_model import get_model
 
-from pypy.jit.metainterp.history import \
-     get_const_ptr_for_string, get_const_ptr_for_unicode
 from pypy.jit.metainterp.resoperation import rop, ResOperation, \
                                             ResOpWithDescr, N_aryOp, \
                                             UnaryOp, PlainResOp
@@ -164,11 +162,11 @@
                 arg.startswith('s"')):
                 # XXX ootype
                 info = arg[1:].strip("'\"")
-                return get_const_ptr_for_string(info)
+                return self.model.get_const_ptr_for_string(info)
             if arg.startswith('u"'):
                 # XXX ootype
                 info = arg[1:].strip("'\"")
-                return get_const_ptr_for_unicode(info)
+                return self.model.get_const_ptr_for_unicode(info)
             if arg.startswith('ConstClass('):
                 name = arg[len('ConstClass('):-1]
                 return self.get_const(name, 'class')
diff --git a/pypy/jit/tool/oparser_model.py b/pypy/jit/tool/oparser_model.py
--- a/pypy/jit/tool/oparser_model.py
+++ b/pypy/jit/tool/oparser_model.py
@@ -8,6 +8,11 @@
         from pypy.jit.metainterp.history import ConstInt, ConstObj, ConstPtr, ConstFloat
         from pypy.jit.metainterp.typesystem import llhelper
 
+        from pypy.jit.metainterp.history import get_const_ptr_for_string
+        from pypy.jit.metainterp.history import get_const_ptr_for_unicode
+        get_const_ptr_for_string = staticmethod(get_const_ptr_for_string)
+        get_const_ptr_for_unicode = staticmethod(get_const_ptr_for_unicode)
+
     return LoopModel
 
 def get_mock_model():
@@ -51,6 +56,9 @@
             def __init__(self, value=None):
                 self.value = value
 
+            def _get_str(self):
+                return str(self.value)
+
         class ConstInt(Const):
             pass
 
@@ -60,6 +68,14 @@
         class ConstFloat(Const):
             pass
 
+        @classmethod
+        def get_const_ptr_for_string(cls, s):
+            return cls.ConstPtr(s)
+
+        @classmethod
+        def get_const_ptr_for_unicode(cls, s):
+            return cls.ConstPtr(s)
+
         class llhelper(object):
             pass
 


More information about the pypy-commit mailing list