[pypy-svn] r49368 - pypy/dist/pypy/rlib
fijal at codespeak.net
fijal at codespeak.net
Wed Dec 5 10:35:17 CET 2007
Author: fijal
Date: Wed Dec 5 10:35:15 2007
New Revision: 49368
Modified:
pypy/dist/pypy/rlib/debug.py
Log:
New operation, rlib.debug.check_assertion, which will perform a translation-
time check if annotations are as we expect.
Modified: pypy/dist/pypy/rlib/debug.py
==============================================================================
--- pypy/dist/pypy/rlib/debug.py (original)
+++ pypy/dist/pypy/rlib/debug.py Wed Dec 5 10:35:15 2007
@@ -57,3 +57,28 @@
return hop.genop('debug_llinterpcall', [c_pythonfunction] + args_v,
resulttype=RESTYPE)
+
+def check_annotation(arg, checker):
+ """ Function checking if annotation is as expected when translating,
+ does nothing when just run. Checker is supposed to be a constant
+ callable which checks if annotation is as expected,
+ arguments passed are (current annotation, bookkeeper)
+ """
+ pass
+
+class Entry(ExtRegistryEntry):
+ _about_ = check_annotation
+
+ def compute_result_annotation(self, s_arg, s_checker):
+ if not s_checker.is_constant():
+ raise ValueError("Second argument of check_annotation must be constant")
+ checker = s_checker.const
+ checker(s_arg, self.bookkeeper)
+ from pypy.annotation import model
+ return s_arg
+
+ def specialize_call(self, hop):
+ hop.exception_cannot_occur()
+ vlist = [hop.inputarg(hop.args_r[0], arg=0)]
+ return hop.genop("same_as", vlist, resulttype=hop.r_result)
+
More information about the Pypy-commit
mailing list