1 31 package org.jruby.internal.runtime.methods; 32 33 import org.jruby.Ruby; 34 import org.jruby.RubyModule; 35 import org.jruby.RubyProc; 36 import org.jruby.runtime.Arity; 37 import org.jruby.runtime.Block; 38 import org.jruby.runtime.ThreadContext; 39 import org.jruby.runtime.Visibility; 40 import org.jruby.runtime.builtin.IRubyObject; 41 42 46 public class ProcMethod extends DynamicMethod { 47 private RubyProc proc; 48 49 53 public ProcMethod(RubyModule implementationClass, RubyProc proc, Visibility visibility) { 54 super(implementationClass, visibility); 55 this.proc = proc; 56 } 57 58 public void preMethod(ThreadContext context, RubyModule klazz, IRubyObject self, String name, IRubyObject[] args, boolean noSuper, Block block) { 60 context.preMethodCall(implementationClass, klazz, self, name, args, block, noSuper); 61 } 62 63 public void postMethod(ThreadContext context) { 64 context.postMethodCall(); 65 } 66 67 70 public IRubyObject internalCall(ThreadContext context, RubyModule klazz, IRubyObject self, String name, IRubyObject[] args, boolean noSuper, Block block) { 71 return proc.call(args, self, Block.NULL_BLOCK); 72 } 73 74 public DynamicMethod dup() { 75 return new ProcMethod(getImplementationClass(), proc, getVisibility()); 76 } 77 78 public Arity getArity() { 79 return proc.getBlock().arity(); 80 } 81 } 82 | Popular Tags |