def fold(self): if hasattr(self, "_fold"): return self._fold global lltype # <- lazy import hack, worth an XXX from rpython.rtyper.lltypesystem import lltype if self.canrun: from rpython.rtyper.lltypesystem.opimpl import get_op_impl op_impl = get_op_impl(self.opname) else: error = TypeError("cannot constant-fold operation %r" % ( self.opname,)) def op_impl(*args): raise error # cache the implementation function into 'self' self._fold = op_impl return op_impl
def test_canfold_opimpl_complete(): for opname, llop in LL_OPERATIONS.items(): assert opname == llop.opname if llop.canfold: func = opimpl.get_op_impl(opname) assert callable(func)