Example usage for org.objectweb.asm.tree.analysis BasicValue REFERENCE_VALUE

List of usage examples for org.objectweb.asm.tree.analysis BasicValue REFERENCE_VALUE

Introduction

In this page you can find the example usage for org.objectweb.asm.tree.analysis BasicValue REFERENCE_VALUE.

Prototype

BasicValue REFERENCE_VALUE

To view the source code for org.objectweb.asm.tree.analysis BasicValue REFERENCE_VALUE.

Click Source Link

Document

An object or array reference value.

Usage

From source file:com.github.fge.grappa.transform.RuleMethodInterpreter.java

License:Open Source License

@Override
public BasicValue newValue(Type type) {
    BasicValue basicValue = super.newValue(type);
    if (basicValue == BasicValue.REFERENCE_VALUE)
        // record the exact type and not just "Ljava/lang/Object"
        basicValue = new BasicValue(type);

    return basicValue;
}

From source file:com.lodgon.parboiled.transform.RuleMethodInterpreter.java

License:Open Source License

@Override
public BasicValue newValue(Type type) {
    BasicValue basicValue = super.newValue(type);
    if (basicValue == BasicValue.REFERENCE_VALUE) {
        basicValue = new BasicValue(type); // record the exact type and not just "Ljava/lang/Object"
    }/*from w  ww . j a  va2s  . co  m*/
    return basicValue;
}

From source file:edu.ubc.mirrors.holograms.BetterVerifier.java

License:Open Source License

@Override
public BasicValue merge(final BasicValue v, final BasicValue w) {
    if (!v.equals(w)) {
        Type t = v.getType();//w w w.  j a v  a 2 s  .  c o  m
        Type u = w.getType();
        if (t != null && (t.getSort() == Type.OBJECT || t.getSort() == Type.ARRAY)) {
            if (u != null && (u.getSort() == Type.OBJECT || u.getSort() == 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;
                }

                if (t.getSort() == Type.ARRAY && u.getSort() == Type.ARRAY) {
                    BasicValue vComp = new BasicValue(
                            Reflection.makeArrayType(t.getDimensions() - 1, t.getElementType()));
                    BasicValue wComp = new BasicValue(
                            Reflection.makeArrayType(u.getDimensions() - 1, u.getElementType()));
                    BasicValue mergedComp = merge(vComp, wComp);
                    if (!mergedComp.equals(BasicValue.UNINITIALIZED_VALUE)) {
                        Type mergedCompType = mergedComp.getType();
                        return new BasicValue(Reflection.makeArrayType(1, mergedCompType));
                    }
                }

                do {
                    if (t == null || isInterface(t)) {
                        return BasicValue.REFERENCE_VALUE;
                    }
                    t = getSuperClass(t);
                    if (isAssignableFrom(t, u)) {
                        return newValue(t);
                    }
                } while (true);
            }
        }
        return BasicValue.UNINITIALIZED_VALUE;
    }
    return v;
}

From source file:jaspex.speculation.newspec.FlowFrame.java

License:Open Source License

/** Converte lista de tipos no formato do visitFrame em BasicValues **/
private UtilList<BasicValue> convertFromFrame(List<Object> values, boolean locals) {
    UtilList<BasicValue> outList = new UtilArrayList<BasicValue>();

    for (Object o : values) {
        if (o instanceof Integer) {
            Integer i = (Integer) o;
            if (i.equals(Opcodes.TOP)) {
                outList.add(BasicValue.UNINITIALIZED_VALUE);
            } else if (i.equals(Opcodes.INTEGER)) {
                outList.add(BasicValue.INT_VALUE);
            } else if (i.equals(Opcodes.FLOAT)) {
                outList.add(BasicValue.FLOAT_VALUE);
            } else if (i.equals(Opcodes.LONG)) {
                outList.add(BasicValue.LONG_VALUE);
                if (locals)
                    outList.add(BasicValue.UNINITIALIZED_VALUE);
            } else if (i.equals(Opcodes.DOUBLE)) {
                outList.add(BasicValue.DOUBLE_VALUE);
                if (locals)
                    outList.add(BasicValue.UNINITIALIZED_VALUE);
            } else if (i.equals(Opcodes.NULL)) {
                outList.add(BasicValue.REFERENCE_VALUE);
            } else if (i.equals(Opcodes.UNINITIALIZED_THIS)) {
                throw new AssertionError("FIXME");
            } else {
                throw new AssertionError();
            }//from w  ww . j ava 2s . com
        } else if (o instanceof String) {
            String s = (String) o;
            outList.add(_interpreter.newValue(Type.getObjectType(s)));
        } else if (o instanceof Label) {
            throw new AssertionError("FIXME");
        } else {
            throw new AssertionError("FIXME");
        }
    }

    return outList;
}

From source file:jaspex.speculation.newspec.FlowFrame.java

License:Open Source License

@Override
/** Implementao do merge que mantm informao dos dois tipos que originaram o merge
  * num MergedUninitializedValue.//ww w. j av  a 2 s . co m
  **/
public BasicValue merge(BasicValue v, BasicValue w) {
    BasicValue value = super.merge(v, w);
    if (!v.equals(w)) {
        boolean isFutureV = isFuture(v);
        boolean isFutureW = isFuture(w);
        if ((value.equals(BasicValue.UNINITIALIZED_VALUE) && (isFutureV || isFutureW
                || v instanceof MergedUninitializedValue || w instanceof MergedUninitializedValue)) ||
        // Nota: REFERENCE_VALUE parece ocorrer quando ASM est a tomar atalhos
        // e no lhe "apetece" ver quais os verdadeiros tipos
                (value.equals(BasicValue.REFERENCE_VALUE) && (isFutureV || isFutureW)) ||
                // ASM considera merge(null, T) = T, mas quando T  um Futuro, no podemos
                // assumir isso, pois por exemplo podem existir dois caminhos: um que coloca
                // null na pilha, e outro um futuro, como exemplificado no NewSpecExample28
                (isFutureV && "null".equals(w.getType().getInternalName()))
                || (isFutureW && "null".equals(v.getType().getInternalName()))) {
            BasicValue muv = new MergedUninitializedValue(v, w);
            return muv.equals(v) ? v : muv.equals(w) ? w : muv;
        }
    }
    if (value.equals(BasicValue.REFERENCE_VALUE) && !value.equals(v) && !value.equals(w)) {
        // Ou os dois tipos s tem Object em comum, ou s tm uma interface em comum e
        // o ASM no faz o trabalho de a descobrir
        Type tv = v.getType();
        Type tw = w.getType();
        if (tv != null && tw != null) {
            Type commonInterface = ClassHierarchy.getBestCommonInterface(tv, tw);
            if (commonInterface != null)
                return newValue(commonInterface);
        }
    }
    return value;
}

From source file:org.evosuite.instrumentation.ThisInterpreter.java

License:Open Source License

/** {@inheritDoc} */
@Override//from www .jav  a2 s.  c o  m
public BasicValue merge(BasicValue v, BasicValue w) {
    if (v == THIS_VALUE && w == BasicValue.REFERENCE_VALUE)
        return BasicValue.REFERENCE_VALUE;
    else if (w == THIS_VALUE && v == BasicValue.REFERENCE_VALUE)
        return BasicValue.REFERENCE_VALUE;
    else
        return super.merge(v, w);
}