Java Code Examples for org.objectweb.asm.tree.analysis.BasicValue#equals()

The following examples show how to use org.objectweb.asm.tree.analysis.BasicValue#equals() . 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: HideAccessObfuscationTransformer.java    From deobfuscator with Apache License 2.0 5 votes vote down vote up
@Override
public BasicValue merge(final BasicValue v, final BasicValue w)
{
    if(!v.equals(w))
        return new BasicValue(Type.getType("java/lang/Object"));
    return v;
}
 
Example 2
Source File: FastClassVerifier.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@Override
public BasicValue merge(BasicValue v, BasicValue w) {
    if (!v.equals(w)) {
        Type t = v.getType();
        Type u = w.getType();
        int tsort = t == null ? -1 : t.getSort();
        if (tsort == Type.OBJECT || tsort == Type.ARRAY) {
            int usort = u == null ? -1 : u.getSort();
            if (usort == Type.OBJECT || usort == Type.ARRAY) {
                if ("Lnull;".equals(t.getDescriptor())) {
                    return w;
                }
                if ("Lnull;".equals(u.getDescriptor())) {
                    return v;
                }
                if (isAssignableFrom(t, u)) {
                    return v;
                }
                if (isAssignableFrom(u, t)) {
                    return w;
                }
                return new BasicValue(classHierarchy.getCommonSuperType(t, u));
            }
        }
        return BasicValue.UNINITIALIZED_VALUE;
    }
    return v;
}
 
Example 3
Source File: FastClassVerifier.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@Override
public BasicValue merge(BasicValue v, BasicValue w) {
    if (!v.equals(w)) {
        Type t = v.getType();
        Type u = w.getType();
        int tsort = t == null ? -1 : t.getSort();
        if (tsort == Type.OBJECT || tsort == Type.ARRAY) {
            int usort = u == null ? -1 : u.getSort();
            if (usort == Type.OBJECT || usort == Type.ARRAY) {
                if ("Lnull;".equals(t.getDescriptor())) {
                    return w;
                }
                if ("Lnull;".equals(u.getDescriptor())) {
                    return v;
                }
                if (isAssignableFrom(t, u)) {
                    return v;
                }
                if (isAssignableFrom(u, t)) {
                    return w;
                }
                return new BasicValue(classHierarchy.getCommonSuperType(t, u));
            }
        }
        return BasicValue.UNINITIALIZED_VALUE;
    }
    return v;
}
 
Example 4
Source File: ArrayWrappingInterpreter.java    From AVM with MIT License 4 votes vote down vote up
@Override
public BasicValue merge(BasicValue value1, BasicValue value2) {
    BasicValue b = super.merge(value1, value2);

    if (b.equals(BasicValue.UNINITIALIZED_VALUE)) {

        if (value1.equals(BasicValue.UNINITIALIZED_VALUE) && value2.equals(BasicValue.UNINITIALIZED_VALUE)) {
            return b;
        }

        // Grab the value descriptors.
        String cleanDescriptor1 = value1.toString();
        String cleanDescriptor2 = value2.toString();

        int dimension1 = getArrayDimension(cleanDescriptor1);
        int dimension2 = getArrayDimension(cleanDescriptor2);

        if (dimension1 == 0 || dimension2 == 0) {
            return new BasicValue(Type.getType("[L" + Utilities.fulllyQualifiedNameToInternalName(CommonType.SHADOW_OBJECT.dotName) + ";"));
        }

        if (dimension1 != dimension2) {
            return new BasicValue(Type.getType("[L" + Utilities.fulllyQualifiedNameToInternalName(CommonType.I_OBJECT_ARRAY.dotName) + ";"));
        }

        // Strip the leading array signifiers (the '[' characters)
        cleanDescriptor1 = cleanDescriptor1.substring(dimension1);
        cleanDescriptor2 = cleanDescriptor2.substring(dimension2);

        boolean descriptor1isObject = cleanDescriptor1.startsWith("L");
        boolean descriptor2isObject = cleanDescriptor2.startsWith("L");

        // If we have object arrays, since we know they must differ, we return IObjectArray
        if (!descriptor1isObject && !descriptor2isObject) {
            return new BasicValue(Type.getType("[L" + Utilities.fulllyQualifiedNameToInternalName(CommonType.I_OBJECT_ARRAY.dotName) + ";"));
        }

        // If we have one object array and one non-object array then we return object.
        if ((descriptor1isObject && !descriptor2isObject) || (!descriptor1isObject && descriptor2isObject)) {
            return new BasicValue(Type.getType("[L" + Utilities.fulllyQualifiedNameToInternalName(CommonType.SHADOW_OBJECT.dotName) + ";"));
        }

        // Strip the 'L' character.
        cleanDescriptor1 = cleanDescriptor1.substring(1);
        cleanDescriptor2 = cleanDescriptor2.substring(1);

        // Next we strip the trailing ';' character.
        cleanDescriptor1 = cleanDescriptor1.substring(0,cleanDescriptor1.length() - 1);
        cleanDescriptor2 = cleanDescriptor2.substring(0, cleanDescriptor2.length() - 1);

        // Finally, convert them to dot-style names.
        cleanDescriptor1 = Utilities.internalNameToFulllyQualifiedName(cleanDescriptor1);
        cleanDescriptor2 = Utilities.internalNameToFulllyQualifiedName(cleanDescriptor2);

        // Find the common super class.
        String commonSuper = this.hierarchy.getTightestCommonSuperClass(cleanDescriptor1, cleanDescriptor2);

        // If the super class is ambiguous return IObject, otherwise return it.
        if (commonSuper == null) {
            commonSuper = Utilities.fulllyQualifiedNameToInternalName(CommonType.I_OBJECT.dotName);
        } else {
            // Convert back to slash-style and re-add the characters we stripped.
            commonSuper = Utilities.fulllyQualifiedNameToInternalName(commonSuper);
        }

        // Re-construct the descriptor that we took apart and return it.
        return new BasicValue(Type.getType(getArrayDimensionPrefix(dimension1) + "L" + commonSuper + ";"));
    }

    return b;
}