1 28 package org.jruby.runtime; 29 30 import org.jruby.RubyModule; 31 import org.jruby.ast.util.ArgsUtil; 32 import org.jruby.runtime.builtin.IRubyObject; 33 34 39 public class CompiledBlock extends Block { 40 private Arity arity; 41 private CompiledBlockCallback callback; 42 private ThreadContext context; 43 private IRubyObject self; 44 private IRubyObject[][] scopes; 45 46 public CompiledBlock(ThreadContext context, IRubyObject self, Arity arity, IRubyObject[][] scopes, CompiledBlockCallback callback) { 47 super(null, 48 null, 49 self, 50 context.getCurrentFrame(), 51 context.peekCRef(), 52 Visibility.PUBLIC, 53 context.getRubyClass(), 54 context.getCurrentScope()); 55 this.arity = arity; 56 this.callback = callback; 57 this.context = context; 58 this.self = self; 59 this.scopes = scopes; 60 } 61 62 public IRubyObject call(ThreadContext context, IRubyObject[] args, IRubyObject replacementSelf) { 63 return callback.call(context, replacementSelf, args, Block.NULL_BLOCK, scopes); 64 } 65 66 public IRubyObject yield(ThreadContext context, IRubyObject args, IRubyObject self, RubyModule klass, boolean aValue) { 67 return callback.call(context, this.self, ArgsUtil.convertToJavaArray(args), Block.NULL_BLOCK, scopes); 68 } 69 70 public Block cloneBlock() { 71 return new CompiledBlock(context, self, arity, scopes, callback); 72 } 73 74 public Arity arity() { 75 return arity; 76 } 77 } 78 | Popular Tags |