* Print a shared textual ATerm if the term if very large. Due to

substitutions, Fix terms are very large when printed as trees (in 
  memory, they are quite compact due to sharing).
This commit is contained in:
Eelco Dolstra 2003-11-05 16:20:57 +00:00
parent 80bb477cc4
commit e17e95a828
1 changed files with 9 additions and 1 deletions

View File

@ -6,13 +6,21 @@
string printTerm(ATerm t)
{
char * s = ATwriteToString(t);
if (!s) throw Error("cannot print term");
return s;
}
Error badTerm(const format & f, ATerm t)
{
return Error(format("%1%, in `%2%'") % f.str() % printTerm(t));
char * s = ATwriteToString(t);
if (!s) throw Error("cannot print term");
if (strlen(s) > 1000) {
int len;
s = ATwriteToSharedString(t, &len);
if (!s) throw Error("cannot print term");
}
return Error(format("%1%, in `%2%'") % f.str() % (string) s);
}