1 30 package org.jruby.internal.runtime.methods; 31 32 import org.jruby.ast.Node; 33 import org.jruby.evaluator.EvaluationState; 34 import org.jruby.runtime.Arity; 35 import org.jruby.runtime.Block; 36 import org.jruby.runtime.ICallable; 37 import org.jruby.runtime.ThreadContext; 38 import org.jruby.runtime.builtin.IRubyObject; 39 40 44 public class EvaluateCallable extends AbstractCallable { 45 private final Node node; 46 private final Arity arity; 47 48 private EvaluateCallable(Node node, Arity arity) { 49 this.node = node; 50 this.arity = arity; 51 } 52 53 public EvaluateCallable(Node node, Node vars) { 54 this(node, Arity.procArityOf(vars)); 55 } 56 57 public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) { 58 return EvaluationState.eval(context.getRuntime(), context, node, self, block); 59 } 60 61 public Node getNode() { 62 return node; 63 } 64 65 public Arity getArity() { 66 return arity; 67 } 68 69 public ICallable dup() { 70 return new EvaluateCallable(node, arity); 71 } 72 } 73 | Popular Tags |