[pypy-svn] r41336 - pypy/dist/pypy/jit/tl
arigo at codespeak.net
arigo at codespeak.net
Mon Mar 26 13:18:15 CEST 2007
Author: arigo
Date: Mon Mar 26 13:18:12 2007
New Revision: 41336
Modified:
pypy/dist/pypy/jit/tl/tiny1.py
pypy/dist/pypy/jit/tl/tiny2.py
Log:
Shuffle things around.
Modified: pypy/dist/pypy/jit/tl/tiny1.py
==============================================================================
--- pypy/dist/pypy/jit/tl/tiny1.py (original)
+++ pypy/dist/pypy/jit/tl/tiny1.py Mon Mar 26 13:18:12 2007
@@ -6,7 +6,7 @@
pc = 0
while pc < len(s):
op = s[pc]
- op = hint(op, concrete=True)
+ hint(op, concrete=True)
if op == '+':
acc += y
elif op == '-':
Modified: pypy/dist/pypy/jit/tl/tiny2.py
==============================================================================
--- pypy/dist/pypy/jit/tl/tiny2.py (original)
+++ pypy/dist/pypy/jit/tl/tiny2.py Mon Mar 26 13:18:12 2007
@@ -1,34 +1,4 @@
from pypy.rlib.objectmodel import hint, _is_early_constant
-import sys
-
-
-INVALID = -sys.maxint-1
-
-def myint_internal(s, start=0):
- if start >= len(s):
- return INVALID
- res = 0
- while start < len(s):
- c = s[start]
- n = ord(c) - ord('0')
- if not (0 <= n <= 9):
- return INVALID
- res = res * 10 + n
- start += 1
- return res
-
-def myint(s, start=0):
- if _is_early_constant(s):
- s = hint(s, promote=True)
- start = hint(start, promote=True)
- n = myint_internal(s, start)
- if n == INVALID:
- raise ValueError
- else:
- n = myint_internal(s, start)
- if n == INVALID:
- raise ValueError
- return n
class Box:
@@ -116,6 +86,33 @@
return stack.pop()
+def myint_internal(s, start=0):
+ if start >= len(s):
+ return -1
+ res = 0
+ while start < len(s):
+ c = s[start]
+ n = ord(c) - ord('0')
+ if not (0 <= n <= 9):
+ return -1
+ res = res * 10 + n
+ start += 1
+ return res
+
+def myint(s, start=0):
+ if _is_early_constant(s):
+ s = hint(s, promote=True)
+ start = hint(start, promote=True)
+ n = myint_internal(s, start)
+ if n < 0:
+ raise ValueError
+ else:
+ n = myint_internal(s, start)
+ if n < 0:
+ raise ValueError
+ return n
+
+
def test_main():
main = """#1 5 ADD""".split()
res = interpret(main, [IntBox(20)])
More information about the Pypy-commit
mailing list