1 28 package org.jruby.runtime; 29 30 import org.jruby.RubyModule; 31 import org.jruby.ast.Node; 32 import org.jruby.runtime.builtin.IRubyObject; 33 import org.jruby.util.collections.SinglyLinkedList; 34 35 42 public class ForBlock extends Block { 43 private ForBlock(Node varNode, ICallable method, IRubyObject self, Frame frame, 44 SinglyLinkedList cref, Visibility visibility, RubyModule klass, 45 DynamicScope dynamicScope) { 46 super(varNode, method, self, frame, cref, visibility, klass, dynamicScope); 47 } 48 49 public static Block createBlock(ThreadContext context, Node varNode, DynamicScope dynamicScope, 50 ICallable method, IRubyObject self) { 51 return new ForBlock(varNode, method, self, 52 context.getCurrentFrame(), 53 context.peekCRef(), 54 context.getCurrentFrame().getVisibility(), 55 context.getRubyClass(), 56 dynamicScope); 57 } 58 59 protected void pre(ThreadContext context, RubyModule klass) { 60 context.preForBlock(this, klass); 61 } 62 63 public IRubyObject call(ThreadContext context, IRubyObject[] args, IRubyObject replacementSelf) { 64 return yield(context, context.getRuntime().newArrayNoCopy(args), null, null, true); 65 } 66 67 public Block cloneBlock() { 68 return this; 69 } 70 } 71 | Popular Tags |