mirror of
https://github.com/NixOS/nix.git
synced 2025-11-19 00:39:37 +01:00
libexpr: Statically allocate commonly used symbols
The motivation for this change is two-fold: 1. Commonly used Symbol values can be referred to quite often and they can be assigned at compile-time rather than runtime. 2. This also unclutters EvalState constructor, which was getting very long and unreadable. Spiritually similar to https://gerrit.lix.systems/c/lix/+/2218, though that patch doesn't allocate the Symbol at compile time. Co-authored-by: eldritch horrors <pennae@lix.systems>
This commit is contained in:
parent
2746985d90
commit
363620dd24
23 changed files with 313 additions and 255 deletions
|
|
@ -232,7 +232,7 @@ static Flake readFlake(
|
|||
.path = flakePath,
|
||||
};
|
||||
|
||||
if (auto description = vInfo.attrs()->get(state.sDescription)) {
|
||||
if (auto description = vInfo.attrs()->get(state.s.description)) {
|
||||
expectType(state, nString, *description->value, description->pos);
|
||||
flake.description = description->value->c_str();
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ static Flake readFlake(
|
|||
|
||||
if (outputs->value->isLambda() && outputs->value->lambda().fun->hasFormals()) {
|
||||
for (auto & formal : outputs->value->lambda().fun->formals->formals) {
|
||||
if (formal.name != state.sSelf)
|
||||
if (formal.name != state.s.self)
|
||||
flake.inputs.emplace(
|
||||
state.symbols[formal.name],
|
||||
FlakeInput{.ref = parseFlakeRef(state.fetchSettings, std::string(state.symbols[formal.name]))});
|
||||
|
|
@ -305,7 +305,8 @@ static Flake readFlake(
|
|||
}
|
||||
|
||||
for (auto & attr : *vInfo.attrs()) {
|
||||
if (attr.name != state.sDescription && attr.name != sInputs && attr.name != sOutputs && attr.name != sNixConfig)
|
||||
if (attr.name != state.s.description && attr.name != sInputs && attr.name != sOutputs
|
||||
&& attr.name != sNixConfig)
|
||||
throw Error(
|
||||
"flake '%s' has an unsupported attribute '%s', at %s",
|
||||
resolvedRef,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue