use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class SignatureParser method consumeGenericArgs.
private ArgType[] consumeGenericArgs() {
List<ArgType> list = new LinkedList<ArgType>();
ArgType type;
do {
if (lookAhead('*')) {
next();
type = ArgType.wildcard();
} else if (lookAhead('+')) {
next();
type = ArgType.wildcard(consumeType(), 1);
} else if (lookAhead('-')) {
next();
type = ArgType.wildcard(consumeType(), -1);
} else {
type = consumeType();
}
if (type != null) {
list.add(type);
}
} while (type != null && !lookAhead('>'));
return list.toArray(new ArgType[list.size()]);
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class InsnGen method inlineAnonymousConstr.
private void inlineAnonymousConstr(CodeWriter code, ClassNode cls, ConstructorInsn insn) throws CodegenException {
// anonymous class construction
if (cls.contains(AFlag.DONT_GENERATE)) {
code.add("/* anonymous class already generated */");
ErrorsCounter.methodError(mth, "Anonymous class already generated: " + cls);
return;
}
ArgType parent;
if (cls.getInterfaces().size() == 1) {
parent = cls.getInterfaces().get(0);
} else {
parent = cls.getSuperClass();
}
cls.add(AFlag.DONT_GENERATE);
MethodNode defCtr = cls.getDefaultConstructor();
if (defCtr != null) {
if (RegionUtils.notEmpty(defCtr.getRegion())) {
defCtr.add(AFlag.ANONYMOUS_CONSTRUCTOR);
} else {
defCtr.add(AFlag.DONT_GENERATE);
}
}
code.add("new ");
if (parent == null) {
code.add("Object");
} else {
useClass(code, parent);
}
MethodNode callMth = mth.dex().resolveMethod(insn.getCallMth());
generateMethodArguments(code, insn, 0, callMth);
code.add(' ');
new ClassGen(cls, mgen.getClassGen().getParentGen()).addClassBody(code);
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class InsnGen method processOverloadedArg.
/**
* Add additional cast for overloaded method argument.
*/
private boolean processOverloadedArg(CodeWriter code, MethodNode callMth, InsnArg arg, int origPos) {
ArgType origType = callMth.getMethodInfo().getArgumentsTypes().get(origPos);
if (!arg.getType().equals(origType)) {
code.add('(');
useType(code, origType);
code.add(") ");
return true;
}
return false;
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class ClassNode method parseClassSignature.
private void parseClassSignature() {
SignatureParser sp = SignatureParser.fromNode(this);
if (sp == null) {
return;
}
try {
// parse class generic map
genericMap = sp.consumeGenericMap();
// parse super class signature
superClass = sp.consumeType();
// parse interfaces signatures
for (int i = 0; i < interfaces.size(); i++) {
ArgType type = sp.consumeType();
if (type != null) {
interfaces.set(i, type);
} else {
break;
}
}
} catch (JadxRuntimeException e) {
LOG.error("Class signature parse error: {}", this, e);
}
}
use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.
the class DexNode method readParamList.
public List<ArgType> readParamList(int parametersOffset) {
TypeList paramList = dexBuf.readTypeList(parametersOffset);
List<ArgType> args = new ArrayList<ArgType>(paramList.getTypes().length);
for (short t : paramList.getTypes()) {
args.add(getType(t));
}
return Collections.unmodifiableList(args);
}
Aggregations