Search in sources :

Example 6 with LazyFloatArrayObjTags

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

the class MultiDTaintedArrayWithObjTag method unboxVal.

public static final Object unboxVal(final Object _in, final int componentType, final int dims) {
    if (dims == 0) {
        switch(componentType) {
            case Type.BOOLEAN:
            case Type.BYTE:
            case Type.CHAR:
            case Type.DOUBLE:
            case Type.FLOAT:
            case Type.INT:
            case Type.LONG:
            case Type.SHORT:
                return ((LazyArrayObjTags) _in).getVal();
            default:
                throw new IllegalArgumentException();
        }
    } else if (dims == 1) {
        final Object[] in = (Object[]) _in;
        switch(componentType) {
            case Type.BOOLEAN:
                boolean[][] retz = new boolean[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    retz[i] = ((LazyBooleanArrayObjTags) in[i]).val;
                return retz;
            case Type.BYTE:
                byte[][] retb = new byte[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    retb[i] = ((LazyByteArrayObjTags) in[i]).val;
                return retb;
            case Type.CHAR:
                char[][] retc = new char[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    retc[i] = ((LazyCharArrayObjTags) in[i]).val;
                return retc;
            case Type.DOUBLE:
                double[][] retd = new double[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    retd[i] = ((LazyDoubleArrayObjTags) in[i]).val;
                return retd;
            case Type.FLOAT:
                float[][] retf = new float[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    retf[i] = ((LazyFloatArrayObjTags) in[i]).val;
                return retf;
            case Type.INT:
                int[][] reti = new int[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    reti[i] = ((LazyIntArrayObjTags) in[i]).val;
                return reti;
            case Type.LONG:
                long[][] retl = new long[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    retl[i] = ((LazyLongArrayObjTags) in[i]).val;
                return retl;
            case Type.SHORT:
                short[][] rets = new short[in.length][];
                for (int i = 0; i < in.length; i++) if (in[i] != null)
                    rets[i] = ((LazyShortArrayObjTags) in[i]).val;
                return rets;
        }
    } else if (dims == 2) {
        final Object[][] ina = (Object[][]) _in;
        final Object[] in = (Object[]) _in;
        switch(componentType) {
            case Type.BOOLEAN:
                boolean[][][] retz = new boolean[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    retz[i] = new boolean[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) retz[i][j] = ((LazyBooleanArrayObjTags) ina[i][j]).val;
                }
                return retz;
            case Type.BYTE:
                byte[][][] retb = new byte[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    retb[i] = new byte[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) retb[i][j] = ((LazyByteArrayObjTags) ina[i][j]).val;
                }
                return retb;
            case Type.CHAR:
                char[][][] retc = new char[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    retc[i] = new char[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) retc[i][j] = ((LazyCharArrayObjTags) ina[i][j]).val;
                }
                return retc;
            case Type.DOUBLE:
                double[][][] retd = new double[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    retd[i] = new double[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) retd[i][j] = ((LazyDoubleArrayObjTags) ina[i][j]).val;
                }
                return retd;
            case Type.FLOAT:
                float[][][] retf = new float[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    retf[i] = new float[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) retf[i][j] = ((LazyFloatArrayObjTags) ina[i][j]).val;
                }
                return retf;
            case Type.INT:
                int[][][] reti = new int[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    reti[i] = new int[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) reti[i][j] = ((LazyIntArrayObjTags) ina[i][j]).val;
                }
                return reti;
            case Type.LONG:
                long[][][] retl = new long[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    retl[i] = new long[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) retl[i][j] = ((LazyLongArrayObjTags) ina[i][j]).val;
                }
                return retl;
            case Type.SHORT:
                short[][][] rets = new short[in.length][][];
                for (int i = 0; i < in.length; i++) {
                    rets[i] = new short[ina[i].length][];
                    for (int j = 0; j < ina[i].length; j++) rets[i][j] = ((LazyShortArrayObjTags) ina[i][j]).val;
                }
                return rets;
        }
    }
    throw new IllegalArgumentException();
}
Also used : LazyByteArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags) LazyLongArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags) LazyCharArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags) LazyFloatArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags) Taint(edu.columbia.cs.psl.phosphor.runtime.Taint) LazyArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags) LazyIntArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags) LazyDoubleArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags) LazyShortArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags) LazyBooleanArrayObjTags(edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags)

Example 7 with LazyFloatArrayObjTags

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

the class ArrayReflectionMasker method setFloat$$PHOSPHORTAGGED.

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

Aggregations

LazyFloatArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags)7 LazyBooleanArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyBooleanArrayObjTags)5 LazyByteArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyByteArrayObjTags)5 LazyCharArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyCharArrayObjTags)5 LazyDoubleArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyDoubleArrayObjTags)5 LazyIntArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyIntArrayObjTags)5 LazyLongArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyLongArrayObjTags)5 LazyShortArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyShortArrayObjTags)5 Taint (edu.columbia.cs.psl.phosphor.runtime.Taint)3 Type (org.objectweb.asm.Type)2 LazyArrayObjTags (edu.columbia.cs.psl.phosphor.struct.LazyArrayObjTags)1 TaintedBooleanWithObjTag (edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag)1 HashSet (java.util.HashSet)1