use of edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags in project phosphor by gmu-swe.
the class UninstArrayReflectionMasker 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!");
}
use of edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags in project phosphor by gmu-swe.
the class UninstArrayReflectionMasker method newInstance$$PHOSPHORTAGGED.
public static Object newInstance$$PHOSPHORTAGGED(Class clazz, Object 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 LazyDoubleArrayObjTags(new double[len]);
if (tmp == Float.TYPE)
return new LazyFloatArrayObjTags(new float[len]);
if (tmp == Integer.TYPE)
return new LazyIntArrayObjTags(new int[len]);
if (tmp == Long.TYPE)
return new LazyLongArrayObjTags(new long[len]);
if (tmp == Short.TYPE)
return new LazyShortArrayObjTags(new short[len]);
if (tmp == Boolean.TYPE)
return new LazyBooleanArrayObjTags(new boolean[len]);
if (tmp == Byte.TYPE)
return new LazyByteArrayObjTags(new byte[len]);
if (tmp == Character.TYPE)
return new LazyCharArrayObjTags(new char[len]);
} else
clazz = MultiDTaintedArrayWithObjTag.getUnderlyingBoxClassForUnderlyingClass(clazz);
}
return Array.newInstance(clazz, len);
}
use of edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags in project phosphor by gmu-swe.
the class ArrayReflectionMasker method newInstance$$PHOSPHORTAGGED.
public static Object newInstance$$PHOSPHORTAGGED(Class clazz, Taint 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 LazyDoubleArrayObjTags(new double[len]);
if (tmp == Float.TYPE)
return new LazyFloatArrayObjTags(new float[len]);
if (tmp == Integer.TYPE)
return new LazyIntArrayObjTags(new int[len]);
if (tmp == Long.TYPE)
return new LazyLongArrayObjTags(new long[len]);
if (tmp == Short.TYPE)
return new LazyShortArrayObjTags(new short[len]);
if (tmp == Boolean.TYPE)
return new LazyBooleanArrayObjTags(new boolean[len]);
if (tmp == Byte.TYPE)
return new LazyByteArrayObjTags(new byte[len]);
if (tmp == Character.TYPE)
return new LazyCharArrayObjTags(new char[len]);
} else
clazz = MultiDTaintedArrayWithObjTag.getUnderlyingBoxClassForUnderlyingClass(clazz);
}
return Array.newInstance(clazz, len);
}
use of edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags in project phosphor by gmu-swe.
the class MultiDTaintedArrayWithObjTag method boxIfNecessary.
public static final Object boxIfNecessary(final Object in, final HashSet<Object> done) {
if (in != null && in.getClass().isArray()) {
if (in.getClass().getComponentType().isPrimitive()) {
// Is prim arraytype
Class tmp = in.getClass();
int dims = 0;
while (tmp.isArray()) {
tmp = tmp.getComponentType();
dims++;
}
if (dims > 1) {
// this should never be possible.
Type t = Type.getType(in.getClass());
initWithEmptyTaints((Object[]) in, t.getElementType().getSort(), t.getDimensions());
} else {
if (tmp == Boolean.TYPE)
return new LazyBooleanArrayObjTags((boolean[]) in);
if (tmp == Byte.TYPE)
return new LazyByteArrayObjTags(((byte[]) in));
if (tmp == Character.TYPE)
return new LazyCharArrayObjTags(((char[]) in));
if (tmp == Double.TYPE)
return new LazyDoubleArrayObjTags(((double[]) in));
if (tmp == Float.TYPE)
return new LazyFloatArrayObjTags(((float[]) in));
if (tmp == Integer.TYPE)
return new LazyIntArrayObjTags(((int[]) in));
if (tmp == Long.TYPE)
return new LazyLongArrayObjTags(((long[]) in));
if (tmp == Short.TYPE)
return new LazyShortArrayObjTags(((short[]) in));
throw new IllegalArgumentException();
}
} else if (in.getClass().getComponentType().isArray() && in.getClass().getComponentType().getComponentType().isPrimitive()) {
// THIS array is an prim[][] array
Object[] _in = (Object[]) in;
Class tmp = in.getClass();
while (tmp.isArray()) {
tmp = tmp.getComponentType();
}
if (tmp == Boolean.TYPE) {
LazyBooleanArrayObjTags[] ret = new LazyBooleanArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyBooleanArrayObjTags((boolean[]) _in[i]);
return ret;
}
if (tmp == Byte.TYPE) {
LazyByteArrayObjTags[] ret = new LazyByteArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyByteArrayObjTags((byte[]) _in[i]);
return ret;
}
if (tmp == Character.TYPE) {
LazyCharArrayObjTags[] ret = new LazyCharArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyCharArrayObjTags((char[]) _in[i]);
return ret;
}
if (tmp == Double.TYPE) {
LazyDoubleArrayObjTags[] ret = new LazyDoubleArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyDoubleArrayObjTags((double[]) _in[i]);
return ret;
}
if (tmp == Float.TYPE) {
LazyFloatArrayObjTags[] ret = new LazyFloatArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyFloatArrayObjTags((float[]) _in[i]);
return ret;
}
if (tmp == Integer.TYPE) {
LazyIntArrayObjTags[] ret = new LazyIntArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyIntArrayObjTags((int[]) _in[i]);
return ret;
}
if (tmp == Short.TYPE) {
LazyShortArrayObjTags[] ret = new LazyShortArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyShortArrayObjTags((short[]) _in[i]);
return ret;
}
if (tmp == Long.TYPE) {
LazyLongArrayObjTags[] ret = new LazyLongArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyLongArrayObjTags((long[]) _in[i]);
return ret;
}
throw new UnsupportedOperationException();
} else if (in.getClass().getComponentType().getName().equals("java.lang.Object")) {
Object[] _in = (Object[]) in;
TaintedBooleanWithObjTag tmpRet = new TaintedBooleanWithObjTag();
for (int i = 0; i < _in.length; i++) {
if (done.add$$PHOSPHORTAGGED(_in[i], tmpRet).val)
_in[i] = boxIfNecessary(_in[i], done);
}
}
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.LazyFloatArrayObjTags in project phosphor by gmu-swe.
the class MultiDTaintedArrayWithObjTag method boxIfNecessary.
public static final Object boxIfNecessary(final Object in) {
if (in != null && in.getClass().isArray()) {
if (in.getClass().getComponentType().isPrimitive()) {
// Is prim arraytype
Class tmp = in.getClass();
int dims = 0;
while (tmp.isArray()) {
tmp = tmp.getComponentType();
dims++;
}
if (dims > 1) {
// this should never be possible.
Type t = Type.getType(in.getClass());
initWithEmptyTaints((Object[]) in, t.getElementType().getSort(), t.getDimensions());
} else {
if (tmp == Boolean.TYPE)
return new LazyBooleanArrayObjTags((boolean[]) in);
if (tmp == Byte.TYPE)
return new LazyByteArrayObjTags(((byte[]) in));
if (tmp == Character.TYPE)
return new LazyCharArrayObjTags(((char[]) in));
if (tmp == Double.TYPE)
return new LazyDoubleArrayObjTags(((double[]) in));
if (tmp == Float.TYPE)
return new LazyFloatArrayObjTags(((float[]) in));
if (tmp == Integer.TYPE)
return new LazyIntArrayObjTags(((int[]) in));
if (tmp == Long.TYPE)
return new LazyLongArrayObjTags(((long[]) in));
if (tmp == Short.TYPE)
return new LazyShortArrayObjTags(((short[]) in));
throw new IllegalArgumentException();
}
} else if (in.getClass().getComponentType().isArray() && in.getClass().getComponentType().getComponentType().isPrimitive()) {
// THIS array is an prim[][] array
Object[] _in = (Object[]) in;
Class tmp = in.getClass();
while (tmp.isArray()) {
tmp = tmp.getComponentType();
}
if (tmp == Boolean.TYPE) {
LazyBooleanArrayObjTags[] ret = new LazyBooleanArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyBooleanArrayObjTags((boolean[]) _in[i]);
return ret;
}
if (tmp == Byte.TYPE) {
LazyByteArrayObjTags[] ret = new LazyByteArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyByteArrayObjTags((byte[]) _in[i]);
return ret;
}
if (tmp == Character.TYPE) {
LazyCharArrayObjTags[] ret = new LazyCharArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyCharArrayObjTags((char[]) _in[i]);
return ret;
}
if (tmp == Double.TYPE) {
LazyDoubleArrayObjTags[] ret = new LazyDoubleArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyDoubleArrayObjTags((double[]) _in[i]);
return ret;
}
if (tmp == Float.TYPE) {
LazyFloatArrayObjTags[] ret = new LazyFloatArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyFloatArrayObjTags((float[]) _in[i]);
return ret;
}
if (tmp == Integer.TYPE) {
LazyIntArrayObjTags[] ret = new LazyIntArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyIntArrayObjTags((int[]) _in[i]);
return ret;
}
if (tmp == Short.TYPE) {
LazyShortArrayObjTags[] ret = new LazyShortArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyShortArrayObjTags((short[]) _in[i]);
return ret;
}
if (tmp == Long.TYPE) {
LazyLongArrayObjTags[] ret = new LazyLongArrayObjTags[_in.length];
for (int i = 0; i < _in.length; i++) ret[i] = new LazyLongArrayObjTags((long[]) _in[i]);
return ret;
}
throw new UnsupportedOperationException();
} 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;
}
Aggregations