Transpiled version (5407L) is out of date.
1 | sbool newPreciseCall_debug; |
2 | |
3 | sO newPreciseCall(O o, S method, O... args) ctex { |
4 | if (o == null) null; |
5 | bool staticCall = o instanceof Class; |
6 | Class c = staticCall ? (Class) o : o.getClass(); |
7 | O target = staticCall ? null : o; |
8 | |
9 | _MethodCache cache = callOpt_getCache(c); |
10 | L<Method> methods = cache.cache.get(method); |
11 | Method best = null; |
12 | int bestScore = Int.MAX_VALUE; |
13 | bool widening; |
14 | if (newPreciseCall_debug) |
15 | printVars("newPreciseCall", +method, +staticCall, +c, methods := l(methods)); |
16 | |
17 | if (methods != null) for (Method m : methods) { |
18 | if (staticCall && !isStaticMethod(m)) continue; |
19 | |
20 | int score = methodApplicabilityScore_withPrimitiveWidening(m, args); |
21 | if (score == 0) |
22 | ret invokeMethod(m, target, args); |
23 | |
24 | if (newPreciseCall_debug) |
25 | print("Method score: " + m + " " + score); |
26 | |
27 | if (abs(score) < bestScore) { |
28 | best = m; |
29 | bestScore = abs(score); |
30 | widening = score < 0; |
31 | } |
32 | } |
33 | |
34 | if (best != null) |
35 | if (widening) |
36 | ret invokeMethodWithWidening(best, target, args); |
37 | else |
38 | ret invokeMethod(best, target, args); |
39 | |
40 | ret callWithVarargs(o, method, args); // TODO: make this precise too |
41 | } |
Began life as a copy of #1007856
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034745 |
Snippet name: | newPreciseCall - better method resolution with primitive conversion |
Eternal ID of this version: | #1034745/15 |
Text MD5: | 0553bd45fef2edcacf07cb3ea20db101 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-08 03:51:01 |
Source code size: | 1232 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 174 / 279 |
Version history: | 14 change(s) |
Referenced in: | [show references] |