use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class MethodNode method checkInstructions.
public void checkInstructions() {
List<RegisterArg> list = new ArrayList<RegisterArg>();
for (InsnNode insnNode : instructions) {
if (insnNode == null) {
continue;
}
list.clear();
RegisterArg resultArg = insnNode.getResult();
if (resultArg != null) {
list.add(resultArg);
}
insnNode.getRegisterArgs(list);
int argsCount = list.size();
for (int i = 0; i < argsCount; i++) {
if (list.get(i).getRegNum() >= regsCount) {
throw new JadxRuntimeException("Incorrect register number in instruction: " + insnNode + ", expected to be less than " + regsCount);
}
}
}
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class SignatureParser method consumeType.
public ArgType consumeType() {
char ch = next();
mark();
switch(ch) {
case 'L':
ArgType obj = consumeObjectType(false);
if (obj != null) {
return obj;
}
break;
case 'T':
next();
mark();
if (forwardTo(';')) {
return ArgType.genericType(slice());
}
break;
case '[':
return ArgType.array(consumeType());
case STOP_CHAR:
return null;
default:
// primitive type (one char)
ArgType type = ArgType.parse(ch);
if (type != null) {
return type;
}
break;
}
throw new JadxRuntimeException("Can't parse type: " + debugString());
}
use of jadx.core.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class InsnGen method makeConstructor.
private void makeConstructor(ConstructorInsn insn, CodeWriter code) throws CodegenException {
ClassNode cls = mth.dex().resolveClass(insn.getClassType());
if (cls != null && cls.contains(AFlag.ANONYMOUS_CLASS) && !fallback) {
inlineAnonymousConstr(code, cls, insn);
return;
}
if (insn.isSelf()) {
throw new JadxRuntimeException("Constructor 'self' invoke must be removed!");
}
if (insn.isSuper()) {
code.add("super");
} else if (insn.isThis()) {
code.add("this");
} else {
code.add("new ");
useClass(code, insn.getClassType());
}
MethodNode callMth = mth.dex().resolveMethod(insn.getCallMth());
generateMethodArguments(code, insn, 0, callMth);
}
use of jadx.core.utils.exceptions.JadxRuntimeException 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.utils.exceptions.JadxRuntimeException in project jadx by skylot.
the class FillArrayNode method getLiteralArgs.
public List<LiteralArg> getLiteralArgs() {
List<LiteralArg> list = new ArrayList<LiteralArg>(size);
Object array = data;
if (array instanceof int[]) {
for (int b : (int[]) array) {
list.add(InsnArg.lit(b, elemType));
}
} else if (array instanceof byte[]) {
for (byte b : (byte[]) array) {
list.add(InsnArg.lit(b, elemType));
}
} else if (array instanceof short[]) {
for (short b : (short[]) array) {
list.add(InsnArg.lit(b, elemType));
}
} else if (array instanceof long[]) {
for (long b : (long[]) array) {
list.add(InsnArg.lit(b, elemType));
}
} else {
throw new JadxRuntimeException("Unknown type: " + data.getClass() + ", expected: " + elemType);
}
return list;
}
Aggregations