Libraryless. Click here for Pure Java version (9399L/52K).
1 | sO newPreciseCall_sentinel(O o, S method, O methodNotFoundSentinel, O... args) ctex { |
2 | if (o == null) null; |
3 | bool staticCall = o instanceof Class; |
4 | Class c = staticCall ? (Class) o : o.getClass(); |
5 | O target = staticCall ? null : o; |
6 | |
7 | _MethodCache cache = callOpt_getCache(c); |
8 | L<Method> methods = cache.cache.get(method); |
9 | Method best = null; |
10 | int bestScore = Int.MAX_VALUE; |
11 | bool widening; |
12 | |
13 | if (methods != null) for (Method m : methods) { |
14 | if (staticCall && !isStaticMethod(m)) continue; |
15 | |
16 | int score = methodApplicabilityScore_withPrimitiveWidening(m, args); |
17 | if (score == 0) |
18 | ret invokeMethod(m, target, args); |
19 | |
20 | if (abs(score) < bestScore) { |
21 | best = m; |
22 | bestScore = abs(score); |
23 | widening = score < 0; |
24 | } |
25 | } |
26 | |
27 | if (best != null) |
28 | if (widening) |
29 | ret invokeMethodWithWidening(best, target, args); |
30 | else |
31 | ret invokeMethod(best, target, args); |
32 | |
33 | ret callWithVarargs_sentinel(o, method, methodNotFoundSentinel, args); // TODO: make this precise too |
34 | } |
Began life as a copy of #1034745
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035534 |
Snippet name: | newPreciseCall_sentinel - newPreciseCall + return function result or a sentinel if method not found |
Eternal ID of this version: | #1035534/4 |
Text MD5: | 74df7224500ee467193ce78994f2b5a3 |
Transpilation MD5: | a3811f71baf9d119db021e458014d417 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-04 09:16:59 |
Source code size: | 1062 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 130 / 187 |
Version history: | 3 change(s) |
Referenced in: | [show references] |