1. # Takes a foreign code object and tries to make it feel somewhat like a Perl
  2. # 6 one. Note that it doesn't have signature information we can know about.
  3. my class ForeignCode does Callable { # declared in BOOTSTRAP
  4. # class ForeignCode
  5. # has Code $!do; # Code object we delegate to
  6. method arity() { self.signature.arity }
  7. method count() { self.signature.count }
  8. method signature(ForeignCode:D:) { (sub (|) { }).signature }
  9. method name() { (nqp::can($!do, 'name') ?? $!do.name !! nqp::getcodename($!do)) || '<anon>' }
  10. multi method gist(ForeignCode:D:) { self.name }
  11. multi method Str(ForeignCode:D:) { self.name }
  12. }