Author: Ronan Lamy <[email protected]>
Branch: 
Changeset: r71523:7a2c9e5f2782
Date: 2014-05-14 21:52 +0100
http://bitbucket.org/pypy/pypy/changeset/7a2c9e5f2782/

Log:    move some utilities to rpython.annotator.bookkeeper

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -14,16 +14,12 @@
     SomeLongFloat, SomeType, SomeConstantType, unionof, UnionError,
     read_can_only_throw, add_knowntypedata,
     merge_knowntypedata,)
-from rpython.annotator.bookkeeper import getbookkeeper
+from rpython.annotator.bookkeeper import getbookkeeper, immutablevalue
 from rpython.flowspace.model import Variable, Constant
 from rpython.flowspace.operation import op
 from rpython.rlib import rarithmetic
 from rpython.annotator.model import AnnotatorError
 
-# convenience only!
-def immutablevalue(x):
-    return getbookkeeper().immutablevalue(x)
-
 BINARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
                         if oper.dispatch == 2])
 
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -27,6 +27,14 @@
 from rpython.rtyper import extregistry
 
 
+BUILTIN_ANALYZERS = {}
+
+def analyzer_for(func):
+    def wrapped(ann_func):
+        BUILTIN_ANALYZERS[func] = ann_func
+        return func
+    return wrapped
+
 class Bookkeeper(object):
     """The log of choices that have been made while analysing the operations.
     It ensures that the same 'choice objects' will be returned if we ask
@@ -600,6 +608,7 @@
         return False
     else:
         return True
+
 # get current bookkeeper
 
 def getbookkeeper():
@@ -610,7 +619,8 @@
     except AttributeError:
         return None
 
+def immutablevalue(x):
+    return getbookkeeper().immutablevalue(x)
+
 def delayed_imports():
-    # import ordering hack
-    global BUILTIN_ANALYZERS
-    from rpython.annotator.builtin import BUILTIN_ANALYZERS
+    import rpython.annotator.builtin
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -10,16 +10,13 @@
     SomeOrderedDict, SomeByteArray, add_knowntypedata, s_ImpossibleValue,)
 from rpython.rtyper.llannotation import (
     SomeAddress, annotation_to_lltype, lltype_to_annotation, ll_to_annotation)
-from rpython.annotator.bookkeeper import getbookkeeper
+from rpython.annotator.bookkeeper import (
+        getbookkeeper, immutablevalue, BUILTIN_ANALYZERS, analyzer_for)
 from rpython.annotator import description
 from rpython.flowspace.model import Constant
 import rpython.rlib.rarithmetic
 import rpython.rlib.objectmodel
 
-# convenience only!
-def immutablevalue(x):
-    return getbookkeeper().immutablevalue(x)
-
 def constpropagate(func, args_s, s_result):
     """Returns s_result unless all args are constants, in which case the
     func() is called and a constant result is returned (it must be contained
@@ -44,14 +41,6 @@
             func, args, realresult, s_result))
     return s_realresult
 
-BUILTIN_ANALYZERS = {}
-
-def analyzer_for(func):
-    def wrapped(ann_func):
-        BUILTIN_ANALYZERS[func] = ann_func
-        return func
-    return wrapped
-
 # ____________________________________________________________
 
 def builtin_range(*args):
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -11,15 +11,11 @@
     SomePBC, SomeType, s_ImpossibleValue,
     s_Bool, s_None, unionof, add_knowntypedata,
     HarmlesslyBlocked, SomeWeakRef, SomeUnicodeString, SomeByteArray)
-from rpython.annotator.bookkeeper import getbookkeeper
+from rpython.annotator.bookkeeper import getbookkeeper, immutablevalue
 from rpython.annotator import builtin
 from rpython.annotator.binaryop import _clone ## XXX where to put this?
 from rpython.annotator.model import AnnotatorError
 
-# convenience only!
-def immutablevalue(x):
-    return getbookkeeper().immutablevalue(x)
-
 UNARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
                         if oper.dispatch == 1])
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to