org.jruby.runtime
Class MethodBlock

java.lang.Object
  extended byorg.jruby.runtime.Block
      extended byorg.jruby.runtime.MethodBlock

public class MethodBlock
extends Block

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


Field Summary
protected  Frame frame
          frame of method which defined this block
 boolean isLambda
           
 
Fields inherited from class org.jruby.runtime.Block
NULL_BLOCK
 
Constructor Summary
MethodBlock(IRubyObject self, Frame frame, SinglyLinkedList cref, Visibility visibility, RubyModule klass, DynamicScope dynamicScope, Callback callback, RubyMethod method)
           
 
Method Summary
 Arity arity()
          What is the arity of this block?
 IRubyObject call(ThreadContext context, IRubyObject[] args)
           
 Block cloneBlock()
           
static MethodBlock createMethodBlock(ThreadContext context, DynamicScope dynamicScope, Callback callback, RubyMethod method, 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 org.jruby.runtime.Block
createBinding, createBlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frame

protected final Frame frame
frame of method which defined this block


isLambda

public boolean isLambda
Constructor Detail

MethodBlock

public MethodBlock(IRubyObject self,
                   Frame frame,
                   SinglyLinkedList cref,
                   Visibility visibility,
                   RubyModule klass,
                   DynamicScope dynamicScope,
                   Callback callback,
                   RubyMethod method)
Method Detail

createMethodBlock

public static MethodBlock createMethodBlock(ThreadContext context,
                                            DynamicScope dynamicScope,
                                            Callback callback,
                                            RubyMethod method,
                                            IRubyObject self)

call

public IRubyObject call(ThreadContext context,
                        IRubyObject[] args)
Overrides:
call in class Block

pre

protected void pre(ThreadContext context,
                   RubyModule klass)
Overrides:
pre in class Block

post

protected void post(ThreadContext context)
Overrides:
post in class Block

yield

public IRubyObject yield(ThreadContext context,
                         IRubyObject value)
Overrides:
yield in class Block

yield

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

Overrides:
yield in class Block
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()
Overrides:
cloneBlock in class Block

arity

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

Overrides:
arity in class Block
Returns:
the arity

getVisibility

public Visibility getVisibility()
Overrides:
getVisibility in class Block

setVisibility

public void setVisibility(Visibility visibility)
Overrides:
setVisibility in class Block

setSelf

public void setSelf(IRubyObject self)
Overrides:
setSelf in class Block

getCRef

public SinglyLinkedList getCRef()
Overrides:
getCRef in class Block

getProcObject

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

Overrides:
getProcObject in class 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

Overrides:
setProcObject in class 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.

Overrides:
getDynamicScope in class Block
Returns:
Returns all relevent variable scoping information

getFrame

public Frame getFrame()
Gets the frame.

Overrides:
getFrame in class Block
Returns:
Returns a RubyFrame

getKlass

public RubyModule getKlass()
Gets the klass.

Overrides:
getKlass in class Block
Returns:
Returns a RubyModule

isGiven

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

Overrides:
isGiven in class Block
Returns:
true if this is a valid block or false otherwise


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