本文整理汇总了Java中soot.jimple.StringConstant.v方法的典型用法代码示例。如果您正苦于以下问题:Java StringConstant.v方法的具体用法?Java StringConstant.v怎么用?Java StringConstant.v使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soot.jimple.StringConstant
的用法示例。
在下文中一共展示了StringConstant.v方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: caseSpecialInvokeExpr
import soot.jimple.StringConstant; //导入方法依赖的package包/类
@Override
public void caseSpecialInvokeExpr(SpecialInvokeExpr v) {
//is the invokeExpr a source method?
if(isSourceMethod(v)) {
StringConstant newSourceValue = StringConstant.v("loggingPoint");
SMTBinding binding = stmtVisitor.createNewBindingForValue(newSourceValue);
stmtVisitor.addValueBindingToVariableDeclaration(newSourceValue, binding);
//no smt-statement required, just return the binding
this.result = binding;
// Additionally check whether the source method need special treatment
if(isExpressionThatNeedsToBeConvertedToSMT(v)) {
convertSpecialExpressionsToSMT(v, currentStatement);
}
} else {
if(isStringOperationSupportedBySMT(v))
convertStringOperationToSMT(v, v.getBase());
else if(isExpressionThatNeedsToBeConvertedToSMT(v))
convertSpecialExpressionsToSMT(v, currentStatement);
else
convertAPIMethodToSMT(v);
}
}
示例2: caseVirtualInvokeExpr
import soot.jimple.StringConstant; //导入方法依赖的package包/类
@Override
public void caseVirtualInvokeExpr(VirtualInvokeExpr virtualInvokeExpr) {
//is the invokeExpr a source method?
if(isSourceMethod(virtualInvokeExpr)) {
StringConstant newSourceValue = StringConstant.v("loggingPoint");
SMTBinding binding = stmtVisitor.createNewBindingForValue(newSourceValue);
stmtVisitor.addValueBindingToVariableDeclaration(newSourceValue, binding);
//no smt-statement required, just return the binding
this.result = binding;
// Additionally check whether the source method need special treatment
if(isExpressionThatNeedsToBeConvertedToSMT(virtualInvokeExpr)) {
convertSpecialExpressionsToSMT(virtualInvokeExpr, currentStatement);
}
} else {
if(isStringOperationSupportedBySMT(virtualInvokeExpr))
convertStringOperationToSMT(virtualInvokeExpr, virtualInvokeExpr.getBase());
else if(isExpressionThatNeedsToBeConvertedToSMT(virtualInvokeExpr))
convertSpecialExpressionsToSMT(virtualInvokeExpr, currentStatement);
else
convertAPIMethodToSMT(virtualInvokeExpr);
}
}
示例3: getSimpleDefaultValue
import soot.jimple.StringConstant; //导入方法依赖的package包/类
protected Value getSimpleDefaultValue(String t) {
if (t.equals("java.lang.String"))
return StringConstant.v("");
if (t.equals("char"))
return DIntConstant.v(0, CharType.v());
if (t.equals("byte"))
return DIntConstant.v(0, ByteType.v());
if (t.equals("short"))
return DIntConstant.v(0, ShortType.v());
if (t.equals("int"))
return IntConstant.v(0);
if (t.equals("float"))
return FloatConstant.v(0);
if (t.equals("long"))
return LongConstant.v(0);
if (t.equals("double"))
return DoubleConstant.v(0);
if (t.equals("boolean"))
return DIntConstant.v(0, BooleanType.v());
//also for arrays etc.
return G.v().soot_jimple_NullConstant();
}
示例4: toSootValue
import soot.jimple.StringConstant; //导入方法依赖的package包/类
private Value toSootValue(Object val) throws AssertionError {
Value v;
if (val instanceof Integer)
v = IntConstant.v((Integer) val);
else if (val instanceof Float)
v = FloatConstant.v((Float) val);
else if (val instanceof Long)
v = LongConstant.v((Long) val);
else if (val instanceof Double)
v = DoubleConstant.v((Double) val);
else if (val instanceof String)
v = StringConstant.v(val.toString());
else if (val instanceof org.objectweb.asm.Type)
v = ClassConstant.v(((org.objectweb.asm.Type) val).getInternalName());
else if (val instanceof Handle)
v = MethodHandle.v(toSootMethodRef((Handle) val), ((Handle)val).getTag());
else
throw new AssertionError("Unknown constant type: " + val.getClass());
return v;
}
示例5: createTemporalBinding
import soot.jimple.StringConstant; //导入方法依赖的package包/类
public SMTBinding createTemporalBinding(SMTBinding.TYPE type) {
String tmpName = null;
switch(type) {
case String : tmpName = "StringTMP"; break;
case Int : tmpName = "IntTMP"; break;
case Bool : tmpName = "BoolTMP"; break;
case Real:
break;
default:
break;
}
StringConstant tmpValue = StringConstant.v(tmpName);
SMTBinding binding = null;
if(hasBindingForValue(tmpValue)) {
SMTBinding oldBinding = getLatestBindingForValue(tmpValue);
int ssaVersionOldBinding = oldBinding.getVersion();
//increment version
ssaVersionOldBinding += 1;
binding = new SMTBinding(oldBinding.getVariableName(), oldBinding.getType(), ssaVersionOldBinding);
}
else {
binding = new SMTBinding(tmpName, type, 0);
}
addValueBindingToVariableDeclaration(tmpValue, binding);
return binding;
}
示例6: caseInterfaceInvokeExpr
import soot.jimple.StringConstant; //导入方法依赖的package包/类
@Override
public void caseInterfaceInvokeExpr(InterfaceInvokeExpr v) {
if(isSourceMethod(v)) {
StringConstant newSourceValue = StringConstant.v("loggingPoint");
SMTBinding binding = stmtVisitor.createNewBindingForValue(newSourceValue);
stmtVisitor.addValueBindingToVariableDeclaration(newSourceValue, binding);
//no smt-statement required, just return the binding
this.result = binding;
// Additionally check whether the source method need special treatment
if(isExpressionThatNeedsToBeConvertedToSMT(v)) {
convertSpecialExpressionsToSMT(v, currentStatement);
}
}
else if(isExpressionThatNeedsToBeConvertedToSMT(v)){
convertSpecialExpressionsToSMT(v, currentStatement);
}else{
//just propagate the taint value of previous statement
Stmt prevStmt = stmtVisitor.getPreviousDataFlowPathElement(currentStatement);
if(prevStmt == null)
throw new RuntimeException("there is no previous statement");
else{
this.result = stmtVisitor.getBindingForTaintedValue(prevStmt);
if(this.result == null)
throw new RuntimeException("double check this here");
}
}
}
示例7: testStringConstant
import soot.jimple.StringConstant; //导入方法依赖的package包/类
@Test
public void testStringConstant() {
Value v = StringConstant.v("test");
assertTrue(ExceptionTestUtility.sameMembers(utility.VM_ERRORS, Collections.EMPTY_SET,
unitAnalysis.mightThrow(v)));
assertEquals(utility.VM_ERRORS_PLUS_SUPERTYPES,
utility.catchableSubset(unitAnalysis.mightThrow(v)));
}
示例8: createJimpleConstantValue
import soot.jimple.StringConstant; //导入方法依赖的package包/类
public Value createJimpleConstantValue(cp_info[] constant_pool) {
CONSTANT_Utf8_info ci = (CONSTANT_Utf8_info)(constant_pool[string_index]);
return StringConstant.v(ci.convert());
}
示例9: createJimpleConstantValue
import soot.jimple.StringConstant; //导入方法依赖的package包/类
public Value createJimpleConstantValue(cp_info[] constant_pool) {
return StringConstant.v(convert());
}
示例10: inInvokeStmt
import soot.jimple.StringConstant; //导入方法依赖的package包/类
public void inInvokeStmt(InvokeStmt s){
InvokeExpr invokeExpr = s.getInvokeExpr();
SootMethod maybeInline = invokeExpr.getMethod();
//check whether we want to inline
ASTMethodNode toInlineASTMethod = cleaner.inline(maybeInline);
if(toInlineASTMethod ==null){
//not to inline
return;
}
else{//yes we want to inline
// we know that the method to be inlined has no declarations.
List<Object> subBodies = toInlineASTMethod.get_SubBodies();
if(subBodies.size() != 1){
throw new RuntimeException ("Found ASTMEthod node with more than one subBodies");
}
List body = (List)subBodies.get(0);
ASTParentNodeFinder finder = new ASTParentNodeFinder();
underAnalysis.apply(finder);
List<ASTStatementSequenceNode> newChangedBodyPart = createChangedBodyPart(s,body,finder);
boolean replaced = replaceSubBody(s,newChangedBodyPart,finder);
if(replaced){
//so the invoke stmt has been replaced with the body of the method invoked
/*
* if the inlined method contained an assignment to a static field
* we want to replace that with a throw stmt
*/
StaticDefinitionFinder defFinder = new StaticDefinitionFinder(maybeInline);
toInlineASTMethod.apply(defFinder);
if(defFinder.anyFinalFieldDefined()){
//create throw stmt to be added to inlined method
//create a SootMethodRef
SootClass runtime = Scene.v().loadClassAndSupport("java.lang.RuntimeException");
if(runtime.declaresMethod("void <init>(java.lang.String)")){
SootMethod sootMethod = runtime.getMethod("void <init>(java.lang.String)");
SootMethodRef methodRef = sootMethod.makeRef();
RefType myRefType = RefType.v(runtime);
StringConstant tempString = StringConstant.v("This method used to have a definition of a final variable. "+
"Dava inlined the definition into the static initializer");
List list = new ArrayList();
list.add(tempString);
GNewInvokeExpr newInvokeExpr = new GNewInvokeExpr(myRefType,methodRef,list);
GThrowStmt throwStmt = new GThrowStmt(newInvokeExpr);
AugmentedStmt augStmt = new AugmentedStmt(throwStmt);
List<Object> sequence = new ArrayList<Object>();
sequence.add(augStmt);
ASTStatementSequenceNode seqNode = new ASTStatementSequenceNode(sequence);
List<Object> subBody = new ArrayList<Object>();
subBody.add(seqNode);
toInlineASTMethod.replaceBody(subBody);
}
}
}
}
}