Fix compatibility with latest boost::format

This commit is contained in:
Eelco Dolstra 2018-03-14 19:20:32 +01:00
parent c04bca3401
commit 55aa622fb1
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 23 additions and 23 deletions

View file

@ -10,7 +10,7 @@ namespace nix {
/* Displaying abstract syntax trees. */ /* Displaying abstract syntax trees. */
std::ostream & operator << (std::ostream & str, Expr & e) std::ostream & operator << (std::ostream & str, const Expr & e)
{ {
e.show(str); e.show(str);
return str; return str;
@ -58,48 +58,48 @@ std::ostream & operator << (std::ostream & str, const Symbol & sym)
return str; return str;
} }
void Expr::show(std::ostream & str) void Expr::show(std::ostream & str) const
{ {
abort(); abort();
} }
void ExprInt::show(std::ostream & str) void ExprInt::show(std::ostream & str) const
{ {
str << n; str << n;
} }
void ExprFloat::show(std::ostream & str) void ExprFloat::show(std::ostream & str) const
{ {
str << nf; str << nf;
} }
void ExprString::show(std::ostream & str) void ExprString::show(std::ostream & str) const
{ {
showString(str, s); showString(str, s);
} }
void ExprPath::show(std::ostream & str) void ExprPath::show(std::ostream & str) const
{ {
str << s; str << s;
} }
void ExprVar::show(std::ostream & str) void ExprVar::show(std::ostream & str) const
{ {
str << name; str << name;
} }
void ExprSelect::show(std::ostream & str) void ExprSelect::show(std::ostream & str) const
{ {
str << "(" << *e << ")." << showAttrPath(attrPath); str << "(" << *e << ")." << showAttrPath(attrPath);
if (def) str << " or (" << *def << ")"; if (def) str << " or (" << *def << ")";
} }
void ExprOpHasAttr::show(std::ostream & str) void ExprOpHasAttr::show(std::ostream & str) const
{ {
str << "((" << *e << ") ? " << showAttrPath(attrPath) << ")"; str << "((" << *e << ") ? " << showAttrPath(attrPath) << ")";
} }
void ExprAttrs::show(std::ostream & str) void ExprAttrs::show(std::ostream & str) const
{ {
if (recursive) str << "rec "; if (recursive) str << "rec ";
str << "{ "; str << "{ ";
@ -113,7 +113,7 @@ void ExprAttrs::show(std::ostream & str)
str << "}"; str << "}";
} }
void ExprList::show(std::ostream & str) void ExprList::show(std::ostream & str) const
{ {
str << "[ "; str << "[ ";
for (auto & i : elems) for (auto & i : elems)
@ -121,7 +121,7 @@ void ExprList::show(std::ostream & str)
str << "]"; str << "]";
} }
void ExprLambda::show(std::ostream & str) void ExprLambda::show(std::ostream & str) const
{ {
str << "("; str << "(";
if (matchAttrs) { if (matchAttrs) {
@ -143,7 +143,7 @@ void ExprLambda::show(std::ostream & str)
str << ": " << *body << ")"; str << ": " << *body << ")";
} }
void ExprLet::show(std::ostream & str) void ExprLet::show(std::ostream & str) const
{ {
str << "(let "; str << "(let ";
for (auto & i : attrs->attrs) for (auto & i : attrs->attrs)
@ -155,27 +155,27 @@ void ExprLet::show(std::ostream & str)
str << "in " << *body << ")"; str << "in " << *body << ")";
} }
void ExprWith::show(std::ostream & str) void ExprWith::show(std::ostream & str) const
{ {
str << "(with " << *attrs << "; " << *body << ")"; str << "(with " << *attrs << "; " << *body << ")";
} }
void ExprIf::show(std::ostream & str) void ExprIf::show(std::ostream & str) const
{ {
str << "(if " << *cond << " then " << *then << " else " << *else_ << ")"; str << "(if " << *cond << " then " << *then << " else " << *else_ << ")";
} }
void ExprAssert::show(std::ostream & str) void ExprAssert::show(std::ostream & str) const
{ {
str << "assert " << *cond << "; " << *body; str << "assert " << *cond << "; " << *body;
} }
void ExprOpNot::show(std::ostream & str) void ExprOpNot::show(std::ostream & str) const
{ {
str << "(! " << *e << ")"; str << "(! " << *e << ")";
} }
void ExprConcatStrings::show(std::ostream & str) void ExprConcatStrings::show(std::ostream & str) const
{ {
bool first = true; bool first = true;
str << "("; str << "(";
@ -186,7 +186,7 @@ void ExprConcatStrings::show(std::ostream & str)
str << ")"; str << ")";
} }
void ExprPos::show(std::ostream & str) void ExprPos::show(std::ostream & str) const
{ {
str << "__curPos"; str << "__curPos";
} }

View file

@ -76,17 +76,17 @@ string showAttrPath(const AttrPath & attrPath);
struct Expr struct Expr
{ {
virtual ~Expr() { }; virtual ~Expr() { };
virtual void show(std::ostream & str); virtual void show(std::ostream & str) const;
virtual void bindVars(const StaticEnv & env); virtual void bindVars(const StaticEnv & env);
virtual void eval(EvalState & state, Env & env, Value & v); virtual void eval(EvalState & state, Env & env, Value & v);
virtual Value * maybeThunk(EvalState & state, Env & env); virtual Value * maybeThunk(EvalState & state, Env & env);
virtual void setName(Symbol & name); virtual void setName(Symbol & name);
}; };
std::ostream & operator << (std::ostream & str, Expr & e); std::ostream & operator << (std::ostream & str, const Expr & e);
#define COMMON_METHODS \ #define COMMON_METHODS \
void show(std::ostream & str); \ void show(std::ostream & str) const; \
void eval(EvalState & state, Env & env, Value & v); \ void eval(EvalState & state, Env & env, Value & v); \
void bindVars(const StaticEnv & env); void bindVars(const StaticEnv & env);
@ -289,7 +289,7 @@ struct ExprOpNot : Expr
Expr * e1, * e2; \ Expr * e1, * e2; \
name(Expr * e1, Expr * e2) : e1(e1), e2(e2) { }; \ name(Expr * e1, Expr * e2) : e1(e1), e2(e2) { }; \
name(const Pos & pos, Expr * e1, Expr * e2) : pos(pos), e1(e1), e2(e2) { }; \ name(const Pos & pos, Expr * e1, Expr * e2) : pos(pos), e1(e1), e2(e2) { }; \
void show(std::ostream & str) \ void show(std::ostream & str) const \
{ \ { \
str << "(" << *e1 << " " s " " << *e2 << ")"; \ str << "(" << *e1 << " " s " " << *e2 << ")"; \
} \ } \