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

Commits on Dec 16, 2015

  1. Copy the full SHA
    7e07288 View commit details
  2. Copy the full SHA
    824c7da View commit details
  3. [Truffle] Handle null sources.

    Back port of 1a483cd from truffle-head.
    chrisseaton committed Dec 16, 2015
    Copy the full SHA
    ff2143c View commit details
Original file line number Diff line number Diff line change
@@ -307,7 +307,10 @@ public DynamicObject coverageResult() {
for (Map.Entry<Source, Long[]> source : getContext().getCoverageTracker().getCounts().entrySet()) {
final Object[] store = lineCountsStore(source.getValue());
final DynamicObject array = Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), store, store.length);
converted.put(createString(StringOperations.encodeByteList(source.getKey().getPath(), UTF8Encoding.INSTANCE)), array);

if (source.getKey().getPath() != null) {
converted.put(createString(StringOperations.encodeByteList(source.getKey().getPath(), UTF8Encoding.INSTANCE)), array);
}
}

return BucketsStrategy.create(getContext(), converted.entrySet(), false);
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ private RequireResult tryToRequireFile(String path, Node currentNode) throws IOE

public void setMainScriptSource(Source source) {
this.mainScriptSource = source;
if (!source.getPath().equals("-e")) {
if (source.getPath() != null && !source.getPath().equals("-e")) {
this.mainScriptFullPath = expandPath(context, source.getPath());
}
}
Original file line number Diff line number Diff line change
@@ -427,9 +427,9 @@ public RubyNode visitCallNode(CallNode node) {
final RubyNode ret = nilNode(sourceSection);
return addNewlineIfNeeded(node, ret);
}
} else if (receiver instanceof VCallNode // undefined.equal?(obj)
&& ((VCallNode) receiver).getName().equals("undefined")
&& sourceSection.getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")
} else if (receiver instanceof org.jruby.ast.VCallNode // undefined.equal?(obj)
&& ((org.jruby.ast.VCallNode) receiver).getName().equals("undefined")
&& getSourcePath(sourceSection).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")
&& methodName.equals("equal?")) {
RubyNode argument = translateArgumentsAndBlock(sourceSection, null, node.getArgsNode(), methodName).getArguments()[0];
final RubyNode ret = new IsRubiniusUndefinedNode(context, sourceSection, argument);
@@ -965,6 +965,22 @@ public RubyNode visitConstDeclNode(org.jruby.ast.ConstDeclNode node) {
return addNewlineIfNeeded(node, ret);
}

private String getSourcePath(SourceSection sourceSection) {
final Source source = sourceSection.getSource();

if (source == null) {
return "(unknown)";
}

final String path = source.getPath();

if (path == null) {
return source.getShortName();
}

return path;
}

@Override
public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {
// Unqualified constant access, as in CONST
@@ -979,13 +995,13 @@ public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {

final String name = ConstantReplacer.replacementName(sourceSection, node.getName());

if (name.equals("Rubinius") && sourceSection.getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius")) {
if (name.equals("Rubinius") && getSourcePath(sourceSection).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius")) {
final RubyNode ret = new org.jruby.ast.Colon3Node(node.getPosition(), name).accept(this);
return addNewlineIfNeeded(node, ret);
}

// TODO (pitr 01-Dec-2015): remove when RUBY_PLATFORM is set to "truffle"
if (name.equals("RUBY_PLATFORM") && sourceSection.getSource().getPath().contains("test/xml_mini/jdom_engine_test.rb")) {
if (name.equals("RUBY_PLATFORM") && getSourcePath(sourceSection).contains("test/xml_mini/jdom_engine_test.rb")) {
final LiteralNode ret = new LiteralNode(context, sourceSection, StringOperations.createString(context, StringOperations.encodeByteList("truffle", UTF8Encoding.INSTANCE)));
return addNewlineIfNeeded(node, ret);
}
@@ -1105,7 +1121,7 @@ public RubyNode visitDefnNode(org.jruby.ast.DefnNode node) {
// a bit different than aliasing because normally if a Rubinius method name conflicts with an already defined
// method, we simply ignore the method definition. Here we explicitly rename the method so it's always defined.

final String path = sourceSection.getSource().getPath();
final String path = getSourcePath(sourceSection);
final String coreRubiniusPath = context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius/";
if (path.startsWith(coreRubiniusPath)) {
boolean rename = false;
@@ -1435,7 +1451,8 @@ public RubyNode visitGlobalAsgnNode(org.jruby.ast.GlobalAsgnNode node) {
return new UpdateLastBacktraceNode(context, sourceSection, rhs);
}

final boolean inCore = rhs.getSourceSection().getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/");
final boolean inCore = getSourcePath(rhs.getSourceSection()).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/");

if (!inCore && READ_ONLY_GLOBAL_VARIABLES.contains(name)) {
return new WriteReadOnlyGlobalNode(context, sourceSection, name, rhs);
}
@@ -1501,7 +1518,7 @@ public RubyNode visitGlobalVarNode(org.jruby.ast.GlobalVarNode node) {
RubyNode readNode = environment.findLocalVarNode(name, sourceSection);

if (name.equals("$_")) {
if (sourceSection.getSource().getPath().equals(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius/common/regexp.rb")) {
if (getSourcePath(sourceSection).equals(context.getCoreLibrary().getCoreLoadPath() + "/core/rubinius/common/regexp.rb")) {
readNode = new RubiniusLastStringReadNode(context, sourceSection);
} else {
readNode = GetFromThreadLocalNodeGen.create(context, sourceSection, readNode);
@@ -1600,7 +1617,7 @@ public RubyNode visitInstAsgnNode(org.jruby.ast.InstAsgnNode node) {
// Also note the check for frozen.
final RubyNode self = new RaiseIfFrozenNode(new SelfNode(context, sourceSection));

final String path = sourceSection.getSource().getPath();
final String path = getSourcePath(sourceSection);
final String corePath = context.getCoreLibrary().getCoreLoadPath() + "/core/";
final RubyNode ret;
if (path.equals(corePath + "rubinius/common/time.rb")) {
@@ -1661,7 +1678,7 @@ public RubyNode visitInstVarNode(org.jruby.ast.InstVarNode node) {
* expects that we'll replace it statically with a call to Array#size. We also replace @tuple with
* self, and @start to be 0.
*/
final String path = sourceSection.getSource().getPath();
final String path = getSourcePath(sourceSection);
final String corePath = context.getCoreLibrary().getCoreLoadPath() + "/core/";
final RubyNode ret;
if (path.equals(corePath + "rubinius/common/array.rb") || path.equals(corePath + "rubinius/api/shims/array.rb")) {
@@ -2638,7 +2655,7 @@ public RubyNode visitUntilNode(org.jruby.ast.UntilNode node) {
@Override
public RubyNode visitVCallNode(org.jruby.ast.VCallNode node) {
final SourceSection sourceSection = translate(node.getPosition());
if (node.getName().equals("undefined") && sourceSection.getSource().getPath().startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")) {
if (node.getName().equals("undefined") && getSourcePath(sourceSection).startsWith(context.getCoreLibrary().getCoreLoadPath() + "/core/")) {
final RubyNode ret = new LiteralNode(context, sourceSection, context.getCoreLibrary().getRubiniusUndefined());
return addNewlineIfNeeded(node, ret);
}