Package org.jruby.runtime
Class Block
java.lang.Object
org.jruby.runtime.Block
- All Implemented Interfaces:
BiFunction<ThreadContext,,IRubyObject, IRubyObject> Function<ThreadContext,,IRubyObject> FunctionOneOrTwoOrThree<ThreadContext,,IRubyObject, IRubyObject, IRubyObject> TriFunction<ThreadContext,IRubyObject, IRubyObject, IRubyObject>
public class Block
extends Object
implements FunctionOneOrTwoOrThree<ThreadContext,IRubyObject,IRubyObject,IRubyObject>
Internal live representation of a block ({...} or do ... end).
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Bindingprivate final BlockBodyprivate final BlockWhat block to use for determining escape; defaults to thisprivate booleanWhether this block and any clones of it should be considered "escaped"private final EvalTypestatic final BlockAll Block variables should either refer to a real block or this NULL_BLOCK.private RubyProcThe Proc that this block is associated with.final Block.Type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocScope(DynamicScope parentScope) apply(ThreadContext context) apply(ThreadContext context, IRubyObject arg0) apply(ThreadContext context, IRubyObject arg0, IRubyObject arg1) arity()Deprecated.call(ThreadContext context) call(ThreadContext context, Block blockArg) call(ThreadContext context, IRubyObject arg0) call(ThreadContext context, IRubyObject[] args) call(ThreadContext context, IRubyObject[] args, Block blockArg) call(ThreadContext context, IRubyObject arg0, Block blockArg) call(ThreadContext context, IRubyObject arg0, IRubyObject arg1) call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block blockArg) call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block blockArg) cloneBlockAndBinding(EvalType evalType) cloneBlockAndFrame(EvalType evalType) cloneBlockAsType(Block.Type newType) cloneBlockForEval(IRubyObject self, EvalType evalType) deepCloneBlockForEval(IRubyObject self, EvalType evalType) booleanvoidescape()getBody()getFrame()Gets the frame.Retrieve the proc object associated with this blockinthashCode()booleanfinal booleanisGiven()Is the current block a real yield'able block instead a null oneprivate static IRubyObject[]maybeSpreadArgs(ThreadContext context, IRubyObject[] args, Block block) voidsetProcObject(RubyProc procObject) Set the proc object associated with this blockvoidsetVisibility(Visibility vis) yield(ThreadContext context, IRubyObject value) yieldArray(ThreadContext context, IRubyObject value, IRubyObject self) yieldNonArray(ThreadContext context, IRubyObject value, IRubyObject self) yieldSpecific(ThreadContext context) yieldSpecific(ThreadContext context, IRubyObject arg0) yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1) yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) yieldValues(ThreadContext context, IRubyObject[] args) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jruby.util.func.FunctionOneOrTwoOrThree
andThen
-
Field Details
-
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. -
type
-
binding
-
body
-
escaped
private boolean escapedWhether this block and any clones of it should be considered "escaped" -
escapeBlock
What block to use for determining escape; defaults to this -
evalType
-
NULL_BLOCK
All Block variables should either refer to a real block or this NULL_BLOCK.
-
-
Constructor Details
-
Block
private Block(BlockBody body, Binding binding, Block.Type type, Block escapeBlock, EvalType evalType) -
Block
-
Block
-
Block
-
-
Method Details
-
allocScope
-
getEvalType
-
call
-
call
-
call
-
call
-
yieldSpecific
-
call
-
call
-
yieldSpecific
-
call
-
call
-
yieldSpecific
-
call
public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
call
public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block blockArg) -
yieldSpecific
public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
yield
-
apply
- Specified by:
applyin interfaceFunction<ThreadContext,IRubyObject> - See Also:
-
apply
- Specified by:
applyin interfaceBiFunction<ThreadContext,IRubyObject, IRubyObject> - See Also:
-
apply
- Specified by:
applyin interfaceTriFunction<ThreadContext,IRubyObject, IRubyObject, IRubyObject> - See Also:
-
maybeSpreadArgs
private static IRubyObject[] maybeSpreadArgs(ThreadContext context, IRubyObject[] args, Block block) -
yieldNonArray
-
yieldArray
-
yieldValues
-
cloneBlock
-
cloneBlockAsType
-
cloneBlockAndBinding
-
cloneBlockAndBinding
-
cloneBlockAndFrame
-
cloneBlockAndFrame
-
cloneBlockForEval
-
deepCloneBlockForEval
-
arity
Deprecated.What is the arity of this block?- Returns:
- the arity
-
getSignature
-
getProcObject
Retrieve the proc object associated with this block- Returns:
- the proc or null if this has no proc associated with it
-
setProcObject
Set the proc object associated with this block- Parameters:
procObject-
-
isGiven
public final 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
-
getBinding
-
getBody
-
getFrame
Gets the frame.- Returns:
- Returns a RubyFrame
-
isEscaped
public boolean isEscaped() -
escape
public void escape() -
getVisibility
-
setVisibility
-
equals
-
hashCode
public int hashCode()
-