Ejemplo n.º 1
0
 def record_delegate_standalone_func_impl(self, graph):
     """
     Creates a class with an invoke() method that invokes the given
     graph.  This object can be used as a function pointer.  It
     will extend the appropriate delegate for the graph's
     signature.
     """
     jargtypes, jrettype = self.types_for_graph(graph)
     super_class = self.record_delegate_sig(jargtypes, jrettype)
     pfunc = self.pending_function(graph)
     implnm = self._pkg(self._uniq(graph.name + '_delegate'))
     n = node.StaticMethodImplementation(implnm, super_class, None, pfunc)
     self.pending_node(n)
     return n
Ejemplo n.º 2
0
 def record_delegate_bound_method_impl(self, INSTANCE, method_name):
     """
     Creates an object with an invoke() method which invokes
     a method named method_name on an instance of INSTANCE.
     """
     key = (INSTANCE, method_name)
     if key in self._bound_methods:
         return self._bound_methods[key]
     METH_TYPE = INSTANCE._lookup(method_name)[1]._TYPE
     super_class = self.record_delegate(METH_TYPE)
     self_class = self.lltype_to_cts(INSTANCE)
     mthd_obj = self_class.lookup_method(method_name)
     implnm = self._pkg(self._uniq(
         self_class.simple_name()+"_"+method_name+"_delegate"))
     n = self._bound_methods[key] = node.StaticMethodImplementation(
         implnm, super_class, self_class, mthd_obj)
     self.pending_node(n)
     return n