[pypy-commit] pypy desc-specialize: Extract normalize_args() method out of funcdesc.specialize
rlamy
pypy.commits at gmail.com
Wed Feb 24 09:48:29 EST 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: desc-specialize
Changeset: r82483:5089fd09c1d1
Date: 2016-02-24 15:47 +0100
http://bitbucket.org/pypy/pypy/changeset/5089fd09c1d1/
Log: Extract normalize_args() method out of funcdesc.specialize
diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py
--- a/rpython/annotator/description.py
+++ b/rpython/annotator/description.py
@@ -275,19 +275,7 @@
getattr(self.bookkeeper, "position_key", None) is not None):
_, block, i = self.bookkeeper.position_key
op = block.operations[i]
- enforceargs = getattr(self.pyobj, '_annenforceargs_', None)
- signature = getattr(self.pyobj, '_signature_', None)
- if enforceargs and signature:
- raise Exception("%r: signature and enforceargs cannot both be "
- "used" % (self,))
- if enforceargs:
- if not callable(enforceargs):
- from rpython.annotator.signature import Sig
- enforceargs = Sig(*enforceargs)
- self.pyobj._annenforceargs_ = enforceargs
- enforceargs(self, inputcells) # can modify inputcells in-place
- if signature:
- enforce_signature_args(self, signature[0], inputcells) # mutates inputcells
+ self.normalize_args(inputcells)
if getattr(self.pyobj, '_annspecialcase_', '').endswith("call_location"):
return self.specializer(self, inputcells, op)
else:
@@ -319,6 +307,27 @@
result = unionof(result, s_previous_result)
return result
+ def normalize_args(self, inputs_s):
+ """
+ Canonicalize argument annotations into the exact parameter
+ annotations of a specific specialized graph.
+
+ Note: this method has no return value but mutates its argument instead.
+ """
+ enforceargs = getattr(self.pyobj, '_annenforceargs_', None)
+ signature = getattr(self.pyobj, '_signature_', None)
+ if enforceargs and signature:
+ raise Exception("%r: signature and enforceargs cannot both be "
+ "used" % (self,))
+ if enforceargs:
+ if not callable(enforceargs):
+ from rpython.annotator.signature import Sig
+ enforceargs = Sig(*enforceargs)
+ self.pyobj._annenforceargs_ = enforceargs
+ enforceargs(self, inputs_s) # can modify inputs_s in-place
+ if signature:
+ enforce_signature_args(self, signature[0], inputs_s) # mutates inputs_s
+
def get_graph(self, args, op):
inputs_s = self.parse_arguments(args)
return self.specialize(inputs_s, op)
More information about the pypy-commit
mailing list