use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag in project phosphor by gmu-swe.
the class NativeHelper method ensureIsBoxed.
@SuppressWarnings("rawtypes")
public static final Collection ensureIsBoxed(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(MultiDTaintedArrayWithIntTag.boxIfNecessary(o), new TaintedBooleanWithIntTag());
} else
break;
}
if (tmp != null) {
in.clear();
tmp.add$$PHOSPHORTAGGED(tmp, new TaintedBooleanWithIntTag());
}
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag in project phosphor by gmu-swe.
the class NativeHelper method ensureIsUnBoxed.
public static final Collection ensureIsUnBoxed(Collection in) {
if (in != null) {
Collection tmp = null;
for (Object o : in) {
if (o != null && MultiDTaintedArrayWithIntTag.isPrimitiveBoxClass(o.getClass()) != null) {
if (tmp == null) {
try {
tmp = (Collection) in.getClass().getConstructor().newInstance(null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
tmp.add$$PHOSPHORTAGGED(MultiDTaintedArrayWithIntTag.unboxRaw(o), new TaintedBooleanWithIntTag());
} else
break;
}
if (tmp != null) {
in.clear();
tmp.add$$PHOSPHORTAGGED(tmp, new TaintedBooleanWithIntTag());
}
}
return in;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag 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;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag in project phosphor by gmu-swe.
the class BoxedPrimitiveStoreWithIntTags method booleanValue.
public static TaintedBooleanWithIntTag booleanValue(Boolean z) {
TaintedBooleanWithIntTag ret = new TaintedBooleanWithIntTag();
ret.val = z;
if (z.valueOf && tags.containsKey(z))
ret.taint = tags.get(z);
return ret;
}
use of edu.columbia.cs.psl.phosphor.struct.TaintedBooleanWithIntTag in project phosphor by gmu-swe.
the class RuntimeReflectionPropogator method get.
public static Object get(Field f, Object obj, boolean isObjTags) throws IllegalArgumentException, IllegalAccessException {
f.setAccessible(true);
Object ret;
if (f.getType().isPrimitive()) {
if (f.getType() == Boolean.TYPE)
if (isObjTags)
ret = getBoolean$$PHOSPHORTAGGED(f, obj, new TaintedBooleanWithObjTag());
else
ret = getBoolean$$PHOSPHORTAGGED(f, obj, new TaintedBooleanWithIntTag());
else if (f.getType() == Byte.TYPE)
if (isObjTags)
ret = getByte$$PHOSPHORTAGGED(f, obj, new TaintedByteWithObjTag());
else
ret = getByte$$PHOSPHORTAGGED(f, obj, new TaintedByteWithIntTag());
else if (f.getType() == Character.TYPE)
if (isObjTags)
ret = getChar$$PHOSPHORTAGGED(f, obj, new TaintedCharWithObjTag());
else
ret = getChar$$PHOSPHORTAGGED(f, obj, new TaintedCharWithIntTag());
else if (f.getType() == Double.TYPE)
if (isObjTags)
ret = getDouble$$PHOSPHORTAGGED(f, obj, new TaintedDoubleWithObjTag());
else
ret = getDouble$$PHOSPHORTAGGED(f, obj, new TaintedDoubleWithIntTag());
else if (f.getType() == Float.TYPE)
if (isObjTags)
ret = getFloat$$PHOSPHORTAGGED(f, obj, new TaintedFloatWithObjTag());
else
ret = getFloat$$PHOSPHORTAGGED(f, obj, new TaintedFloatWithIntTag());
else if (f.getType() == Long.TYPE)
if (isObjTags)
ret = getLong$$PHOSPHORTAGGED(f, obj, new TaintedLongWithObjTag());
else
ret = getLong$$PHOSPHORTAGGED(f, obj, new TaintedLongWithIntTag());
else if (f.getType() == Integer.TYPE)
if (isObjTags)
ret = getInt$$PHOSPHORTAGGED(f, obj, new TaintedIntWithObjTag());
else
ret = getInt$$PHOSPHORTAGGED(f, obj, new TaintedIntWithIntTag());
else if (f.getType() == Short.TYPE)
if (isObjTags)
ret = getShort$$PHOSPHORTAGGED(f, obj, new TaintedShortWithObjTag());
else
ret = getShort$$PHOSPHORTAGGED(f, obj, new TaintedShortWithIntTag());
else
throw new IllegalArgumentException();
} else
ret = f.get(obj);
if (f.getType().isArray() && f.getType().getComponentType().isPrimitive()) {
Object taint = null;
try {
try {
if (ret instanceof LazyArrayIntTags && ((LazyArrayIntTags) ret).taints != null) {
return ret;
} else if (ret instanceof LazyArrayObjTags && ((LazyArrayObjTags) ret).taints != null) {
return ret;
} else {
Field taintField;
if (fieldToField.containsKey(f))
taintField = fieldToField.get(f);
else {
taintField = f.getDeclaringClass().getDeclaredField(f.getName() + TaintUtils.TAINT_FIELD);
taintField.setAccessible(true);
fieldToField.put(f, taintField);
}
taint = taintField.get(obj);
return taint;
}
} catch (NoSuchFieldException t) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (ret instanceof TaintedPrimitiveWithIntTag) {
return ((TaintedPrimitiveWithIntTag) ret).toPrimitiveType();
}
if (ret instanceof TaintedPrimitiveWithObjTag) {
return ((TaintedPrimitiveWithObjTag) ret).toPrimitiveType();
}
return ret;
}
Aggregations