nixd
Loading...
Searching...
No Matches
PrimOpInfo.h
Go to the documentation of this file.
1#include <cstdint>
2#include <map>
3#include <string>
4#include <vector>
5
6namespace nixf {
7
8/**
9 * Info about a primitive operation, but omit the implementation.
10 */
11struct PrimOpInfo {
12 /**
13 * Names of the parameters of a primop, for primops that take a
14 * fixed number of arguments to be substituted for these parameters.
15 */
16 std::vector<std::string> Args;
17
18 /**
19 * Aritiy of the primop.
20 *
21 * If `args` is not empty, this field will be computed from that
22 * field instead, so it doesn't need to be manually set.
23 */
24 size_t Arity = 0;
25
26 /**
27 * Optional free-form documentation about the primop.
28 */
29 std::string Doc;
30
31 /**
32 * If true, this primop is not exposed to the user.
33 */
35};
36
37extern std::map<std::string, nixf::PrimOpInfo> PrimOpsInfo;
38
39/// \brief Result of looking up a primop by name.
40enum class PrimopLookupResult : std::uint8_t {
41 /// The primop was found with an exact match.
43 /// The primop was found, but needs "builtin." prefix.
45 /// The primop was not found.
47};
48
49/// \brief Look up information about a global primop by name.
50PrimopLookupResult lookupGlobalPrimOpInfo(const std::string &Name);
51
52} // namespace nixf
PrimopLookupResult lookupGlobalPrimOpInfo(const std::string &Name)
Look up information about a global primop by name.
std::map< std::string, nixf::PrimOpInfo > PrimOpsInfo
PrimopLookupResult
Result of looking up a primop by name.
Definition PrimOpInfo.h:40
@ PrefixedFound
The primop was found, but needs "builtin." prefix.
Definition PrimOpInfo.h:44
@ NotFound
The primop was not found.
Definition PrimOpInfo.h:46
@ Found
The primop was found with an exact match.
Definition PrimOpInfo.h:42
std::vector< std::string > Args
Definition PrimOpInfo.h:16
std::string Doc
Definition PrimOpInfo.h:29