[pypy-svn] r10821 - in pypy/dist/pypy: annotation translator
pedronis at codespeak.net
pedronis at codespeak.net
Mon Apr 18 19:53:44 CEST 2005
Author: pedronis
Date: Mon Apr 18 19:53:44 2005
New Revision: 10821
Modified:
pypy/dist/pypy/annotation/classdef.py
pypy/dist/pypy/annotation/dictdef.py
pypy/dist/pypy/annotation/listdef.py
pypy/dist/pypy/annotation/model.py
pypy/dist/pypy/translator/annrpython.py
Log:
hook on unionof that allows to write code to stop the annotation process or ignore when something degenerate
to SomeObject
Modified: pypy/dist/pypy/annotation/classdef.py
==============================================================================
--- pypy/dist/pypy/annotation/classdef.py (original)
+++ pypy/dist/pypy/annotation/classdef.py Mon Apr 18 19:53:44 2005
@@ -4,7 +4,7 @@
from __future__ import generators
from types import FunctionType
-from pypy.annotation.model import SomeImpossibleValue, SomePBC, unionof
+from pypy.annotation.model import SomeImpossibleValue, SomePBC, tracking_unionof
class Attribute:
@@ -28,13 +28,13 @@
source.__dict__[self.name])
if classdef:
s_value = s_value.bindcallables(classdef)
- self.s_value = unionof(self.s_value, s_value)
+ self.s_value = tracking_unionof(self, self.s_value, s_value)
return self.s_value
def merge(self, other):
assert self.name == other.name
self.sources.update(other.sources)
- self.s_value = unionof(self.s_value, other.s_value)
+ self.s_value = tracking_unionof(self, self.s_value, other.s_value)
self.readonly = self.readonly and other.readonly
self.read_locations.update(other.read_locations)
Modified: pypy/dist/pypy/annotation/dictdef.py
==============================================================================
--- pypy/dist/pypy/annotation/dictdef.py (original)
+++ pypy/dist/pypy/annotation/dictdef.py Mon Apr 18 19:53:44 2005
@@ -1,4 +1,4 @@
-from pypy.annotation.model import SomeObject, SomeImpossibleValue, unionof
+from pypy.annotation.model import SomeObject, SomeImpossibleValue
from pypy.annotation.listdef import ListItem
Modified: pypy/dist/pypy/annotation/listdef.py
==============================================================================
--- pypy/dist/pypy/annotation/listdef.py (original)
+++ pypy/dist/pypy/annotation/listdef.py Mon Apr 18 19:53:44 2005
@@ -1,4 +1,4 @@
-from pypy.annotation.model import SomeObject, SomeImpossibleValue, unionof
+from pypy.annotation.model import SomeObject, SomeImpossibleValue, tracking_unionof
class ListItem:
@@ -21,7 +21,7 @@
listdef.listitem = self
def generalize(self, s_other_value):
- s_new_value = unionof(self.s_value, s_other_value)
+ s_new_value = tracking_unionof(self.__class__.__name__, self.s_value, s_other_value)
if s_new_value != self.s_value:
self.s_value = s_new_value
# reflow from all reading points
Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py (original)
+++ pypy/dist/pypy/annotation/model.py Mon Apr 18 19:53:44 2005
@@ -267,6 +267,10 @@
s1.caused_by_merge = somevalues
return s1
+def tracking_unionof(ctxt, *somevalues):
+ return unionof(*somevalues)
+
+
# ____________________________________________________________
# internal
Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py (original)
+++ pypy/dist/pypy/translator/annrpython.py Mon Apr 18 19:53:44 2005
@@ -128,9 +128,9 @@
for a in cells:
assert isinstance(a, annmodel.SomeObject)
if block not in self.annotated:
- self.bindinputargs(block, cells, called_from)
+ self.bindinputargs(fn, block, cells, called_from)
else:
- self.mergeinputargs(block, cells, called_from)
+ self.mergeinputargs(fn, block, cells, called_from)
if not self.annotated[block]:
self.pendingblocks[block] = fn
@@ -320,21 +320,21 @@
assert block in self.annotated
self.annotated[block] = False # must re-flow
- def bindinputargs(self, block, inputcells, called_from=None):
+ def bindinputargs(self, fn, block, inputcells, called_from=None):
# Create the initial bindings for the input args of a block.
assert len(block.inputargs) == len(inputcells)
for a, cell in zip(block.inputargs, inputcells):
self.setbinding(a, cell, called_from)
self.annotated[block] = False # must flowin.
- def mergeinputargs(self, block, inputcells, called_from=None):
+ def mergeinputargs(self, fn, block, inputcells, called_from=None):
# Merge the new 'cells' with each of the block's existing input
# variables.
oldcells = [self.binding(a) for a in block.inputargs]
- unions = [annmodel.unionof(c1,c2) for c1, c2 in zip(oldcells,inputcells)]
+ unions = [annmodel.tracking_unionof((fn, block), c1,c2) for c1, c2 in zip(oldcells,inputcells)]
# if the merged cells changed, we must redo the analysis
if unions != oldcells:
- self.bindinputargs(block, unions, called_from)
+ self.bindinputargs(fn, block, unions, called_from)
def whereami(self, position_key):
fn, block, i = position_key
More information about the Pypy-commit
mailing list