Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1007856 // preciseCall - better method resolution. Could optimize method lookup

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5399L/30K).

sbool preciseCall_debug;

static Object preciseCall(Object o, String method, Object... args) ctex {
  if (o cast Class) {
    _MethodCache cache = callOpt_getCache(o);
    L<Method> methods = cache.cache.get(method);
    //L<Method> methods = findMethodsNamed2(o, method, true);
    new Lowest<Method> best;
    if (methods != null) for (Method m : methods) {
      continue unless isStaticMethod(m);
      int score = methodApplicabilityScore(m, args);
      if (score < Int.MAX_VALUE) {
        if (preciseCall_debug)
          print("Method score: " + m + " " + score);
        best.put(m, score);
      }
    }
    Method m = best!;
    if (m != null) 
      ret invokeMethod(m, null, args);
    
    ret call_withVarargs(o, method, args); // TODO: make this precise too
  } else
    throw todo();
}

Author comment

Began life as a copy of #1000630

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007856
Snippet name: preciseCall - better method resolution. Could optimize method lookup
Eternal ID of this version: #1007856/14
Text MD5: da6b29433a7f97355e59344f67181097
Transpilation MD5: 0f04a732ead3049c7f1568aec5d1a59d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 02:12:32
Source code size: 829 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 487 / 539
Version history: 13 change(s)
Referenced in: [show references]