MustDef result = new MustDef();
Map<Var, Definition> resultMap = result.reachingDef;
// Take the join of all variables that are not TOP in this.
for (Map.Entry<Var, Definition> varEntry : a.reachingDef.entrySet()) {
Var var = varEntry.getKey();
Definition aDef = varEntry.getValue();
if (aDef == null) {
// "a" is BOTTOM implies that the variable has more than one possible
// definition. We set the join of this to be BOTTOM regardless of what
// "b" might be.
resultMap.put(var, null);
continue;
}
if (b.reachingDef.containsKey(var)) {
Definition bDef = b.reachingDef.get(var);
if (aDef.equals(bDef)) {
resultMap.put(var, aDef);
} else {
resultMap.put(var, null);
}
} else {
resultMap.put(var, aDef);
}
}
// Take the join of all variables that are not TOP in other but it is TOP
// in this.
for (Map.Entry<Var, Definition> entry : b.reachingDef.entrySet()) {
Var var = entry.getKey();
if (!a.reachingDef.containsKey(var)) {
resultMap.put(var, entry.getValue());
}
}
return result;