libexpr: fully separate evaluator and running evaluation
this finally gives us a witness type we can use to prove that a certain call graph subtree can't be used in kj promises using only a single new assumption: if EvalState& is never held as a reference member of a type and instead only ever passes as an argument or held on the stack we can be certain that anything that has access to en EvalState ref must never be run inside a promise and, crucially, that anything that doesn't have access to an EvalState& *can* be run inside a promise without problems. Change-Id: I6c15ada479175ad7e6cd3e4a729a5586b3ba30d6
This commit is contained in:
@@ -31,7 +31,7 @@ TEST(Arguments, lookupFileArg) {
|
||||
searchPath.elements.push_back(SearchPath::Elem::parse(searchPathElem));
|
||||
|
||||
auto store = openStore("dummy://");
|
||||
auto state = std::make_shared<EvalState>(searchPath, store, store);
|
||||
auto state = std::make_shared<Evaluator>(searchPath, store, store);
|
||||
|
||||
SourcePath const foundUnitData = lookupFileArg(*state, "<example>");
|
||||
EXPECT_EQ(foundUnitData.path, canonDataPath);
|
||||
|
||||
@@ -24,7 +24,8 @@ namespace nix {
|
||||
LibExprTest()
|
||||
: LibStoreTest()
|
||||
, evaluator({}, store)
|
||||
, state(evaluator)
|
||||
, statePtr(evaluator.begin())
|
||||
, state(*statePtr)
|
||||
{
|
||||
}
|
||||
Value eval(std::string input, bool forceValue = true, const FeatureSettings & fSettings = featureSettings) {
|
||||
@@ -40,7 +41,8 @@ namespace nix {
|
||||
return evaluator.symbols.create(value);
|
||||
}
|
||||
|
||||
EvalState evaluator;
|
||||
Evaluator evaluator;
|
||||
box_ptr<EvalState> statePtr;
|
||||
EvalState & state;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user