Search in sources :

Example 1 with LineAttrNode

use of jadx.core.dex.attributes.nodes.LineAttrNode in project jadx by skylot.

the class CodeWriter method finish.

public void finish() {
    removeFirstEmptyLine();
    buf.trimToSize();
    code = buf.toString();
    buf = null;
    Iterator<Map.Entry<CodePosition, Object>> it = annotations.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<CodePosition, Object> entry = it.next();
        Object v = entry.getValue();
        if (v instanceof DefinitionWrapper) {
            LineAttrNode l = ((DefinitionWrapper) v).getNode();
            l.setDecompiledLine(entry.getKey().getLine());
            it.remove();
        }
    }
}
Also used : CodePosition(jadx.api.CodePosition) LineAttrNode(jadx.core.dex.attributes.nodes.LineAttrNode) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 2 with LineAttrNode

use of jadx.core.dex.attributes.nodes.LineAttrNode in project jadx by skylot.

the class JadxDecompiler method convertNode.

@Nullable
JavaNode convertNode(Object obj) {
    if (obj instanceof VarRef) {
        VarRef varRef = (VarRef) obj;
        MethodNode mthNode = varRef.getMth();
        JavaMethod mth = getJavaMethodByNode(mthNode);
        if (mth == null) {
            return null;
        }
        return new JavaVariable(mth, varRef);
    }
    if (!(obj instanceof LineAttrNode)) {
        return null;
    }
    LineAttrNode node = (LineAttrNode) obj;
    if (node.contains(AFlag.DONT_GENERATE)) {
        return null;
    }
    if (obj instanceof ClassNode) {
        return convertClassNode((ClassNode) obj);
    }
    if (obj instanceof MethodNode) {
        return getJavaMethodByNode(((MethodNode) obj));
    }
    if (obj instanceof FieldNode) {
        return getJavaFieldByNode((FieldNode) obj);
    }
    throw new JadxRuntimeException("Unexpected node type: " + obj);
}
Also used : VarRef(jadx.api.data.annotations.VarRef) ClassNode(jadx.core.dex.nodes.ClassNode) LineAttrNode(jadx.core.dex.attributes.nodes.LineAttrNode) MethodNode(jadx.core.dex.nodes.MethodNode) FieldNode(jadx.core.dex.nodes.FieldNode) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

LineAttrNode (jadx.core.dex.attributes.nodes.LineAttrNode)2 CodePosition (jadx.api.CodePosition)1 VarRef (jadx.api.data.annotations.VarRef)1 ClassNode (jadx.core.dex.nodes.ClassNode)1 FieldNode (jadx.core.dex.nodes.FieldNode)1 MethodNode (jadx.core.dex.nodes.MethodNode)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Nullable (org.jetbrains.annotations.Nullable)1