From c395a48be2ad58560590897e11793db032873ed6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 21 May 2020 04:56:22 +0100 Subject: fix(3p/nix): Compatibility with updated SymbolTable The functions in SymbolTable have been renamed to match the Google Style guide, and some debug-only functions have been removed. --- third_party/nix/src/libexpr/attr-path.cc | 2 +- third_party/nix/src/libexpr/common-eval-args.cc | 2 +- third_party/nix/src/libexpr/eval.cc | 77 +++++++++++----------- third_party/nix/src/libexpr/get-drvs.cc | 10 +-- third_party/nix/src/libexpr/json-to-value.cc | 2 +- third_party/nix/src/libexpr/lexer.l | 2 +- third_party/nix/src/libexpr/meson.build | 14 ++-- third_party/nix/src/libexpr/parser.y | 58 ++++++++-------- third_party/nix/src/libexpr/primops.cc | 49 +++++++------- third_party/nix/src/libexpr/primops/context.cc | 10 +-- third_party/nix/src/libexpr/primops/fetchGit.cc | 6 +- .../nix/src/libexpr/primops/fetchMercurial.cc | 8 +-- third_party/nix/src/libexpr/primops/fromTOML.cc | 2 +- third_party/nix/src/libexpr/value-to-json.cc | 2 +- third_party/nix/src/libexpr/value-to-xml.cc | 4 +- third_party/nix/src/nix-env/nix-env.cc | 4 +- third_party/nix/src/nix-env/user-env.cc | 8 +-- .../nix/src/nix-prefetch-url/nix-prefetch-url.cc | 8 +-- third_party/nix/src/nix/installables.cc | 4 +- third_party/nix/src/nix/repl.cc | 2 +- third_party/nix/src/nix/search.cc | 4 +- 21 files changed, 141 insertions(+), 137 deletions(-) (limited to 'third_party/nix') diff --git a/third_party/nix/src/libexpr/attr-path.cc b/third_party/nix/src/libexpr/attr-path.cc index 485c240e3a..b9b9106be8 100644 --- a/third_party/nix/src/libexpr/attr-path.cc +++ b/third_party/nix/src/libexpr/attr-path.cc @@ -75,7 +75,7 @@ Value* findAlongAttrPath(EvalState& state, const string& attrPath, attrPath); } - Bindings::iterator a = v->attrs->find(state.symbols.create(attr)); + Bindings::iterator a = v->attrs->find(state.symbols.Create(attr)); if (a == v->attrs->end()) { throw Error( format("attribute '%1%' in selection path '%2%' not found") % attr % diff --git a/third_party/nix/src/libexpr/common-eval-args.cc b/third_party/nix/src/libexpr/common-eval-args.cc index 33319cbabb..398d42b355 100644 --- a/third_party/nix/src/libexpr/common-eval-args.cc +++ b/third_party/nix/src/libexpr/common-eval-args.cc @@ -42,7 +42,7 @@ Bindings* MixEvalArgs::getAutoArgs(EvalState& state) { } else { mkString(*v, string(i.second, 1)); } - res->push_back(Attr(state.symbols.create(i.first), v)); + res->push_back(Attr(state.symbols.Create(i.first), v)); } res->sort(); return res; diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc index 4053dffe51..5896bc96e3 100644 --- a/third_party/nix/src/libexpr/eval.cc +++ b/third_party/nix/src/libexpr/eval.cc @@ -198,7 +198,7 @@ static Symbol getName(const AttrName& name, EvalState& state, Env& env) { Value nameValue; name.expr->eval(state, env, nameValue); state.forceStringNoCtx(nameValue); - return state.symbols.create(nameValue.string.s); + return state.symbols.Create(nameValue.string.s); } static bool gcInitialised = false; @@ -299,31 +299,31 @@ static Strings parseNixPath(const string& s) { } EvalState::EvalState(const Strings& _searchPath, const ref& store) - : sWith(symbols.create("")), - sOutPath(symbols.create("outPath")), - sDrvPath(symbols.create("drvPath")), - sType(symbols.create("type")), - sMeta(symbols.create("meta")), - sName(symbols.create("name")), - sValue(symbols.create("value")), - sSystem(symbols.create("system")), - sOverrides(symbols.create("__overrides")), - sOutputs(symbols.create("outputs")), - sOutputName(symbols.create("outputName")), - sIgnoreNulls(symbols.create("__ignoreNulls")), - sFile(symbols.create("file")), - sLine(symbols.create("line")), - sColumn(symbols.create("column")), - sFunctor(symbols.create("__functor")), - sToString(symbols.create("__toString")), - sRight(symbols.create("right")), - sWrong(symbols.create("wrong")), - sStructuredAttrs(symbols.create("__structuredAttrs")), - sBuilder(symbols.create("builder")), - sArgs(symbols.create("args")), - sOutputHash(symbols.create("outputHash")), - sOutputHashAlgo(symbols.create("outputHashAlgo")), - sOutputHashMode(symbols.create("outputHashMode")), + : sWith(symbols.Create("")), + sOutPath(symbols.Create("outPath")), + sDrvPath(symbols.Create("drvPath")), + sType(symbols.Create("type")), + sMeta(symbols.Create("meta")), + sName(symbols.Create("name")), + sValue(symbols.Create("value")), + sSystem(symbols.Create("system")), + sOverrides(symbols.Create("__overrides")), + sOutputs(symbols.Create("outputs")), + sOutputName(symbols.Create("outputName")), + sIgnoreNulls(symbols.Create("__ignoreNulls")), + sFile(symbols.Create("file")), + sLine(symbols.Create("line")), + sColumn(symbols.Create("column")), + sFunctor(symbols.Create("__functor")), + sToString(symbols.Create("__toString")), + sRight(symbols.Create("right")), + sWrong(symbols.Create("wrong")), + sStructuredAttrs(symbols.Create("__structuredAttrs")), + sBuilder(symbols.Create("builder")), + sArgs(symbols.Create("args")), + sOutputHash(symbols.Create("outputHash")), + sOutputHashAlgo(symbols.Create("outputHashAlgo")), + sOutputHashMode(symbols.Create("outputHashMode")), repair(NoRepair), store(store), baseEnv(allocEnv(128)), @@ -467,10 +467,10 @@ Path EvalState::toRealPath(const Path& path, const PathSet& context) { Value* EvalState::addConstant(const string& name, Value& v) { Value* v2 = allocValue(); *v2 = v; - staticBaseEnv.vars[symbols.create(name)] = baseEnvDispl; + staticBaseEnv.vars[symbols.Create(name)] = baseEnvDispl; baseEnv.values[baseEnvDispl++] = v2; string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name; - baseEnv.values[0]->attrs->push_back(Attr(symbols.create(name2), v2)); + baseEnv.values[0]->attrs->push_back(Attr(symbols.Create(name2), v2)); return v2; } @@ -483,17 +483,17 @@ Value* EvalState::addPrimOp(const string& name, size_t arity, } Value* v = allocValue(); string name2 = string(name, 0, 2) == "__" ? string(name, 2) : name; - Symbol sym = symbols.create(name2); + Symbol sym = symbols.Create(name2); v->type = tPrimOp; v->primOp = new PrimOp(primOp, arity, sym); - staticBaseEnv.vars[symbols.create(name)] = baseEnvDispl; + staticBaseEnv.vars[symbols.Create(name)] = baseEnvDispl; baseEnv.values[baseEnvDispl++] = v; baseEnv.values[0]->attrs->push_back(Attr(sym, v)); return v; } Value& EvalState::getBuiltin(const string& name) { - return *baseEnv.values[0]->attrs->find(symbols.create(name))->value; + return *baseEnv.values[0]->attrs->find(symbols.Create(name))->value; } /* Every "format" object (even temporary) takes up a few hundred bytes @@ -885,7 +885,7 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) { continue; } state.forceStringNoCtx(nameVal); - Symbol nameSym = state.symbols.create(nameVal.string.s); + Symbol nameSym = state.symbols.Create(nameVal.string.s); Bindings::iterator j = v.attrs->find(nameSym); if (j != v.attrs->end()) { throwEvalError("dynamic attribute '%1%' at %2% already defined at %3%", @@ -1828,8 +1828,8 @@ void EvalState::printStats() { } { auto syms = topObj.object("symbols"); - syms.attr("number", symbols.size()); - syms.attr("bytes", symbols.totalSize()); + syms.attr("number", symbols.Size()); + syms.attr("bytes", symbols.TotalSize()); } { auto sets = topObj.object("sets"); @@ -1897,10 +1897,11 @@ void EvalState::printStats() { } } - if (getEnv("NIX_SHOW_SYMBOLS", "0") != "0") { - auto list = topObj.list("symbols"); - symbols.dump([&](const std::string& s) { list.elem(s); }); - } + // TODO(tazjin): what is this? commented out because .dump() is gone. + // if (getEnv("NIX_SHOW_SYMBOLS", "0") != "0") { + // auto list = topObj.list("symbols"); + // symbols.dump([&](const std::string& s) { list.elem(s); }); + // } } } diff --git a/third_party/nix/src/libexpr/get-drvs.cc b/third_party/nix/src/libexpr/get-drvs.cc index 39870abcbd..4d412a9c61 100644 --- a/third_party/nix/src/libexpr/get-drvs.cc +++ b/third_party/nix/src/libexpr/get-drvs.cc @@ -99,7 +99,7 @@ DrvInfo::Outputs DrvInfo::queryOutputs(bool onlyOutputsToInstall) { /* Evaluate the corresponding set. */ string name = state->forceStringNoCtx(*i->value->listElems()[j], *i->pos); - Bindings::iterator out = attrs->find(state->symbols.create(name)); + Bindings::iterator out = attrs->find(state->symbols.Create(name)); if (out == attrs->end()) { continue; // FIXME: throw error? } @@ -213,7 +213,7 @@ Value* DrvInfo::queryMeta(const string& name) { if (getMeta() == nullptr) { return nullptr; } - Bindings::iterator a = meta->find(state->symbols.create(name)); + Bindings::iterator a = meta->find(state->symbols.Create(name)); if (a == meta->end() || !checkMeta(*a->value)) { return nullptr; } @@ -291,7 +291,7 @@ void DrvInfo::setMeta(const string& name, Value* v) { getMeta(); Bindings* old = meta; meta = state->allocBindings(1 + (old != nullptr ? old->size() : 0)); - Symbol sym = state->symbols.create(name); + Symbol sym = state->symbols.Create(name); if (old != nullptr) { for (auto i : *old) { if (i.name != sym) { @@ -377,7 +377,7 @@ static void getDerivations(EvalState& state, Value& vIn, /* !!! undocumented hackery to support combining channels in nix-env.cc. */ bool combineChannels = - v.attrs->find(state.symbols.create("_combineChannels")) != + v.attrs->find(state.symbols.Create("_combineChannels")) != v.attrs->end(); /* Consider the attributes in sorted order to get more @@ -401,7 +401,7 @@ static void getDerivations(EvalState& state, Value& vIn, `recurseForDerivations = true' attribute. */ if (i->value->type == tAttrs) { Bindings::iterator j = i->value->attrs->find( - state.symbols.create("recurseForDerivations")); + state.symbols.Create("recurseForDerivations")); if (j != i->value->attrs->end() && state.forceBool(*j->value, *j->pos)) { getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, diff --git a/third_party/nix/src/libexpr/json-to-value.cc b/third_party/nix/src/libexpr/json-to-value.cc index 68f016904e..ea7d575aa9 100644 --- a/third_party/nix/src/libexpr/json-to-value.cc +++ b/third_party/nix/src/libexpr/json-to-value.cc @@ -105,7 +105,7 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) { s++; Value* v2 = state.allocValue(); parseJSON(state, s, *v2); - attrs[state.symbols.create(name)] = v2; + attrs[state.symbols.Create(name)] = v2; skipWhitespace(s); if (*s == '}') { break; diff --git a/third_party/nix/src/libexpr/lexer.l b/third_party/nix/src/libexpr/lexer.l index a0d6bd7e16..1f9e45a1cd 100644 --- a/third_party/nix/src/libexpr/lexer.l +++ b/third_party/nix/src/libexpr/lexer.l @@ -72,7 +72,7 @@ static Expr * unescapeStr(SymbolTable & symbols, const char * s, size_t length) } else t += c; } - return new ExprString(symbols.create(t)); + return new ExprString(symbols.Create(t)); } diff --git a/third_party/nix/src/libexpr/meson.build b/third_party/nix/src/libexpr/meson.build index 7ddd4cff4e..1bb311e999 100644 --- a/third_party/nix/src/libexpr/meson.build +++ b/third_party/nix/src/libexpr/meson.build @@ -16,6 +16,7 @@ libexpr_src = files( join_paths(meson.source_root(), 'src/libexpr/names.cc'), join_paths(meson.source_root(), 'src/libexpr/nixexpr.cc'), join_paths(meson.source_root(), 'src/libexpr/primops.cc'), + join_paths(meson.source_root(), 'src/libexpr/symbol-table.cc'), join_paths(meson.source_root(), 'src/libexpr/value-to-json.cc'), join_paths(meson.source_root(), 'src/libexpr/value-to-xml.cc'), ) @@ -42,18 +43,17 @@ libexpr_dep_list = [ glog_dep, libdl_dep, libsodium_dep, -] - -if sys_name == 'freebsd' - libexpr_dep_list += libdl_dep -endif +] + absl_deps libexpr_link_list = [ libutil_lib, libstore_lib, - libmain_lib] + libmain_lib, +] -libexpr_link_args = [] +libexpr_link_args = [ + '-lpthread', +] libexpr_cxx_args = [] diff --git a/third_party/nix/src/libexpr/parser.y b/third_party/nix/src/libexpr/parser.y index 5aa38bf2b8..f5a25d5934 100644 --- a/third_party/nix/src/libexpr/parser.y +++ b/third_party/nix/src/libexpr/parser.y @@ -35,7 +35,7 @@ namespace nix { ParseData(EvalState & state) : state(state) , symbols(state.symbols) - , sLetBody(symbols.create("")) + , sLetBody(symbols.Create("")) { }; }; @@ -148,7 +148,7 @@ static void addFormal(const Pos & pos, Formals * formals, const Formal & formal) static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector & 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 whitespace-only final lines are not taken into account. (So @@ -228,7 +228,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vectorpush_back(new ExprString(symbols.create(s2))); + es2->push_back(new ExprString(symbols.Create(s2))); } /* If this is a single string, then don't do a concatenation. */ @@ -314,13 +314,13 @@ expr: expr_function; expr_function : ID ':' expr_function - { $$ = new ExprLambda(CUR_POS, data->symbols.create($1), false, 0, $3); } + { $$ = new ExprLambda(CUR_POS, data->symbols.Create($1), false, 0, $3); } | '{' formals '}' ':' expr_function - { $$ = new ExprLambda(CUR_POS, data->symbols.create(""), true, $2, $5); } + { $$ = new ExprLambda(CUR_POS, data->symbols.Create(""), true, $2, $5); } | '{' formals '}' '@' ID ':' expr_function - { $$ = new ExprLambda(CUR_POS, data->symbols.create($5), true, $2, $7); } + { $$ = new ExprLambda(CUR_POS, data->symbols.Create($5), true, $2, $7); } | ID '@' '{' formals '}' ':' expr_function - { $$ = new ExprLambda(CUR_POS, data->symbols.create($1), true, $4, $7); } + { $$ = new ExprLambda(CUR_POS, data->symbols.Create($1), true, $4, $7); } | ASSERT expr ';' expr_function { $$ = new ExprAssert(CUR_POS, $2, $4); } | WITH expr ';' expr_function @@ -341,13 +341,13 @@ expr_if expr_op : '!' expr_op %prec NOT { $$ = new ExprOpNot($2); } - | '-' expr_op %prec NEGATE { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__sub")), new ExprInt(0)), $2); } + | '-' expr_op %prec NEGATE { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__sub")), new ExprInt(0)), $2); } | expr_op EQ expr_op { $$ = new ExprOpEq($1, $3); } | expr_op NEQ expr_op { $$ = new ExprOpNEq($1, $3); } - | expr_op '<' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $1), $3); } - | expr_op LEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $3), $1)); } - | expr_op '>' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $3), $1); } - | expr_op GEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__lessThan")), $1), $3)); } + | expr_op '<' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__lessThan")), $1), $3); } + | expr_op LEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__lessThan")), $3), $1)); } + | expr_op '>' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__lessThan")), $3), $1); } + | expr_op GEQ expr_op { $$ = new ExprOpNot(new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__lessThan")), $1), $3)); } | expr_op AND expr_op { $$ = new ExprOpAnd(CUR_POS, $1, $3); } | expr_op OR expr_op { $$ = new ExprOpOr(CUR_POS, $1, $3); } | expr_op IMPL expr_op { $$ = new ExprOpImpl(CUR_POS, $1, $3); } @@ -355,9 +355,9 @@ expr_op | expr_op '?' attrpath { $$ = new ExprOpHasAttr($1, *$3); } | expr_op '+' expr_op { $$ = new ExprConcatStrings(CUR_POS, false, new vector({$1, $3})); } - | expr_op '-' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__sub")), $1), $3); } - | expr_op '*' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__mul")), $1), $3); } - | expr_op '/' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.create("__div")), $1), $3); } + | expr_op '-' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__sub")), $1), $3); } + | expr_op '*' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__mul")), $1), $3); } + | expr_op '/' expr_op { $$ = new ExprApp(CUR_POS, new ExprApp(new ExprVar(data->symbols.Create("__div")), $1), $3); } | expr_op CONCAT expr_op { $$ = new ExprOpConcatLists(CUR_POS, $1, $3); } | expr_app ; @@ -376,7 +376,7 @@ expr_select | /* Backwards compatibility: because Nixpkgs has a rarely used function named ‘or’, allow stuff like ‘map or [...]’. */ expr_simple OR_KW - { $$ = new ExprApp(CUR_POS, $1, new ExprVar(CUR_POS, data->symbols.create("or"))); } + { $$ = new ExprApp(CUR_POS, $1, new ExprVar(CUR_POS, data->symbols.Create("or"))); } | expr_simple { $$ = $1; } ; @@ -385,7 +385,7 @@ expr_simple if (strcmp($1, "__curPos") == 0) $$ = new ExprPos(CUR_POS); else - $$ = new ExprVar(CUR_POS, data->symbols.create($1)); + $$ = new ExprVar(CUR_POS, data->symbols.Create($1)); } | INT { $$ = new ExprInt($1); } | FLOAT { $$ = new ExprFloat($1); } @@ -398,16 +398,16 @@ expr_simple | SPATH { string path($1 + 1, strlen($1) - 2); $$ = new ExprApp(CUR_POS, - new ExprApp(new ExprVar(data->symbols.create("__findFile")), - new ExprVar(data->symbols.create("__nixPath"))), - new ExprString(data->symbols.create(path))); + new ExprApp(new ExprVar(data->symbols.Create("__findFile")), + new ExprVar(data->symbols.Create("__nixPath"))), + new ExprString(data->symbols.Create(path))); } - | URI { $$ = new ExprString(data->symbols.create($1)); } + | URI { $$ = new ExprString(data->symbols.Create($1)); } | '(' expr ')' { $$ = $2; } /* Let expressions `let {..., body = ...}' are just desugared into `(rec {..., body = ...}).body'. */ | LET '{' binds '}' - { $3->recursive = true; $$ = new ExprSelect(noPos, $3, data->symbols.create("body")); } + { $3->recursive = true; $$ = new ExprSelect(noPos, $3, data->symbols.Create("body")); } | REC '{' binds '}' { $3->recursive = true; $$ = $3; } | '{' binds '}' @@ -418,7 +418,7 @@ expr_simple string_parts : STR | string_parts_interpolated { $$ = new ExprConcatStrings(CUR_POS, true, $1); } - | { $$ = new ExprString(data->symbols.create("")); } + | { $$ = new ExprString(data->symbols.Create("")); } ; string_parts_interpolated @@ -462,7 +462,7 @@ binds ; attrs - : attrs attr { $$ = $1; $1->push_back(AttrName(data->symbols.create($2))); } + : attrs attr { $$ = $1; $1->push_back(AttrName(data->symbols.Create($2))); } | attrs string_attr { $$ = $1; ExprString * str = dynamic_cast($2); @@ -477,7 +477,7 @@ attrs ; attrpath - : attrpath '.' attr { $$ = $1; $1->push_back(AttrName(data->symbols.create($3))); } + : attrpath '.' attr { $$ = $1; $1->push_back(AttrName(data->symbols.Create($3))); } | attrpath '.' string_attr { $$ = $1; ExprString * str = dynamic_cast($3); @@ -487,7 +487,7 @@ attrpath } else $$->push_back(AttrName($3)); } - | attr { $$ = new vector; $$->push_back(AttrName(data->symbols.create($1))); } + | attr { $$ = new vector; $$->push_back(AttrName(data->symbols.Create($1))); } | string_attr { $$ = new vector; ExprString *str = dynamic_cast($1); @@ -526,8 +526,8 @@ formals ; formal - : ID { $$ = new Formal(data->symbols.create($1), 0); } - | ID '?' expr { $$ = new Formal(data->symbols.create($1), $3); } + : ID { $$ = new Formal(data->symbols.Create($1), 0); } + | ID '?' expr { $$ = new Formal(data->symbols.Create($1), $3); } ; %% @@ -552,7 +552,7 @@ Expr * EvalState::parse(const char * text, yyscan_t scanner; ParseData data(*this); data.basePath = basePath; - data.path = data.symbols.create(path); + data.path = data.symbols.Create(path); yylex_init(&scanner); yy_scan_string(text, scanner); diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc index 307459396e..50a745624d 100644 --- a/third_party/nix/src/libexpr/primops.cc +++ b/third_party/nix/src/libexpr/primops.cc @@ -118,12 +118,12 @@ static void prim_scopedImport(EvalState& state, const Pos& pos, Value** args, mkString(*v2, path, {"=" + path}); v2 = state.allocAttr(w, state.sName); mkString(*v2, drv.env["name"]); - Value* outputsVal = state.allocAttr(w, state.symbols.create("outputs")); + Value* outputsVal = state.allocAttr(w, state.symbols.Create("outputs")); state.mkList(*outputsVal, drv.outputs.size()); unsigned int outputs_index = 0; for (const auto& o : drv.outputs) { - v2 = state.allocAttr(w, state.symbols.create(o.first)); + v2 = state.allocAttr(w, state.symbols.Create(o.first)); mkString(*v2, o.second.path, {"!" + o.first + "!" + path}); outputsVal->listElems()[outputs_index] = state.allocValue(); mkString(*(outputsVal->listElems()[outputs_index++]), o.first); @@ -291,7 +291,7 @@ static void prim_typeOf(EvalState& state, const Pos& pos, Value** args, default: abort(); } - mkString(v, state.symbols.create(t)); + mkString(v, state.symbols.Create(t)); } /* Determine whether the argument is the null value. */ @@ -394,7 +394,7 @@ static void prim_genericClosure(EvalState& state, const Pos& pos, Value** args, /* Get the start set. */ Bindings::iterator startSet = - args[0]->attrs->find(state.symbols.create("startSet")); + args[0]->attrs->find(state.symbols.Create("startSet")); if (startSet == args[0]->attrs->end()) { throw EvalError(format("attribute 'startSet' required, at %1%") % pos); } @@ -407,7 +407,7 @@ static void prim_genericClosure(EvalState& state, const Pos& pos, Value** args, /* Get the operator. */ Bindings::iterator op = - args[0]->attrs->find(state.symbols.create("operator")); + args[0]->attrs->find(state.symbols.Create("operator")); if (op == args[0]->attrs->end()) { throw EvalError(format("attribute 'operator' required, at %1%") % pos); } @@ -426,7 +426,7 @@ static void prim_genericClosure(EvalState& state, const Pos& pos, Value** args, state.forceAttrs(*e, pos); - Bindings::iterator key = e->attrs->find(state.symbols.create("key")); + Bindings::iterator key = e->attrs->find(state.symbols.Create("key")); if (key == e->attrs->end()) { throw EvalError(format("attribute 'key' required, at %1%") % pos); } @@ -493,10 +493,10 @@ static void prim_tryEval(EvalState& state, const Pos& pos, Value** args, try { state.forceValue(*args[0]); v.attrs->push_back(Attr(state.sValue, args[0])); - mkBool(*state.allocAttr(v, state.symbols.create("success")), true); + mkBool(*state.allocAttr(v, state.symbols.Create("success")), true); } catch (AssertionError& e) { mkBool(*state.allocAttr(v, state.sValue), false); - mkBool(*state.allocAttr(v, state.symbols.create("success")), false); + mkBool(*state.allocAttr(v, state.symbols.Create("success")), false); } v.attrs->sort(); } @@ -846,7 +846,7 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos, state.mkAttrs(v, 1 + drv.outputs.size()); mkString(*state.allocAttr(v, state.sDrvPath), drvPath, {"=" + drvPath}); for (auto& i : drv.outputs) { - mkString(*state.allocAttr(v, state.symbols.create(i.first)), i.second.path, + mkString(*state.allocAttr(v, state.symbols.Create(i.first)), i.second.path, {"!" + i.first + "!" + drvPath}); } v.attrs->sort(); @@ -987,12 +987,12 @@ static void prim_findFile(EvalState& state, const Pos& pos, Value** args, state.forceAttrs(v2, pos); string prefix; - Bindings::iterator i = v2.attrs->find(state.symbols.create("prefix")); + Bindings::iterator i = v2.attrs->find(state.symbols.Create("prefix")); if (i != v2.attrs->end()) { prefix = state.forceStringNoCtx(*i->value, pos); } - i = v2.attrs->find(state.symbols.create("path")); + i = v2.attrs->find(state.symbols.Create("path")); if (i == v2.attrs->end()) { throw EvalError(format("attribute 'path' missing, at %1%") % pos); } @@ -1050,7 +1050,7 @@ static void prim_readDir(EvalState& state, const Pos& pos, Value** args, state.mkAttrs(v, entries.size()); for (auto& ent : entries) { - Value* ent_val = state.allocAttr(v, state.symbols.create(ent.name)); + Value* ent_val = state.allocAttr(v, state.symbols.Create(ent.name)); if (ent.type == DT_UNKNOWN) { ent.type = getFileType(path + "/" + ent.name); } @@ -1301,7 +1301,7 @@ void prim_getAttr(EvalState& state, const Pos& pos, Value** args, Value& v) { string attr = state.forceStringNoCtx(*args[0], pos); state.forceAttrs(*args[1], pos); // !!! Should we create a symbol here or just do a lookup? - Bindings::iterator i = args[1]->attrs->find(state.symbols.create(attr)); + Bindings::iterator i = args[1]->attrs->find(state.symbols.Create(attr)); if (i == args[1]->attrs->end()) { throw EvalError(format("attribute '%1%' missing, at %2%") % attr % pos); } @@ -1318,7 +1318,7 @@ void prim_unsafeGetAttrPos(EvalState& state, const Pos& pos, Value** args, Value& v) { string attr = state.forceStringNoCtx(*args[0], pos); state.forceAttrs(*args[1], pos); - Bindings::iterator i = args[1]->attrs->find(state.symbols.create(attr)); + Bindings::iterator i = args[1]->attrs->find(state.symbols.Create(attr)); if (i == args[1]->attrs->end()) { mkNull(v); } else { @@ -1331,7 +1331,7 @@ static void prim_hasAttr(EvalState& state, const Pos& pos, Value** args, Value& v) { string attr = state.forceStringNoCtx(*args[0], pos); state.forceAttrs(*args[1], pos); - mkBool(v, args[1]->attrs->find(state.symbols.create(attr)) != + mkBool(v, args[1]->attrs->find(state.symbols.Create(attr)) != args[1]->attrs->end()); } @@ -1351,7 +1351,7 @@ static void prim_removeAttrs(EvalState& state, const Pos& pos, Value** args, std::set names; for (unsigned int i = 0; i < args[1]->listSize(); ++i) { state.forceStringNoCtx(*args[1]->listElems()[i], pos); - names.insert(state.symbols.create(args[1]->listElems()[i]->string.s)); + names.insert(state.symbols.Create(args[1]->listElems()[i]->string.s)); } /* Copy all attributes not in that set. Note that we don't need @@ -1391,10 +1391,13 @@ static void prim_listToAttrs(EvalState& state, const Pos& pos, Value** args, } string name = state.forceStringNoCtx(*j->value, pos); - Symbol sym = state.symbols.create(name); + Symbol sym = state.symbols.Create(name); if (seen.find(sym) == seen.end()) { Bindings::iterator j2 = - v2.attrs->find(state.symbols.create(state.sValue)); + // TODO(tazjin): this line used to construct the symbol again: + // state.symbols.Create(state.sValue)); + // Why? + v2.attrs->find(state.sValue); if (j2 == v2.attrs->end()) { throw TypeError(format("'value' attribute missing in a call to " "'listToAttrs', at %1%") % @@ -1436,7 +1439,7 @@ static void prim_intersectAttrs(EvalState& state, const Pos& pos, Value** args, */ static void prim_catAttrs(EvalState& state, const Pos& pos, Value** args, Value& v) { - Symbol attrName = state.symbols.create(state.forceStringNoCtx(*args[0], pos)); + Symbol attrName = state.symbols.Create(state.forceStringNoCtx(*args[0], pos)); state.forceList(*args[1], pos); Value* res[args[1]->listSize()]; @@ -2144,7 +2147,7 @@ static void prim_parseDrvName(EvalState& state, const Pos& pos, Value** args, DrvName parsed(name); state.mkAttrs(v, 2); mkString(*state.allocAttr(v, state.sName), parsed.name); - mkString(*state.allocAttr(v, state.symbols.create("version")), + mkString(*state.allocAttr(v, state.symbols.Create("version")), parsed.version); v.attrs->sort(); } @@ -2430,7 +2433,7 @@ void EvalState::createBaseEnv() { `drvPath' and `outPath' attributes lazily. */ string path = canonPath(settings.nixDataDir + "/nix/corepkgs/derivation.nix", true); - sDerivationNix = symbols.create(path); + sDerivationNix = symbols.Create(path); evalFile(path, v); addConstant("derivation", v); @@ -2440,8 +2443,8 @@ void EvalState::createBaseEnv() { for (auto& i : searchPath) { v2 = v.listElems()[n++] = allocValue(); mkAttrs(*v2, 2); - mkString(*allocAttr(*v2, symbols.create("path")), i.second); - mkString(*allocAttr(*v2, symbols.create("prefix")), i.first); + mkString(*allocAttr(*v2, symbols.Create("path")), i.second); + mkString(*allocAttr(*v2, symbols.Create("prefix")), i.first); v2->attrs->sort(); } addConstant("__nixPath", v); diff --git a/third_party/nix/src/libexpr/primops/context.cc b/third_party/nix/src/libexpr/primops/context.cc index 347b7a0a52..7fa33bd87f 100644 --- a/third_party/nix/src/libexpr/primops/context.cc +++ b/third_party/nix/src/libexpr/primops/context.cc @@ -108,10 +108,10 @@ static void prim_getContext(EvalState& state, const Pos& pos, Value** args, state.mkAttrs(v, contextInfos.size()); - auto sPath = state.symbols.create("path"); - auto sAllOutputs = state.symbols.create("allOutputs"); + auto sPath = state.symbols.Create("path"); + auto sAllOutputs = state.symbols.Create("allOutputs"); for (const auto& info : contextInfos) { - auto& infoVal = *state.allocAttr(v, state.symbols.create(info.first)); + auto& infoVal = *state.allocAttr(v, state.symbols.Create(info.first)); state.mkAttrs(infoVal, 3); if (info.second.path) { mkBool(*state.allocAttr(infoVal, sPath), true); @@ -145,8 +145,8 @@ static void prim_appendContext(EvalState& state, const Pos& pos, Value** args, state.forceAttrs(*args[1], pos); - auto sPath = state.symbols.create("path"); - auto sAllOutputs = state.symbols.create("allOutputs"); + auto sPath = state.symbols.Create("path"); + auto sAllOutputs = state.symbols.Create("allOutputs"); for (auto& i : *args[1]->attrs) { if (!state.store->isStorePath(i.name)) throw EvalError("Context key '%s' is not a store path, at %s", i.name, diff --git a/third_party/nix/src/libexpr/primops/fetchGit.cc b/third_party/nix/src/libexpr/primops/fetchGit.cc index 818a475f5e..374f075a91 100644 --- a/third_party/nix/src/libexpr/primops/fetchGit.cc +++ b/third_party/nix/src/libexpr/primops/fetchGit.cc @@ -246,10 +246,10 @@ static void prim_fetchGit(EvalState& state, const Pos& pos, Value** args, state.mkAttrs(v, 8); mkString(*state.allocAttr(v, state.sOutPath), gitInfo.storePath, PathSet({gitInfo.storePath})); - mkString(*state.allocAttr(v, state.symbols.create("rev")), gitInfo.rev); - mkString(*state.allocAttr(v, state.symbols.create("shortRev")), + mkString(*state.allocAttr(v, state.symbols.Create("rev")), gitInfo.rev); + mkString(*state.allocAttr(v, state.symbols.Create("shortRev")), gitInfo.shortRev); - mkInt(*state.allocAttr(v, state.symbols.create("revCount")), + mkInt(*state.allocAttr(v, state.symbols.Create("revCount")), gitInfo.revCount); v.attrs->sort(); diff --git a/third_party/nix/src/libexpr/primops/fetchMercurial.cc b/third_party/nix/src/libexpr/primops/fetchMercurial.cc index 392dbcb008..67ecf4f498 100644 --- a/third_party/nix/src/libexpr/primops/fetchMercurial.cc +++ b/third_party/nix/src/libexpr/primops/fetchMercurial.cc @@ -220,11 +220,11 @@ static void prim_fetchMercurial(EvalState& state, const Pos& pos, Value** args, state.mkAttrs(v, 8); mkString(*state.allocAttr(v, state.sOutPath), hgInfo.storePath, PathSet({hgInfo.storePath})); - mkString(*state.allocAttr(v, state.symbols.create("branch")), hgInfo.branch); - mkString(*state.allocAttr(v, state.symbols.create("rev")), hgInfo.rev); - mkString(*state.allocAttr(v, state.symbols.create("shortRev")), + mkString(*state.allocAttr(v, state.symbols.Create("branch")), hgInfo.branch); + mkString(*state.allocAttr(v, state.symbols.Create("rev")), hgInfo.rev); + mkString(*state.allocAttr(v, state.symbols.Create("shortRev")), std::string(hgInfo.rev, 0, 12)); - mkInt(*state.allocAttr(v, state.symbols.create("revCount")), hgInfo.revCount); + mkInt(*state.allocAttr(v, state.symbols.Create("revCount")), hgInfo.revCount); v.attrs->sort(); if (state.allowedPaths) diff --git a/third_party/nix/src/libexpr/primops/fromTOML.cc b/third_party/nix/src/libexpr/primops/fromTOML.cc index 4b652b379a..320b6120e7 100644 --- a/third_party/nix/src/libexpr/primops/fromTOML.cc +++ b/third_party/nix/src/libexpr/primops/fromTOML.cc @@ -25,7 +25,7 @@ static void prim_fromTOML(EvalState& state, const Pos& pos, Value** args, state.mkAttrs(v, size); for (auto& i : *t2) { - auto& v2 = *state.allocAttr(v, state.symbols.create(i.first)); + auto& v2 = *state.allocAttr(v, state.symbols.Create(i.first)); if (auto i2 = i.second->as_table_array()) { size_t size2 = i2->get().size(); diff --git a/third_party/nix/src/libexpr/value-to-json.cc b/third_party/nix/src/libexpr/value-to-json.cc index eaf0fca3d3..52ab44083b 100644 --- a/third_party/nix/src/libexpr/value-to-json.cc +++ b/third_party/nix/src/libexpr/value-to-json.cc @@ -54,7 +54,7 @@ void printValueAsJSON(EvalState& state, bool strict, Value& v, names.insert(j.name); } for (auto& j : names) { - Attr& a(*v.attrs->find(state.symbols.create(j))); + Attr& a(*v.attrs->find(state.symbols.Create(j))); auto placeholder(obj.placeholder(j)); printValueAsJSON(state, strict, *a.value, placeholder, context); } diff --git a/third_party/nix/src/libexpr/value-to-xml.cc b/third_party/nix/src/libexpr/value-to-xml.cc index 7fab6e2ffe..160c6eba33 100644 --- a/third_party/nix/src/libexpr/value-to-xml.cc +++ b/third_party/nix/src/libexpr/value-to-xml.cc @@ -34,7 +34,7 @@ static void showAttrs(EvalState& state, bool strict, bool location, } for (auto& i : names) { - Attr& a(*attrs.find(state.symbols.create(i))); + Attr& a(*attrs.find(state.symbols.Create(i))); XMLAttrs xmlAttrs; xmlAttrs["name"] = i; @@ -86,7 +86,7 @@ static void printValueAsXML(EvalState& state, bool strict, bool location, XMLAttrs xmlAttrs; Bindings::iterator a = - v.attrs->find(state.symbols.create("derivation")); + v.attrs->find(state.symbols.Create("derivation")); Path drvPath; a = v.attrs->find(state.sDrvPath); diff --git a/third_party/nix/src/nix-env/nix-env.cc b/third_party/nix/src/nix-env/nix-env.cc index 95a395a96f..93a8e4c1ec 100644 --- a/third_party/nix/src/nix-env/nix-env.cc +++ b/third_party/nix/src/nix-env/nix-env.cc @@ -132,7 +132,7 @@ static void getAllExprs(EvalState& state, const Path& path, StringSet& attrs, throw Error(format("too many Nix expressions in directory '%1%'") % path); } - mkApp(*state.allocAttr(v, state.symbols.create(attrName)), vFun, vArg); + mkApp(*state.allocAttr(v, state.symbols.Create(attrName)), vFun, vArg); } else if (S_ISDIR(st.st_mode)) { /* `path2' is a directory (with no default.nix in it); recurse into it. */ @@ -159,7 +159,7 @@ static void loadSourceExpr(EvalState& state, const Path& path, Value& v) { directory). */ else if (S_ISDIR(st.st_mode)) { state.mkAttrs(v, 1024); - state.mkList(*state.allocAttr(v, state.symbols.create("_combineChannels")), + state.mkList(*state.allocAttr(v, state.symbols.Create("_combineChannels")), 0); StringSet attrs; getAllExprs(state, path, attrs, v); diff --git a/third_party/nix/src/nix-env/user-env.cc b/third_party/nix/src/nix-env/user-env.cc index bf15543c3f..adff263ff4 100644 --- a/third_party/nix/src/nix-env/user-env.cc +++ b/third_party/nix/src/nix-env/user-env.cc @@ -73,7 +73,7 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile, unsigned int m = 0; for (auto& j : outputs) { mkString(*(vOutputs.listElems()[m++] = state.allocValue()), j.first); - Value& vOutputs = *state.allocAttr(v, state.symbols.create(j.first)); + Value& vOutputs = *state.allocAttr(v, state.symbols.Create(j.first)); state.mkAttrs(vOutputs, 2); mkString(*state.allocAttr(vOutputs, state.sOutPath), j.second); @@ -94,7 +94,7 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile, if (v == nullptr) { continue; } - vMeta.attrs->push_back(Attr(state.symbols.create(j), v)); + vMeta.attrs->push_back(Attr(state.symbols.Create(j), v)); } vMeta.attrs->sort(); v.attrs->sort(); @@ -119,9 +119,9 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile, Value args; Value topLevel; state.mkAttrs(args, 3); - mkString(*state.allocAttr(args, state.symbols.create("manifest")), + mkString(*state.allocAttr(args, state.symbols.Create("manifest")), manifestFile, {manifestFile}); - args.attrs->push_back(Attr(state.symbols.create("derivations"), &manifest)); + args.attrs->push_back(Attr(state.symbols.Create("derivations"), &manifest)); args.attrs->sort(); mkApp(topLevel, envBuilder, args); diff --git a/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc b/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc index 5a9b81103d..17341e382d 100644 --- a/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc +++ b/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc @@ -39,7 +39,7 @@ string resolveMirrorUri(EvalState& state, string uri) { vMirrors); state.forceAttrs(vMirrors); - auto mirrorList = vMirrors.attrs->find(state.symbols.create(mirrorName)); + auto mirrorList = vMirrors.attrs->find(state.symbols.Create(mirrorName)); if (mirrorList == vMirrors.attrs->end()) { throw Error(format("unknown mirror name '%1%'") % mirrorName); } @@ -126,7 +126,7 @@ static int _main(int argc, char** argv) { state->forceAttrs(v); /* Extract the URI. */ - auto attr = v.attrs->find(state->symbols.create("urls")); + auto attr = v.attrs->find(state->symbols.Create("urls")); if (attr == v.attrs->end()) { throw Error("attribute set does not contain a 'urls' attribute"); } @@ -137,7 +137,7 @@ static int _main(int argc, char** argv) { uri = state->forceString(*attr->value->listElems()[0]); /* Extract the hash mode. */ - attr = v.attrs->find(state->symbols.create("outputHashMode")); + attr = v.attrs->find(state->symbols.Create("outputHashMode")); if (attr == v.attrs->end()) { LOG(WARNING) << "this does not look like a fetchurl call"; } else { @@ -146,7 +146,7 @@ static int _main(int argc, char** argv) { /* Extract the name. */ if (name.empty()) { - attr = v.attrs->find(state->symbols.create("name")); + attr = v.attrs->find(state->symbols.Create("name")); if (attr != v.attrs->end()) { name = state->forceString(*attr->value); } diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc index 8d2f932568..59dfc1b1ac 100644 --- a/third_party/nix/src/nix/installables.cc +++ b/third_party/nix/src/nix/installables.cc @@ -27,7 +27,7 @@ Value* SourceExprCommand::getSourceExpr(EvalState& state) { return vSourceExpr; } - auto sToplevel = state.symbols.create("_toplevel"); + auto sToplevel = state.symbols.Create("_toplevel"); vSourceExpr = state.allocValue(); @@ -57,7 +57,7 @@ Value* SourceExprCommand::getSourceExpr(EvalState& state) { state.getBuiltin("nixPath")); Value* v2 = state.allocValue(); mkApp(*v2, *v1, mkString(*state.allocValue(), name)); - mkApp(*state.allocAttr(*vSourceExpr, state.symbols.create(name)), + mkApp(*state.allocAttr(*vSourceExpr, state.symbols.Create(name)), state.getBuiltin("import"), *v2); }; diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 78991645ac..e60ef89652 100644 --- a/third_party/nix/src/nix/repl.cc +++ b/third_party/nix/src/nix/repl.cc @@ -574,7 +574,7 @@ bool NixRepl::processLine(string line) { v.type = tThunk; v.thunk.env = env; v.thunk.expr = e; - addVarToScope(state.symbols.create(name), v); + addVarToScope(state.symbols.Create(name), v); } else { Value v; evalString(line, v); diff --git a/third_party/nix/src/nix/search.cc b/third_party/nix/src/nix/search.cc index 7fe81adb69..169daf7a32 100644 --- a/third_party/nix/src/nix/search.cc +++ b/third_party/nix/src/nix/search.cc @@ -90,8 +90,8 @@ struct CmdSearch : SourceExprCommand, MixJSON { auto jsonOut = json ? std::make_unique(std::cout) : nullptr; - auto sToplevel = state->symbols.create("_toplevel"); - auto sRecurse = state->symbols.create("recurseForDerivations"); + auto sToplevel = state->symbols.Create("_toplevel"); + auto sRecurse = state->symbols.Create("recurseForDerivations"); bool fromCache = false; -- cgit 1.4.1