Skip to content

Commit

Permalink
Showing 94 changed files with 1,375 additions and 1,338 deletions.
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@
jar 'com.github.jnr:jnr-x86asm:1.0.2'
jar 'com.github.jnr:jnr-unixsocket:0.8'
jar 'com.github.jnr:jnr-posix:3.0.15'
jar 'com.github.jnr:jnr-constants:0.8.8'
jar 'com.github.jnr:jnr-constants:0.9.0-SNAPSHOT'
jar 'com.github.jnr:jnr-ffi:2.0.3'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-constants</artifactId>
<version>0.8.8</version>
<version>0.9.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
48 changes: 24 additions & 24 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@
*/
public class Main {
private static final Logger LOG = LoggerFactory.getLogger("Main");

public Main(RubyInstanceConfig config) {
this(config, false);
}
@@ -99,16 +99,16 @@ private Main(boolean hardExit) {
this.config = new RubyInstanceConfig();
config.setHardExit(hardExit);
}

private static List<String> getDotfileDirectories() {
ArrayList<String> searchList = new ArrayList<String>();
for (String homeProp : new String[] {"user.dir", "user.home"}) {
String home = SafePropertyAccessor.getProperty(homeProp);
if (home != null) searchList.add(home);
}

// JVM sometimes picks odd location for user.home based on a registry entry
// (see http://bugs.sun.com/view_bug.do?bug_id=4787931). Add extra check in
// (see http://bugs.sun.com/view_bug.do?bug_id=4787931). Add extra check in
// case that entry is wrong. Add before user.home in search list.
if (Platform.IS_WINDOWS) {
String homeDrive = System.getenv("HOMEDRIVE");
@@ -117,10 +117,10 @@ private static List<String> getDotfileDirectories() {
searchList.add(1, (homeDrive + homePath).replace('\\', '/'));
}
}

return searchList;
}

public static void processDotfile() {
for (String home : getDotfileDirectories()) {
File dotfile = new File(home + "/.jrubyrc");
@@ -130,7 +130,7 @@ public static void processDotfile() {

private static void loadJRubyProperties(File dotfile) {
FileInputStream fis = null;

try {
// update system properties with long form jruby properties from .jrubyrc
Properties sysProps = System.getProperties();
@@ -146,7 +146,7 @@ private static void loadJRubyProperties(File dotfile) {
} catch (SecurityException se) {
LOG.debug("exception loading " + dotfile, se);
} finally {
if (fis != null) try {fis.close();} catch (Exception e) {}
if (fis != null) try {fis.close();} catch (Exception e) {}
}
}

@@ -184,15 +184,15 @@ public static class Status {
*/
public static void main(String[] args) {
doGCJCheck();

Main main;

if (DripMain.DRIP_RUNTIME != null) {
main = new Main(DripMain.DRIP_CONFIG, true);
} else {
main = new Main(true);
}

try {
Status status = main.run(args);
if (status.isExit()) {
@@ -253,9 +253,9 @@ private Status internalRun() {

InputStream in = config.getScriptSource();
String filename = config.displayedFileName();

doProcessArguments(in);

Ruby _runtime;

if (DripMain.DRIP_RUNTIME != null) {
@@ -265,10 +265,10 @@ private Status internalRun() {
} else {
_runtime = Ruby.newInstance(config);
}

final Ruby runtime = _runtime;
final AtomicBoolean didTeardown = new AtomicBoolean();

if (config.isHardExit()) {
// we're the command-line JRuby, and should set a shutdown hook for
// teardown.
@@ -362,7 +362,7 @@ private Status handleOutOfMemory(OutOfMemoryError oome) {
}
config.getError().println("Specify -J-Xmx####m to increase it (#### = cap size in MB).");
}

if (config.isVerbose()) {
config.getError().println("Exception trace follows:");
oome.printStackTrace(config.getError());
@@ -412,15 +412,15 @@ private Status doRunFromMain(Ruby runtime, InputStream in, String filename) {
private Status doCheckSyntax(Ruby runtime, InputStream in, String filename) throws RaiseException {
// check primary script
boolean status = checkStreamSyntax(runtime, in, filename);

// check other scripts specified on argv
for (String arg : config.getArgv()) {
status = status && checkFileSyntax(runtime, arg);
}

return new Status(status ? 0 : -1);
}

private boolean checkFileSyntax(Ruby runtime, String filename) {
File file = new File(filename);
if (file.exists()) {
@@ -434,21 +434,21 @@ private boolean checkFileSyntax(Ruby runtime, String filename) {
return false;
}
}

private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename) {
IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $!
final ThreadContext context = runtime.getCurrentContext();
final IRubyObject $ex = context.getErrorInfo();
try {
runtime.parseFromMain(in, filename);
config.getOutput().println("Syntax OK");
return true;
} catch (RaiseException re) {
if (re.getException().getMetaClass().getBaseName().equals("SyntaxError")) {
context.setErrorInfo($ex);
config.getError().println("SyntaxError in " + re.getException().message(runtime.getCurrentContext()));
} else {
throw re;
return false;
}
runtime.getGlobalVariables().set("$!", oldExc); // Restore $!
return false;
throw re;
}
}

22 changes: 8 additions & 14 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -1151,21 +1151,16 @@ public IRubyObject op_not_equal(ThreadContext context, IRubyObject other) {
* @return 0 if equal,
* &lt; 0 if this is less than other,
* &gt; 0 if this is greater than other
* @throws IllegalArgumentException if the objects cannot be compared.
*/
@Override
public int compareTo(IRubyObject other) {
IRubyObject oldExc = getRuntime().getGlobalVariables().get("$!");
try {
IRubyObject cmp = invokedynamic(getRuntime().getCurrentContext(),
this, OP_CMP, other);
final Ruby runtime = getRuntime();

// if RubyBasicObject#op_cmp is used, the result may be nil
if (!cmp.isNil()) {
return (int) cmp.convertToInteger().getLongValue();
}
} catch (RaiseException ex) {
getRuntime().getGlobalVariables().set("$!", oldExc);
IRubyObject cmp = invokedynamic(runtime.getCurrentContext(), this, OP_CMP, other);

// if RubyBasicObject#op_cmp is used, the result may be nil (not comparable)
if ( ! cmp.isNil() ) {
return (int) cmp.convertToInteger().getLongValue();
}

/* We used to raise an error if two IRubyObject were not comparable, but
@@ -1935,11 +1930,10 @@ public IRubyObject eql_p(IRubyObject obj) {
}

public IRubyObject op_cmp(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
if (this == other || invokedynamic(context, this, OP_EQUAL, other).isTrue()){
return RubyFixnum.zero(runtime);
return RubyFixnum.zero(context.runtime);
}
return runtime.getNil();
return context.nil;
}

/** rb_obj_init_copy
Loading

0 comments on commit a0dc6f9

Please sign in to comment.