refactor(3p/tvix): make Value.primOp a std::shared_ptr

Change-Id: I04cc42ae62d2ff71b07fde8e3710dcc9b4363a05
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1973
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Kane York 2020-09-12 08:40:55 -07:00 committed by kanepyork
parent d9c7f32a9c
commit fedbe693b9
2 changed files with 3 additions and 4 deletions

View file

@ -434,13 +434,12 @@ Value* EvalState::addPrimOp(const std::string& name, size_t arity,
primOp(*this, noPos, nullptr, v);
return addConstant(name, v);
}
Value* v = allocValue();
std::string name2 =
std::string(name, 0, 2) == "__" ? std::string(name, 2) : name;
Symbol sym = symbols.Create(name2);
// Even though PrimOp doesn't need tracing, it needs to be collected.
Value* v = allocValue();
v->type = tPrimOp;
v->primOp = new PrimOp(primOp, arity, sym);
v->primOp = std::make_shared<PrimOp>(primOp, arity, sym);
staticBaseEnv.vars[symbols.Create(name)] = baseEnvDispl;
baseEnv.values[baseEnvDispl++] = v;
baseEnv.values[0]->attrs->push_back(Attr(sym, v));

View file

@ -100,7 +100,7 @@ struct Value {
NixThunk thunk;
NixApp app; // TODO(tazjin): "app"?
NixLambda lambda;
PrimOp* primOp;
std::shared_ptr<PrimOp> primOp;
NixPrimOpApp primOpApp;
NixFloat fpoint;
};