Skip to content

Commit

Permalink
Showing 452 changed files with 2,382 additions and 2,699 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -24,7 +24,9 @@ env:
matrix:
- PHASE='-Ptest'
- PHASE='-Prake -Dtask=test:jruby'
- PHASE='-Prake -Dtask=test:jruby:jit'
- PHASE='-Prake -Dtask=test:mri'
- PHASE='-Prake -Dtask=test:mri:jit'
- PHASE='-Prake -Dtask=test:slow_suites'
- PHASE='-Prake -Dtask=test:tracing'
- PHASE='-Prake -Dtask=spec:ji'
@@ -70,6 +72,7 @@ matrix:
- env: PHASE='-Pmain'
- env: PHASE='-Prake -Dtask=spec:jrubyc'
- env: PHASE='-Prake -Dtask=spec:profiler'
- env: PHASE='-Prake -Dtask=test:mri:jit'

branches:
only:
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
<artifactId>jruby-core</artifactId>
<name>JRuby Core</name>
<properties>
<version.ruby>2.2.0</version.ruby>
<version.ruby>2.2.1</version.ruby>
<prawn.dir>${test.dir}/prawn</prawn.dir>
<spec.tags.dir>${spec.dir}/tags</spec.tags.dir>
<pkg.dir>${build.dir}/pkg</pkg.dir>
15 changes: 6 additions & 9 deletions core/src/main/java/org/jruby/RubyBignum.java
Original file line number Diff line number Diff line change
@@ -632,56 +632,53 @@ public IRubyObject op_pow19(ThreadContext context, IRubyObject other) {
*
*/
public IRubyObject op_and(ThreadContext context, IRubyObject other) {
other = other.convertToInteger();
if (other instanceof RubyBignum) {
return bignorm(getRuntime(), value.and(((RubyBignum) other).value));
} else if (other instanceof RubyFixnum) {
return bignorm(getRuntime(), value.and(fix2big((RubyFixnum)other)));
}
return coerceBin(context, "&", other);
return coerceBit(context, "&", other);
}

@JRubyMethod(name = "&", required = 1)
public IRubyObject op_and19(ThreadContext context, IRubyObject other) {
return op_and(context, convertToInteger(context, other));
return op_and(context, other);
}

/** rb_big_or
*
*/
public IRubyObject op_or(ThreadContext context, IRubyObject other) {
other = other.convertToInteger();
if (other instanceof RubyBignum) {
return bignorm(getRuntime(), value.or(((RubyBignum) other).value));
}
if (other instanceof RubyFixnum) { // no bignorm here needed
return bignorm(getRuntime(), value.or(fix2big((RubyFixnum)other)));
}
return coerceBin(context, "|", other);
return coerceBit(context, "|", other);
}

@JRubyMethod(name = "|", required = 1)
public IRubyObject op_or19(ThreadContext context, IRubyObject other) {
return op_or(context, convertToInteger(context, other));
return op_or(context, other);
}

/** rb_big_xor
*
*/
public IRubyObject op_xor(ThreadContext context, IRubyObject other) {
other = other.convertToInteger();
if (other instanceof RubyBignum) {
return bignorm(getRuntime(), value.xor(((RubyBignum) other).value));
}
if (other instanceof RubyFixnum) {
return bignorm(getRuntime(), value.xor(BigInteger.valueOf(((RubyFixnum) other).getLongValue())));
}
return coerceBin(context, "^", other);
return coerceBit(context, "^", other);
}

@JRubyMethod(name = "^", required = 1)
public IRubyObject op_xor19(ThreadContext context, IRubyObject other) {
return op_xor(context, convertToInteger(context, other));
return op_xor(context, other);
}

private IRubyObject convertToInteger(ThreadContext context, IRubyObject other) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyComparable.java
Original file line number Diff line number Diff line change
@@ -145,8 +145,8 @@ private static IRubyObject callCmpMethod(ThreadContext context, IRubyObject recv

return RubyBoolean.newBoolean(runtime, cmpint(context, result, recv, other) == 0);
} catch (RaiseException e) {
cmpFailed(context);
if (e.getException().kind_of_p(context, runtime.getStandardError()).isTrue()) {
cmpFailed(context);
// clear error info resulting from failure to compare (JRUBY-3292)
runtime.getGlobalVariables().set("$!", savedError);
return returnValueOnError;
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -1421,10 +1421,10 @@ private void addAccessor(ThreadContext context, String internedName, Visibility
final Ruby runtime = context.runtime;

if (visibility == PRIVATE) {
//FIXME warning
runtime.getWarnings().warn(ID.PRIVATE_ACCESSOR, "private attribute?");
} else if (visibility == MODULE_FUNCTION) {
runtime.getWarnings().warn(ID.ACCESSOR_MODULE_FUNCTION, "attribute accessor as module_function");
visibility = PRIVATE;
// FIXME warning
}

if (!(IdUtil.isLocal(internedName) || IdUtil.isConstant(internedName))) {
56 changes: 47 additions & 9 deletions core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -459,20 +459,32 @@ protected final IRubyObject coerceBody(ThreadContext context, IRubyObject other)
*
*/
protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boolean err) {
Ruby runtime = context.runtime;
IRubyObject result;

IRubyObject savedError = context.runtime.getGlobalVariables().get("$!"); // Svae $!
IRubyObject savedError = runtime.getGlobalVariables().get("$!"); // Svae $!

if (!other.respondsTo("coerce")) {
if (err) {
coerceRescue(context, other);
}
return null;
}
try {
result = coerceBody(context, other);
} catch (RaiseException e) {
RubyWarnings warnings = context.runtime.getWarnings();
warnings.warn("Numerical comparison operators will no more rescue exceptions of #coerce");
warnings.warn("in the next release. Return nil in #coerce if the coercion is impossible.");
if (err) {
coerceFailed(context, other);
if (e.getException().kind_of_p(context, runtime.getStandardError()).isTrue()) {
RubyWarnings warnings = context.runtime.getWarnings();
warnings.warn("Numerical comparison operators will no more rescue exceptions of #coerce");
warnings.warn("in the next release. Return nil in #coerce if the coercion is impossible.");
if (err) {
coerceFailed(context, other);
}
context.runtime.getGlobalVariables().set("$!", savedError); // Restore $!
return null;
} else {
throw e;
}
context.runtime.getGlobalVariables().set("$!", savedError); // Restore $!
return null;
}

if (!(result instanceof RubyArray) || ((RubyArray) result).getLength() != 2) {
@@ -488,6 +500,14 @@ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boo
return (RubyArray) result;
}

/** coerce_rescue
*
*/
protected final IRubyObject coerceRescue(ThreadContext context, IRubyObject other) {
coerceFailed(context, other);
return context.runtime.getNil();
}

/** coerce_failed
*
*/
@@ -504,13 +524,31 @@ protected final IRubyObject coerceBin(ThreadContext context, String method, IRub
return (ary.eltInternal(0)).callMethod(context, method, ary.eltInternal(1));
}

/** rb_num_coerce_bit
* coercion taking two arguments
*/
protected final IRubyObject coerceBit(ThreadContext context, String method, IRubyObject other) {
if (!(other instanceof RubyFixnum) && !(other instanceof RubyBignum)) {
RubyArray ary = doCoerce(context, other, true);
IRubyObject x = ary.eltInternal(0);
IRubyObject y = ary.eltInternal(1);

if (!(x instanceof RubyFixnum) && !(x instanceof RubyBignum)
&& !(y instanceof RubyFixnum) && !(y instanceof RubyBignum)) {
coerceFailed(context, other);
}
return x.callMethod(context, method, y);
}
return callMethod(context, method, other);
}

/** rb_num_coerce_cmp
* coercion used for comparisons
*/
protected final IRubyObject coerceCmp(ThreadContext context, String method, IRubyObject other) {
RubyArray ary = doCoerce(context, other, false);
if (ary == null) {
return context.runtime.getNil(); // MRI does it!
return context.nil; // MRI does it!
}
return (ary.eltInternal(0)).callMethod(context, method, ary.eltInternal(1));
}
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/RubyRegexp.java
Original file line number Diff line number Diff line change
@@ -83,8 +83,8 @@ public class RubyRegexp extends RubyObject implements ReOptions, EncodingCapable
private ByteList str = ByteList.EMPTY_BYTELIST;
private RegexpOptions options;

public static final int ARG_ENCODING_FIXED = 16;
public static final int ARG_ENCODING_NONE = 32;
public static final int ARG_ENCODING_FIXED = ReOptions.RE_FIXED;
public static final int ARG_ENCODING_NONE = ReOptions.RE_NONE;

public void setLiteral() {
options.setLiteral(true);
@@ -206,8 +206,8 @@ public static RubyClass createRegexpClass(Ruby runtime) {
regexpClass.defineConstant("EXTENDED", runtime.newFixnum(RE_OPTION_EXTENDED));
regexpClass.defineConstant("MULTILINE", runtime.newFixnum(RE_OPTION_MULTILINE));

regexpClass.defineConstant("FIXEDENCODING", runtime.newFixnum(ARG_ENCODING_FIXED));
regexpClass.defineConstant("NOENCODING", runtime.newFixnum(ARG_ENCODING_NONE));
regexpClass.defineConstant("FIXEDENCODING", runtime.newFixnum(RE_FIXED));
regexpClass.defineConstant("NOENCODING", runtime.newFixnum(RE_NONE));

regexpClass.defineAnnotatedMethods(RubyRegexp.class);
regexpClass.getSingletonClass().defineAlias("compile", "new");
@@ -2146,7 +2146,7 @@ public static void marshalTo(RubyRegexp regexp, MarshalStream output) throws jav

int options = regexp.pattern.getOptions() & EMBEDDABLE;

if (regexp.getOptions().isFixed()) options |= ARG_ENCODING_FIXED;
if (regexp.getOptions().isFixed()) options |= RE_FIXED;

output.writeByte(options);
}
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -5165,7 +5165,7 @@ public IRubyObject lines20(ThreadContext context, Block block) {
return each_lineCommon19(context, block);
}
// FIXME: Inefficient; build array manually rather than via Enumerator
return enumeratorize(context.runtime, this, "lines").callMethod(context, "to_a");
return enumeratorize(context.runtime, this, "each_line").callMethod(context, "to_a");
}

@JRubyMethod(name = "lines")
@@ -5175,7 +5175,7 @@ public IRubyObject lines20(ThreadContext context, IRubyObject arg, Block block)
return each_lineCommon19(context, arg, block);
}
// FIXME: Inefficient; build array manually rather than via Enumerator
return enumeratorize(context.runtime, this, "lines", arg).callMethod(context, "to_a");
return enumeratorize(context.runtime, this, "each_line", arg).callMethod(context, "to_a");
}

private IRubyObject each_lineCommon19(ThreadContext context, Block block) {
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/common/IRubyWarnings.java
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ public interface IRubyWarnings {
public enum ID {
AMBIGUOUS_ARGUMENT,
ACCESSOR_NOT_INITIALIZED,
ACCESSOR_MODULE_FUNCTION,
ARGUMENT_AS_PREFIX,
ARGUMENT_EXTRA_SPACE,
ASSIGNMENT_IN_CONDITIONAL,
@@ -72,6 +73,7 @@ public enum ID {
NOT_IMPLEMENTED,
OBSOLETE_ARGUMENT,
PARENTHISE_ARGUMENTS,
PRIVATE_ACCESSOR,
PROXY_EXTENDED_LATE,
STATEMENT_NOT_REACHED,
LITERAL_IN_CONDITIONAL_RANGE,
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
pre(context, self, name, block);

try {
return (IRubyObject)this.variable.invokeExact(context, method.getStaticScope(), self, args, block, implementationClass);
return (IRubyObject)this.variable.invokeExact(context, method.getStaticScope(), self, args, block, implementationClass, name);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
@@ -119,7 +119,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
pre(context, self, name, block);

try {
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, block, implementationClass);
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, block, implementationClass, name);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
@@ -135,7 +135,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
pre(context, self, name, block);

try {
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, arg0, block, implementationClass);
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, arg0, block, implementationClass, name);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
@@ -151,7 +151,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
pre(context, self, name, block);

try {
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, arg0, arg1, block, implementationClass);
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, arg0, arg1, block, implementationClass, name);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
@@ -167,7 +167,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
pre(context, self, name, block);

try {
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, arg0, arg1, arg2, block, implementationClass);
return (IRubyObject)this.specific.invokeExact(context, method.getStaticScope(), self, arg0, arg1, arg2, block, implementationClass, name);
} catch (Throwable t) {
Helpers.throwException(t);
// not reached
Original file line number Diff line number Diff line change
@@ -35,19 +35,49 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
if (IRRuntimeHelpers.isDebug()) doDebug();

return callInternal(context, self, clazz, name, block);
}

protected IRubyObject callInternal(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
InterpreterContext ic = ensureInstrsReady();
if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, getImplementationClass().getMethodLocation(), name, block, null);
} else {
try {
this.pre(ic, context, self, name, block, getImplementationClass());
return ic.engine.interpret(context, self, ic, getImplementationClass().getMethodLocation(), name, block, null);
} finally {
if (!ic.hasExplicitCallProtocol()) {
this.pre(ic, context, self, name, block, getImplementationClass());
}
try {
switch (method.getScopeType()) {
case MODULE_BODY: return INTERPRET_MODULE(ic, context, self, clazz, method.getName(), block);
case CLASS_BODY: return INTERPRET_CLASS(ic, context, self, clazz, method.getName(), block);
case METACLASS_BODY: return INTERPRET_METACLASS(ic, context, self, clazz, "singleton class", block);
default: throw new RuntimeException("invalid body method type: " + method);
}
} finally {
if (!ic.hasExplicitCallProtocol()) {
this.post(ic, context);
}
}
}

private IRubyObject INTERPRET_METACLASS(InterpreterContext ic, ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
return interpretWithBacktrace(ic, context, self, name, block);
}

private IRubyObject INTERPRET_MODULE(InterpreterContext ic, ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
return interpretWithBacktrace(ic, context, self, name, block);
}

private IRubyObject INTERPRET_CLASS(InterpreterContext ic, ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) {
return interpretWithBacktrace(ic, context, self, name, block);
}

private IRubyObject interpretWithBacktrace(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block) {
try {
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());
return ic.engine.interpret(context, self, ic, getImplementationClass().getMethodLocation(), name, block, null);
} finally {
ThreadContext.popBacktrace(context);
}
}

@Override
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) {
return call(context, self, clazz, name, block);
Loading

0 comments on commit 25d21b2

Please sign in to comment.