forked from lix-project/lix
mildly cleanup libexpr/eval.hh
Change-Id: I40d01a8f8b7fb101279c6f88ebdf1f0969d9d7f0
This commit is contained in:
parent
c59096a841
commit
cab1666121
|
@ -9,14 +9,13 @@
|
||||||
#include "symbol-table.hh"
|
#include "symbol-table.hh"
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "experimental-features.hh"
|
#include "experimental-features.hh"
|
||||||
#include "input-accessor.hh"
|
|
||||||
#include "search-path.hh"
|
#include "search-path.hh"
|
||||||
#include "repl-exit-status.hh"
|
#include "repl-exit-status.hh"
|
||||||
|
|
||||||
|
#include <gc/gc_allocator.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <mutex>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
@ -38,11 +37,29 @@ namespace eval_cache {
|
||||||
class EvalCache;
|
class EvalCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Alias for std::map which uses boehmgc's allocator conditional on us actually
|
||||||
|
* using boehmgc in this build.
|
||||||
|
*/
|
||||||
|
#if HAVE_BOEHMGC
|
||||||
|
template<typename KeyT, typename ValueT>
|
||||||
|
using GcMap = std::map<
|
||||||
|
KeyT,
|
||||||
|
ValueT,
|
||||||
|
std::less<KeyT>,
|
||||||
|
traceable_allocator<std::pair<KeyT const, ValueT>>
|
||||||
|
>;
|
||||||
|
#else
|
||||||
|
using GcMap = std::map<KeyT, ValueT>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that implements a primop.
|
* Function that implements a primop.
|
||||||
*/
|
*/
|
||||||
typedef void (* PrimOpFun) (EvalState & state, const PosIdx pos, Value * * args, Value & v);
|
using PrimOpImpl = void(EvalState & state, PosIdx pos, Value ** args, Value & v);
|
||||||
|
|
||||||
|
/** Pointer to a function that implements a primop. */
|
||||||
|
using PrimOpFun = PrimOpImpl *;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Info about a primitive operation, and its implementation
|
* Info about a primitive operation, and its implementation
|
||||||
|
@ -76,7 +93,7 @@ struct PrimOp
|
||||||
/**
|
/**
|
||||||
* Implementation of the primop.
|
* Implementation of the primop.
|
||||||
*/
|
*/
|
||||||
std::function<std::remove_pointer<PrimOpFun>::type> fun;
|
std::function<PrimOpImpl> fun;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional experimental for this to be gated on.
|
* Optional experimental for this to be gated on.
|
||||||
|
@ -115,11 +132,7 @@ struct Constant
|
||||||
bool impureOnly = false;
|
bool impureOnly = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if HAVE_BOEHMGC
|
using ValMap = GcMap<std::string, Value *>;
|
||||||
typedef std::map<std::string, Value *, std::less<std::string>, traceable_allocator<std::pair<const std::string, Value *> > > ValMap;
|
|
||||||
#else
|
|
||||||
typedef std::map<std::string, Value *> ValMap;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct Env
|
struct Env
|
||||||
{
|
{
|
||||||
|
@ -214,7 +227,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* Debugger
|
* Debugger
|
||||||
*/
|
*/
|
||||||
ReplExitStatus (* debugRepl)(ref<EvalState> es, const ValMap & extraEnv);
|
using ReplCallbackImpl = ReplExitStatus(ref<EvalState> es, ValMap const & extraEnv);
|
||||||
|
ReplCallbackImpl * debugRepl;
|
||||||
bool debugStop;
|
bool debugStop;
|
||||||
bool inDebugger = false;
|
bool inDebugger = false;
|
||||||
int trylevel;
|
int trylevel;
|
||||||
|
@ -252,21 +266,13 @@ private:
|
||||||
/**
|
/**
|
||||||
* A cache from path names to parse trees.
|
* A cache from path names to parse trees.
|
||||||
*/
|
*/
|
||||||
#if HAVE_BOEHMGC
|
using FileParseCache = GcMap<SourcePath, Expr *>;
|
||||||
typedef std::map<SourcePath, Expr *, std::less<SourcePath>, traceable_allocator<std::pair<const SourcePath, Expr *>>> FileParseCache;
|
|
||||||
#else
|
|
||||||
typedef std::map<SourcePath, Expr *> FileParseCache;
|
|
||||||
#endif
|
|
||||||
FileParseCache fileParseCache;
|
FileParseCache fileParseCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cache from path names to values.
|
* A cache from path names to values.
|
||||||
*/
|
*/
|
||||||
#if HAVE_BOEHMGC
|
using FileEvalCache = GcMap<SourcePath, Value>;
|
||||||
typedef std::map<SourcePath, Value, std::less<SourcePath>, traceable_allocator<std::pair<const SourcePath, Value>>> FileEvalCache;
|
|
||||||
#else
|
|
||||||
typedef std::map<SourcePath, Value> FileEvalCache;
|
|
||||||
#endif
|
|
||||||
FileEvalCache fileEvalCache;
|
FileEvalCache fileEvalCache;
|
||||||
|
|
||||||
SearchPath searchPath;
|
SearchPath searchPath;
|
||||||
|
@ -737,15 +743,15 @@ private:
|
||||||
|
|
||||||
bool countCalls;
|
bool countCalls;
|
||||||
|
|
||||||
typedef std::map<std::string, size_t> PrimOpCalls;
|
using PrimOpCalls = std::map<std::string, size_t>;
|
||||||
PrimOpCalls primOpCalls;
|
PrimOpCalls primOpCalls;
|
||||||
|
|
||||||
typedef std::map<ExprLambda *, size_t> FunctionCalls;
|
using FunctionCalls = std::map<ExprLambda *, size_t>;
|
||||||
FunctionCalls functionCalls;
|
FunctionCalls functionCalls;
|
||||||
|
|
||||||
void incrFunctionCall(ExprLambda * fun);
|
void incrFunctionCall(ExprLambda * fun);
|
||||||
|
|
||||||
typedef std::map<PosIdx, size_t> AttrSelects;
|
using AttrSelects = std::map<PosIdx, size_t>;
|
||||||
AttrSelects attrSelects;
|
AttrSelects attrSelects;
|
||||||
|
|
||||||
friend struct ExprOpUpdate;
|
friend struct ExprOpUpdate;
|
||||||
|
@ -787,7 +793,7 @@ std::string showType(const Value & v);
|
||||||
*/
|
*/
|
||||||
SourcePath resolveExprPath(SourcePath path);
|
SourcePath resolveExprPath(SourcePath path);
|
||||||
|
|
||||||
static const std::string corepkgsPrefix{"/__corepkgs__/"};
|
static constexpr std::string_view corepkgsPrefix{"/__corepkgs__/"};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue