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

Commits on Nov 3, 2016

  1. Copy the full SHA
    0fce2a5 View commit details
  2. Copy the full SHA
    2b3e077 View commit details
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ public Object execute(VirtualFrame frame) {

@TruffleBoundary
private Collection<String> getRequiredLibraries() {
return getContext().getJRubyRuntime().getInstanceConfig().getRequiredLibraries();
return getContext().getJRubyInterop().getRequiredLibraries();
}

}
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import java.net.URISyntaxException;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class JRubyInterop {
@@ -65,7 +66,7 @@ private String findJRubyHome() {
}
}

return context.getJRubyRuntime().getJRubyHome();
return jrubyRuntime.getJRubyHome();
}

@TruffleBoundary
@@ -132,4 +133,16 @@ public void setOriginalInputFile(String originalInputFile) {
public String getOriginalInputFile() {
return originalInputFile;
}

public byte[] getInlineScript() {
return jrubyRuntime.getInstanceConfig().inlineScript();
}

public Collection<String> getRequiredLibraries() {
return jrubyRuntime.getInstanceConfig().getRequiredLibraries();
}

public boolean isFrozenStringLiteral() {
return jrubyRuntime.getInstanceConfig().isFrozenStringLiteral();
}
}
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public SourceLoader(RubyContext context) {
@TruffleBoundary
public Source load(String canonicalPath) throws IOException {
if (canonicalPath.equals("-e")) {
return loadFragment(new String(context.getJRubyRuntime().getInstanceConfig().inlineScript(), StandardCharsets.UTF_8), "-e");
return loadFragment(new String(context.getJRubyInterop().getInlineScript(), StandardCharsets.UTF_8), "-e");
} else if (canonicalPath.startsWith(TRUFFLE_SCHEME) || canonicalPath.startsWith(JRUBY_SCHEME)) {
return loadResource(canonicalPath);
} else {
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ public RubyRootNode parse(RubyContext context, Source source, Encoding defaultEn

final org.jruby.truffle.parser.parser.Parser parser = new org.jruby.truffle.parser.parser.Parser(context);

final StaticScopeFactory staticScopeFactory = new StaticScopeFactory(context.getJRubyRuntime());
final StaticScopeFactory staticScopeFactory = new StaticScopeFactory();
final StaticScope staticScope = staticScopeFactory.newLocalScope(null);

/*
@@ -119,7 +119,7 @@ public RubyRootNode parse(RubyContext context, Source source, Encoding defaultEn
boolean isEvalParse = parserContext == ParserContext.EVAL || parserContext == ParserContext.INLINE || parserContext == ParserContext.MODULE;
final ParserConfiguration parserConfiguration = new ParserConfiguration(context.getJRubyRuntime(), 0, isInlineSource, !isEvalParse, false);

if (context.getJRubyRuntime().getInstanceConfig().isFrozenStringLiteral()) {
if (context.getJRubyInterop().isFrozenStringLiteral()) {
parserConfiguration.setFrozenStringLiteral(true);
}

Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ public ParserConfiguration(Ruby runtime, int lineNumber, boolean inlineSource, b
this.lineNumber = lineNumber;
this.isEvalParse = !isFileParse;
this.saveData = saveData;
staticScopeFactory = new StaticScopeFactory(runtime);
staticScopeFactory = new StaticScopeFactory();
}

public ParserConfiguration(Ruby runtime, int lineNumber,
Original file line number Diff line number Diff line change
@@ -83,30 +83,17 @@ public class StaticScope implements Serializable {
// File name where this static scope came from or null if a native or artificial scope
private String file;

private DynamicScope dummyScope;

protected IRScopeType scopeType;

private static final String[] NO_NAMES = new String[0];

private Type type;
private boolean isBlockOrEval;
private boolean isArgumentScope; // Is this block and argument scope of a define_method.

private long commandArgumentStack;

// Method/Closure that this static scope corresponds to. This is used to tell whether this
// scope refers to a method scope or to determined IRScope of the parent of a compiling eval.
private IRScope irScope;

private RubyModule overlayModule;

public enum Type {
LOCAL, BLOCK, EVAL;

public static Type fromOrdinal(int value) {
return value < 0 || value >= values().length ? null : values()[value];
}
}

/**
@@ -144,13 +131,7 @@ protected StaticScope(Type type, StaticScope enclosingScope, String[] names) {
this.enclosingScope = enclosingScope;
this.variableNames = names;
this.type = type;
this.irScope = null;
this.isBlockOrEval = (type != Type.LOCAL);
this.isArgumentScope = !isBlockOrEval;
}

public IRScope getIRScope() {
return irScope;
}

public IRScopeType getScopeType() {
@@ -161,11 +142,6 @@ public void setScopeType(IRScopeType scopeType) {
this.scopeType = scopeType;
}

public void setIRScope(IRScope irScope) {
this.irScope = irScope;
this.scopeType = irScope.getScopeType();
}

/**
* Check that all strings in the given array are the interned versions.
*
@@ -444,34 +420,6 @@ public StaticScope getLocalScope() {
return (type != Type.BLOCK) ? this : enclosingScope.getLocalScope();
}

/**
* Get the live CRef module associated with this scope.
*
* @return the live module
*/
public RubyModule getModule() {
return cref;
}

public StaticScope getPreviousCRefScope() {
return previousCRefScope;
}

public void setPreviousCRefScope(StaticScope crefScope) {
this.previousCRefScope = crefScope;
}

public void setModule(RubyModule module) {
this.cref = module;

for (StaticScope scope = getEnclosingScope(); scope != null; scope = scope.getEnclosingScope()) {
if (scope.cref != null) {
previousCRefScope = scope;
return;
}
}
}

/**
* Update current scoping structure to populate with proper cref scoping values. This should
* be called at any point when you reference a scope for the first time. For the interpreter
@@ -496,18 +444,6 @@ public boolean isBlockScope() {
return isBlockOrEval;
}

/**
* Argument scopes represent scopes which contain arguments for zsuper. All LocalStaticScopes
* are argument scopes and BlockStaticScopes can be when they are used by define_method.
*/
public boolean isArgumentScope() {
return isArgumentScope;
}

public void makeArgumentScope() {
this.isArgumentScope = true;
}

/**
* For all block or method associated with static scopes this will return the signature for that
* signature-providing scope. module bodies and other non-arity specific code will return null.
@@ -523,10 +459,6 @@ public void setSignature(Signature signature) {
this.signature = signature;
}

public DynamicScope getDummyScope() {
return dummyScope == null ? dummyScope = new DummyDynamicScope(this) : dummyScope;
}

public void setCommandArgumentStack(long commandArgumentStack) {
this.commandArgumentStack = commandArgumentStack;
}
@@ -575,28 +507,4 @@ public String getFile() {
return file;
}

public StaticScope duplicate() {
StaticScope dupe = new StaticScope(type, enclosingScope, variableNames == null ? NO_NAMES : variableNames);
// irScope is not guaranteed to be set onto StaticScope until it is executed for the first time.
// We can call duplicate before its first execution.
if (irScope != null) dupe.setIRScope(irScope);
dupe.setScopeType(scopeType);
dupe.setPreviousCRefScope(previousCRefScope);
dupe.setModule(cref);
dupe.setSignature(signature);

return dupe;
}

public RubyModule getOverlayModuleForRead() {
return overlayModule;
}

public RubyModule getOverlayModuleForWrite(ThreadContext context) {
RubyModule omod = overlayModule;
if (omod == null) {
overlayModule = omod = RubyModule.newModule(context.runtime);
}
return omod;
}
}
Original file line number Diff line number Diff line change
@@ -35,9 +35,8 @@
public class StaticScopeFactory {
private final StaticScope dummyScope;

public StaticScopeFactory(Ruby runtime) {
public StaticScopeFactory() {
dummyScope = new StaticScope(StaticScope.Type.LOCAL, null);
dummyScope.setModule(runtime.getObject());
}

public StaticScope newBlockScope(StaticScope parent, String file) {