Top Description Inners Fields Constructors Methods
org.jruby.runtime

public Class Block

extends Object
implements FunctionOneOrTwoOrThree<ThreadContext, IRubyObject, IRubyObject, IRubyObject>, ThreadContext.RecursiveFunctionEx<IRubyObject>
Class Inheritance
All Implemented Interfaces
org.jruby.runtime.ThreadContext.RecursiveFunctionEx, org.jruby.util.func.FunctionOneOrTwoOrThree, org.jruby.util.func.TriFunction, java.util.function.BiFunction, java.util.function.Function
Imports
java.util.Objects, java.util.function.BiFunction, .Function, org.jruby.EvalType, .RubyModule, .RubyProc, org.jruby.api.Convert, org.jruby.ir.runtime.IRRuntimeHelpers, org.jruby.runtime.ThreadContext.RecursiveFunctionEx, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.func.FunctionOneOrTwoOrThree, .TriFunction

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private final Binding
private final BlockBody
private final Block
escapeBlock

What block to use for determining escape; defaults to this

private boolean
escaped

Whether this block and any clones of it should be considered "escaped"

private final EvalType
public static final Block
NULL_BLOCK

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

private RubyProc
proc

The Proc that this block is associated with.

public final Block.Type

Constructor Summary

AccessConstructor and Description
private
Block(BlockBody body, Binding binding, Block.Type type, Block escapeBlock, EvalType evalType)

public
Block(BlockBody body, Binding binding, Block.Type type)

public
Block(BlockBody body, Binding binding)

public

Method Summary

Modifier and TypeMethod and Description
public DynamicScope
allocScope(DynamicScope parentScope)

public IRubyObject
apply(ThreadContext
the function argument
context
)

Implements java.util.function.Function.apply.

Applies this function to the given argument.

public IRubyObject
apply(ThreadContext
the first function argument
context
,
IRubyObject
the second function argument
arg0
)

Implements java.util.function.BiFunction.apply.

Applies this function to the given arguments.

public IRubyObject
public Arity

Returns:

the arity
arity
()
Deprecated

What is the arity of this block?

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

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

public IRubyObject
public IRubyObject
call(ThreadContext context, Block blockArg)

public IRubyObject
public IRubyObject
call(ThreadContext context, IRubyObject arg0, Block blockArg)

public IRubyObject
public IRubyObject
call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block blockArg)

public IRubyObject
public IRubyObject
call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block blockArg)

public IRubyObject
public Block
public Block
public Block
public Block
public Block
public Block
public Block
public Block
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public void
public Binding
public BlockBody
public EvalType
public Frame

Returns:

Returns a RubyFrame
getFrame
()

Gets the frame.

public RubyModule

Returns:

the binding's frame's self class
getFrameClass
()

Gets the frame class.

public RubyProc

Returns:

the proc or null if this has no proc associated with it
getProcObject
()

Retrieve the proc object associated with this block

public Signature
public Visibility
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public final boolean

Returns:

true if this is a valid block or false otherwise
isGiven
()

Is the current block a real yield'able block instead a null one

private static IRubyObject[]
public void
setProcObject(RubyProc
the proc tu associate
procObject
)

Set the proc object associated with this block

public void
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

bindingback to summary
private final Binding binding
bodyback to summary
private final BlockBody body
escapeBlockback to summary
private final Block escapeBlock

What block to use for determining escape; defaults to this

escapedback to summary
private boolean escaped

Whether this block and any clones of it should be considered "escaped"

evalTypeback to summary
private final EvalType evalType
NULL_BLOCKback to summary
public static final Block NULL_BLOCK

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

procback to summary
private RubyProc proc

The Proc that this block is associated with. When we reference blocks via variable reference they are converted to Proc objects. We store a reference of the associated Proc object for easy conversion.

typeback to summary
public final Block.Type type

Constructor Detail

Blockback to summary
private Block(BlockBody body, Binding binding, Block.Type type, Block escapeBlock, EvalType evalType)
Blockback to summary
public Block(BlockBody body, Binding binding, Block.Type type)
Blockback to summary
public Block(BlockBody body, Binding binding)
Blockback to summary
public Block(BlockBody body)

Method Detail

allocScopeback to summary
public DynamicScope allocScope(DynamicScope parentScope)
applyback to summary
public IRubyObject apply(ThreadContext context)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Parameters
context:ThreadContext

the function argument

Returns:IRubyObject

the function result

Annotations
@Override
See Also
Function#apply(Object)
applyback to summary
public IRubyObject apply(ThreadContext context, IRubyObject arg0)

Implements java.util.function.BiFunction.apply.

Doc from java.util.function.BiFunction.apply.

Applies this function to the given arguments.

Parameters
context:ThreadContext

the first function argument

arg0:IRubyObject

the second function argument

Returns:IRubyObject

the function result

Annotations
@Override
See Also
BiFunction#apply(Object, Object)
applyback to summary
public IRubyObject apply(ThreadContext context, IRubyObject arg0, IRubyObject arg1)

Implements org.jruby.util.func.TriFunction.apply.

Annotations
@Override
See Also
TriFunction#apply(Object, Object, Object)
arityback to summary
public Arity arity()

Deprecated

What is the arity of this block?

Returns:Arity

the arity

Annotations
@Deprecated
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject[] args)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject[] args, Block blockArg)
callback to summary
public IRubyObject call(ThreadContext context)
callback to summary
public IRubyObject call(ThreadContext context, Block blockArg)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject arg0)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject arg0, Block blockArg)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block blockArg)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block blockArg)
callback to summary
public IRubyObject call(ThreadContext context, IRubyObject state, IRubyObject obj, boolean recur)

Implements org.jruby.runtime.ThreadContext.RecursiveFunctionEx.call.

Annotations
@Override
See Also
RecursiveFunctionEx#safeRecurse(RecursiveFunctionEx, Object, IRubyObject, String, boolean)
cloneBlockback to summary
public Block cloneBlock()
cloneBlockAndBindingback to summary
public Block cloneBlockAndBinding()
cloneBlockAndBindingback to summary
public Block cloneBlockAndBinding(EvalType evalType)
cloneBlockAndFrameback to summary
public Block cloneBlockAndFrame()
cloneBlockAndFrameback to summary
public Block cloneBlockAndFrame(EvalType evalType)
cloneBlockAsTypeback to summary
public Block cloneBlockAsType(Block.Type newType)
cloneBlockForEvalback to summary
public Block cloneBlockForEval(IRubyObject self, EvalType evalType)
deepCloneBlockForEvalback to summary
public Block deepCloneBlockForEval(IRubyObject self, EvalType evalType)
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
escapeback to summary
public void escape()
getBindingback to summary
public Binding getBinding()
getBodyback to summary
public BlockBody getBody()
getEvalTypeback to summary
public EvalType getEvalType()
getFrameback to summary
public Frame getFrame()

Gets the frame.

Returns:Frame

Returns a RubyFrame

getFrameClassback to summary
public RubyModule getFrameClass()

Gets the frame class.

Returns:RubyModule

the binding's frame's self class

getProcObjectback to summary
public RubyProc getProcObject()

Retrieve the proc object associated with this block

Returns:RubyProc

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

getSignatureback to summary
public Signature getSignature()
getVisibilityback to summary
public Visibility getVisibility()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isEscapedback to summary
public boolean isEscaped()
isGivenback to summary
public final boolean isGiven()

Is the current block a real yield'able block instead a null one

Returns:boolean

true if this is a valid block or false otherwise

Annotations
@SuppressWarnings:ReferenceEquality
maybeSpreadArgsback to summary
private static IRubyObject[] maybeSpreadArgs(ThreadContext context, IRubyObject[] args, Block block)
setProcObjectback to summary
public void setProcObject(RubyProc procObject)

Set the proc object associated with this block

Parameters
procObject:RubyProc

the proc tu associate

setVisibilityback to summary
public void setVisibility(Visibility vis)
yieldback to summary
public IRubyObject yield(ThreadContext context, IRubyObject value)
yieldArrayback to summary
public IRubyObject yieldArray(ThreadContext context, IRubyObject value, IRubyObject self)
yieldNonArrayback to summary
public IRubyObject yieldNonArray(ThreadContext context, IRubyObject value, IRubyObject self)
yieldSpecificback to summary
public IRubyObject yieldSpecific(ThreadContext context)
yieldSpecificback to summary
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0)
yieldSpecificback to summary
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1)
yieldSpecificback to summary
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2)
yieldValuesback to summary
public IRubyObject yieldValues(ThreadContext context, IRubyObject[] args)
org.jruby.runtime back to summary

public final Enum Block.Type

extends Enum<Block.Type>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public final boolean
public static final Block.Type
public static final Block.Type
public static final Block.Type
public static final Block.Type

Constructor Summary

AccessConstructor and Description
private
Type(boolean checkArity)

Method Summary

Modifier and TypeMethod and Description
public static Block.Type
public static Block.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

checkArityback to summary
public final boolean checkArity
LAMBDAback to summary
public static final Block.Type LAMBDA
NORMALback to summary
public static final Block.Type NORMAL
PROCback to summary
public static final Block.Type PROC
THREADback to summary
public static final Block.Type THREAD

Constructor Detail

Typeback to summary
private Type(boolean checkArity)

Method Detail

valueOfback to summary
public static Block.Type valueOf(String name)
valuesback to summary
public static Block.Type[] values()