Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private BitSet getAmbiguousParameters(List<StructMethod> matches) {
- StructClass cl = DecompilerContext.getStructContext().getClass(classname);
- if (cl == null || matches.size() == 1) {
- return EMPTY_BIT_SET;
- }
- BitSet missed = new BitSet(lstParameters.size());
- // check if a call is unambiguous
- StructMethod mt = cl.getMethod(InterpreterUtil.makeUniqueKey(name, stringDescriptor));
- if (mt != null) {
- MethodDescriptor md = MethodDescriptor.parseDescriptor(mt.getDescriptor());
- if (md.params.length == lstParameters.size()) {
- boolean exact = true;
- for (int i = 0; i < md.params.length; i++) {
- if (!md.params[i].equals(lstParameters.get(i).getExprType())) {
- missed.set(i);
- exact = false;
- }
- }
- if (exact) return EMPTY_BIT_SET;
- }
- }
- List<StructMethod> mtds = new ArrayList<>();
- for (StructMethod mtt : matches) {
- boolean failed = false;
- MethodDescriptor md = MethodDescriptor.parseDescriptor(mtt.getDescriptor());
- for (int i = 0; i < lstParameters.size(); i++) {
- VarType ptype = lstParameters.get(i).getExprType();
- if (!missed.get(i)) {
- if (!md.params[i].equals(ptype)) {
- failed = true;
- break;
- }
- }
- else {
- if (md.params[i].type == CodeConstants.TYPE_OBJECT) {
- if (ptype.type != CodeConstants.TYPE_NULL) {
- if (!Util.instanceOf(DecompilerContext.getStructContext(), ptype.value, md.params[i].value)) {
- failed = true;
- break;
- }
- }
- }
- }
- }
- if (!failed) {
- mtds.add(mtt);
- }
- }
- // mark parameters
- BitSet ambiguous = new BitSet(descriptor.params.length);
- for (int i = 0; i < descriptor.params.length; i++) {
- VarType paramType = descriptor.params[i];
- for (StructMethod mtt : mtds) {
- if (mtt.getSignature() != null && mtt.getSignature().params.get(i).isGeneric()) {
- break;
- }
- MethodDescriptor md = MethodDescriptor.parseDescriptor(mtt.getDescriptor());
- if (!paramType.equals(md.params[i])) {
- ambiguous.set(i);
- break;
- }
- }
- }
- return ambiguous;
- }
Advertisement
Add Comment
Please, Sign In to add comment