}
@Override
public void visitCallStm(CallStm s) {
for (int i=0; i<s.getArguments().length; i++) {
// merge argument and parameter if either one is used as an array
Variable arg = s.getArgument(i);
Variable param = s.getMethod().getParameter(i);
if (var_alias.getData(arg).array || var_alias.getData(param).array) {
var_alias.merge(arg, param);
s.setArgumentMutable(i, true);
}
}
// merge return var and result if ether one is used as an array
if (var_alias.getData(s.getResult()).array || var_alias.getData(s.getMethod().getReturnVar()).array) {
var_alias.merge(s.getResult(), s.getMethod().getReturnVar());
}
}
@Override
public void visitEscapeStm(EscapeStm s) {
Component c = var_alias.getData(s.getVar());
if (c.array) {
cfg.addStatement(new UnknownStm(s.getVar(), s.getOrigin()));
replace(s, cfg.finish());
} else {
cfg.setOrigin(s.getOrigin());
replace(s, cfg.finish());
}
}
});
}
// replace each variable by its component representative IF the representative is an array
for (Statement s : graph.getNodes()) {
// replace variables in nodes
s.visitBy(new StatementVisitor() {
private Variable getrep(Variable var) {
return var_alias.getRepresentativeKey(var);
}
private Variable replace(Variable var) {
Variable rep = getrep(var);
if (!var_alias.getData(rep).array) {
return var;
} else {
Debug.println(6, true, "Aliasing: " + var);
return rep;