org.jruby.runtime
Class Block

java.lang.Object
  extended byorg.jruby.runtime.Block
Direct Known Subclasses:
CallBlock, CompiledBlock, MethodBlock, SharedScopeBlock

public class Block
extends java.lang.Object

Internal live representation of a block ({...} or do ... end).


Field Summary
protected  Arity arity
           
protected  SinglyLinkedList cref
           
protected  DynamicScope dynamicScope
          A reference to all variable values (and names) that are in-scope for this block.
protected  Frame frame
          frame of method which defined this block
 boolean isLambda
           
protected  RubyModule klass
           
static Block NULL_BLOCK
          All Block variables should either refer to a real block or this NULL_BLOCK.
protected  IRubyObject self
          'self' at point when the block is defined
protected  Visibility visibility
           
 
Constructor Summary
protected Block()
           
  Block(IterNode iterNode, IRubyObject self, Frame frame, SinglyLinkedList cref, Visibility visibility, RubyModule klass, DynamicScope dynamicScope)
           
 
Method Summary
 Arity arity()
          What is the arity of this block?
 IRubyObject call(ThreadContext context, IRubyObject[] args)
           
 Block cloneBlock()
           
static Block createBinding(Frame frame, DynamicScope dynamicScope)
           
static Block createBlock(ThreadContext context, IterNode iterNode, DynamicScope dynamicScope, IRubyObject self)
           
 SinglyLinkedList getCRef()
           
 DynamicScope getDynamicScope()
          Gets the dynamicVariables that are local to this block.
 Frame getFrame()
          Gets the frame.
 RubyModule getKlass()
          Gets the klass.
 RubyProc getProcObject()
          Retrieve the proc object associated with this block
 Visibility getVisibility()
           
 boolean isGiven()
          Is the current block a real yield'able block instead a null one
protected  void post(ThreadContext context)
           
protected  void pre(ThreadContext context, RubyModule klass)
           
 void setProcObject(RubyProc procObject)
          Set the proc object associated with this block
 void setSelf(IRubyObject self)
           
 void setVisibility(Visibility visibility)
           
 IRubyObject yield(ThreadContext context, IRubyObject value)
           
 IRubyObject yield(ThreadContext context, IRubyObject value, IRubyObject self, RubyModule klass, boolean aValue)
          Yield to this block, usually passed to the current call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_BLOCK

public static final Block NULL_BLOCK
All Block variables should either refer to a real block or this NULL_BLOCK.


self

protected IRubyObject self
'self' at point when the block is defined


frame

protected Frame frame
frame of method which defined this block


cref

protected SinglyLinkedList cref

visibility

protected Visibility visibility

klass

protected RubyModule klass

dynamicScope

protected DynamicScope dynamicScope
A reference to all variable values (and names) that are in-scope for this block.


isLambda

public boolean isLambda

arity

protected Arity arity
Constructor Detail

Block

protected Block()

Block

public Block(IterNode iterNode,
             IRubyObject self,
             Frame frame,
             SinglyLinkedList cref,
             Visibility visibility,
             RubyModule klass,
             DynamicScope dynamicScope)
Method Detail

createBlock

public static Block createBlock(ThreadContext context,
                                IterNode iterNode,
                                DynamicScope dynamicScope,
                                IRubyObject self)

createBinding

public static Block createBinding(Frame frame,
                                  DynamicScope dynamicScope)

call

public IRubyObject call(ThreadContext context,
                        IRubyObject[] args)

pre

protected void pre(ThreadContext context,
                   RubyModule klass)

post

protected void post(ThreadContext context)

yield

public IRubyObject yield(ThreadContext context,
                         IRubyObject value)

yield

public IRubyObject yield(ThreadContext context,
                         IRubyObject value,
                         IRubyObject self,
                         RubyModule klass,
                         boolean aValue)
Yield to this block, usually passed to the current call.

Parameters:
context - represents the current thread-specific data
value - The value to yield, either a single value or an array of values
self - The current self
klass -
aValue - Should value be arrayified or not?
Returns:

cloneBlock

public Block cloneBlock()

arity

public Arity arity()
What is the arity of this block?

Returns:
the arity

getVisibility

public Visibility getVisibility()

setVisibility

public void setVisibility(Visibility visibility)

setSelf

public void setSelf(IRubyObject self)

getCRef

public SinglyLinkedList getCRef()

getProcObject

public RubyProc getProcObject()
Retrieve the proc object associated with this block

Returns:
the proc or null if this has no proc associated with it

setProcObject

public void setProcObject(RubyProc procObject)
Set the proc object associated with this block

Parameters:
procObject -

getDynamicScope

public DynamicScope getDynamicScope()
Gets the dynamicVariables that are local to this block. Parent dynamic scopes are also accessible via the current dynamic scope.

Returns:
Returns all relevent variable scoping information

getFrame

public Frame getFrame()
Gets the frame.

Returns:
Returns a RubyFrame

getKlass

public RubyModule getKlass()
Gets the klass.

Returns:
Returns a RubyModule

isGiven

public boolean isGiven()
Is the current block a real yield'able block instead a null one

Returns:
true if this is a valid block or false otherwise


Copyright © 2002-2007 JRuby Team. All Rights Reserved.