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

Commits on Aug 21, 2015

  1. Copy the full SHA
    f28cadc View commit details
  2. Copy the full SHA
    09f3771 View commit details
  3. Copy the full SHA
    d8556a9 View commit details
  4. [Truffle] Formatting.

    chrisseaton committed Aug 21, 2015
    Copy the full SHA
    038f3ff View commit details
  5. Copy the full SHA
    ca26641 View commit details
  6. 1
    Copy the full SHA
    9e4dcb2 View commit details
4 changes: 1 addition & 3 deletions truffle/src/main/java/org/jruby/truffle/Main.java
Original file line number Diff line number Diff line change
@@ -36,9 +36,7 @@ public static void main(String[] args) {

config.setCompileMode(RubyInstanceConfig.CompileMode.TRUFFLE);

if (in == null) {
return;
} else {
if (in != null) {
// Global variables
IAccessor programName = new ValueAccessor(runtime.newString(filename));
runtime.getGlobalVariables().define("$PROGRAM_NAME", programName, GlobalVariable.Scope.GLOBAL);
34 changes: 34 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/TruffleVMMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle;

import com.oracle.truffle.api.vm.TruffleVM;
import org.jruby.truffle.runtime.RubyLanguage;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class TruffleVMMain {

public static void main(String[] args) {
final TruffleVM vm = TruffleVM.newVM().build();

for (String arg : args) {
try (InputStream inputStream = new FileInputStream(arg)) {
final Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
vm.eval(RubyLanguage.MIME_TYPE, reader);
} catch (IOException e) {
e.printStackTrace();
}
}

}

}
Original file line number Diff line number Diff line change
@@ -113,6 +113,7 @@ public class RubyContext extends ExecutionContext implements TruffleContextInter
public RubyContext(Ruby runtime) {
this(runtime, null);
}

public RubyContext(Ruby runtime, TruffleLanguage.Env env) {
latestInstance = this;

Original file line number Diff line number Diff line change
@@ -22,18 +22,21 @@

import java.io.IOException;

@TruffleLanguage.Registration(name = "Ruby", version = Constants.RUBY_VERSION, mimeType = "application/x-ruby")
@TruffleLanguage.Registration(name = "Ruby", version = Constants.RUBY_VERSION, mimeType = RubyLanguage.MIME_TYPE)
public class RubyLanguage extends TruffleLanguage<RubyContext> {

public static final String MIME_TYPE = "application/x-ruby";

private RubyLanguage() {
}

public static final RubyLanguage INSTANCE = new RubyLanguage();

@Override
public RubyContext createContext(Env env) {
Ruby r = Ruby.newInstance();
return new RubyContext(r, env);
final RubyContext context = new RubyContext(Ruby.newInstance(), env);
context.initialize();
return context;
}

@Override
Original file line number Diff line number Diff line change
@@ -142,11 +142,16 @@ public String formatLine(List<Activation> activations, int n) {
final Activation activation = activations.get(n);
final SourceSection sourceSection = activation.getCallNode().getEncapsulatingSourceSection();
final SourceSection reportedSourceSection;
final String reportedName;
String reportedName;

if (isCore(sourceSection) && !flags.contains(FormattingFlags.INCLUDE_CORE_FILES)) {
reportedSourceSection = nextUserSourceSection(activations, n);
reportedName = RubyArguments.getMethod(activation.getMaterializedFrame().getArguments()).getName();

try {
reportedName = RubyArguments.getMethod(activation.getMaterializedFrame().getArguments()).getName();
} catch (Exception e) {
reportedName = "???";
}
} else {
reportedSourceSection = sourceSection;
reportedName = sourceSection.getIdentifier();
@@ -185,7 +190,7 @@ private SourceSection nextUserSourceSection(List<Activation> activations, int n)
}

private boolean isCore(SourceSection sourceSection) {
return sourceSection.getSource() == null || sourceSection.getSource().getPath().startsWith("core:");
return sourceSection == null || sourceSection.getSource() == null || sourceSection.getSource().getPath().startsWith("core:");
}

}
3 changes: 2 additions & 1 deletion truffle/src/test/java/org/jruby/truffle/tck/RubyTckTest.java
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.vm.TruffleVM;
import com.oracle.truffle.tck.TruffleTCK;

import org.jruby.truffle.runtime.RubyLanguage;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -70,7 +71,7 @@ protected String fourtyTwo() {

@Override
protected String mimeType() {
return "application/x-ruby";
return RubyLanguage.MIME_TYPE;
}

@Override