Search in sources :

Example 1 with LazyIntArrayIntTags

use of edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags in project phosphor by gmu-swe.

the class ArrayReflectionMasker method newInstance.

public static Object newInstance(Class clazz, int len) {
    Class tmp = clazz;
    int dims = 0;
    while (tmp.isArray()) {
        tmp = tmp.getComponentType();
        dims++;
    }
    if (tmp.isPrimitive()) {
        if (dims == 0) {
            if (tmp == Double.TYPE)
                return new LazyDoubleArrayIntTags(new double[len]);
            if (tmp == Float.TYPE)
                return new LazyFloatArrayIntTags(new float[len]);
            if (tmp == Integer.TYPE)
                return new LazyIntArrayIntTags(new int[len]);
            if (tmp == Long.TYPE)
                return new LazyLongArrayIntTags(new long[len]);
            if (tmp == Short.TYPE)
                return new LazyShortArrayIntTags(new short[len]);
            if (tmp == Boolean.TYPE)
                return new LazyBooleanArrayIntTags(new boolean[len]);
            if (tmp == Byte.TYPE)
                return new LazyByteArrayIntTags(new byte[len]);
            if (tmp == Character.TYPE)
                return new LazyCharArrayIntTags(new char[len]);
        } else
            clazz = MultiDTaintedArrayWithIntTag.getUnderlyingBoxClassForUnderlyingClass(clazz);
    }
    return Array.newInstance(clazz, len);
}
Also used : LazyShortArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayIntTags) LazyFloatArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayIntTags) LazyLongArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayIntTags) LazyDoubleArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayIntTags) LazyBooleanArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayIntTags) LazyIntArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags) LazyByteArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayIntTags) LazyCharArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayIntTags)

Example 2 with LazyIntArrayIntTags

use of edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags in project phosphor by gmu-swe.

the class UninstArrayReflectionMasker method setInt$$PHOSPHORTAGGED.

public static void setInt$$PHOSPHORTAGGED(Object obj, int idxtaint, int idx, int taint, int val) {
    if (obj instanceof LazyIntArrayIntTags) {
        LazyIntArrayIntTags a = (LazyIntArrayIntTags) obj;
        a.set(null, idx, taint, val);
    } else
        throw new ArrayStoreException("Called setX, but don't have tainted X array!");
}
Also used : LazyIntArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags)

Example 3 with LazyIntArrayIntTags

use of edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags in project phosphor by gmu-swe.

the class UninstArrayReflectionMasker method newInstance$$PHOSPHORTAGGED.

public static Object newInstance$$PHOSPHORTAGGED(Class clazz, int lenTaint, int len) {
    Class tmp = clazz;
    int dims = 0;
    while (tmp.isArray()) {
        tmp = tmp.getComponentType();
        dims++;
    }
    if (tmp.isPrimitive()) {
        // else
        if (dims == 0) {
            if (tmp == Double.TYPE)
                return new LazyDoubleArrayIntTags(new double[len]);
            if (tmp == Float.TYPE)
                return new LazyFloatArrayIntTags(new float[len]);
            if (tmp == Integer.TYPE)
                return new LazyIntArrayIntTags(new int[len]);
            if (tmp == Long.TYPE)
                return new LazyLongArrayIntTags(new long[len]);
            if (tmp == Short.TYPE)
                return new LazyShortArrayIntTags(new short[len]);
            if (tmp == Boolean.TYPE)
                return new LazyBooleanArrayIntTags(new boolean[len]);
            if (tmp == Byte.TYPE)
                return new LazyByteArrayIntTags(new byte[len]);
            if (tmp == Character.TYPE)
                return new LazyCharArrayIntTags(new char[len]);
        } else
            clazz = MultiDTaintedArrayWithIntTag.getUnderlyingBoxClassForUnderlyingClass(clazz);
    }
    return Array.newInstance(clazz, len);
}
Also used : LazyShortArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayIntTags) LazyFloatArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayIntTags) LazyLongArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayIntTags) LazyDoubleArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayIntTags) LazyBooleanArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayIntTags) LazyIntArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags) LazyByteArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayIntTags) LazyCharArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayIntTags)

Example 4 with LazyIntArrayIntTags

use of edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags in project phosphor by gmu-swe.

the class MultiDTaintedArrayWithIntTag method boxIfNecessary.

public static final Object boxIfNecessary(final Object in, final HashSet<Object> includedObjs) {
    if (in != null && in.getClass().isArray()) {
        Class tmp = in.getClass();
        int dims = 0;
        while (tmp.isArray()) {
            tmp = tmp.getComponentType();
            dims++;
        }
        if (tmp.isPrimitive()) {
            // Is prim arraytype
            if (dims > 1) {
                // this should never be possible.
                Type t = Type.getType(in.getClass());
                return initWithEmptyTaints((Object[]) in, t.getElementType().getSort(), t.getDimensions());
            } else {
                if (tmp == Boolean.TYPE)
                    return new LazyBooleanArrayIntTags((boolean[]) in);
                if (tmp == Byte.TYPE)
                    return new LazyByteArrayIntTags(((byte[]) in));
                if (tmp == Character.TYPE)
                    return new LazyCharArrayIntTags(((char[]) in));
                if (tmp == Double.TYPE)
                    return new LazyDoubleArrayIntTags(((double[]) in));
                if (tmp == Float.TYPE)
                    return new LazyFloatArrayIntTags(((float[]) in));
                if (tmp == Integer.TYPE)
                    return new LazyIntArrayIntTags(((int[]) in));
                if (tmp == Long.TYPE)
                    return new LazyLongArrayIntTags(((long[]) in));
                if (tmp == Short.TYPE)
                    return new LazyShortArrayIntTags(((short[]) in));
                throw new IllegalArgumentException();
            }
        } else if (in.getClass().getComponentType().getName().equals("java.lang.Object")) {
            TaintedBooleanWithIntTag tmpRet = new TaintedBooleanWithIntTag();
            Object[] _in = (Object[]) in;
            for (int i = 0; i < _in.length; i++) {
                if (includedObjs.add$$PHOSPHORTAGGED(_in[i], tmpRet).val)
                    _in[i] = boxIfNecessary(_in[i], includedObjs);
            }
        }
    }
    return in;
}
Also used : TaintedBooleanWithIntTag(edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag) LazyFloatArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayIntTags) LazyIntArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags) LazyShortArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayIntTags) Type(org.objectweb.asm.Type) LazyLongArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayIntTags) LazyDoubleArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayIntTags) LazyBooleanArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayIntTags) LazyByteArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayIntTags) LazyCharArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayIntTags)

Example 5 with LazyIntArrayIntTags

use of edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags in project phosphor by gmu-swe.

the class MultiDTaintedArrayWithIntTag method boxIfNecessary.

public static final Object boxIfNecessary(final Object in) {
    if (in != null && in.getClass().isArray()) {
        Class tmp = in.getClass();
        int dims = 0;
        while (tmp.isArray()) {
            tmp = tmp.getComponentType();
            dims++;
        }
        if (tmp.isPrimitive()) {
            // Is prim arraytype
            if (dims > 1) {
                // this should never be possible.
                Type t = Type.getType(in.getClass());
                return initWithEmptyTaints((Object[]) in, t.getElementType().getSort(), t.getDimensions());
            } else {
                if (tmp == Boolean.TYPE)
                    return new LazyBooleanArrayIntTags((boolean[]) in);
                if (tmp == Byte.TYPE)
                    return new LazyByteArrayIntTags(((byte[]) in));
                if (tmp == Character.TYPE)
                    return new LazyCharArrayIntTags(((char[]) in));
                if (tmp == Double.TYPE)
                    return new LazyDoubleArrayIntTags(((double[]) in));
                if (tmp == Float.TYPE)
                    return new LazyFloatArrayIntTags(((float[]) in));
                if (tmp == Integer.TYPE)
                    return new LazyIntArrayIntTags(((int[]) in));
                if (tmp == Long.TYPE)
                    return new LazyLongArrayIntTags(((long[]) in));
                if (tmp == Short.TYPE)
                    return new LazyShortArrayIntTags(((short[]) in));
                throw new IllegalArgumentException();
            }
        } else if (in.getClass().getComponentType().getName().equals("java.lang.Object")) {
            Object[] _in = (Object[]) in;
            for (int i = 0; i < _in.length; i++) {
                _in[i] = boxIfNecessary(_in[i], new HashSet<Object>());
            }
        }
    }
    return in;
}
Also used : LazyFloatArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayIntTags) LazyIntArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags) LazyShortArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayIntTags) Type(org.objectweb.asm.Type) LazyLongArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayIntTags) LazyDoubleArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayIntTags) LazyBooleanArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayIntTags) LazyByteArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayIntTags) LazyCharArrayIntTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayIntTags)

Aggregations

LazyIntArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyIntArrayIntTags)7 LazyBooleanArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayIntTags)5 LazyByteArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyByteArrayIntTags)5 LazyCharArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyCharArrayIntTags)5 LazyDoubleArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayIntTags)5 LazyFloatArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayIntTags)5 LazyLongArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyLongArrayIntTags)5 LazyShortArrayIntTags (edu.columbia.cs.psl.phosphor.struct.LazyShortArrayIntTags)5 Type (org.objectweb.asm.Type)2 TaintedBooleanWithIntTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag)1