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: a30c5372203a
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 17c67a636cd8
Choose a head ref
  • 2 commits
  • 11 files changed
  • 1 contributor

Commits on Dec 2, 2014

  1. Clean up block cloning for instance_eval and friends.

    Conflicts:
    	core/src/main/java/org/jruby/RubyBasicObject.java
    	core/src/main/java/org/jruby/RubySymbol.java
    headius committed Dec 2, 2014
    Copy the full SHA
    f568e2e View commit details
  2. Copy the full SHA
    17c67a6 View commit details
6 changes: 1 addition & 5 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -1597,11 +1597,7 @@ protected IRubyObject yieldUnder(final ThreadContext context, RubyModule under,

private Block setupBlock(Block block) {
// FIXME: This is an ugly hack to resolve JRUBY-1381; I'm not proud of it
block = block.cloneBlock();
block.getBinding().setSelf(this);
block.getBinding().getFrame().setSelf(this);

return block;
return block.cloneBlockForEval(this);
}

/**
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/RubySymbol.java
Original file line number Diff line number Diff line change
@@ -488,11 +488,6 @@ public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyO
return site.call(context, arg0, arg0, arg1, arg2);
}

@Override
public Block cloneBlock(Binding binding) {
return new Block(this, binding);
}

public String getFile() {
return symbol;
}
14 changes: 14 additions & 0 deletions core/src/main/java/org/jruby/runtime/Block.java
Original file line number Diff line number Diff line change
@@ -190,6 +190,20 @@ public Block cloneBlockAndFrame() {
return newBlock;
}

public Block cloneBlockForEval(IRubyObject self) {
Binding newBinding = new Binding(self, binding.getFrame().duplicate(), binding.getVisibility(), binding.getKlass(), binding.getDynamicScope(), binding.getBacktrace());

Block block = new Block(body, newBinding);

block.type = type;
block.escapeBlock = this;

block.getBinding().setSelf(self);
block.getBinding().getFrame().setSelf(self);

return block;
}

/**
* What is the arity of this block?
*
4 changes: 1 addition & 3 deletions core/src/main/java/org/jruby/runtime/BlockBody.java
Original file line number Diff line number Diff line change
@@ -157,8 +157,6 @@ public IRubyObject yieldSpecific(ThreadContext context, IRubyObject arg0, IRubyO
public abstract StaticScope getStaticScope();
public abstract void setStaticScope(StaticScope newScope);

public abstract Block cloneBlock(Binding binding);

/**
* What is the arity of this block?
*
@@ -284,4 +282,4 @@ public IRubyObject newArgsArrayFromArgsWithoutUnbox(IRubyObject[] args, ThreadCo
}
return value;
}
}
}
4 changes: 0 additions & 4 deletions core/src/main/java/org/jruby/runtime/CallBlock.java
Original file line number Diff line number Diff line change
@@ -119,10 +119,6 @@ public void setStaticScope(StaticScope newScope) {
// ignore
}

public Block cloneBlock(Binding binding) {
return new Block(this, binding.clone());
}

public Arity arity() {
return arity;
}
4 changes: 0 additions & 4 deletions core/src/main/java/org/jruby/runtime/CallBlock19.java
Original file line number Diff line number Diff line change
@@ -118,10 +118,6 @@ public void setStaticScope(StaticScope newScope) {
// ignore
}

public Block cloneBlock(Binding binding) {
return new Block(this, binding.clone());
}

public Arity arity() {
return arity;
}
Original file line number Diff line number Diff line change
@@ -52,9 +52,4 @@ private CompiledSharedScopeBlock(Arity arity, DynamicScope containingScope, Comp
protected Frame pre(ThreadContext context, RubyModule klass, Binding binding) {
return context.preForBlock(binding, klass);
}

@Override
public Block cloneBlock(Binding binding) {
return new Block(this, binding);
}
}
Original file line number Diff line number Diff line change
@@ -40,12 +40,4 @@ public void setStaticScope(StaticScope newScope) {
public Arity arity() {
return arity;
}

public Block cloneBlock(Binding binding) {
// We clone dynamic scope because this will be a new instance of a block. Any previously
// captured instances of this block may still be around and we do not want to start
// overwriting those values when we create a new one.
// ENEBO: Once we make self, lastClass, and lastMethod immutable we can remove duplicate
return new Block(this, binding.clone());
}
}
Original file line number Diff line number Diff line change
@@ -97,11 +97,6 @@ public StaticScope getStaticScope() {
public void setStaticScope(StaticScope newScope) {
}

@Override
public Block cloneBlock(Binding binding) {
return new Block(this, binding);
}

@Override
public Arity arity() {
return arity;
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/runtime/NullBlockBody.java
Original file line number Diff line number Diff line change
@@ -67,11 +67,6 @@ public StaticScope getStaticScope() {
public void setStaticScope(StaticScope newScope) {
}

@Override
public Block cloneBlock(Binding binding) {
return null;
}

@Override
public Arity arity() {
return null;
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/runtime/SharedScopeBlock.java
Original file line number Diff line number Diff line change
@@ -58,9 +58,4 @@ protected Frame pre(ThreadContext context, RubyModule klass, Binding binding) {
public IRubyObject call(ThreadContext context, IRubyObject[] args, IRubyObject replacementSelf, Binding binding, Block.Type type) {
return yield(context, newArgsArrayFromArgsWithoutUnbox(args, context), null, null, true, binding, type);
}

@Override
public Block cloneBlock(Binding binding) {
return new Block(this, binding);
}
}