2003-10-30 16:11:24 +00:00
|
|
|
#include "fix-expr.hh"
|
|
|
|
#include "expr.hh"
|
|
|
|
|
|
|
|
|
|
|
|
ATerm bottomupRewrite(TermFun & f, ATerm e)
|
|
|
|
{
|
|
|
|
e = f(e);
|
|
|
|
|
|
|
|
if (ATgetType(e) == AT_APPL) {
|
|
|
|
AFun fun = ATgetAFun(e);
|
|
|
|
int arity = ATgetArity(fun);
|
|
|
|
ATermList args = ATempty;
|
|
|
|
|
|
|
|
for (int i = arity - 1; i >= 0; i--)
|
|
|
|
args = ATinsert(args, bottomupRewrite(f, ATgetArgument(e, i)));
|
|
|
|
|
|
|
|
return (ATerm) ATmakeApplList(fun, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ATgetType(e) == AT_LIST) {
|
|
|
|
ATermList in = (ATermList) e;
|
|
|
|
ATermList out = ATempty;
|
|
|
|
|
|
|
|
while (!ATisEmpty(in)) {
|
|
|
|
out = ATinsert(out, bottomupRewrite(f, ATgetFirst(in)));
|
|
|
|
in = ATgetNext(in);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ATerm) ATreverse(out);
|
|
|
|
}
|
|
|
|
|
2003-10-30 16:18:40 +00:00
|
|
|
return e;
|
2003-10-30 16:11:24 +00:00
|
|
|
}
|