mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-31 23:46:48 +02:00
tryEval: Allocate true and false once
This commit is contained in:
parent
d71e74838a
commit
a865049c4f
3 changed files with 23 additions and 4 deletions
|
@ -437,6 +437,8 @@ EvalState::EvalState(
|
||||||
|
|
||||||
vEmptyList.mkList(buildList(0));
|
vEmptyList.mkList(buildList(0));
|
||||||
vNull.mkNull();
|
vNull.mkNull();
|
||||||
|
vTrue.mkBool(true);
|
||||||
|
vFalse.mkBool(false);
|
||||||
vStringRegular.mkString("regular");
|
vStringRegular.mkString("regular");
|
||||||
vStringDirectory.mkString("directory");
|
vStringDirectory.mkString("directory");
|
||||||
vStringSymlink.mkString("symlink");
|
vStringSymlink.mkString("symlink");
|
||||||
|
|
|
@ -187,10 +187,26 @@ public:
|
||||||
Value vEmptyList;
|
Value vEmptyList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Null constant.
|
* `null` constant.
|
||||||
|
*
|
||||||
|
* This is _not_ a singleton. Pointer equality is _not_ sufficient.
|
||||||
*/
|
*/
|
||||||
Value vNull;
|
Value vNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `true` constant.
|
||||||
|
*
|
||||||
|
* This is _not_ a singleton. Pointer equality is _not_ sufficient.
|
||||||
|
*/
|
||||||
|
Value vTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `true` constant.
|
||||||
|
*
|
||||||
|
* This is _not_ a singleton. Pointer equality is _not_ sufficient.
|
||||||
|
*/
|
||||||
|
Value vFalse;
|
||||||
|
|
||||||
/** `"regular"` */
|
/** `"regular"` */
|
||||||
Value vStringRegular;
|
Value vStringRegular;
|
||||||
/** `"directory"` */
|
/** `"directory"` */
|
||||||
|
|
|
@ -896,10 +896,11 @@ static void prim_tryEval(EvalState & state, const PosIdx pos, Value * * args, Va
|
||||||
try {
|
try {
|
||||||
state.forceValue(*args[0], pos);
|
state.forceValue(*args[0], pos);
|
||||||
attrs.insert(state.sValue, args[0]);
|
attrs.insert(state.sValue, args[0]);
|
||||||
attrs.alloc("success").mkBool(true);
|
attrs.insert(state.symbols.create("success"), &state.vTrue);
|
||||||
} catch (AssertionError & e) {
|
} catch (AssertionError & e) {
|
||||||
attrs.alloc(state.sValue).mkBool(false);
|
// `value = false;` is unfortunate but removing it is a breaking change.
|
||||||
attrs.alloc("success").mkBool(false);
|
attrs.insert(state.sValue, &state.vFalse);
|
||||||
|
attrs.insert(state.symbols.create("success"), &state.vFalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore the debugRepl pointer if we saved it earlier.
|
// restore the debugRepl pointer if we saved it earlier.
|
||||||
|
|
Loading…
Reference in a new issue