[pypy-svn] r65376 - pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test
fijal at codespeak.net
fijal at codespeak.net
Sun May 24 03:06:00 CEST 2009
Author: fijal
Date: Sun May 24 03:05:56 2009
New Revision: 65376
Modified:
pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py
Log:
* Fix trivial bug
* Add a cache for names, so the same name will have the same box.
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py Sun May 24 03:05:56 2009
@@ -8,6 +8,8 @@
from pypy.jit.metainterp.resoperation import rop, ResOperation
from pypy.rpython.lltypesystem import lltype, llmemory
+_cache = {}
+
class ParseError(Exception):
pass
@@ -19,6 +21,10 @@
self.consts = namespace
def box_for_var(self, elem):
+ try:
+ return _cache[elem]
+ except KeyError:
+ pass
if elem.startswith('i'):
# integer
box = BoxInt()
@@ -27,6 +33,7 @@
box = BoxPtr()
else:
raise ParseError("Unknown variable type: %s" % elem)
+ _cache[elem] = box
return box
def parse_header_line(self, line):
@@ -134,6 +141,8 @@
def parse_inpargs(self, line):
base_indent = line.find('[')
line = line.strip()
+ if line == '[]':
+ return base_indent, []
if base_indent == -1 or not line.endswith(']'):
raise ParseError("Wrong header: %s" % line)
inpargs = self.parse_header_line(line[1:-1])
More information about the Pypy-commit
mailing list