use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag 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.TaintedBooleanWithObjTag in project phosphor by gmu-swe.
the class NativeHelper method ensureIsBoxedObjTags.
@SuppressWarnings("rawtypes")
public static final Collection ensureIsBoxedObjTags(Collection in) {
if (in != null) {
Collection tmp = null;
for (Object o : in) {
if (o == null)
break;
Type t = Type.getType(o.getClass());
if (t.getSort() == Type.ARRAY && t.getElementType().getSort() != Type.OBJECT) {
if (tmp == null) {
try {
tmp = (Collection) in.getClass().getConstructor().newInstance(null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithObjTag.boxIfNecessary(o), new TaintedBooleanWithObjTag());
} else
break;
}
if (tmp != null) {
in.clear();
tmp.add$$PHOSPHORTAGGED(tmp, new TaintedBooleanWithObjTag());
}
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag in project phosphor by gmu-swe.
the class NativeHelper method ensureIsUnBoxedImplicitTracking.
public static final Collection ensureIsUnBoxedImplicitTracking(Collection in) {
if (in != null) {
Collection tmp = null;
for (Object o : in) {
if (o != null && MultiDTaintedArrayWithObjTag.isPrimitiveBoxClass(o.getClass()) != null) {
if (tmp == null) {
try {
tmp = (Collection) in.getClass().getConstructor().newInstance(null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithObjTag.unboxRaw(o), new ControlTaintTagStack(), new TaintedBooleanWithObjTag());
} else
break;
}
if (tmp != null) {
in.clear();
tmp.add$$PHOSPHORTAGGED(tmp, new ControlTaintTagStack(), new TaintedBooleanWithObjTag());
}
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag in project phosphor by gmu-swe.
the class NativeHelper method ensureIsUnBoxedObjTags.
public static final Collection ensureIsUnBoxedObjTags(Collection in) {
if (in != null) {
Collection tmp = null;
for (Object o : in) {
if (o != null && MultiDTaintedArrayWithObjTag.isPrimitiveBoxClass(o.getClass()) != null) {
if (tmp == null) {
try {
tmp = (Collection) in.getClass().getConstructor().newInstance(null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithObjTag.unboxRaw(o), new TaintedBooleanWithObjTag());
} else
break;
}
if (tmp != null) {
in.clear();
tmp.add$$PHOSPHORTAGGED(tmp, new TaintedBooleanWithObjTag());
}
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithObjTag in project phosphor by gmu-swe.
the class BoxedPrimitiveStoreWithObjTags method booleanValue.
public static TaintedBooleanWithObjTag booleanValue(Boolean z) {
TaintedBooleanWithObjTag ret = new TaintedBooleanWithObjTag();
ret.val = z;
if (z.valueOf && tags.containsKey(z))
ret.taint = tags.get(z);
return ret;
}
Aggregations