forked from lix-project/lix
Turn mkString(Symbol) into a method
This commit is contained in:
parent
ed93aec3c3
commit
ca5baf2392
|
@ -112,7 +112,7 @@ struct ExprString : Expr
|
||||||
{
|
{
|
||||||
Symbol s;
|
Symbol s;
|
||||||
Value v;
|
Value v;
|
||||||
ExprString(const Symbol & s) : s(s) { mkString(v, s); };
|
ExprString(const Symbol & s) : s(s) { v.mkString(s); };
|
||||||
COMMON_METHODS
|
COMMON_METHODS
|
||||||
Value * maybeThunk(EvalState & state, Env & env);
|
Value * maybeThunk(EvalState & state, Env & env);
|
||||||
};
|
};
|
||||||
|
|
|
@ -412,7 +412,7 @@ static void prim_typeOf(EvalState & state, const Pos & pos, Value * * args, Valu
|
||||||
case nFloat: t = "float"; break;
|
case nFloat: t = "float"; break;
|
||||||
case nThunk: abort();
|
case nThunk: abort();
|
||||||
}
|
}
|
||||||
mkString(v, state.symbols.create(t));
|
v.mkString(state.symbols.create(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp primop_typeOf({
|
static RegisterPrimOp primop_typeOf({
|
||||||
|
@ -2129,7 +2129,7 @@ static void prim_attrNames(EvalState & state, const Pos & pos, Value * * args, V
|
||||||
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
for (auto & i : *args[0]->attrs)
|
for (auto & i : *args[0]->attrs)
|
||||||
mkString(*(v.listElems()[n++] = state.allocValue()), i.name);
|
(v.listElems()[n++] = state.allocValue())->mkString(i.name);
|
||||||
|
|
||||||
std::sort(v.listElems(), v.listElems() + n,
|
std::sort(v.listElems(), v.listElems() + n,
|
||||||
[](Value * v1, Value * v2) { return strcmp(v1->string.s, v2->string.s) < 0; });
|
[](Value * v1, Value * v2) { return strcmp(v1->string.s, v2->string.s) < 0; });
|
||||||
|
@ -2477,7 +2477,7 @@ static void prim_mapAttrs(EvalState & state, const Pos & pos, Value * * args, Va
|
||||||
for (auto & i : *args[1]->attrs) {
|
for (auto & i : *args[1]->attrs) {
|
||||||
Value * vName = state.allocValue();
|
Value * vName = state.allocValue();
|
||||||
Value * vFun2 = state.allocValue();
|
Value * vFun2 = state.allocValue();
|
||||||
mkString(*vName, i.name);
|
vName->mkString(i.name);
|
||||||
vFun2->mkApp(args[0], vName);
|
vFun2->mkApp(args[0], vName);
|
||||||
state.allocAttr(v, i.name)->mkApp(vFun2, i.value);
|
state.allocAttr(v, i.name)->mkApp(vFun2, i.value);
|
||||||
}
|
}
|
||||||
|
@ -2540,8 +2540,8 @@ static void prim_zipAttrsWith(EvalState & state, const Pos & pos, Value * * args
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & attr : *v.attrs) {
|
for (auto & attr : *v.attrs) {
|
||||||
Value * name = state.allocValue();
|
auto name = state.allocValue();
|
||||||
mkString(*name, attr.name);
|
name->mkString(attr.name);
|
||||||
auto call1 = state.allocValue();
|
auto call1 = state.allocValue();
|
||||||
call1->mkApp(args[0], name);
|
call1->mkApp(args[0], name);
|
||||||
auto call2 = state.allocValue();
|
auto call2 = state.allocValue();
|
||||||
|
|
|
@ -241,6 +241,11 @@ public:
|
||||||
|
|
||||||
void mkString(std::string_view s, const PathSet & context);
|
void mkString(std::string_view s, const PathSet & context);
|
||||||
|
|
||||||
|
inline void mkString(const Symbol & s)
|
||||||
|
{
|
||||||
|
mkString(((const std::string &) s).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
inline void mkPath(const char * s)
|
inline void mkPath(const char * s)
|
||||||
{
|
{
|
||||||
clearValue();
|
clearValue();
|
||||||
|
@ -393,14 +398,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Remove these static functions, replace call sites with v.mk* instead
|
|
||||||
static inline void mkString(Value & v, const Symbol & s)
|
|
||||||
{
|
|
||||||
v.mkString(((const string &) s).c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
#if HAVE_BOEHMGC
|
||||||
typedef std::vector<Value *, traceable_allocator<Value *> > ValueVector;
|
typedef std::vector<Value *, traceable_allocator<Value *> > ValueVector;
|
||||||
typedef std::map<Symbol, Value *, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, Value *> > > ValueMap;
|
typedef std::map<Symbol, Value *, std::less<Symbol>, traceable_allocator<std::pair<const Symbol, Value *> > > ValueMap;
|
||||||
|
|
Loading…
Reference in a new issue