private ConstantValueTag createConstantTagFromValue(Constant rightOp) { if (rightOp instanceof DoubleConstant) { return new DoubleConstantValueTag(((DoubleConstant) rightOp).value); } else if (rightOp instanceof FloatConstant) { return new FloatConstantValueTag(((FloatConstant) rightOp).value); } else if (rightOp instanceof IntConstant) { return new IntegerConstantValueTag(((IntConstant) rightOp).value); } else if (rightOp instanceof LongConstant) { return new LongConstantValueTag(((LongConstant) rightOp).value); } else if (rightOp instanceof StringConstant) { return new StringConstantValueTag(((StringConstant) rightOp).value); } else { return null; } }
IntegerConstantValueTag i = (IntegerConstantValueTag) t; if (sft instanceof BooleanType) { int v = i.getIntValue(); if (v == 0) { return ImmutableBooleanEncodedValue.FALSE_VALUE; return new ImmutableCharEncodedValue((char) i.getIntValue()); } else if (sft instanceof ByteType) { return new ImmutableByteEncodedValue((byte) i.getIntValue()); } else if (sft instanceof IntType) { return new ImmutableIntEncodedValue(i.getIntValue()); } else if (sft instanceof ShortType) { return new ImmutableShortEncodedValue((short) i.getIntValue()); } else { throw new RuntimeException("error: unexpected constant tag type: " + t + " for field " + sf);
tag = new IntegerConstantValueTag(((BooleanEncodedValue) ev).getValue() == true ? 1 : 0); } else if (ev instanceof ByteEncodedValue) { tag = new IntegerConstantValueTag(((ByteEncodedValue) ev).getValue()); } else if (ev instanceof CharEncodedValue) { tag = new IntegerConstantValueTag(((CharEncodedValue) ev).getValue()); } else if (ev instanceof DoubleEncodedValue) { tag = new DoubleConstantValueTag(((DoubleEncodedValue) ev).getValue()); tag = new FloatConstantValueTag(((FloatEncodedValue) ev).getValue()); } else if (ev instanceof IntEncodedValue) { tag = new IntegerConstantValueTag(((IntEncodedValue) ev).getValue()); } else if (ev instanceof LongEncodedValue) { tag = new LongConstantValueTag(((LongEncodedValue) ev).getValue()); } else if (ev instanceof ShortEncodedValue) { tag = new IntegerConstantValueTag(((ShortEncodedValue) ev).getValue()); } else if (ev instanceof StringEncodedValue) { tag = new StringConstantValueTag(((StringEncodedValue) ev).getValue());
return false; return ((IntegerConstantValueTag) t).getIntValue() == ((IntConstant) rightOp).value; } else if (t instanceof LongConstantValueTag) { if (!(rightOp instanceof LongConstant)) {
.addTag(new soot.tagkit.IntegerConstantValueTag(((Integer) field.fieldInstance().constantValue()).intValue())); } else if (field.fieldInstance().constantValue() instanceof Character) { sootField .addTag(new soot.tagkit.IntegerConstantValueTag(((Character) field.fieldInstance().constantValue()).charValue())); } else if (field.fieldInstance().constantValue() instanceof Short) { sootField .addTag(new soot.tagkit.IntegerConstantValueTag(((Short) field.fieldInstance().constantValue()).shortValue())); } else if (field.fieldInstance().constantValue() instanceof Byte) { sootField.addTag(new soot.tagkit.IntegerConstantValueTag(((Byte) field.fieldInstance().constantValue()).byteValue())); } else if (field.fieldInstance().constantValue() instanceof Boolean) { boolean b = ((Boolean) field.fieldInstance().constantValue()).booleanValue(); sootField.addTag(new soot.tagkit.IntegerConstantValueTag(b ? 1 : 0)); } else if (field.fieldInstance().constantValue() instanceof Long) { sootField.addTag(new soot.tagkit.LongConstantValueTag(((Long) field.fieldInstance().constantValue()).longValue()));
value = new Long(val); } else if (fieldType instanceof CharType && f.hasTag("IntegerConstantValueTag")) { int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); value = new Integer(val); } else if (fieldType instanceof BooleanType && f.hasTag("IntegerConstantValueTag")) { int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); if (val == 0) { value = new Boolean(false); int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); value = new Integer(val);
@Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { soot.Type type = AsmUtil.toJimpleType(desc); addDep(type); SootField field = Scene.v().makeSootField(name, type, access); Tag tag; if (value instanceof Integer) { tag = new IntegerConstantValueTag((Integer) value); } else if (value instanceof Float) { tag = new FloatConstantValueTag((Float) value); } else if (value instanceof Long) { tag = new LongConstantValueTag((Long) value); } else if (value instanceof Double) { tag = new DoubleConstantValueTag((Double) value); } else if (value instanceof String) { tag = new StringConstantValueTag(value.toString()); } else { tag = null; } if (tag != null) { field.addTag(tag); } if (signature != null) { field.addTag(new SignatureTag(signature)); } field = klass.getOrAddField(field); return new FieldBuilder(field, this); }
finalFields.put(new Long(val), f); } else if (fieldType instanceof CharType && f.hasTag("IntegerConstantValueTag")) { int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); finalFields.put(new Integer(val), f); } else if (fieldType instanceof BooleanType && f.hasTag("IntegerConstantValueTag")) { int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); if (val == 0) { finalFields.put(new Boolean(false), f); int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); finalFields.put(new Integer(val), f); } else if (f.hasTag("StringConstantValueTag")) {
switch (cval.tag) { case cp_info.CONSTANT_Integer: tag = new IntegerConstantValueTag((int) ((CONSTANT_Integer_info) cval).bytes); break; case cp_info.CONSTANT_Float:
int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); out.println(" " + declaration + " = '" + ((char) val) + "';"); int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); && f.hasTag("IntegerConstantValueTag")) { int val = ((IntegerConstantValueTag) f.getTag("IntegerConstantValueTag")).getIntValue(); out.println(" " + declaration + " = " + val + ";");
/** * @ast method * @aspect EmitJimple * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddExtensions/JimpleBackend/EmitJimple.jrag:329 */ public void jimplify1phase2() { String name = name(); soot.Type type = type().getSootType(); int modifiers = sootTypeModifiers(); if (!hostType().getSootClassDecl().declaresFieldByName(name)) { SootField f = Scene.v().makeSootField(name, type, modifiers); hostType().getSootClassDecl().addField(f); if (isStatic() && isFinal() && isConstant() && (type().isPrimitive() || type().isString())) { if (type().isString()) f.addTag(new soot.tagkit.StringConstantValueTag(constant().stringValue())); else if (type().isLong()) f.addTag(new soot.tagkit.LongConstantValueTag(constant().longValue())); else if (type().isDouble()) f.addTag(new soot.tagkit.DoubleConstantValueTag(constant().doubleValue())); else if (type().isFloat()) f.addTag(new soot.tagkit.FloatConstantValueTag(constant().floatValue())); else if (type().isIntegralType()) f.addTag(new soot.tagkit.IntegerConstantValueTag(constant().intValue())); } sootField = f; } else { sootField = hostType().getSootClassDecl().getFieldByName(name); } addAttributes(); }
} else if (field.hasTag("IntegerConstantValueTag")) { fieldString += " = "; fieldString += ((IntegerConstantValueTag) field.getTag("IntegerConstantValueTag")).getIntValue(); } else if (field.hasTag("LongConstantValueTag")) { fieldString += " = ";
switch (cval.tag) { case cp_info.CONSTANT_Integer: tag = new IntegerConstantValueTag((int)((CONSTANT_Integer_info)cval).bytes); break; case cp_info.CONSTANT_Float:
/** * Get default value of a field for constant pool * * @param field * Field to get default value for * @return Default value or <code>null</code> if there is no default value. */ public static Object getDefaultValue(SootField field) { if (field.hasTag("StringConstantValueTag")) { /* * Default value for string may only be returned if the field is of type String or a sub-type. */ if (acceptsStringInitialValue(field)) { return ((StringConstantValueTag) field.getTag("StringConstantValueTag")).getStringValue(); } } else if (field.hasTag("IntegerConstantValueTag")) { return ((IntegerConstantValueTag) field.getTag("IntegerConstantValueTag")).getIntValue(); } else if (field.hasTag("LongConstantValueTag")) { return ((LongConstantValueTag) field.getTag("LongConstantValueTag")).getLongValue(); } else if (field.hasTag("FloatConstantValueTag")) { return ((FloatConstantValueTag) field.getTag("FloatConstantValueTag")).getFloatValue(); } else if (field.hasTag("DoubleConstantValueTag")) { return ((DoubleConstantValueTag) field.getTag("DoubleConstantValueTag")).getDoubleValue(); } return null; }
switch (cval.tag) { case cp_info.CONSTANT_Integer: tag = new IntegerConstantValueTag((int)((CONSTANT_Integer_info)cval).bytes); break; case cp_info.CONSTANT_Float:
constant = FloatConstant.v(value); } else if (t instanceof IntegerConstantValueTag) { int value = ((IntegerConstantValueTag) t).getIntValue(); constant = IntConstant.v(value); } else if (t instanceof LongConstantValueTag) {
if (t instanceof IntegerConstantValueTag) { IntegerConstantValueTag cvt = (IntegerConstantValueTag) t; return cvt.getIntValue();
if (t instanceof IntegerConstantValueTag) { IntegerConstantValueTag cvt = (IntegerConstantValueTag) t; if (cvt.getIntValue() == resourceId) { tname = sf.getName(); idToNameMap.put(resourceId, tname);
for (Tag tag : field.getTags()) if (tag instanceof IntegerConstantValueTag) return ((IntegerConstantValueTag) tag).getIntValue(); else logger.error("Constant %s was of unexpected type", field.toString());