本文整理汇总了Java中soot.tagkit.IntegerConstantValueTag类的典型用法代码示例。如果您正苦于以下问题:Java IntegerConstantValueTag类的具体用法?Java IntegerConstantValueTag怎么用?Java IntegerConstantValueTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntegerConstantValueTag类属于soot.tagkit包,在下文中一共展示了IntegerConstantValueTag类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributeResourceId
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
/**
* Returns the Android resource Id of the attribute which has the given name.
*
* @param name the attribute's name.
* @return the resource Id defined by Android or -1 if the attribute does not exist.
* @see android.R.attr
*/
public static int getAttributeResourceId(String name) {
// try to get attribute's resource Id from Androids R class. Since we
// don't want a hard-coded reference to the Android classes, we maintain
// our own list.
if (name.equals("name"))
return resId_name;
else if (name.equals("maxSdkVersion"))
return resId_maxSdkVersion;
else if (name.equals("minSdkVersion"))
return resId_minSdkVersion;
else if (name.equals("onClick"))
return resId_onClick;
// If we couldn't find the value, try to find Android's R class in Soot
SootClass rClass = Scene.v().forceResolve("android.R$attr", SootClass.BODIES);
if (!rClass.declaresFieldByName(name))
return -1;
SootField idField = rClass.getFieldByName(name);
for (Tag t : idField.getTags())
if (t instanceof IntegerConstantValueTag) {
IntegerConstantValueTag cvt = (IntegerConstantValueTag) t;
return cvt.getIntValue();
}
return -1;
}
示例2: getDefaultValue
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
/**
* 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;
}
示例3: parseFieldTags
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
public static LinkedList<SootAnnotations.Annotation> parseFieldTags(SootField sf) {
List<Tag> tags = sf.getTags();
LinkedList<SootAnnotations.Annotation> annot = null;
for (Tag t : tags) {
if (t instanceof VisibilityAnnotationTag) {
if (annot!=null) {
throw new RuntimeException("Bug in parseFieldTags");
}
annot = parseAnnotations((VisibilityAnnotationTag)t);
} else if (t instanceof SignatureTag) {
//TODO: do we want to do something with that?
} else if (t instanceof StringConstantValueTag) {
} else if (t instanceof IntegerConstantValueTag) {
} else {
Log.debug("Unimplemented Tag found: "+t.getName());
}
}
if (annot == null) annot = new LinkedList<SootAnnotations.Annotation>();
return annot;
}
示例4: parseFieldTags
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
public static LinkedList<SootAnnotations.Annotation> parseFieldTags(SootField sf) {
List<Tag> tags = sf.getTags();
LinkedList<SootAnnotations.Annotation> annot = null;
for (Tag t : tags) {
if (t instanceof VisibilityAnnotationTag) {
if (annot!=null) {
throw new RuntimeException("Bug in parseFieldTags");
}
annot = parseAnnotations((VisibilityAnnotationTag)t);
} else if (t instanceof SignatureTag) {
//TODO: do we want to do something with that?
} else if (t instanceof StringConstantValueTag) {
} else if (t instanceof IntegerConstantValueTag) {
} else {
Log.error("Unimplemented Tag found: "+t.getName());
}
}
if (annot == null) annot = new LinkedList<SootAnnotations.Annotation>();
return annot;
}
示例5: makeConstantItem
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
private EncodedValue makeConstantItem(SootField sf, Tag t) {
if (!(t instanceof ConstantValueTag))
throw new RuntimeException("error: t not ConstantValueTag.");
if (t instanceof IntegerConstantValueTag) {
Type sft = sf.getType();
IntegerConstantValueTag i = (IntegerConstantValueTag) t;
if (sft instanceof BooleanType) {
int v = i.getIntValue();
if (v == 0) {
return ImmutableBooleanEncodedValue.FALSE_VALUE;
} else if (v == 1) {
return ImmutableBooleanEncodedValue.TRUE_VALUE;
} else {
throw new RuntimeException(
"error: boolean value from int with value != 0 or 1.");
}
} else if (sft instanceof CharType) {
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);
}
} else if (t instanceof LongConstantValueTag) {
LongConstantValueTag l = (LongConstantValueTag) t;
return new ImmutableLongEncodedValue(l.getLongValue());
} else if (t instanceof DoubleConstantValueTag) {
DoubleConstantValueTag d = (DoubleConstantValueTag) t;
return new ImmutableDoubleEncodedValue(d.getDoubleValue());
} else if (t instanceof FloatConstantValueTag) {
FloatConstantValueTag f = (FloatConstantValueTag) t;
return new ImmutableFloatEncodedValue(f.getFloatValue());
} else if (t instanceof StringConstantValueTag) {
StringConstantValueTag s = (StringConstantValueTag) t;
return new ImmutableStringEncodedValue(s.getStringValue());
} else
throw new RuntimeException("Unexpected constant type");
}
示例6: createConstantTagFromValue
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
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;
}
示例7: checkConstantValue
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
private boolean checkConstantValue(ConstantValueTag t, Constant rightOp) {
if (t == null || rightOp == null)
return true;
if (t instanceof DoubleConstantValueTag) {
if (!(rightOp instanceof DoubleConstant))
return false;
return ((DoubleConstantValueTag) t).getDoubleValue() == ((DoubleConstant) rightOp).value;
}
else if (t instanceof FloatConstantValueTag) {
if (!(rightOp instanceof FloatConstant))
return false;
return ((FloatConstantValueTag) t).getFloatValue() == ((FloatConstant) rightOp).value;
}
else if (t instanceof IntegerConstantValueTag) {
if (!(rightOp instanceof IntConstant))
return false;
return ((IntegerConstantValueTag) t).getIntValue() == ((IntConstant) rightOp).value;
}
else if (t instanceof LongConstantValueTag) {
if (!(rightOp instanceof LongConstant))
return false;
return ((LongConstantValueTag) t).getLongValue() == ((LongConstant) rightOp).value;
}
else if (t instanceof StringConstantValueTag) {
if (!(rightOp instanceof StringConstant))
return false;
return ((StringConstantValueTag) t).getStringValue().equals(((StringConstant) rightOp).value);
}
else
// We don't know the type, so we assume it's alright
return true;
}
示例8: findLastResIDAssignment
import soot.tagkit.IntegerConstantValueTag; //导入依赖的package包/类
/**
* Finds the last assignment to the given local representing a resource ID
* by searching upwards from the given statement
*
* @param stmt
* The statement from which to look backwards
* @param local
* The variable for which to look for assignments
* @return The last value assigned to the given variable
*/
private Integer findLastResIDAssignment(Stmt stmt, Local local, BiDiInterproceduralCFG<Unit, SootMethod> cfg, Set<Stmt> doneSet) {
if (!doneSet.add(stmt))
return null;
// If this is an assign statement, we need to check whether it changes
// the variable we're looking for
if (stmt instanceof AssignStmt) {
AssignStmt assign = (AssignStmt) stmt;
if (assign.getLeftOp() == local) {
// ok, now find the new value from the right side
if (assign.getRightOp() instanceof IntConstant)
return ((IntConstant) assign.getRightOp()).value;
else if (assign.getRightOp() instanceof FieldRef) {
SootField field = ((FieldRef) assign.getRightOp()).getField();
for (Tag tag : field.getTags())
if (tag instanceof IntegerConstantValueTag)
return ((IntegerConstantValueTag) tag).getIntValue();
else
System.err.println("Constant " + field + " was of unexpected type");
} else if (assign.getRightOp() instanceof InvokeExpr) {
InvokeExpr inv = (InvokeExpr) assign.getRightOp();
if (inv.getMethod().getName().equals("getIdentifier") && inv.getMethod().getDeclaringClass().getName().equals("android.content.res.Resources") && this.resourcePackages != null) {
// The right side of the assignment is a call into the
// well-known
// Android API method for resource handling
if (inv.getArgCount() != 3) {
System.err.println("Invalid parameter count for call to getIdentifier");
return null;
}
// Find the parameter values
String resName = "";
String resID = "";
String packageName = "";
// In the trivial case, these values are constants
if (inv.getArg(0) instanceof StringConstant)
resName = ((StringConstant) inv.getArg(0)).value;
if (inv.getArg(1) instanceof StringConstant)
resID = ((StringConstant) inv.getArg(1)).value;
if (inv.getArg(2) instanceof StringConstant)
packageName = ((StringConstant) inv.getArg(2)).value;
else if (inv.getArg(2) instanceof Local)
packageName = findLastStringAssignment(stmt, (Local) inv.getArg(2), cfg);
else {
System.err.println("Unknown parameter type in call to getIdentifier");
return null;
}
// Find the resource
ARSCFileParser.AbstractResource res = findResource(resName, resID, packageName);
if (res != null)
return res.getResourceID();
}
}
}
}
// Continue the search upwards
for (Unit pred : cfg.getPredsOf(stmt)) {
if (!(pred instanceof Stmt))
continue;
Integer lastAssignment = findLastResIDAssignment((Stmt) pred, local, cfg, doneSet);
if (lastAssignment != null)
return lastAssignment;
}
return null;
}