def specialize(self, inputcells, op=None): if (op is None and getattr(self.bookkeeper, "position_key", None) is not None): _, block, i = self.bookkeeper.position_key op = block.operations[i] if self.specializer is None: # get the specializer based on the tag of the 'pyobj' # (if any), according to the current policy tag = getattr(self.pyobj, '_annspecialcase_', None) policy = self.bookkeeper.annotator.policy self.specializer = policy.get_specializer(tag) 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 if getattr(self.pyobj, '_annspecialcase_', '').endswith("call_location"): return self.specializer(self, inputcells, op) else: return self.specializer(self, inputcells)
def specialize(self, inputcells, op=None): if (op is None and getattr(self.bookkeeper, "position_key", None) is not None): _, block, i = self.bookkeeper.position_key op = block.operations[i] if self.specializer is None: # get the specializer based on the tag of the 'pyobj' # (if any), according to the current policy tag = getattr(self.pyobj, '_annspecialcase_', None) policy = self.bookkeeper.annotator.policy self.specializer = policy.get_specializer(tag) 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 if getattr(self.pyobj, '_annspecialcase_', '').endswith("call_location"): return self.specializer(self, inputcells, op) else: return self.specializer(self, inputcells)
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 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