diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-04-12T21·21+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-04-12T21·21+0000 |
commit | a60317f20fbc8be8e339060d932946f6d99ece6a (patch) | |
tree | b6cd2cc61fb904fafc7527f2a776cdb6b0e9c179 /src/libexpr/nixexpr.cc | |
parent | 4d6ad5be1738c64b1de4274cafbd4b8f23ca287c (diff) |
* More missing constructs.
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r-- | src/libexpr/nixexpr.cc | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 05dfbd3223e3..b044aaa943d4 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -40,6 +40,11 @@ void ExprSelect::show(std::ostream & str) str << "(" << *e << ")." << name; } +void ExprOpHasAttr::show(std::ostream & str) +{ + str << "(" << *e << ") ? " << name; +} + void ExprAttrs::show(std::ostream & str) { if (recursive) str << "rec "; @@ -87,19 +92,37 @@ void ExprIf::show(std::ostream & str) str << "if " << *cond << " then " << *then << " else " << *else_; } +void ExprAssert::show(std::ostream & str) +{ + str << "assert " << *cond << "; " << *body; +} -#if 0 -string showPos(ATerm pos) +void ExprOpNot::show(std::ostream & str) +{ + str << "! " << *e; +} + +void ExprConcatStrings::show(std::ostream & str) +{ + bool first = true; + foreach (vector<Expr *>::iterator, i, *es) { + if (first) first = false; else str << " + "; + str << **i; + } +} + + +std::ostream & operator << (std::ostream & str, const Pos & pos) { - ATerm path; - int line, column; - if (matchNoPos(pos)) return "undefined position"; - if (!matchPos(pos, path, line, column)) - throw badTerm("position expected", pos); - return (format("`%1%:%2%:%3%'") % aterm2String(path) % line % column).str(); + if (!pos.line) + str << "undefined position"; + else + str << (format("`%1%:%2%:%3%'") % pos.file % pos.line % pos.column).str(); + return str; } +#if 0 ATerm bottomupRewrite(TermFun & f, ATerm e) { checkInterrupt(); |