Skip to content

Commit

Permalink
Showing 151 changed files with 1,915 additions and 1,580 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -86,7 +86,8 @@ matrix:
# group: edge
# jdk: oraclejdk9

install: tool/travis-install.sh
install:
- ./mvnw $MAVEN_CLI_OPTS package -B -Dinvoker.skip -Dmaven.test.skip
script: tool/travis-script.sh

notifications:
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@
jar 'org.jruby.jcodings:jcodings:1.0.18'
jar 'org.jruby:dirgra:0.3'

jar 'com.headius:invokebinder:1.7'
jar 'com.headius:invokebinder:1.8-SNAPSHOT'
jar 'com.headius:options:1.4'
jar 'com.headius:unsafe-fences:1.0'

2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -193,7 +193,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.headius</groupId>
<artifactId>invokebinder</artifactId>
<version>1.7</version>
<version>1.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.headius</groupId>
18 changes: 18 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -65,6 +65,8 @@
import org.jruby.runtime.JavaSites;
import org.jruby.runtime.invokedynamic.InvokeDynamicSupport;
import org.jruby.util.MRIRecursionGuard;
import org.jruby.util.StrptimeParser;
import org.jruby.util.StrptimeToken;
import org.objectweb.asm.util.TraceClassVisitor;

import jnr.constants.Constant;
@@ -4429,6 +4431,17 @@ public RuntimeCache getRuntimeCache() {
return runtimeCache;
}

public List<StrptimeToken> getCachedStrptimePattern(String pattern) {
List<StrptimeToken> tokens = strptimeFormatCache.get(pattern);

if (tokens == null) {
tokens = new StrptimeParser().compilePattern(pattern);
strptimeFormatCache.put(pattern, tokens);
}

return tokens;
}

/**
* Add a method, so it can be printed out later.
*
@@ -5165,4 +5178,9 @@ protected TypePopulator computeValue(Class<?> type) {
public final JavaSites sites = new JavaSites();

private volatile MRIRecursionGuard mriRecursionGuard;

// For strptime processing we cache the parsed format strings since most applications
// reuse the same formats over and over. This is also unbounded (for now) since all applications
// I know of use very few of them. Even if there are many the size of these lists are modest.
private Map<String, List<StrptimeToken>> strptimeFormatCache = new ConcurrentHashMap<>();
}
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -1262,7 +1262,7 @@ public RubyArray append(IRubyObject item) {
/** rb_ary_push_m - instance method push
*
*/

@Deprecated // not-used
public RubyArray push_m(IRubyObject[] items) {
return push(items);
}
@@ -3711,7 +3711,7 @@ public IRubyObject product(ThreadContext context, IRubyObject[] args, Block bloc
arrays[0] = this;
RubyClass array = runtime.getArray();
JavaSites.CheckedSites to_ary_checked = sites(context).to_ary_checked;
for (int i = 1; i < n; i++) arrays[i] = (RubyArray) TypeConverter.convertToType19(context, args[i - 1], array, to_ary_checked);
for (int i = 1; i < n; i++) arrays[i] = (RubyArray) TypeConverter.convertToType(context, args[i - 1], array, to_ary_checked);

int resultLen = 1;
for (int i = 0; i < n; i++) {
@@ -4614,7 +4614,7 @@ public static IRubyObject try_convert(ThreadContext context, IRubyObject self, I
public RubyString pack(ThreadContext context, IRubyObject obj) {
RubyString iFmt = obj.convertToString();
try {
return Pack.pack(context, context.runtime, this, iFmt);
return Pack.pack(context, this, iFmt);
} catch (ArrayIndexOutOfBoundsException e) {
throw concurrentModification(context.runtime, e);
}
53 changes: 36 additions & 17 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -746,7 +746,9 @@ public RubyInteger convertToInteger() {

IRubyObject result = TypeConverter.convertToType(context, this, runtime.getInteger(), sites.to_int_checked, true);

if (!(result instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#to_int should return Integer");
if (!(result instanceof RubyInteger)) {
throw getRuntime().newTypeError(getMetaClass().getName() + "#to_int should return Integer");
}

return (RubyInteger) result;
}
@@ -769,7 +771,9 @@ public RubyInteger convertToInteger(String convertMethod) {
result = TypeConverter.convertToType(this, getRuntime().getInteger(), convertMethod, true);
}

if (!(result instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#to_int should return Integer");
if (!(result instanceof RubyInteger)) {
throw getRuntime().newTypeError(getMetaClass().getName() + '#' + convertMethod + " should return Integer");
}

return (RubyInteger) result;
}
@@ -2347,35 +2351,39 @@ public RubyBoolean kind_of_p(ThreadContext context, IRubyObject type) {
* "methods", "extend", "__send__", "instance_eval"]
* k.methods.length #=> 42
*/
public IRubyObject methods(ThreadContext context, IRubyObject[] args) {
return methods(context, args, true);
public IRubyObject methods(ThreadContext context, IRubyObject... args) {
return methodsImpl(context, args.length == 1 ? args[0].isTrue() : true);
}

@Deprecated
public IRubyObject methods19(ThreadContext context, IRubyObject[] args) {
return methods(context, args);
}

public final IRubyObject methods(ThreadContext context, IRubyObject[] args, boolean useSymbols) {
boolean all = args.length == 1 ? args[0].isTrue() : true;
Ruby runtime = getRuntime();
RubyArray methods = runtime.newArray();
Set<String> seen = new HashSet<String>();
final IRubyObject methodsImpl(ThreadContext context, final boolean all) {
final RubyArray methods = RubyArray.newArray(context.runtime);
final Set<String> seen = new HashSet<>();

if (getMetaClass().isSingleton()) {
getMetaClass().populateInstanceMethodNames(seen, methods, PRIVATE, false, true, false);
RubyClass metaClass = getMetaClass();
if (metaClass.isSingleton()) {
metaClass.populateInstanceMethodNames(seen, methods, PRIVATE, false, true, false);
if (all) {
getMetaClass().getSuperClass().populateInstanceMethodNames(seen, methods, PRIVATE, false, true, true);
metaClass.getSuperClass().populateInstanceMethodNames(seen, methods, PRIVATE, false, true, true);
}
} else if (all) {
getMetaClass().populateInstanceMethodNames(seen, methods, PRIVATE, false, true, true);
metaClass.populateInstanceMethodNames(seen, methods, PRIVATE, false, true, true);
} else {
// do nothing, leave empty
}

return methods;
}

@Deprecated
public final IRubyObject methods(ThreadContext context, IRubyObject[] args, boolean useSymbols) {
return methodsImpl(context, args.length == 1 ? args[0].isTrue() : true);
}

/** rb_obj_public_methods
*
* call-seq:
@@ -2471,10 +2479,7 @@ public IRubyObject private_methods19(ThreadContext context, IRubyObject[] args)
// TODO: This is almost RubyModule#instance_methods on the metaClass. Perhaps refactor.
public RubyArray singleton_methods(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
boolean all = true;
if(args.length == 1) {
all = args[0].isTrue();
}
boolean all = (args.length == 1) ? args[0].isTrue() : true;

RubyClass klass = metaClass;
RubyModule origin = klass.getMethodLocation();
@@ -2507,6 +2512,20 @@ public RubyArray singleton_methods(ThreadContext context, IRubyObject[] args) {
return context.runtime.newEmptyArray();
}

public IRubyObject singleton_method(IRubyObject name) {
final String methodName = TypeConverter.checkID(name).asJavaString();
final RubyClass klass = metaClass;
if (klass.isSingleton()) {
DynamicMethod method = klass.searchMethod(methodName);
if (klass == method.getDefinedClass()) { // ! method.isUndefined()
AbstractRubyMethod newMethod = RubyMethod.newMethod(klass, methodName, klass, methodName, method, this);
newMethod.infectBy(this);
return newMethod;
}
}
throw getRuntime().newNameError("undefined method `" + methodName + "' for `" + inspect() + '\'', methodName);
}

/** rb_obj_method
*
* call-seq:
Loading

0 comments on commit b3c5bad

Please sign in to comment.