Top Description Fields Constructors Methods
org.jruby.runtime

public Class Binding

extends Object
Class Inheritance
Imports
org.jruby.Ruby, .RubyBasicObject, org.jruby.runtime.backtrace.BacktraceElement, org.jruby.parser.StaticScope, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.scope.ManyVarsDynamicScope

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

Field Summary

Modifier and TypeField and Description
public static final Binding
DUMMY

Deprecated
private DynamicScope
private final DynamicScope
dynamicScope

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

private DynamicScope
evalScope

Binding-local scope for 1.9 mode.

private Binding
evalScopeBinding

Location of eval scope.

public String
private final Frame
frame

frame of method which defined this block

public int
public String
private IRubyObject
self

'self' at point when the block is defined

private Visibility

Constructor Summary

AccessConstructor and Description
public
Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope, String method, String filename, int line)

private
Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope, String method, String filename, int line, DynamicScope dummyScope)

public
Binding(Frame frame, DynamicScope dynamicScope, String method, String filename, int line)

public
public
Binding(IRubyObject self, Frame frame, Visibility visibility)

public
Binding(IRubyObject self, DynamicScope dynamicScope)

public
Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope)

private
public
Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope, BacktraceElement backtrace)
Deprecated

public
Binding(Frame frame, DynamicScope dynamicScope, BacktraceElement backtrace)
Deprecated

Method Summary

Modifier and TypeMethod and Description
public Binding

Returns:

a new cloned Binding
clone
()

Overrides java.lang.Object.clone.

Clone the binding.

public Binding

Returns:

a new Binding with shared eval context
cloneForEval
()

Clone the binding, but maintain a reference to the original "eval binding" to continue sharing eval context.

public Binding

Returns:

the duplicated binding
dup
(ThreadContext
the current thread context
context
)

Duplicate this binding and setup the proper cloned instance of the eval scope so that any previously captured variables still exist but are not shared with the original binding.

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 BacktraceElement
getBacktrace()
Deprecated

public DynamicScope
public DynamicScope

Returns:

Returns all relevant variable scoping information
getDynamicScope
()

Gets the dynamicVariables that are local to this block.

public final DynamicScope
getEvalScope(Ruby runtime)

public String
public Frame

Returns:

Returns a RubyFrame
getFrame
()

Gets the frame.

public int
public String
public IRubyObject
public Visibility
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
setFile(String filename)

public void
setLine(int line)

public void
setMethod(String method)

public void
public void
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

DUMMYback to summary
public static final Binding DUMMY

Deprecated

Annotations
@Deprecated
dummyScopeback to summary
private DynamicScope dummyScope
dynamicScopeback to summary
private final DynamicScope dynamicScope

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

evalScopeback to summary
private DynamicScope evalScope

Binding-local scope for 1.9 mode.

evalScopeBindingback to summary
private Binding evalScopeBinding

Location of eval scope. Because bindings are usually cloned before used for eval, we indirect the reference of the eval scope through another Binding reference, allowing us to share the same eval scope across multiple cloned Binding instances.

filenameback to summary
public String filename
frameback to summary
private final Frame frame

frame of method which defined this block

lineback to summary
public int line
methodback to summary
public String method
selfback to summary
private IRubyObject self

'self' at point when the block is defined

visibilityback to summary
private Visibility visibility

Constructor Detail

Bindingback to summary
public Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope, String method, String filename, int line)
Bindingback to summary
private Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope, String method, String filename, int line, DynamicScope dummyScope)
Bindingback to summary
public Binding(Frame frame, DynamicScope dynamicScope, String method, String filename, int line)
Bindingback to summary
public Binding(IRubyObject self)
Bindingback to summary
public Binding(IRubyObject self, Frame frame, Visibility visibility)
Bindingback to summary
public Binding(IRubyObject self, DynamicScope dynamicScope)
Bindingback to summary
public Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope)
Bindingback to summary
private Binding(Binding other)
Bindingback to summary
public Binding(IRubyObject self, Frame frame, Visibility visibility, DynamicScope dynamicScope, BacktraceElement backtrace)

Deprecated

Annotations
@Deprecated
Bindingback to summary
public Binding(Frame frame, DynamicScope dynamicScope, BacktraceElement backtrace)

Deprecated

Annotations
@Deprecated

Method Detail

cloneback to summary
public Binding clone()

Overrides java.lang.Object.clone.

Clone the binding. The frame will be duplicated, and eval context will point to the new binding, but other fields will be copied as-is.

Returns:Binding

a new cloned Binding

cloneForEvalback to summary
public Binding cloneForEval()

Clone the binding, but maintain a reference to the original "eval binding" to continue sharing eval context.

Returns:Binding

a new Binding with shared eval context

dupback to summary
public Binding dup(ThreadContext context)

Duplicate this binding and setup the proper cloned instance of the eval scope so that any previously captured variables still exist but are not shared with the original binding.

Parameters
context:ThreadContext

the current thread context

Returns:Binding

the duplicated binding

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
getBacktraceback to summary
public BacktraceElement getBacktrace()

Deprecated

Annotations
@Deprecated
getDummyScopeback to summary
public DynamicScope getDummyScope(StaticScope staticScope)
getDynamicScopeback to summary
public DynamicScope getDynamicScope()

Gets the dynamicVariables that are local to this block. Parent dynamic scopes are also accessible via the current dynamic scope.

Returns:DynamicScope

Returns all relevant variable scoping information

getEvalScopeback to summary
public final DynamicScope getEvalScope(Ruby runtime)
getFileback to summary
public String getFile()
getFrameback to summary
public Frame getFrame()

Gets the frame.

Returns:Frame

Returns a RubyFrame

getLineback to summary
public int getLine()
getMethodback to summary
public String getMethod()
getSelfback to summary
public IRubyObject getSelf()
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
setFileback to summary
public void setFile(String filename)
setLineback to summary
public void setLine(int line)
setMethodback to summary
public void setMethod(String method)
setSelfback to summary
public void setSelf(IRubyObject self)
setVisibilityback to summary
public void setVisibility(Visibility visibility)