public static <T extends ParameterTypes> T matchingCallableArityFour(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) { final int signatureCode = argsHashCode(arg0, arg1, arg2, arg3); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0, arg1, arg2, arg3); if (method != null) cache.putSignature(signatureCode, method); } return method; }
private static <T extends ParameterTypes> T findCallable(T[] callables, CallableAcceptor acceptor, IRubyObject[] args) { T bestCallable = null; int bestScore = -1; for ( int i = 0; i < callables.length; i++ ) { final T callable = callables[i]; if ( acceptor.accept(callable, args) ) { int currentScore = calcExactnessScore(callable, args); if (currentScore > bestScore) { bestCallable = callable; bestScore = currentScore; } } } return bestCallable; }
private static int argsHashCode(final IRubyObject[] args) { final int last = args.length - 1; if ( last == -1 ) return 0; int result = 31; for ( int i = 0; i < last; i++ ) { result = 17 * ( result + javaClassHashCode( args[i] ) ); } return result + javaClassOrProcHashCode( args[last] ); }
private static ParameterTypes findCallable(ParameterTypes[] callables, CallableAcceptor acceptor, IRubyObject... args) { ParameterTypes bestCallable = null; int bestScore = -1; for (int k = 0; k < callables.length; k++) { ParameterTypes callable = callables[k]; if (acceptor.accept(callable, args)) { int currentScore = getExactnessScore(callable, args); if (currentScore > bestScore) { bestCallable = callable; bestScore = currentScore; } } } return bestCallable; }
private static int argsHashCode(IRubyObject[] a) { if (a == null) { return 0; } int result = 1; for (IRubyObject element : a) { result = 31 * result + classHashCode(element); } return result; }
public static <T extends ParameterTypes> T matchingCallableArityN(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject[] args) { final int signatureCode = argsHashCode(args); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, args); if (method != null) cache.putSignature(signatureCode, method); } return method; }
private static int argsHashCode(IRubyObject a0, IRubyObject a1) { return 17 * ( 31 + javaClassHashCode(a0) ) + javaClassOrProcHashCode(a1); }
private static <T extends ParameterTypes> T findCallable(T[] callables, CallableAcceptor acceptor, IRubyObject[] args) { T bestCallable = null; int bestScore = -1; for ( int i = 0; i < callables.length; i++ ) { final T callable = callables[i]; if ( acceptor.accept(callable, args) ) { int currentScore = calcExactnessScore(callable, args); if (currentScore > bestScore) { bestCallable = callable; bestScore = currentScore; } } } return bestCallable; }
private static int argsHashCode(IRubyObject[] a) { if (a == null) { return 0; } int result = 1; for (IRubyObject element : a) { result = 31 * result + classHashCode(element); } return result; }
public static <T extends ParameterTypes> T matchingCallableArityTwo(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1) { final int signatureCode = argsHashCode(arg0, arg1); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0, arg1); if (method != null) cache.putSignature(signatureCode, method); } return method; }
private static int argsHashCode(IRubyObject a0, IRubyObject a1, IRubyObject a2) { return 17 * ( 17 * ( 31 + javaClassHashCode(a0) ) + javaClassHashCode(a1) ) + javaClassOrProcHashCode(a2); }
public static <T extends ParameterTypes> T matchingCallableArityThree(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { final int signatureCode = argsHashCode(arg0, arg1, arg2); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0, arg1, arg2); if (method != null) cache.putSignature(signatureCode, method); } return method; }
private static int argsHashCode(final IRubyObject[] args) { final int last = args.length - 1; if ( last == -1 ) return 0; int result = 31; for ( int i = 0; i < last; i++ ) { result = 17 * ( result + javaClassHashCode( args[i] ) ); } return result + javaClassOrProcHashCode( args[last] ); }
public static <T extends ParameterTypes> T matchingCallableArityFour(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) { final int signatureCode = argsHashCode(arg0, arg1, arg2, arg3); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0, arg1, arg2, arg3); if (method != null) cache.putSignature(signatureCode, method); } return method; }
private static int argsHashCode(IRubyObject a0, IRubyObject a1, IRubyObject a2, IRubyObject a3) { return 17 * ( 17 * ( 17 * ( 31 + javaClassHashCode(a0) ) + javaClassHashCode(a1) ) + javaClassHashCode(a2) ) + javaClassOrProcHashCode(a3); }
public static <T extends ParameterTypes> T matchingCallableArityTwo(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1) { final int signatureCode = argsHashCode(arg0, arg1); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0, arg1); if (method != null) cache.putSignature(signatureCode, method); } return method; }
public static <T extends ParameterTypes> T matchingCallableArityOne(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0) { final int signatureCode = argsHashCode(arg0); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0); if (method != null) cache.putSignature(signatureCode, method); } return method; }
public static <T extends ParameterTypes> T matchingCallableArityOne(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0) { final int signatureCode = argsHashCode(arg0); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0); if (method != null) cache.putSignature(signatureCode, method); } return method; }
public static <T extends ParameterTypes> T matchingCallableArityN(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject[] args) { final int signatureCode = argsHashCode(args); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, args); if (method != null) cache.putSignature(signatureCode, method); } return method; }
public static <T extends ParameterTypes> T matchingCallableArityThree(Ruby runtime, CallableCache<T> cache, T[] methods, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { final int signatureCode = argsHashCode(arg0, arg1, arg2); T method = cache.getSignature(signatureCode); if (method == null) { method = findMatchingCallableForArgs(runtime, methods, arg0, arg1, arg2); if (method != null) cache.putSignature(signatureCode, method); } return method; }