mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
* 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:
parent
80bb477cc4
commit
e17e95a828
1 changed files with 9 additions and 1 deletions
|
@ -6,13 +6,21 @@
|
||||||
string printTerm(ATerm t)
|
string printTerm(ATerm t)
|
||||||
{
|
{
|
||||||
char * s = ATwriteToString(t);
|
char * s = ATwriteToString(t);
|
||||||
|
if (!s) throw Error("cannot print term");
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Error badTerm(const format & f, ATerm t)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue