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

Commits on Feb 12, 2015

  1. Copy the full SHA
    0d67492 View commit details
  2. Copy the full SHA
    376f091 View commit details
Original file line number Diff line number Diff line change
@@ -541,16 +541,14 @@ public Object eval(RubyString source, RubyBinding binding, UndefinedPlaceholder
public Object eval(RubyString source, RubyBinding binding, RubyString filename, UndefinedPlaceholder lineNumber) {
notDesignedForCompilation();

// TODO (nirvdrum Dec. 29, 2014) Do something with the supplied filename.
return getContext().eval(source.getBytes(), binding, false, this);
return getContext().eval(source.getBytes(), binding, false, filename.toString(), this);
}

@Specialization
public Object eval(RubyString source, RubyBinding binding, RubyString filename, int lineNumber) {
notDesignedForCompilation();

// TODO (nirvdrum Dec. 29, 2014) Do something with the supplied filename and lineNumber.
return getContext().eval(source.getBytes(), binding, false, this);
return getContext().eval(source.getBytes(), binding, false, filename.toString(), this);
}

@Specialization(guards = "!isRubyBinding(binding)")
16 changes: 12 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
Original file line number Diff line number Diff line change
@@ -203,8 +203,8 @@ public RubySymbol newSymbol(ByteList name) {
}

@TruffleBoundary
public Object instanceEval(ByteList code, Object self, RubyNode currentNode) {
final Source source = Source.fromText(code, "(eval)");
public Object instanceEval(ByteList code, Object self, String filename, RubyNode currentNode) {
final Source source = Source.fromText(code, filename);
return execute(this, source, code.getEncoding(), TranslatorDriver.ParserContext.TOP_LEVEL, self, null, currentNode, new NodeWrapper() {
@Override
public RubyNode wrap(RubyNode node) {
@@ -213,12 +213,20 @@ public RubyNode wrap(RubyNode node) {
});
}

public Object instanceEval(ByteList code, Object self, RubyNode currentNode) {
return instanceEval(code, self, "(eval)", currentNode);
}

@TruffleBoundary
public Object eval(ByteList code, RubyBinding binding, boolean ownScopeForAssignments, RubyNode currentNode) {
final Source source = Source.fromText(code, "(eval)");
public Object eval(ByteList code, RubyBinding binding, boolean ownScopeForAssignments, String filename, RubyNode currentNode) {
final Source source = Source.fromText(code, filename);
return execute(this, source, code.getEncoding(), TranslatorDriver.ParserContext.TOP_LEVEL, binding.getSelf(), binding.getFrame(), ownScopeForAssignments, currentNode, NodeWrapper.IDENTITY);
}

public Object eval(ByteList code, RubyBinding binding, boolean ownScopeForAssignments, RubyNode currentNode) {
return eval(code, binding, ownScopeForAssignments, "(eval)", currentNode);
}

public Object execute(RubyContext context, Source source, Encoding defaultEncoding, TranslatorDriver.ParserContext parserContext, Object self, MaterializedFrame parentFrame, RubyNode currentNode, NodeWrapper wrapper) {
return execute(context, source, defaultEncoding, parserContext, self, parentFrame, true, currentNode, wrapper);
}
Original file line number Diff line number Diff line change
@@ -103,8 +103,8 @@ public RubyRootNode parse(RubyContext context, Source source, Encoding defaultEn

try {
node = (org.jruby.ast.RootNode) parser.parse(source.getName(), source.getCode().getBytes(StandardCharsets.UTF_8), new ManyVarsDynamicScope(staticScope), parserConfiguration);
} catch (Exception e) {
String message = e.getMessage();
} catch (org.jruby.exceptions.RaiseException e) {
String message = e.getException().message.asJavaString();

if (message == null) {
message = "(no message)";