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

Commits on Jul 17, 2017

  1. Copy the full SHA
    61c7517 View commit details

Commits on Jul 18, 2017

  1. Copy the full SHA
    03c9565 View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -680,7 +680,7 @@ public IRubyObject runWithGetsLoop(RootNode scriptNode, boolean printing, boolea

// we do pre and post load outside the "body" versions to pre-prepare
// and pre-push the dynamic scope we need for lastline
Helpers.preLoad(context, ((RootNode) scriptNode).getStaticScope().getVariables());
Helpers.preLoad(context, scriptNode.getStaticScope().getVariableSymbols());

try {
if (script != null) {
9 changes: 1 addition & 8 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -674,9 +674,6 @@ public void buildAssignment(Node node, Variable rhsVal) {
case CLASSVARASGNNODE:
addInstr(new PutClassVariableInstr(classVarDefinitionContainer(), ((ClassVarAsgnNode)node).getName(), rhsVal));
break;
case CLASSVARDECLNODE:
addInstr(new PutClassVariableInstr(classVarDeclarationContainer(), ((ClassVarDeclNode)node).getName(), rhsVal));
break;
case CONSTDECLNODE:
buildConstDeclAssignment((ConstDeclNode) node, rhsVal);
break;
@@ -771,11 +768,6 @@ public void buildBlockArgsAssignment(Node node, Operand argsArray, int argIndex,
receiveBlockArg(v, argsArray, argIndex, isSplat);
addInstr(new PutClassVariableInstr(classVarDefinitionContainer(), ((ClassVarAsgnNode)node).getName(), v));
break;
case CLASSVARDECLNODE:
v = createTemporaryVariable();
receiveBlockArg(v, argsArray, argIndex, isSplat);
addInstr(new PutClassVariableInstr(classVarDeclarationContainer(), ((ClassVarDeclNode)node).getName(), v));
break;
case CONSTDECLNODE:
v = createTemporaryVariable();
receiveBlockArg(v, argsArray, argIndex, isSplat);
@@ -1421,6 +1413,7 @@ public Operand buildClassVarAsgn(final ClassVarAsgnNode classVarAsgnNode) {
return val;
}

@Deprecated
public Operand classVarDeclarationContainer() {
return classVarContainer(true);
}
10 changes: 0 additions & 10 deletions core/src/main/java/org/jruby/ir/IRClosure.java
Original file line number Diff line number Diff line change
@@ -243,11 +243,6 @@ protected LocalVariable findExistingLocalVariable(RubySymbol name, int scopeDept
return lvar;
}

@Override
protected LocalVariable findExistingLocalVariable(String name, int scopeDepth) {
return findExistingLocalVariable(getManager().getRuntime().newSymbol(name), scopeDepth);
}

@Deprecated
public LocalVariable getNewLocalVariable(String name, int depth) {
return getNewLocalVariable(getManager().getRuntime().newSymbol(name), depth);
@@ -279,11 +274,6 @@ public LocalVariable getNewLocalVariable(RubySymbol name, int depth) {
}
}

@Override
public LocalVariable getLocalVariable(String name, int depth) {
return getLocalVariable(getManager().getRuntime().newSymbol(name), depth);
}

public LocalVariable getLocalVariable(RubySymbol name, int depth) {
// AST doesn't seem to be implementing shadowing properly and sometimes
// has the wrong depths which screws up variable access. So, we implement
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/ir/IRMethod.java
Original file line number Diff line number Diff line change
@@ -64,11 +64,6 @@ protected LocalVariable findExistingLocalVariable(RubySymbol name, int scopeDept
return super.findExistingLocalVariable(name, scopeDepth);
}

@Override
protected LocalVariable findExistingLocalVariable(String name, int scopeDepth) {
return findExistingLocalVariable(getManager().getRuntime().newSymbol(name), scopeDepth);
}

@Override
public LocalVariable getLocalVariable(RubySymbol name, int scopeDepth) {
LocalVariable lvar = findExistingLocalVariable(name, scopeDepth);
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/LocalVariable.java
Original file line number Diff line number Diff line change
@@ -45,6 +45,10 @@ public int getLocation() {
return offset;
}

public RubySymbol getSymbol() {
return name;
}

@Override
public String getName() {
return name.asJavaString();
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ protected Variable getRenamedVariableSimple(Variable v) {
if (v instanceof LocalVariable) {
LocalVariable lv = (LocalVariable) v;
int depth = lv.getScopeDepth();
return getHostScope().getLocalVariable(lv.getName(), depth > 1 ? depth - 1 : 0);
return getHostScope().getLocalVariable(lv.getSymbol(), depth > 1 ? depth - 1 : 0);
}

return getHostScope().createTemporaryVariable();
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -1470,6 +1470,14 @@ public static IRubyObject stringOrNil(ByteList value, ThreadContext context) {
return RubyString.newStringShared(context.runtime, value);
}

public static StaticScope preLoad(ThreadContext context, RubySymbol[] varNames) {
StaticScope staticScope = context.runtime.getStaticScopeFactory().newLocalScope(null, varNames);
preLoadCommon(context, staticScope, false);

return staticScope;
}

@Deprecated
public static StaticScope preLoad(ThreadContext context, String[] varNames) {
StaticScope staticScope = context.runtime.getStaticScopeFactory().newLocalScope(null, varNames);
preLoadCommon(context, staticScope, false);