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

Commits on May 27, 2015

  1. 2
    Copy the full SHA
    19b64ac View commit details
  2. 1
    Copy the full SHA
    47dc1aa View commit details
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -155,6 +155,8 @@ public class Options {
public static final Option<Boolean> TRUFFLE_RANDOMIZE_STORAGE_ARRAY = bool(TRUFFLE, "truffle.randomize_storage.array", false, "Randomize Array storage strategy.");
public static final Option<Integer> TRUFFLE_RANDOMIZE_SEED = integer(TRUFFLE, "truffle.randomize.seed", 0, "Seed for any randomization.");

public static final Option<Boolean> TRUFFLE_REQUIRE_SHOW_RESOLUTION = bool(TRUFFLE, "truffle.require.show_resolution", false, "So what files require statements resolve to.");

public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_DISPLAY_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.display_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.MRI, "How to format backtraces displayed to the user.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_DEBUG_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.debug_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.DEBUG, "How to format backtraces displayed using TruffleDebug.dump_call_stack.");
public static final Option<TruffleContextInterface.BacktraceFormatter> TRUFFLE_BACKTRACE_EXCEPTION_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.exception_format", TruffleContextInterface.BacktraceFormatter.class, TruffleContextInterface.BacktraceFormatter.MRI, "How to format backtraces in Exception objects.");
Original file line number Diff line number Diff line change
@@ -319,6 +319,10 @@ public Object instanceEval(ByteList code, Object self, Node currentNode) {
return instanceEval(code, self, "(eval)", currentNode);
}

public Object eval(Source source) {
return execute(source, UTF8Encoding.INSTANCE, TranslatorDriver.ParserContext.EVAL, getCoreLibrary().getMainObject(), null, null, NodeWrapper.IDENTITY);
}

@TruffleBoundary
public Object eval(String code, RubyBinding binding, boolean ownScopeForAssignments, String filename, Node currentNode) {
return eval(ByteList.create(code), binding, ownScopeForAssignments, filename, currentNode);
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import org.jruby.truffle.runtime.RubyConstant;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.util.cli.Options;

import java.io.File;
import java.io.IOException;
@@ -29,6 +30,8 @@
*/
public class FeatureManager {

private final boolean SHOW_RESOLUTION = true;//Options.TRUFFLE_REQUIRE_SHOW_RESOLUTION.load();

private final RubyContext context;

private Source mainScriptSource = null;
@@ -38,6 +41,8 @@ public FeatureManager(RubyContext context) {
this.context = context;
}

// TODO CS 27-May-15 we should do lookup in one phase, returning a path, and then do the load

public boolean require(String feature, Node currentNode) throws IOException {
final RubyConstant dataConstantBefore = ModuleOperations.lookupConstant(context, LexicalScope.NONE, context.getCoreLibrary().getObjectClass(), "DATA");

@@ -76,11 +81,11 @@ public boolean require(String feature, Node currentNode) throws IOException {
private boolean requireInPath(String path, String feature, Node currentNode) throws IOException {
String fullPath = new File(path, feature).getPath();

if (requireFile(fullPath, currentNode)) {
if (requireFile(feature, fullPath, currentNode)) {
return true;
}

if (requireFile(fullPath + ".rb", currentNode)) {
if (requireFile(feature, fullPath + ".rb", currentNode)) {
return true;
}

@@ -91,7 +96,7 @@ public boolean isAbsolutePath(String path) {
return path.startsWith("uri:classloader:") || path.startsWith("core:") || new File(path).isAbsolute();
}

private boolean requireFile(String path, Node currentNode) throws IOException {
private boolean requireFile(String feature, String path, Node currentNode) throws IOException {
// We expect '/' in various classpath URLs, so normalize Windows file paths to use '/'
path = path.replace('\\', '/');

@@ -112,6 +117,10 @@ private boolean requireFile(String path, Node currentNode) throws IOException {
return false;
}

if (SHOW_RESOLUTION) {
System.err.printf("resolved %s -> %s\n", feature, coreFileName);
}

context.getCoreLibrary().loadRubyCore(coreFileName, "uri:classloader:/");
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(path));

@@ -130,6 +139,9 @@ else if (path.startsWith("core:/")) {
return false;
}

if (SHOW_RESOLUTION) {
System.err.printf("resolved %s -> %s\n", feature, coreFileName);
}

context.getCoreLibrary().loadRubyCore(coreFileName, "core:/");
context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(path));
@@ -154,6 +166,10 @@ else if (path.startsWith("core:/")) {

context.getCoreLibrary().getLoadedFeatures().slowPush(context.makeString(expandedPath));

if (SHOW_RESOLUTION) {
System.err.printf("resolved %s -> %s\n", feature, expandedPath);
}

// TODO (nirvdrum 15-Jan-15): If we fail to load, we should remove the path from the loaded features because subsequent requires of the same statement may succeed.
context.loadFile(path, currentNode);
}