[pypy-svn] r7311 - pypy/trunk/src/pypy/annotation
arigo at codespeak.net
arigo at codespeak.net
Wed Nov 17 11:25:21 CET 2004
Author: arigo
Date: Wed Nov 17 11:25:21 2004
New Revision: 7311
Modified:
pypy/trunk/src/pypy/annotation/model.py
Log:
For debugging, record where each SomeObject instance comes from.
See their .origin property.
Modified: pypy/trunk/src/pypy/annotation/model.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/model.py (original)
+++ pypy/trunk/src/pypy/annotation/model.py Wed Nov 17 11:25:21 2004
@@ -30,6 +30,7 @@
from types import ClassType, BuiltinFunctionType, FunctionType, MethodType
from types import InstanceType
+import pypy
from pypy.annotation.pairtype import pair, extendabletype
from pypy.objspace.flow.model import Constant
@@ -52,6 +53,22 @@
def is_constant(self):
return hasattr(self, 'const')
+ # for debugging, record where each instance comes from
+ _coming_from = {}
+ def __new__(cls, *args, **kw):
+ self = super(SomeObject, cls).__new__(cls, *args, **kw)
+ try:
+ position_key = pypy.annotation.factory.getbookkeeper().position_key
+ except AttributeError:
+ pass
+ else:
+ SomeObject._coming_from[id(self)] = position_key
+ return self
+ def origin(self):
+ return SomeObject._coming_from[id(self)]
+ origin = property(origin)
+
+
class SomeInteger(SomeObject):
"Stands for an object which is known to be an integer."
knowntype = int
More information about the Pypy-commit
mailing list