LexManos

Untitled

May 13th, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.32 KB | None | 0 0
  1.   private BitSet getAmbiguousParameters(List<StructMethod> matches) {
  2.     StructClass cl = DecompilerContext.getStructContext().getClass(classname);
  3.     if (cl == null || matches.size() == 1) {
  4.       return EMPTY_BIT_SET;
  5.     }
  6.  
  7.     BitSet missed = new BitSet(lstParameters.size());
  8.  
  9.     // check if a call is unambiguous
  10.     StructMethod mt = cl.getMethod(InterpreterUtil.makeUniqueKey(name, stringDescriptor));
  11.     if (mt != null) {
  12.       MethodDescriptor md = MethodDescriptor.parseDescriptor(mt.getDescriptor());
  13.       if (md.params.length == lstParameters.size()) {
  14.         boolean exact = true;
  15.         for (int i = 0; i < md.params.length; i++) {
  16.           if (!md.params[i].equals(lstParameters.get(i).getExprType())) {
  17.             missed.set(i);
  18.             exact = false;
  19.           }
  20.         }
  21.         if (exact) return EMPTY_BIT_SET;
  22.       }
  23.     }
  24.  
  25.     List<StructMethod> mtds = new ArrayList<>();
  26.     for (StructMethod mtt : matches) {
  27.       boolean failed = false;
  28.       MethodDescriptor md = MethodDescriptor.parseDescriptor(mtt.getDescriptor());
  29.       for (int i = 0; i < lstParameters.size(); i++) {
  30.         VarType ptype = lstParameters.get(i).getExprType();
  31.         if (!missed.get(i)) {
  32.           if (!md.params[i].equals(ptype)) {
  33.             failed = true;
  34.             break;
  35.           }
  36.         }
  37.         else {
  38.           if (md.params[i].type == CodeConstants.TYPE_OBJECT) {
  39.             if (ptype.type != CodeConstants.TYPE_NULL) {
  40.               if (!Util.instanceOf(DecompilerContext.getStructContext(), ptype.value, md.params[i].value)) {
  41.                 failed = true;
  42.                 break;
  43.               }
  44.             }
  45.           }
  46.         }
  47.       }
  48.       if (!failed) {
  49.         mtds.add(mtt);
  50.       }
  51.     }
  52.  
  53.     // mark parameters
  54.     BitSet ambiguous = new BitSet(descriptor.params.length);
  55.     for (int i = 0; i < descriptor.params.length; i++) {
  56.       VarType paramType = descriptor.params[i];
  57.       for (StructMethod mtt : mtds) {
  58.  
  59.         if (mtt.getSignature() != null && mtt.getSignature().params.get(i).isGeneric()) {
  60.           break;
  61.         }
  62.  
  63.         MethodDescriptor md = MethodDescriptor.parseDescriptor(mtt.getDescriptor());
  64.         if (!paramType.equals(md.params[i])) {
  65.           ambiguous.set(i);
  66.           break;
  67.         }
  68.       }
  69.     }
  70.     return ambiguous;
  71.   }
Advertisement
Add Comment
Please, Sign In to add comment