org.jf.dexlib2.immutable.ImmutableMethodParameter Java Examples

The following examples show how to use org.jf.dexlib2.immutable.ImmutableMethodParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParamUtil.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Iterable<ImmutableMethodParameter> parseParamString(@Nonnull final String params) {
    return new Iterable<ImmutableMethodParameter>() {
        @Override public Iterator<ImmutableMethodParameter> iterator() {
            return new Iterator<ImmutableMethodParameter>() {

                private int index = 0;

                @Override public boolean hasNext() {
                    return index < params.length();
                }

                @Override public ImmutableMethodParameter next() {
                    int end = findTypeEnd(params, index);
                    String ret = params.substring(index, end);
                    index = end;
                    return new ImmutableMethodParameter(ret, null, null);
                }

                @Override public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}
 
Example #2
Source File: MethodImplReIClassDef.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
protected Iterable<? extends MethodParameter> reParameters(final List<? extends MethodParameter> paramters) {
    final List<ImmutableMethodParameter> list = new ArrayList<ImmutableMethodParameter>();
    for (MethodParameter methodParameter : paramters) {
        boolean isBasic = false;
        if (basicType.containsKey(methodParameter.getType())) {
            isBasic = true;
        }
        list.add(new ImmutableMethodParameter(
                isBasic ? methodParameter.getType() : DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(methodParameter.getType())).className,methodParameter.getType().startsWith("[")),
                methodParameter.getAnnotations(), methodParameter.getName()));
    }
    return new Iterable<ImmutableMethodParameter>() {
        @Override
        public Iterator<ImmutableMethodParameter> iterator() {
            return list.iterator();

        }
    };
}
 
Example #3
Source File: ParamUtil.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Iterable<ImmutableMethodParameter> parseParamString(@Nonnull final String params) {
    return new Iterable<ImmutableMethodParameter>() {
        @Override public Iterator<ImmutableMethodParameter> iterator() {
            return new Iterator<ImmutableMethodParameter>() {

                private int index = 0;

                @Override public boolean hasNext() {
                    return index < params.length();
                }

                @Override public ImmutableMethodParameter next() {
                    int end = findTypeEnd(params, index);
                    String ret = params.substring(index, end);
                    index = end;
                    return new ImmutableMethodParameter(ret, null, null);
                }

                @Override public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}
 
Example #4
Source File: ParamUtil.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Iterable<ImmutableMethodParameter> parseParamString(@Nonnull final String params) {
    return new Iterable<ImmutableMethodParameter>() {
        @Override public Iterator<ImmutableMethodParameter> iterator() {
            return new Iterator<ImmutableMethodParameter>() {

                private int index = 0;

                @Override public boolean hasNext() {
                    return index < params.length();
                }

                @Override public ImmutableMethodParameter next() {
                    int end = findTypeEnd(params, index);
                    String ret = params.substring(index, end);
                    index = end;
                    return new ImmutableMethodParameter(ret, null, null);
                }

                @Override public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}
 
Example #5
Source File: ParamUtil.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Iterable<ImmutableMethodParameter> parseParamString(@Nonnull final String params) {
    return new Iterable<ImmutableMethodParameter>() {
        @Override public Iterator<ImmutableMethodParameter> iterator() {
            return new Iterator<ImmutableMethodParameter>() {

                private int index = 0;

                @Override public boolean hasNext() {
                    return index < params.length();
                }

                @Override public ImmutableMethodParameter next() {
                    int end = findTypeEnd(params, index);
                    String ret = params.substring(index, end);
                    index = end;
                    return new ImmutableMethodParameter(ret, null, null);
                }

                @Override public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}
 
Example #6
Source File: InlineMethodResolver.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name,
                                   @Nonnull String params, @Nonnull String returnType) {
    ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params));
    return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null);
}
 
Example #7
Source File: InlineMethodResolver.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name,
                                   @Nonnull String params, @Nonnull String returnType) {
    ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params));
    return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null);
}
 
Example #8
Source File: DexPrinter.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
private Collection<BuilderMethod> toMethods(SootClass clazz) {
	if (clazz.getMethods().isEmpty())
		return null;
	
       String classType = SootToDexUtils.getDexTypeDescriptor(clazz.getType());
       List<BuilderMethod> methods = new ArrayList<BuilderMethod>();
       for (SootMethod sm : clazz.getMethods()) {
           if (sm.isPhantom()) {
               // Do not print method bodies for inherited methods
               continue;
           }
           
       	MethodImplementation impl = toMethodImplementation(sm);
       	
       	List<String> parameterNames = null;
       	if (sm.hasTag("ParamNamesTag"))
       		parameterNames = ((ParamNamesTag) sm.getTag("ParamNamesTag")).getNames();
       	
       	int paramIdx = 0;
       	List<MethodParameter> parameters = null;
       	if (sm.getParameterCount() > 0) {
       		parameters = new ArrayList<MethodParameter>();
        	for (Type tp : sm.getParameterTypes()) {
        		String paramType = SootToDexUtils.getDexTypeDescriptor(tp);
        		parameters.add(new ImmutableMethodParameter(paramType,
        				buildMethodParameterAnnotations(sm, paramIdx),
        				sm.isConcrete() && parameterNames != null ?
        						parameterNames.get(paramIdx) : null));
        		paramIdx++;
        	}
       	}
       	
           String returnType = SootToDexUtils.getDexTypeDescriptor(sm.getReturnType());
           
		int accessFlags = SootToDexUtils.getDexAccessFlags(sm);
           BuilderMethod meth = dexFile.internMethod(classType,
				sm.getName(),
				parameters,
				returnType,
				accessFlags,
				buildMethodAnnotations(sm),
				impl);
           methods.add(meth);
       }
	return methods;
}
 
Example #9
Source File: InlineMethodResolver.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name,
                                   @Nonnull String params, @Nonnull String returnType) {
    ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params));
    return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null);
}
 
Example #10
Source File: InlineMethodResolver.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name,
                                   @Nonnull String params, @Nonnull String returnType) {
    ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params));
    return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null);
}