[pypy-svn] r7209 - in pypy/trunk/src/pypy: interpreter objspace objspace/flow
arigo at codespeak.net
arigo at codespeak.net
Thu Nov 11 11:24:28 CET 2004
Author: arigo
Date: Thu Nov 11 11:24:28 2004
New Revision: 7209
Modified:
pypy/trunk/src/pypy/interpreter/baseobjspace.py
pypy/trunk/src/pypy/objspace/descroperation.py
pypy/trunk/src/pypy/objspace/flow/model.py
pypy/trunk/src/pypy/objspace/flow/objspace.py
Log:
- we were using 'space.id' to implement 'space.is_', but it's really getting
in the way of the flow objspace, because the 'id' of a constant object is
not constant in general, but the 'is_' of two constant objects has a known
answer. Introduced a primitive 'is_' operation and removed the default
kind-of-broken implementation.
- debugging support for translate_pypy in checkgraph().
- we need to populate more extensively the implicit_exceptions dict.
Modified: pypy/trunk/src/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/baseobjspace.py (original)
+++ pypy/trunk/src/pypy/interpreter/baseobjspace.py Thu Nov 11 11:24:28 2004
@@ -110,11 +110,11 @@
# that can be defined in term of more primitive ones. Subclasses
# may also override specific functions for performance.
- def is_(self, w_x, w_y):
- "'x is y'."
- w_id_x = self.id(w_x)
- w_id_y = self.id(w_y)
- return self.eq(w_id_x, w_id_y)
+ #def is_(self, w_x, w_y): -- not really useful. Must be subclassed
+ # "'x is y'."
+ # w_id_x = self.id(w_x)
+ # w_id_y = self.id(w_y)
+ # return self.eq(w_id_x, w_id_y)
def not_(self, w_obj):
return self.wrap(not self.is_true(w_obj))
@@ -238,6 +238,7 @@
ObjSpace.MethodTable = [
# method name # symbol # number of arguments # special method name(s)
+ ('is_', 'is', 2, []),
('id', 'id', 1, []),
('type', 'type', 1, []),
('issubtype', 'issubtype', 2, []), # not for old-style classes
Modified: pypy/trunk/src/pypy/objspace/descroperation.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/descroperation.py (original)
+++ pypy/trunk/src/pypy/objspace/descroperation.py Thu Nov 11 11:24:28 2004
@@ -423,7 +423,7 @@
_impl_maker = _make_unaryop_impl
if _impl_maker:
setattr(DescrOperation,_name,_impl_maker(_symbol,_specialnames))
- elif _name not in ['id','type','issubtype',
+ elif _name not in ['is_', 'id','type','issubtype',
# not really to be defined in DescrOperation
'ord','round']:
raise Exception,"missing def for operation%s" % _name
Modified: pypy/trunk/src/pypy/objspace/flow/model.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/model.py (original)
+++ pypy/trunk/src/pypy/objspace/flow/model.py Thu Nov 11 11:24:28 2004
@@ -243,16 +243,12 @@
def checkgraph(graph):
"Check the consistency of a flow graph."
if __debug__:
+ this_block = [None]
exitblocks = [graph.returnblock] + graph.exceptblocks.values()
- for block in exitblocks:
- assert len(block.inputargs) == 1
- assert not block.operations
- assert not block.exits
-
- vars_previous_blocks = {}
-
+
def visit(block):
if isinstance(block, Block):
+ this_block[0] = block
assert bool(block.isstartblock) == (block is graph.startblock)
if not block.exits:
assert block in exitblocks
@@ -291,4 +287,19 @@
assert v in vars
vars_previous_blocks.update(vars)
- traverse(visit, graph)
+ try:
+ for block in exitblocks:
+ this_block[0] = block
+ assert len(block.inputargs) == 1
+ assert not block.operations
+ assert not block.exits
+
+ vars_previous_blocks = {}
+
+ traverse(visit, graph)
+
+ except AssertionError, e:
+ # hack for debug tools only
+ if this_block[0] and not hasattr(e, '__annotator_block'):
+ setattr(e, '__annotator_block', this_block[0])
+ raise
Modified: pypy/trunk/src/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/objspace.py (original)
+++ pypy/trunk/src/pypy/objspace/flow/objspace.py Thu Nov 11 11:24:28 2004
@@ -182,7 +182,7 @@
# ______________________________________________________________________
implicit_exceptions = {
- 'getitem': [IndexError],
+ 'getitem': [IndexError, KeyError],
}
def extract_cell_content(c):
@@ -207,8 +207,8 @@
# op = apply
if name == 'issubtype':
op = issubclass
- elif name == 'id':
- op = id
+ elif name == 'is_':
+ op = lambda x, y: x is y
elif name == 'getattr':
op = getattr
else:
More information about the Pypy-commit
mailing list