[pypy-svn] r5363 - in pypy/trunk/src: goal pypy/annotation pypy/interpreter
arigo at codespeak.net
arigo at codespeak.net
Sun Jun 27 13:18:30 CEST 2004
Author: arigo
Date: Sun Jun 27 13:18:30 2004
New Revision: 5363
Modified:
pypy/trunk/src/goal/translate_pypy.py
pypy/trunk/src/pypy/annotation/binaryop.py
pypy/trunk/src/pypy/annotation/builtin.py
pypy/trunk/src/pypy/annotation/model.py
pypy/trunk/src/pypy/interpreter/pyframe.py
Log:
Progress on translate_pypy.
* Unsigned integers
Modified: pypy/trunk/src/goal/translate_pypy.py
==============================================================================
--- pypy/trunk/src/goal/translate_pypy.py (original)
+++ pypy/trunk/src/goal/translate_pypy.py Sun Jun 27 13:18:30 2004
@@ -6,9 +6,7 @@
from pypy.objspace.std.objspace import StdObjSpace, W_Object
from pypy.objspace.std.intobject import W_IntObject
-from pypy.objspace.std.restricted_int import r_int
from pypy.translator.translator import Translator
-from pypy.annotation import model as annmodel
# __________ Entry point __________
@@ -21,24 +19,18 @@
return space.mul(w_a, w_b)
-# __________ Special cases __________
-
-def special_immutablevalue(x):
- if x is r_int:
- x = int
- return general_immutablevalue(x)
-
-general_immutablevalue = annmodel.immutablevalue
-annmodel.immutablevalue = special_immutablevalue
-
# __________ Main __________
if __name__ == '__main__':
- # 2.3 specific
- import os
- os.putenv("PYTHONINSPECT", "1")
-
t = Translator(entry_point, verbose=True, simplifying=True)
- t.simplify()
- a = t.annotate([])
- a.simplify()
+ try:
+ a = t.annotate([])
+ #a.simplify()
+ except:
+ import sys, traceback
+ exc, val, tb = sys.exc_info()
+ print >> sys.stderr
+ traceback.print_exception(exc, val, tb)
+ print >> sys.stderr
+ import pdb
+ pdb.post_mortem(tb)
Modified: pypy/trunk/src/pypy/annotation/binaryop.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/binaryop.py (original)
+++ pypy/trunk/src/pypy/annotation/binaryop.py Sun Jun 27 13:18:30 2004
@@ -39,17 +39,20 @@
class __extend__(pairtype(SomeInteger, SomeInteger)):
+ # unsignedness is considered a rare and contagious disease
def union((int1, int2)):
- return SomeInteger(nonneg = int1.nonneg and int2.nonneg)
+ return SomeInteger(nonneg = int1.nonneg and int2.nonneg,
+ unsigned = int1.unsigned or int2.unsigned)
def add((int1, int2)):
- return SomeInteger(nonneg = int1.nonneg and int2.nonneg)
+ return SomeInteger(nonneg = int1.nonneg and int2.nonneg,
+ unsigned = int1.unsigned or int2.unsigned)
mul = div = mod = add
def sub((int1, int2)):
- return SomeInteger()
+ return SomeInteger(unsigned = int1.unsigned or int2.unsigned)
def lt((int1, int2)): return SomeBool()
def le((int1, int2)): return SomeBool()
Modified: pypy/trunk/src/pypy/annotation/builtin.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/builtin.py (original)
+++ pypy/trunk/src/pypy/annotation/builtin.py Sun Jun 27 13:18:30 2004
@@ -4,6 +4,7 @@
from pypy.annotation.model import SomeInteger, SomeObject
from pypy.annotation.factory import ListFactory, getbookkeeper
+import pypy.objspace.std.restricted_int
def builtin_len(s_obj):
@@ -21,10 +22,10 @@
return SomeObject()
def builtin_int(s_obj): # we can consider 'int' as a function
- if isinstance(s_obj, SomeInteger):
- return s_obj
- else:
- return SomeInteger()
+ return SomeInteger()
+
+def restricted_uint(s_obj): # for r_uint
+ return SomeInteger(nonneg=True, unsigned=True)
# collect all functions
@@ -34,3 +35,6 @@
if name.startswith('builtin_'):
original = getattr(__builtin__, name[8:])
BUILTIN_FUNCTIONS[original] = value
+
+BUILTIN_FUNCTIONS[pypy.objspace.std.restricted_int.r_int] = builtin_int
+BUILTIN_FUNCTIONS[pypy.objspace.std.restricted_int.r_uint] = restricted_uint
Modified: pypy/trunk/src/pypy/annotation/model.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/model.py (original)
+++ pypy/trunk/src/pypy/annotation/model.py Sun Jun 27 13:18:30 2004
@@ -53,13 +53,15 @@
class SomeInteger(SomeObject):
"Stands for an object which is known to be an integer."
knowntype = int
- def __init__(self, nonneg=False):
+ def __init__(self, nonneg=False, unsigned=False):
self.nonneg = nonneg
+ self.unsigned = unsigned # pypy.objspace.std.restricted_int.r_uint
class SomeBool(SomeInteger):
"Stands for true or false."
knowntype = bool
nonneg = True
+ unsigned = False
def __init__(self):
pass
Modified: pypy/trunk/src/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/pyframe.py (original)
+++ pypy/trunk/src/pypy/interpreter/pyframe.py Sun Jun 27 13:18:30 2004
@@ -149,14 +149,13 @@
operationerr = unroller.args[0]
w_type = operationerr.w_type
w_value = operationerr.w_value
- if frame.space.full_exceptions:
- w_normalized = normalize_exception(frame.space, w_type, w_value)
- w_type, w_value = frame.space.unpacktuple(w_normalized, 2)
- # save the normalized exception back into the OperationError
- # -- in particular it makes sure that sys.exc_info() etc see
- # normalized exception.
- operationerr.w_type = w_type
- operationerr.w_value = w_value
+ w_normalized = normalize_exception(frame.space, w_type, w_value)
+ w_type, w_value = frame.space.unpacktuple(w_normalized, 2)
+ # save the normalized exception back into the OperationError
+ # -- in particular it makes sure that sys.exc_info() etc see
+ # normalized exception.
+ operationerr.w_type = w_type
+ operationerr.w_value = w_value
# the stack setup is slightly different than in CPython:
# instead of the traceback, we store the unroller object,
# wrapped.
More information about the Pypy-commit
mailing list