[pypy-commit] pypy oparser-mock-model: move LoopToken to the model; it needs a hack to bypass the isinstance check

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


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: oparser-mock-model
Changeset: r44861:1d6329f137e4
Date: 2011-06-09 12:14 +0200
http://bitbucket.org/pypy/pypy/changeset/1d6329f137e4/

Log:	move LoopToken to the model; it needs a hack to bypass the
	isinstance check

diff --git a/pypy/jit/metainterp/history.py b/pypy/jit/metainterp/history.py
--- a/pypy/jit/metainterp/history.py
+++ b/pypy/jit/metainterp/history.py
@@ -1063,6 +1063,8 @@
     Explodes if the annotator only thinks it is an instance of AbstractValue.
     """
     if x is not None:
+        if not we_are_translated() and getattr(x, 'I_am_a_descr', False):
+            return # needed for the mock case in oparser_model
         assert isinstance(x, AbstractDescr)
 
 class Entry(ExtRegistryEntry):
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
@@ -6,7 +6,7 @@
 from pypy.jit.tool.oparser_model import get_model
 
 from pypy.jit.metainterp.history import \
-     LoopToken, get_const_ptr_for_string, get_const_ptr_for_unicode
+     get_const_ptr_for_string, get_const_ptr_for_unicode
 from pypy.jit.metainterp.resoperation import rop, ResOperation, \
                                             ResOpWithDescr, N_aryOp, \
                                             UnaryOp, PlainResOp
@@ -78,8 +78,8 @@
             self._cache = {}
         self.invent_fail_descr = invent_fail_descr
         self.nonstrict = nonstrict
-        self.looptoken = LoopToken()
         self.model = get_model(self.use_mock_model)
+        self.looptoken = self.model.LoopToken()
 
     def get_const(self, name, typ):
         if self._consts is None:
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
@@ -3,7 +3,7 @@
 
 def get_real_model():
     class LoopModel(object):
-        from pypy.jit.metainterp.history import TreeLoop
+        from pypy.jit.metainterp.history import TreeLoop, LoopToken
         from pypy.jit.metainterp.history import Box, BoxInt, BoxFloat
         from pypy.jit.metainterp.history import ConstInt, ConstObj, ConstPtr, ConstFloat
         from pypy.jit.metainterp.typesystem import llhelper
@@ -17,6 +17,9 @@
             def __init__(self, name):
                 self.name = name
 
+        class LoopToken(object):
+            I_am_a_descr = True
+
         class Box(object):
             _counter = 0
             type = 'b'


More information about the pypy-commit mailing list