Skip to content

Commit

Permalink
Distinguish between normal clone & ensure-block clone for closures.
Browse files Browse the repository at this point in the history
* It is useful to distinguish between different copies of cloned
  closures in cloned ensure blocks, especialy if the name and closure-id
  are used to index into maps.
  • Loading branch information
subbuss committed Oct 10, 2014
1 parent 7381eb9 commit 1a27cb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRClosure.java
Expand Up @@ -304,7 +304,7 @@ public IRClosure cloneForInlining(CloneInfo ii) {
IRClosure clonedClosure;
IRScope lexicalParent = ii.getScope();

if (ii instanceof SimpleCloneInfo) {
if (ii instanceof SimpleCloneInfo && !((SimpleCloneInfo)ii).isEnsureBlockCloneMode()) {
clonedClosure = new IRClosure(this, lexicalParent, closureId, getName());
} else {
int id = lexicalParent.getNextClosureId();
Expand Down
Expand Up @@ -17,6 +17,10 @@ public SimpleCloneInfo(IRScope scope, boolean isEnsureBlock) {
this.isEnsureBlock = isEnsureBlock;
}

public boolean isEnsureBlockCloneMode() {
return this.isEnsureBlock;
}

public Variable getRenamedVariable(Variable variable) {
Variable renamed = super.getRenamedVariable(variable);

Expand Down Expand Up @@ -47,4 +51,4 @@ protected Variable getRenamedVariableSimple(Variable v) {
public void renameLabel(Label l) {
labelRenameMap.put(l, getScope().getNewLabel());
}
}
}

0 comments on commit 1a27cb4

Please sign in to comment.