Fix whitespace

This commit is contained in:
Eelco Dolstra 2013-09-02 16:29:15 +02:00
parent ac1b754138
commit 33972629d7
8 changed files with 82 additions and 82 deletions

View file

@ -18,7 +18,7 @@ void findAlongAttrPath(EvalState & state, const string & attrPath,
string curPath; string curPath;
state.mkThunk_(v, e); state.mkThunk_(v, e);
foreach (Strings::iterator, i, tokens) { foreach (Strings::iterator, i, tokens) {
if (!curPath.empty()) curPath += "."; if (!curPath.empty()) curPath += ".";
@ -65,9 +65,9 @@ void findAlongAttrPath(EvalState & state, const string & attrPath,
v = *v.list.elems[attrIndex]; v = *v.list.elems[attrIndex];
} }
} }
} }
} }

View file

@ -44,7 +44,7 @@ void Bindings::sort()
{ {
std::sort(begin(), end()); std::sort(begin(), end());
} }
std::ostream & operator << (std::ostream & str, const Value & v) std::ostream & operator << (std::ostream & str, const Value & v)
{ {
@ -291,7 +291,7 @@ void mkString(Value & v, const string & s, const PathSet & context)
unsigned int n = 0; unsigned int n = 0;
v.string.context = (const char * *) v.string.context = (const char * *)
GC_MALLOC((context.size() + 1) * sizeof(char *)); GC_MALLOC((context.size() + 1) * sizeof(char *));
foreach (PathSet::const_iterator, i, context) foreach (PathSet::const_iterator, i, context)
v.string.context[n++] = GC_STRDUP(i->c_str()); v.string.context[n++] = GC_STRDUP(i->c_str());
v.string.context[n] = 0; v.string.context[n] = 0;
} }
@ -346,7 +346,7 @@ Env & EvalState::allocEnv(unsigned int size)
/* Clear the values because maybeThunk() and lookupVar fromWith expects this. */ /* Clear the values because maybeThunk() and lookupVar fromWith expects this. */
for (unsigned i = 0; i < size; ++i) for (unsigned i = 0; i < size; ++i)
env->values[i] = 0; env->values[i] = 0;
return *env; return *env;
} }
@ -358,7 +358,7 @@ Value * EvalState::allocAttr(Value & vAttrs, const Symbol & name)
return v; return v;
} }
void EvalState::mkList(Value & v, unsigned int length) void EvalState::mkList(Value & v, unsigned int length)
{ {
v.type = tList; v.type = tList;
@ -607,7 +607,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
e->eval(state, env, vTmp); e->eval(state, env, vTmp);
try { try {
foreach (AttrPath::const_iterator, i, attrPath) { foreach (AttrPath::const_iterator, i, attrPath) {
nrLookups++; nrLookups++;
Bindings::iterator j; Bindings::iterator j;
@ -628,17 +628,17 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
pos = j->pos; pos = j->pos;
if (state.countCalls && pos) state.attrSelects[*pos]++; if (state.countCalls && pos) state.attrSelects[*pos]++;
} }
state.forceValue(*vAttrs); state.forceValue(*vAttrs);
} catch (Error & e) { } catch (Error & e) {
if (pos) if (pos)
addErrorPrefix(e, "while evaluating the attribute `%1%' at %2%:\n", addErrorPrefix(e, "while evaluating the attribute `%1%' at %2%:\n",
showAttrPath(attrPath), *pos); showAttrPath(attrPath), *pos);
throw; throw;
} }
v = *vAttrs; v = *vAttrs;
} }
@ -662,7 +662,7 @@ void ExprOpHasAttr::eval(EvalState & state, Env & env, Value & v)
vAttrs = j->value; vAttrs = j->value;
} }
} }
mkBool(v, true); mkBool(v, true);
} }
@ -697,10 +697,10 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v)
assert(primOp->type == tPrimOp); assert(primOp->type == tPrimOp);
unsigned int arity = primOp->primOp->arity; unsigned int arity = primOp->primOp->arity;
unsigned int argsLeft = arity - argsDone; unsigned int argsLeft = arity - argsDone;
if (argsLeft == 1) { if (argsLeft == 1) {
/* We have all the arguments, so call the primop. */ /* We have all the arguments, so call the primop. */
/* Put all the arguments in an array. */ /* Put all the arguments in an array. */
Value * vArgs[arity]; Value * vArgs[arity];
unsigned int n = arity - 1; unsigned int n = arity - 1;
@ -725,7 +725,7 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v)
} }
return; return;
} }
if (fun.type != tLambda) if (fun.type != tLambda)
throwTypeError("attempt to call something which is not a function but %1%", throwTypeError("attempt to call something which is not a function but %1%",
showType(fun)); showType(fun));
@ -743,7 +743,7 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v)
else { else {
forceAttrs(arg); forceAttrs(arg);
if (!fun.lambda.fun->arg.empty()) if (!fun.lambda.fun->arg.empty())
env2.values[displ++] = &arg; env2.values[displ++] = &arg;
@ -830,7 +830,7 @@ void ExprIf::eval(EvalState & state, Env & env, Value & v)
(state.evalBool(env, cond) ? then : else_)->eval(state, env, v); (state.evalBool(env, cond) ? then : else_)->eval(state, env, v);
} }
void ExprAssert::eval(EvalState & state, Env & env, Value & v) void ExprAssert::eval(EvalState & state, Env & env, Value & v)
{ {
if (!state.evalBool(env, cond)) if (!state.evalBool(env, cond))
@ -838,7 +838,7 @@ void ExprAssert::eval(EvalState & state, Env & env, Value & v)
body->eval(state, env, v); body->eval(state, env, v);
} }
void ExprOpNot::eval(EvalState & state, Env & env, Value & v) void ExprOpNot::eval(EvalState & state, Env & env, Value & v)
{ {
mkBool(v, !state.evalBool(env, e)); mkBool(v, !state.evalBool(env, e));
@ -911,7 +911,7 @@ void ExprOpUpdate::eval(EvalState & state, Env & env, Value & v)
while (i != v1.attrs->end()) v.attrs->push_back(*i++); while (i != v1.attrs->end()) v.attrs->push_back(*i++);
while (j != v2.attrs->end()) v.attrs->push_back(*j++); while (j != v2.attrs->end()) v.attrs->push_back(*j++);
state.nrOpUpdateValuesCopied += v.attrs->size(); state.nrOpUpdateValuesCopied += v.attrs->size();
} }
@ -996,12 +996,12 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
void EvalState::strictForceValue(Value & v) void EvalState::strictForceValue(Value & v)
{ {
forceValue(v); forceValue(v);
if (v.type == tAttrs) { if (v.type == tAttrs) {
foreach (Bindings::iterator, i, *v.attrs) foreach (Bindings::iterator, i, *v.attrs)
strictForceValue(*i->value); strictForceValue(*i->value);
} }
else if (v.type == tList) { else if (v.type == tList) {
for (unsigned int n = 0; n < v.list.length; ++n) for (unsigned int n = 0; n < v.list.length; ++n)
strictForceValue(*v.list.elems[n]); strictForceValue(*v.list.elems[n]);
@ -1047,7 +1047,7 @@ string EvalState::forceString(Value & v)
void copyContext(const Value & v, PathSet & context) void copyContext(const Value & v, PathSet & context)
{ {
if (v.string.context) if (v.string.context)
for (const char * * p = v.string.context; *p; ++p) for (const char * * p = v.string.context; *p; ++p)
context.insert(*p); context.insert(*p);
} }
@ -1097,7 +1097,7 @@ string EvalState::coerceToString(Value & v, PathSet & context,
Path path(canonPath(v.path)); Path path(canonPath(v.path));
if (!copyToStore) return path; if (!copyToStore) return path;
if (nix::isDerivation(path)) if (nix::isDerivation(path))
throwEvalError("file names are not allowed to end in `%1%'", drvExtension); throwEvalError("file names are not allowed to end in `%1%'", drvExtension);
@ -1146,7 +1146,7 @@ string EvalState::coerceToString(Value & v, PathSet & context,
return result; return result;
} }
} }
throwTypeError("cannot coerce %1% to a string", showType(v)); throwTypeError("cannot coerce %1% to a string", showType(v));
} }
@ -1222,7 +1222,7 @@ bool EvalState::eqValues(Value & v1, Value & v2)
for (i = v1.attrs->begin(), j = v2.attrs->begin(); i != v1.attrs->end(); ++i, ++j) for (i = v1.attrs->begin(), j = v2.attrs->begin(); i != v1.attrs->end(); ++i, ++j)
if (i->name != j->name || !eqValues(*i->value, *j->value)) if (i->name != j->name || !eqValues(*i->value, *j->value))
return false; return false;
return true; return true;
} }

View file

@ -88,7 +88,7 @@ struct EvalState;
std::ostream & operator << (std::ostream & str, const Value & v); std::ostream & operator << (std::ostream & str, const Value & v);
class EvalState class EvalState
{ {
public: public:
SymbolTable symbols; SymbolTable symbols;
@ -101,7 +101,7 @@ public:
bool repair; bool repair;
private: private:
SrcToStore srcToStore; SrcToStore srcToStore;
/* A cache from path names to parse trees. */ /* A cache from path names to parse trees. */
std::map<Path, Expr *> parseTrees; std::map<Path, Expr *> parseTrees;
@ -119,7 +119,7 @@ private:
SearchPath::iterator searchPathInsertionPoint; SearchPath::iterator searchPathInsertionPoint;
public: public:
EvalState(); EvalState();
~EvalState(); ~EvalState();
@ -131,7 +131,7 @@ public:
/* Parse a Nix expression from the specified string. */ /* Parse a Nix expression from the specified string. */
Expr * parseExprFromString(const string & s, const Path & basePath); Expr * parseExprFromString(const string & s, const Path & basePath);
/* Evaluate an expression read from the given file to normal /* Evaluate an expression read from the given file to normal
form. */ form. */
void evalFile(const Path & path, Value & v); void evalFile(const Path & path, Value & v);
@ -193,21 +193,21 @@ private:
unsigned int baseEnvDispl; unsigned int baseEnvDispl;
public: public:
/* The same, but used during parsing to resolve variables. */ /* The same, but used during parsing to resolve variables. */
StaticEnv staticBaseEnv; // !!! should be private StaticEnv staticBaseEnv; // !!! should be private
private: private:
void createBaseEnv(); void createBaseEnv();
void addConstant(const string & name, Value & v); void addConstant(const string & name, Value & v);
void addPrimOp(const string & name, void addPrimOp(const string & name,
unsigned int arity, PrimOpFun primOp); unsigned int arity, PrimOpFun primOp);
inline Value * lookupVar(Env * env, const VarRef & var, bool noEval); inline Value * lookupVar(Env * env, const VarRef & var, bool noEval);
friend class ExprVar; friend class ExprVar;
friend class ExprAttrs; friend class ExprAttrs;
friend class ExprLet; friend class ExprLet;
@ -216,7 +216,7 @@ private:
const Path & path, const Path & basePath); const Path & path, const Path & basePath);
public: public:
/* Do a deep equality test between two values. That is, list /* Do a deep equality test between two values. That is, list
elements and attributes are compared recursively. */ elements and attributes are compared recursively. */
bool eqValues(Value & v1, Value & v2); bool eqValues(Value & v1, Value & v2);
@ -226,7 +226,7 @@ public:
/* Automatically call a function for which each argument has a /* Automatically call a function for which each argument has a
default value or has a binding in the `args' map. */ default value or has a binding in the `args' map. */
void autoCallFunction(Bindings & args, Value & fun, Value & res); void autoCallFunction(Bindings & args, Value & fun, Value & res);
/* Allocation primitives. */ /* Allocation primitives. */
Value * allocValue(); Value * allocValue();
Env & allocEnv(unsigned int size); Env & allocEnv(unsigned int size);

View file

@ -15,14 +15,14 @@ using namespace nix;
namespace nix { namespace nix {
static void initLoc(YYLTYPE * loc) static void initLoc(YYLTYPE * loc)
{ {
loc->first_line = loc->last_line = 1; loc->first_line = loc->last_line = 1;
loc->first_column = loc->last_column = 1; loc->first_column = loc->last_column = 1;
} }
static void adjustLoc(YYLTYPE * loc, const char * s, size_t len) static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
{ {
loc->first_line = loc->last_line; loc->first_line = loc->last_line;
@ -34,7 +34,7 @@ static void adjustLoc(YYLTYPE * loc, const char * s, size_t len)
if (*s == '\n') /* cr/lf */ if (*s == '\n') /* cr/lf */
s++; s++;
/* fall through */ /* fall through */
case '\n': case '\n':
++loc->last_line; ++loc->last_line;
loc->last_column = 1; loc->last_column = 1;
break; break;
@ -68,7 +68,7 @@ static Expr * unescapeStr(SymbolTable & symbols, const char * s)
return new ExprString(symbols.create(t)); return new ExprString(symbols.create(t));
} }
} }
#define YY_USER_INIT initLoc(yylloc) #define YY_USER_INIT initLoc(yylloc)
@ -171,7 +171,7 @@ or { return OR_KW; }
namespace nix { namespace nix {
/* Horrible, disgusting hack: allow the parser to set the scanner /* Horrible, disgusting hack: allow the parser to set the scanner
start condition back to STRING. Necessary in interpolations like start condition back to STRING. Necessary in interpolations like
"foo${expr}bar"; after the close brace we have to go back to the "foo${expr}bar"; after the close brace we have to go back to the

View file

@ -224,11 +224,11 @@ void ExprAttrs::bindVars(const StaticEnv & env)
{ {
if (recursive) { if (recursive) {
StaticEnv newEnv(false, &env); StaticEnv newEnv(false, &env);
unsigned int displ = 0; unsigned int displ = 0;
foreach (AttrDefs::iterator, i, attrs) foreach (AttrDefs::iterator, i, attrs)
newEnv.vars[i->first] = i->second.displ = displ++; newEnv.vars[i->first] = i->second.displ = displ++;
foreach (AttrDefs::iterator, i, attrs) foreach (AttrDefs::iterator, i, attrs)
i->second.e->bindVars(i->second.inherited ? env : newEnv); i->second.e->bindVars(i->second.inherited ? env : newEnv);
} }
@ -247,9 +247,9 @@ void ExprList::bindVars(const StaticEnv & env)
void ExprLambda::bindVars(const StaticEnv & env) void ExprLambda::bindVars(const StaticEnv & env)
{ {
StaticEnv newEnv(false, &env); StaticEnv newEnv(false, &env);
unsigned int displ = 0; unsigned int displ = 0;
if (!arg.empty()) newEnv.vars[arg] = displ++; if (!arg.empty()) newEnv.vars[arg] = displ++;
if (matchAttrs) { if (matchAttrs) {
@ -266,14 +266,14 @@ void ExprLambda::bindVars(const StaticEnv & env)
void ExprLet::bindVars(const StaticEnv & env) void ExprLet::bindVars(const StaticEnv & env)
{ {
StaticEnv newEnv(false, &env); StaticEnv newEnv(false, &env);
unsigned int displ = 0; unsigned int displ = 0;
foreach (ExprAttrs::AttrDefs::iterator, i, attrs->attrs) foreach (ExprAttrs::AttrDefs::iterator, i, attrs->attrs)
newEnv.vars[i->first] = i->second.displ = displ++; newEnv.vars[i->first] = i->second.displ = displ++;
foreach (ExprAttrs::AttrDefs::iterator, i, attrs->attrs) foreach (ExprAttrs::AttrDefs::iterator, i, attrs->attrs)
i->second.e->bindVars(i->second.inherited ? env : newEnv); i->second.e->bindVars(i->second.inherited ? env : newEnv);
body->bindVars(newEnv); body->bindVars(newEnv);
} }
@ -290,8 +290,8 @@ void ExprWith::bindVars(const StaticEnv & env)
prevWith = level; prevWith = level;
break; break;
} }
attrs->bindVars(env); attrs->bindVars(env);
StaticEnv newEnv(true, &env); StaticEnv newEnv(true, &env);
body->bindVars(newEnv); body->bindVars(newEnv);
} }

View file

@ -114,7 +114,7 @@ struct VarRef
/* Whether the variable comes from an environment (e.g. a rec, let /* Whether the variable comes from an environment (e.g. a rec, let
or function argument) or from a "with". */ or function argument) or from a "with". */
bool fromWith; bool fromWith;
/* In the former case, the value is obtained by going `level' /* In the former case, the value is obtained by going `level'
levels up from the current environment and getting the levels up from the current environment and getting the
`displ'th value in that environment. In the latter case, the `displ'th value in that environment. In the latter case, the

View file

@ -12,18 +12,18 @@
%expect-rr 1 %expect-rr 1
%code requires { %code requires {
#ifndef BISON_HEADER #ifndef BISON_HEADER
#define BISON_HEADER #define BISON_HEADER
#include "util.hh" #include "util.hh"
#include "nixexpr.hh" #include "nixexpr.hh"
#include "eval.hh" #include "eval.hh"
namespace nix { namespace nix {
struct ParseData struct ParseData
{ {
EvalState & state; EvalState & state;
SymbolTable & symbols; SymbolTable & symbols;
@ -38,7 +38,7 @@ namespace nix {
, sLetBody(symbols.create("<let-body>")) , sLetBody(symbols.create("<let-body>"))
{ }; { };
}; };
} }
#define YY_DECL int yylex \ #define YY_DECL int yylex \
@ -63,14 +63,14 @@ using namespace nix;
namespace nix { namespace nix {
static void dupAttr(const AttrPath & attrPath, const Pos & pos, const Pos & prevPos) static void dupAttr(const AttrPath & attrPath, const Pos & pos, const Pos & prevPos)
{ {
throw ParseError(format("attribute `%1%' at %2% already defined at %3%") throw ParseError(format("attribute `%1%' at %2% already defined at %3%")
% showAttrPath(attrPath) % pos % prevPos); % showAttrPath(attrPath) % pos % prevPos);
} }
static void dupAttr(Symbol attr, const Pos & pos, const Pos & prevPos) static void dupAttr(Symbol attr, const Pos & pos, const Pos & prevPos)
{ {
@ -78,7 +78,7 @@ static void dupAttr(Symbol attr, const Pos & pos, const Pos & prevPos)
throw ParseError(format("attribute `%1%' at %2% already defined at %3%") throw ParseError(format("attribute `%1%' at %2% already defined at %3%")
% showAttrPath(attrPath) % pos % prevPos); % showAttrPath(attrPath) % pos % prevPos);
} }
static void addAttr(ExprAttrs * attrs, AttrPath & attrPath, static void addAttr(ExprAttrs * attrs, AttrPath & attrPath,
Expr * e, const Pos & pos) Expr * e, const Pos & pos)
@ -121,7 +121,7 @@ static void addFormal(const Pos & pos, Formals * formals, const Formal & formal)
static Expr * stripIndentation(SymbolTable & symbols, vector<Expr *> & es) static Expr * stripIndentation(SymbolTable & symbols, vector<Expr *> & es)
{ {
if (es.empty()) return new ExprString(symbols.create("")); if (es.empty()) return new ExprString(symbols.create(""));
/* Figure out the minimum indentation. Note that by design /* Figure out the minimum indentation. Note that by design
whitespace-only final lines are not taken into account. (So whitespace-only final lines are not taken into account. (So
the " " in "\n ''" is ignored, but the " " in "\n foo''" is.) */ the " " in "\n ''" is ignored, but the " " in "\n foo''" is.) */
@ -170,7 +170,7 @@ static Expr * stripIndentation(SymbolTable & symbols, vector<Expr *> & es)
es2->push_back(*i); es2->push_back(*i);
continue; continue;
} }
string s2; string s2;
for (unsigned int j = 0; j < e->s.size(); ++j) { for (unsigned int j = 0; j < e->s.size(); ++j) {
if (atStartOfLine) { if (atStartOfLine) {
@ -232,7 +232,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err
%} %}
%union { %union {
// !!! We're probably leaking stuff here. // !!! We're probably leaking stuff here.
nix::Expr * e; nix::Expr * e;
nix::ExprList * list; nix::ExprList * list;
nix::ExprAttrs * attrs; nix::ExprAttrs * attrs;
@ -465,7 +465,7 @@ formal
: ID { $$ = new Formal(data->symbols.create($1), 0); } : ID { $$ = new Formal(data->symbols.create($1), 0); }
| ID '?' expr { $$ = new Formal(data->symbols.create($1), $3); } | ID '?' expr { $$ = new Formal(data->symbols.create($1), $3); }
; ;
%% %%
@ -478,7 +478,7 @@ formal
namespace nix { namespace nix {
Expr * EvalState::parse(const char * text, Expr * EvalState::parse(const char * text,
const Path & path, const Path & basePath) const Path & path, const Path & basePath)
@ -492,7 +492,7 @@ Expr * EvalState::parse(const char * text,
yy_scan_string(text, scanner); yy_scan_string(text, scanner);
int res = yyparse(scanner, &data); int res = yyparse(scanner, &data);
yylex_destroy(scanner); yylex_destroy(scanner);
if (res) throw ParseError(data.error); if (res) throw ParseError(data.error);
try { try {
@ -500,7 +500,7 @@ Expr * EvalState::parse(const char * text,
} catch (Error & e) { } catch (Error & e) {
throw ParseError(format("%1%, in `%2%'") % e.msg() % path); throw ParseError(format("%1%, in `%2%'") % e.msg() % path);
} }
return data.result; return data.result;
} }
@ -552,7 +552,7 @@ void EvalState::addToSearchPath(const string & s)
prefix = string(s, 0, pos); prefix = string(s, 0, pos);
path = string(s, pos + 1); path = string(s, pos + 1);
} }
path = absPath(path); path = absPath(path);
if (pathExists(path)) { if (pathExists(path)) {
debug(format("adding path `%1%' to the search path") % path); debug(format("adding path `%1%' to the search path") % path);
@ -565,7 +565,7 @@ Path EvalState::findFile(const string & path)
{ {
foreach (SearchPath::iterator, i, searchPath) { foreach (SearchPath::iterator, i, searchPath) {
Path res; Path res;
if (i->first.empty()) if (i->first.empty())
res = i->second + "/" + path; res = i->second + "/" + path;
else { else {
if (path.compare(0, i->first.size(), i->first) != 0 || if (path.compare(0, i->first.size(), i->first) != 0 ||

View file

@ -37,7 +37,7 @@ std::pair<string, string> decodeContext(const string & s)
/* Load and evaluate an expression from path specified by the /* Load and evaluate an expression from path specified by the
argument. */ argument. */
static void prim_import(EvalState & state, Value * * args, Value & v) static void prim_import(EvalState & state, Value * * args, Value & v)
{ {
PathSet context; PathSet context;
@ -56,7 +56,7 @@ static void prim_import(EvalState & state, Value * * args, Value & v)
unsigned long long downloadSize, narSize; unsigned long long downloadSize, narSize;
queryMissing(*store, singleton<PathSet>(ctx), queryMissing(*store, singleton<PathSet>(ctx),
willBuild, willSubstitute, unknown, downloadSize, narSize); willBuild, willSubstitute, unknown, downloadSize, narSize);
/* !!! If using a substitute, we only need to fetch /* !!! If using a substitute, we only need to fetch
the selected output of this derivation. */ the selected output of this derivation. */
store->buildPaths(singleton<PathSet>(ctx)); store->buildPaths(singleton<PathSet>(ctx));
@ -197,7 +197,7 @@ static void prim_genericClosure(EvalState & state, Value * * args, Value & v)
if (doneKeys.find(*key->value) != doneKeys.end()) continue; if (doneKeys.find(*key->value) != doneKeys.end()) continue;
doneKeys.insert(*key->value); doneKeys.insert(*key->value);
res.push_back(*e); res.push_back(*e);
/* Call the `operator' function with `e' as argument. */ /* Call the `operator' function with `e' as argument. */
Value call; Value call;
mkApp(call, *op->value, *e); mkApp(call, *op->value, *e);
@ -247,7 +247,7 @@ static void prim_addErrorContext(EvalState & state, Value * * args, Value & v)
} }
/* Try evaluating the argument. Success => {success=true; value=something;}, /* Try evaluating the argument. Success => {success=true; value=something;},
* else => {success=false; value=false;} */ * else => {success=false; value=false;} */
static void prim_tryEval(EvalState & state, Value * * args, Value & v) static void prim_tryEval(EvalState & state, Value * * args, Value & v)
{ {
@ -634,7 +634,7 @@ static void prim_toFile(EvalState & state, Value * * args, Value & v)
throw EvalError(format("in `toFile': the file `%1%' cannot refer to derivation outputs") % name); throw EvalError(format("in `toFile': the file `%1%' cannot refer to derivation outputs") % name);
refs.insert(path); refs.insert(path);
} }
Path storePath = settings.readOnlyMode Path storePath = settings.readOnlyMode
? computeStorePathForText(name, contents, refs) ? computeStorePathForText(name, contents, refs)
: store->addTextToStore(name, contents, refs, state.repair); : store->addTextToStore(name, contents, refs, state.repair);
@ -651,7 +651,7 @@ struct FilterFromExpr : PathFilter
{ {
EvalState & state; EvalState & state;
Value & filter; Value & filter;
FilterFromExpr(EvalState & state, Value & filter) FilterFromExpr(EvalState & state, Value & filter)
: state(state), filter(filter) : state(state), filter(filter)
{ {
@ -672,12 +672,12 @@ struct FilterFromExpr : PathFilter
state.callFunction(filter, arg1, fun2); state.callFunction(filter, arg1, fun2);
Value arg2; Value arg2;
mkString(arg2, mkString(arg2,
S_ISREG(st.st_mode) ? "regular" : S_ISREG(st.st_mode) ? "regular" :
S_ISDIR(st.st_mode) ? "directory" : S_ISDIR(st.st_mode) ? "directory" :
S_ISLNK(st.st_mode) ? "symlink" : S_ISLNK(st.st_mode) ? "symlink" :
"unknown" /* not supported, will fail! */); "unknown" /* not supported, will fail! */);
Value res; Value res;
state.callFunction(fun2, arg2, res); state.callFunction(fun2, arg2, res);
@ -801,12 +801,12 @@ static void prim_listToAttrs(EvalState & state, Value * * args, Value & v)
for (unsigned int i = 0; i < args[0]->list.length; ++i) { for (unsigned int i = 0; i < args[0]->list.length; ++i) {
Value & v2(*args[0]->list.elems[i]); Value & v2(*args[0]->list.elems[i]);
state.forceAttrs(v2); state.forceAttrs(v2);
Bindings::iterator j = v2.attrs->find(state.sName); Bindings::iterator j = v2.attrs->find(state.sName);
if (j == v2.attrs->end()) if (j == v2.attrs->end())
throw TypeError("`name' attribute missing in a call to `listToAttrs'"); throw TypeError("`name' attribute missing in a call to `listToAttrs'");
string name = state.forceStringNoCtx(*j->value); string name = state.forceStringNoCtx(*j->value);
Bindings::iterator j2 = v2.attrs->find(state.symbols.create("value")); Bindings::iterator j2 = v2.attrs->find(state.symbols.create("value"));
if (j2 == v2.attrs->end()) if (j2 == v2.attrs->end())
throw TypeError("`value' attribute missing in a call to `listToAttrs'"); throw TypeError("`value' attribute missing in a call to `listToAttrs'");
@ -830,7 +830,7 @@ static void prim_intersectAttrs(EvalState & state, Value * * args, Value & v)
{ {
state.forceAttrs(*args[0]); state.forceAttrs(*args[0]);
state.forceAttrs(*args[1]); state.forceAttrs(*args[1]);
state.mkAttrs(v, std::min(args[0]->attrs->size(), args[1]->attrs->size())); state.mkAttrs(v, std::min(args[0]->attrs->size(), args[1]->attrs->size()));
foreach (Bindings::iterator, i, *args[0]->attrs) { foreach (Bindings::iterator, i, *args[0]->attrs) {
@ -933,7 +933,7 @@ static void prim_map(EvalState & state, Value * * args, Value & v)
state.mkList(v, args[1]->list.length); state.mkList(v, args[1]->list.length);
for (unsigned int n = 0; n < v.list.length; ++n) for (unsigned int n = 0; n < v.list.length; ++n)
mkApp(*(v.list.elems[n] = state.allocValue()), mkApp(*(v.list.elems[n] = state.allocValue()),
*args[0], *args[1]->list.elems[n]); *args[0], *args[1]->list.elems[n]);
} }
@ -1105,7 +1105,7 @@ static void prim_unsafeDiscardOutputDependency(EvalState & state, Value * * args
if (p.at(0) == '=') p = "~" + string(p, 1); if (p.at(0) == '=') p = "~" + string(p, 1);
context2.insert(p); context2.insert(p);
} }
mkString(v, s, context2); mkString(v, s, context2);
} }
@ -1167,10 +1167,10 @@ void EvalState::createBaseEnv()
mkBool(v, true); mkBool(v, true);
addConstant("true", v); addConstant("true", v);
mkBool(v, false); mkBool(v, false);
addConstant("false", v); addConstant("false", v);
v.type = tNull; v.type = tNull;
addConstant("null", v); addConstant("null", v);