1 31 package org.jruby.internal.runtime.methods; 32 33 import org.jruby.RubyModule; 34 import org.jruby.runtime.Arity; 35 import org.jruby.runtime.Block; 36 import org.jruby.runtime.ThreadContext; 37 import org.jruby.runtime.builtin.IRubyObject; 38 39 43 public class AliasMethod extends DynamicMethod { 44 private DynamicMethod oldMethod; 45 private String oldName; 46 47 51 public AliasMethod(DynamicMethod oldMethod, String oldName) { 52 super(oldMethod.getImplementationClass(), oldMethod.getVisibility()); 53 54 this.oldName = oldName; 55 this.oldMethod = oldMethod; 56 } 57 58 public String getOriginalName() { 59 return oldName; 60 } 61 62 public void preMethod(ThreadContext context, RubyModule clazz, IRubyObject self, String name, IRubyObject[] args, boolean noSuper, Block block) { 63 } 64 65 public void postMethod(ThreadContext context) { 66 } 67 68 public IRubyObject internalCall(ThreadContext context, RubyModule clazz, IRubyObject self, String name, IRubyObject[] args, boolean noSuper, Block block) { 69 assert false; 70 return null; 71 } 72 73 public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, boolean noSuper, Block block) { 74 return oldMethod.call(context, self, clazz, name, args, noSuper, block); 75 } 76 77 public DynamicMethod dup() { 78 return new AliasMethod(oldMethod, oldName); 79 } 80 81 public boolean needsImplementer() { 82 return oldMethod.needsImplementer(); 83 } 84 85 public Arity getArity(){ 86 return oldMethod.getArity(); 87 } 88 } 89 | Popular Tags |