/* member = {field} modifier* type name semicolon | {method} modifier* type name l_paren parameter_list? r_paren throws_clause? method_body; */ public void outAFieldMember(AFieldMember node) { int modifier = 0; Type type = null; String name = null; name = (String) mProductions.removeLast(); type = (Type) mProductions.removeLast(); modifier = processModifiers(node.getModifier()); SootField f = new SootField(name, type, modifier); mSootClass.addField(f); }
public static SootField createSootField( SootClass sootClass, String name, Type type, boolean isStatic) { int modifier = Modifier.PUBLIC; if (isStatic) { modifier = modifier | Modifier.STATIC; } SootField sootField = new SootField(name, type, modifier); sootClass.addField(sootField); System.out.println("CREATE-FIELD: " + name); return sootField; }
public static SootField mockSootField(String clsName, String fieldName, boolean isStatic) { SootClass sc = mockSootClass(clsName); SootField sf = null; try { sf = sc.getFieldByName(fieldName); } catch (Exception ex) { sf = null; } if (null == sf) { int m = Modifier.PUBLIC; if (isStatic) { m = m | Modifier.STATIC; } sf = new SootField(fieldName, InstrumentationUtils.toSootTypeByName(fieldName), m); sc.addField(sf); } return sf; }
public Code(TypeVars tvars) { this.j = Jimple.v(); this.localX = j.newLocal("x", IntType.v()); this.localY = j.newLocal("y", IntType.v()); this.localZ = j.newLocal("z", IntType.v()); this.localO = j.newLocal("o", RefType.v("java.lang.Object")); this.localT = j.newLocal("t", RefType.v("TestClass")); this.localThis = j.newLocal("this", RefType.v("TestClass")); this.varX = Var.fromLocal(localX); this.varY = Var.fromLocal(localY); this.varZ = Var.fromLocal(localZ); this.varO = Var.fromLocal(localO); this.varT = Var.fromLocal(localT); this.varThis = Var.fromLocal(localThis); this.tvarX = tvars.testParam(varX, ""); this.tvarY = tvars.testParam(varY, ""); this.tvarZ = tvars.testParam(varZ, ""); this.tvarO = tvars.testParam(varO, ""); this.tvarT = tvars.testParam(varT, ""); this.tvarThis = tvars.testParam(varThis, ""); this.init = Environments.makeEmpty() .add(varX, tvarX) .add(varY, tvarY) .add(varZ, tvarZ) .add(varO, tvarO) .add(varT, tvarT) .add(varThis, tvarThis); this.testClass = makeFreshClass("TestClass"); Map<SootField, TypeDomain.Type<Level>> fieldMap = new HashMap<>(); this.testLowField_int = new SootField("testLowField", IntType.v(), 0); testClass.addField(this.testLowField_int); fieldMap.put(testLowField_int, TLOW); this.testHighField_int = new SootField("testHighField", IntType.v(), 0); testClass.addField(this.testHighField_int); fieldMap.put(testHighField_int, THIGH); this.testStaticDynField_int = new SootField("testStaticDynField", IntType.v(), Modifier.STATIC); testClass.addField(this.testStaticDynField_int); fieldMap.put(testStaticDynField_int, DYN); // freeze field map this.fields = new FieldTable<>(fieldMap); Map<SootMethod, Signature<Level>> sigMap = new HashMap<>(); Symbol.Param<LowHigh.Level> param_x = param(0); Symbol.Param<LowHigh.Level> param_y = param(1); // Method: // int testCallee() // with {} effect {} this.testCallee__int = new SootMethod("testCallee", Collections.emptyList(), IntType.v(), Modifier.ABSTRACT); this.testClass.addMethod(testCallee__int); sigMap.put( this.testCallee__int, makeSignature( this.testCallee__int.getParameterCount(), Stream.of(leS(Symbol.literal(PUB), ret())).collect(toList()), Effects.emptyEffect())); // Method: // int testCallee_int_int__int (int, int) // with {@param1 <= @ret, @param2 <= @ret} effect {} this.testCallee_int_int__int = new SootMethod( "testCallee", asList(IntType.v(), IntType.v()), IntType.v(), Modifier.ABSTRACT); this.testClass.addMethod(testCallee_int_int__int); Stream<SigConstraint<Level>> sigCstrs = Stream.of(leS(param_x, ret()), leS(param_y, ret())); sigMap.put( this.testCallee_int_int__int, makeSignature( this.testCallee_int_int__int.getParameterCount(), sigCstrs.collect(toList()), Effects.emptyEffect())); // Method: // int ignoreSnd(int, int) // with { @param1 <= @ret } effect {} this.ignoreSnd_int_int__int = new SootMethod( "ignoreSnd", asList(IntType.v(), IntType.v()), IntType.v(), Modifier.ABSTRACT); this.testClass.addMethod(ignoreSnd_int_int__int); sigCstrs = Stream.of(leS(param_x, ret()), leS(param_y, param_y)); sigMap.put( this.ignoreSnd_int_int__int, makeSignature( this.ignoreSnd_int_int__int.getParameterCount(), sigCstrs.collect(toList()), Effects.emptyEffect())); // Method: // int writeToLowReturn0(int) // with { @param0 <= LOW } effect { LOW } this.writeToLowReturn0_int__int = new SootMethod("writeToLow", singletonList(IntType.v()), IntType.v(), Modifier.ABSTRACT); this.testClass.addMethod(this.writeToLowReturn0_int__int); sigCstrs = Stream.of((leS(param_x, literal(TLOW))), leS(ret(), ret())); sigMap.put( this.writeToLowReturn0_int__int, makeSignature( this.writeToLowReturn0_int__int.getParameterCount(), sigCstrs.collect(toList()), Effects.makeEffects(TLOW))); // Method: // int ignore0Low1ReturnHigh(int, int) // with { @param1 <= LOW, HIGH <= ret } effect {} this.ignore0Low1ReturnHigh = new SootMethod( "ignore0Low1ReturnHigh", asList(IntType.v(), IntType.v()), IntType.v(), Modifier.ABSTRACT); this.testClass.addMethod(this.ignore0Low1ReturnHigh); sigCstrs = Stream.of(leS(param(1), literal(TLOW)), leS(literal(THIGH), ret())); sigMap.put( this.ignore0Low1ReturnHigh, makeSignature( this.ignore0Low1ReturnHigh.getParameterCount(), sigCstrs.collect(toList()), Effects.emptyEffect())); // freeze signatures this.signatures = makeTable(sigMap); }