MCPcopy Create free account
hub / github.com/LFYSec/MScan / VarManager

Class VarManager

src/main/java/pascal/taie/frontend/soot/VarManager.java:38–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36import java.util.Objects;
37
38class VarManager {
39
40 private static final String THIS = "%this";
41
42 private static final String STRING_CONSTANT = "%stringconst";
43
44 private static final String CLASS_CONSTANT = "%classconst";
45
46 private static final String NULL_CONSTANT = "%nullconst";
47
48 /**
49 * The method which contains the variable managed by this VarManager.
50 */
51 private final JMethod method;
52
53 private final Converter converter;
54
55 private final Map<Local, Var> varMap = Maps.newLinkedHashMap();
56
57 private final List<Var> vars = new ArrayList<>();
58
59 private Var thisVar;
60
61 private final List<Var> params = new ArrayList<>();
62
63 private Var nullConst;
64
65 /**
66 * Counter for indexing all variables.
67 */
68 private int varCounter = 0;
69
70 /**
71 * Counter for naming temporary constant variables.
72 */
73 private int tempConstCounter = 0;
74
75 public VarManager(JMethod method, Converter converter) {
76 this.method = method;
77 this.converter = converter;
78 }
79
80 void addThis(Local thisLocal) {
81 thisVar = newVar(THIS, getTypeOf(thisLocal));
82 varMap.put(thisLocal, thisVar);
83 }
84
85 void addParams(List<Local> paramLocals) {
86 for (int i = 0; i < paramLocals.size(); i++) {
87 Local paramLocal = paramLocals.get(i);
88 // soot frontend cannot ensure availability of all parameter names
89 String paramName = Objects.requireNonNullElse(
90 method.getParamName(i), paramLocal.getName());
91 Var param = varMap.computeIfAbsent(paramLocal, l ->
92 newVar(paramName, getTypeOf(l)));
93 params.add(param);
94 }
95 }

Callers

nothing calls this directly

Calls 1

newLinkedHashMapMethod · 0.95

Tested by

no test coverage detected