diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-06-21T07·55+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-06-21T07·55+0000 |
commit | bf87cc44b4484df74388b526c89884fea166ab7f (patch) | |
tree | 18a9a0e77d2e2a027eac094b3cdb43d6dd988cf4 /src/libexpr | |
parent | d1f6c0cbe39b509545f809f08cbd580859f38e34 (diff) | |
parent | b57189174f6e11c3e9e0f7c65c08a72f689fe194 (diff) |
* Sync with the trunk.
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 15 | ||||
-rw-r--r-- | src/libexpr/eval.hh | 2 | ||||
-rw-r--r-- | src/libexpr/nixexpr.hh | 1 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 6 | ||||
-rw-r--r-- | src/libexpr/value-to-xml.cc | 1 |
5 files changed, 19 insertions, 6 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 1ee6c5a7f6aa..eb1d8d432c69 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -59,6 +59,7 @@ std::ostream & operator << (std::ostream & str, const Value & v) str << "]"; break; case tThunk: + case tApp: case tCopy: str << "<CODE>"; break; @@ -901,12 +902,18 @@ string EvalState::forceString(Value & v) } -string EvalState::forceString(Value & v, PathSet & context) +void copyContext(const Value & v, PathSet & context) { - string s = forceString(v); if (v.string.context) for (const char * * p = v.string.context; *p; ++p) context.insert(*p); +} + + +string EvalState::forceString(Value & v, PathSet & context) +{ + string s = forceString(v); + copyContext(v, context); return s; } @@ -937,9 +944,7 @@ string EvalState::coerceToString(Value & v, PathSet & context, string s; if (v.type == tString) { - if (v.string.context) - for (const char * * p = v.string.context; *p; ++p) - context.insert(*p); + copyContext(v, context); return v.string.s; } diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 4e0af70ba64b..03bf43a3b9a4 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -163,6 +163,8 @@ void mkString(Value & v, const char * s); void mkString(Value & v, const string & s, const PathSet & context = PathSet()); void mkPath(Value & v, const char * s); +void copyContext(const Value & v, PathSet & context); + typedef std::map<Path, Hash> DrvHashes; diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index 1c72441b2792..b1043a32684e 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -15,6 +15,7 @@ MakeError(AssertionError, EvalError) MakeError(ThrownError, AssertionError) MakeError(Abort, EvalError) MakeError(TypeError, EvalError) +MakeError(ImportError, EvalError) // error building an imported derivation /* Position objects. */ diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 9d36fb6a05d7..42c8586116aa 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -37,7 +37,11 @@ static void prim_import(EvalState & state, Value * * args, Value & v) throw EvalError(format("cannot import `%1%', since path `%2%' is not valid") % path % *i); if (isDerivation(*i)) - store->buildDerivations(singleton<PathSet>(*i)); + try { + store->buildDerivations(singleton<PathSet>(*i)); + } catch (Error & e) { + throw ImportError(e.msg()); + } } state.evalFile(path, v); diff --git a/src/libexpr/value-to-xml.cc b/src/libexpr/value-to-xml.cc index e751fd300fdb..8955a8a33931 100644 --- a/src/libexpr/value-to-xml.cc +++ b/src/libexpr/value-to-xml.cc @@ -69,6 +69,7 @@ static void printValueAsXML(EvalState & state, bool strict, bool location, case tString: /* !!! show the context? */ + copyContext(v, context); doc.writeEmptyElement("string", singletonAttrs("value", v.string.s)); break; |