Skip to content

Commit

Permalink
Merge branch 'jruby-9.1' into psych_3_update
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Apr 17, 2018
2 parents f5f6d16 + c95601e commit 7390d5a
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ target
test/pom.xml
test/prawn
test/rails
test/testapp/testapp
test/jruby/testapp/testapp
tool/nailgun/Makefile
tool/nailgun/config.log
tool/nailgun/config.status
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/AbstractRubyMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public String getMethodName() {

@JRubyMethod(name = "owner")
public IRubyObject owner(ThreadContext context) {
return method.getRealMethod().getDefinedClass();
return implementationModule;
}

@JRubyMethod(name = "source_location")
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyBignum.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ private IRubyObject op_divide(ThreadContext context, IRubyObject other, boolean
if (slash) {
return RubyFloat.newFloat(runtime, div);
} else {
return RubyNumeric.dbl2num(runtime, div);
return RubyNumeric.dbl2ival(runtime, div);
}
} else {
return coerceBin(context, slash ? sites(context).op_quo : sites(context).div, other);
Expand Down Expand Up @@ -634,7 +634,7 @@ public IRubyObject op_pow19(ThreadContext context, IRubyObject other) {
if (Double.isInfinite(pow)) {
return RubyFloat.newFloat(runtime, pow);
}
return RubyNumeric.dbl2num(runtime, pow);
return RubyNumeric.dbl2ival(runtime, pow);
}

/** rb_big_and
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ private IRubyObject powerFixnum19(ThreadContext context, IRubyObject other) {
return this;
}
if (a == 0) {
return b > 0 ? RubyFixnum.zero(runtime) : RubyNumeric.dbl2num(runtime, 1.0 / 0.0);
return b > 0 ? RubyFixnum.zero(runtime) : RubyNumeric.dbl2ival(runtime, 1.0 / 0.0);
}
if (a == 1) {
return RubyFixnum.one(runtime);
Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/org/jruby/RubyFloat.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public IRubyObject divmod(ThreadContext context, IRubyObject other) {
mod += y;
}
final Ruby runtime = getRuntime();
IRubyObject car = dbl2num(runtime, div);
IRubyObject car = dbl2ival(runtime, div);
RubyFloat cdr = RubyFloat.newFloat(runtime, mod);
return RubyArray.newArray(runtime, car, cdr);
default:
Expand Down Expand Up @@ -717,7 +717,7 @@ public IRubyObject truncate() {
if (f > 0.0) f = Math.floor(f);
if (f < 0.0) f = Math.ceil(f);

return dbl2num(getRuntime(), f);
return dbl2ival(getRuntime(), f);
}

/** flo_numerator
Expand Down Expand Up @@ -756,7 +756,7 @@ public IRubyObject to_r(ThreadContext context) {

Ruby runtime = context.runtime;

IRubyObject rf = RubyNumeric.dbl2num(runtime, f);
IRubyObject rf = RubyNumeric.dbl2ival(runtime, f);
IRubyObject rn = RubyFixnum.newFixnum(runtime, n);
return f_mul(context, rf, f_expt(context, RubyFixnum.newFixnum(runtime, FLT_RADIX), rn));
}
Expand Down Expand Up @@ -786,7 +786,7 @@ public IRubyObject rationalize(ThreadContext context, IRubyObject[] args) {
long n = exp[0] - DBL_MANT_DIG;


IRubyObject rf = RubyNumeric.dbl2num(runtime, f);
IRubyObject rf = RubyNumeric.dbl2ival(runtime, f);
IRubyObject rn = RubyFixnum.newFixnum(runtime, n);

if (f_zero_p(context, rf) || !(f_negative_p(context, rn) || f_zero_p(context, rn)))
Expand Down Expand Up @@ -817,7 +817,7 @@ public IRubyObject rationalize(ThreadContext context, IRubyObject[] args) {
@JRubyMethod(name = "floor")
@Override
public IRubyObject floor() {
return dbl2num(getRuntime(), Math.floor(value));
return dbl2ival(getRuntime(), Math.floor(value));
}

/** flo_ceil
Expand All @@ -826,15 +826,15 @@ public IRubyObject floor() {
@JRubyMethod(name = "ceil")
@Override
public IRubyObject ceil() {
return dbl2num(getRuntime(), Math.ceil(value));
return dbl2ival(getRuntime(), Math.ceil(value));
}

/** flo_round
*
*/
@Override
public IRubyObject round() {
return dbl2num(getRuntime(), val2dbl());
return dbl2ival(getRuntime(), val2dbl());
}

@JRubyMethod(name = "round", optional = 1)
Expand Down Expand Up @@ -869,7 +869,7 @@ public IRubyObject round(ThreadContext context, IRubyObject[] args) {
return RubyFloat.newFloat(context.runtime, number);
}
if (digits < -(binexp > 0 ? binexp / 3 + 1 : binexp / 4)) {
return dbl2num(context.runtime, (long) 0);
return dbl2ival(context.runtime, (long) 0);
}

if (Double.isInfinite(magnifier)) {
Expand Down Expand Up @@ -898,7 +898,7 @@ public IRubyObject round(ThreadContext context, IRubyObject[] args) {
BigDecimal roundedNumber = new BigDecimal(Double.toString(number));
return RubyBignum.newBignum(context.runtime, roundedNumber.toBigInteger());
}
return dbl2num(context.runtime, (long)number);
return dbl2ival(context.runtime, (long)number);
}
}

Expand Down
5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,6 @@ public IRubyObject receiver(ThreadContext context) {
return receiver;
}

@JRubyMethod
public IRubyObject owner(ThreadContext context) {
return implementationModule;
}

@JRubyMethod
public IRubyObject source_location(ThreadContext context) {
Ruby runtime = context.runtime;
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,14 @@ private static long float2long(RubyFloat flt) {
}
}

public static IRubyObject dbl2num(Ruby runtime, double val) {
return RubyFloat.newFloat(runtime, val);
}

/** rb_dbl2big + LONG2FIX at once (numeric.c)
*
*/
public static IRubyObject dbl2num(Ruby runtime, double val) {
public static IRubyObject dbl2ival(Ruby runtime, double val) {
if (Double.isInfinite(val)) {
throw runtime.newFloatDomainError(val < 0 ? "-Infinity" : "Infinity");
}
Expand Down
30 changes: 3 additions & 27 deletions core/src/main/java/org/jruby/util/ShellLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,38 +411,14 @@ private static File findPathFile(Ruby runtime, String fname, String[] path, bool
return pathFile;
}

/**
* This is an older version of the path-finding logic used by our pure-Java process launching in backquote,
* system, etc. The newer version below, used by native process launching, appears to break execution of commands
* in the current working directory, e.g. "./testapp".
*
* MRI: Older version of logic for dln_find_exe_r used by popen logic
*/
public static File findPathExecutable(Ruby runtime, String fname) {
RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV");
IRubyObject pathObject = env.op_aref(runtime.getCurrentContext(), RubyString.newString(runtime, PATH_ENV));
String[] pathNodes = null;
if (pathObject == null) {
pathNodes = DEFAULT_PATH; // ASSUME: not modified by callee
}
else {
String pathSeparator = System.getProperty("path.separator");
String path = pathObject.toString();
if (Platform.IS_WINDOWS) {
// Windows-specific behavior
path = "." + pathSeparator + path;
}
pathNodes = path.split(pathSeparator);
}
return findPathFile(runtime, fname, pathNodes, true);
return findPathExecutable(runtime, fname, pathObject);
}

/**
* Search for the given executable using the given PATH or one provided by system defaults.
*
* This is the updated version of MRI: dln_find_exe_r logic.
*/
public static File dlnFindExe(Ruby runtime, String fname, IRubyObject pathObject) {
// MRI: Hopefully close to dln_find_exe_r used by popen logic
public static File findPathExecutable(Ruby runtime, String fname, IRubyObject pathObject) {
String[] pathNodes;

if (pathObject == null || pathObject.isNil()) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ else if ((flags & FLAG_MINUS) != 0) {
if (type != ClassIndex.FIXNUM && type != ClassIndex.BIGNUM) {
switch(type) {
case FLOAT:
arg = RubyNumeric.dbl2num(arg.getRuntime(),((RubyFloat)arg).getValue());
arg = RubyNumeric.dbl2ival(arg.getRuntime(),((RubyFloat)arg).getValue());
break;
case STRING:
arg = ((RubyString)arg).stringToInum19(0, true);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/TypeConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public static IRubyObject convertToInteger(ThreadContext context, IRubyObject va
double value = ((RubyFloat)val).getValue();
if (value <= RubyFixnum.MAX ||
value >= RubyFixnum.MIN) {
return RubyNumeric.dbl2num(context.runtime, value);
return RubyNumeric.dbl2ival(context.runtime, value);
}
} else if (val instanceof RubyFixnum || val instanceof RubyBignum) {
if (base != 0) raiseIntegerBaseError(context);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/io/PopenExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,7 @@ public int compare(String o1, String o2) {
}

private static String dlnFindExeR(Ruby runtime, String fname, IRubyObject path) {
File exePath = ShellLauncher.dlnFindExe(runtime, fname, path);
File exePath = ShellLauncher.findPathExecutable(runtime, fname, path);
return exePath != null ? exePath.getAbsolutePath() : null;
}

Expand Down
Binary file removed test/jruby/testapp/testapp
Binary file not shown.

0 comments on commit 7390d5a

Please sign in to comment.