Author: Maciej Fijalkowski <[email protected]>
Branch: result-in-resops
Changeset: r57577:12495b247d7b
Date: 2012-09-25 14:35 +0200
http://bitbucket.org/pypy/pypy/changeset/12495b247d7b/

Log:    another feature of oparser

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
@@ -69,7 +69,7 @@
 
     def __init__(self, input, cpu, namespace, type_system, boxkinds,
                  invent_fail_descr=True,
-                 nonstrict=False, results=None):
+                 nonstrict=False, results=None, process_guard=None):
         self.input = input
         self.vars = {}
         self.cpu = cpu
@@ -85,6 +85,7 @@
         self.model = get_model(self.use_mock_model)
         self.original_jitcell_token = self.model.JitCellToken()
         self.results = results
+        self.process_guard = process_guard
 
     def get_const(self, name, typ):
         if self._consts is None:
@@ -288,6 +289,8 @@
             r = create_resop_dispatch(opnum, result, args)
             if descr is not None:
                 r.setdescr(descr)
+            if self.process_guard and r.is_guard():
+                self.process_guard(r)
             return r
 
     def parse_result_op(self, line, num):
@@ -406,11 +409,12 @@
 def parse(input, cpu=None, namespace=None, type_system='lltype',
           boxkinds=None, invent_fail_descr=True,
           no_namespace=False, nonstrict=False, OpParser=OpParser,
-          results=None):
+          results=None, process_guard=None):
     if namespace is None and not no_namespace:
         namespace = {}
     return OpParser(input, cpu, namespace, type_system, boxkinds,
-                    invent_fail_descr, nonstrict, results).parse()
+                    invent_fail_descr, nonstrict, results,
+                    process_guard).parse()
 
 def pure_parse(*args, **kwds):
     kwds['invent_fail_descr'] = False
diff --git a/pypy/jit/tool/test/test_oparser.py 
b/pypy/jit/tool/test/test_oparser.py
--- a/pypy/jit/tool/test/test_oparser.py
+++ b/pypy/jit/tool/test/test_oparser.py
@@ -186,6 +186,17 @@
         loop = self.parse(x, nonstrict=True)
         assert not loop.operations[0].has_extra("failargs")
 
+    def test_fail_args_invent_snapshot(self):
+        def f(op):
+            op.set_rd_snapshot(['foo'])
+        
+        x = '''
+        [i0]
+        guard_true(i0, descr=<Guard0>) [i0]
+        '''
+        loop = self.parse(x, process_guard=f)
+        assert loop.operations[0].get_rd_snapshot() == ['foo']
+
     def test_results(self):
         x = '''
         [i0]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to