Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 59bb737cc3f9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 729f1ed5a4f9
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Aug 12, 2016

  1. Revert "Back to a proc again. Le sigh."

    This reverts commit 59bb737.
    headius committed Aug 12, 2016
    Copy the full SHA
    928f272 View commit details
  2. Can't reference Frame.DUMMY due to circular static init.

    Frame has a static DUMMY = new Frame(). This causes Block's static
    init to run, which has a DUMMY = new Block(). This causes
    Binding's static init to run, which has a DUMMY = new Binding that
    uses Frame.DUMMY. But we're still in the static init for Frame, so
    Frame.DUMMY is still null.
    
    Frame.DUMMY is just a utility for other areas, so creating a new
    blank dummy frame for Binding.DUMMY is ok.
    headius committed Aug 12, 2016
    Copy the full SHA
    20210f4 View commit details
  3. Copy the full SHA
    a53773b View commit details
  4. Better toString for Frame.

    headius committed Aug 12, 2016
    Copy the full SHA
    729f1ed View commit details
16 changes: 13 additions & 3 deletions core/src/main/java/org/jruby/runtime/Binding.java
Original file line number Diff line number Diff line change
@@ -49,7 +49,8 @@ public class Binding {
public static final Binding DUMMY =
new Binding(
RubyBasicObject.NEVER,
Frame.DUMMY,
// Can't use Frame.DUMMY because of circular static init seeing it before it's assigned
new Frame(),
Visibility.PUBLIC,
new NoVarsDynamicScope(StaticScopeFactory.newStaticScope(null, StaticScope.Type.BLOCK, null)),
"<dummy>",
@@ -59,7 +60,7 @@ public class Binding {
/**
* frame of method which defined this block
*/
private Frame frame;
private final Frame frame;

public String method;
public String filename;
@@ -74,7 +75,7 @@ public class Binding {
/**
* A reference to all variable values (and names) that are in-scope for this block.
*/
private DynamicScope dynamicScope;
private final DynamicScope dynamicScope;

/**
* Binding-local scope for 1.9 mode.
@@ -94,6 +95,7 @@ public class Binding {

public Binding(IRubyObject self, Frame frame,
Visibility visibility, DynamicScope dynamicScope, String method, String filename, int line) {
assert frame != null;
this.self = self;
this.frame = frame;
this.visibility = visibility;
@@ -105,6 +107,7 @@ public Binding(IRubyObject self, Frame frame,

private Binding(IRubyObject self, Frame frame,
Visibility visibility, DynamicScope dynamicScope, String method, String filename, int line, DynamicScope dummyScope) {
assert frame != null;
this.self = self;
this.frame = frame;
this.visibility = visibility;
@@ -116,6 +119,7 @@ private Binding(IRubyObject self, Frame frame,
}

public Binding(Frame frame, DynamicScope dynamicScope, String method, String filename, int line) {
assert frame != null;
this.self = frame.getSelf();
this.frame = frame;
this.visibility = frame.getVisibility();
@@ -127,22 +131,28 @@ public Binding(Frame frame, DynamicScope dynamicScope, String method, String fil

public Binding(IRubyObject self) {
this.self = self;
this.frame = Frame.DUMMY;
this.dynamicScope = null;
}

public Binding(IRubyObject self, Frame frame,
Visibility visibility) {
assert frame != null;
this.self = self;
this.frame = frame;
this.visibility = visibility;
this.dynamicScope = null;
}

public Binding(IRubyObject self, DynamicScope dynamicScope) {
this.self = self;
this.frame = Frame.DUMMY;
this.dynamicScope = dynamicScope;
}

public Binding(IRubyObject self, Frame frame,
Visibility visibility, DynamicScope dynamicScope) {
assert frame != null;
this.self = self;
this.frame = frame;
this.visibility = visibility;
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/runtime/Frame.java
Original file line number Diff line number Diff line change
@@ -333,9 +333,11 @@ public boolean isCaptured() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder(50);


sb.append("Frame<");
sb.append(klazz);
if (name != null) sb.append(" in ").append(name);
sb.append(">");

return sb.toString();
}
3 changes: 1 addition & 2 deletions core/src/main/ruby/jruby/kernel/hash.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Hash
def to_proc
this_hash = self
proc {|*a| this_hash[*a]}
method(:[]).to_proc
end
end
1 change: 1 addition & 0 deletions spec/tags/ruby/core/hash/to_proc_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Hash#to_proc the returned proc is not a lambda