Vita
core_interpreter.h
Go to the documentation of this file.
1
13#if !defined(VITA_CORE_INTERPRETER_H)
14#define VITA_CORE_INTERPRETER_H
15
16#include "kernel/common.h"
17#include "kernel/value.h"
18#include "kernel/vitafwd.h"
19
20namespace vita
21{
22
36{
37public:
42 [[nodiscard]] virtual value_t fetch_arg(unsigned) = 0;
43
49 virtual value_t fetch_opaque_arg(unsigned) = 0;
50
52 [[nodiscard]] value_t operator[](unsigned i) { return fetch_arg(i); }
53
54 [[nodiscard]] virtual terminal_param_t fetch_param() const = 0;
55
56 [[nodiscard]] virtual value_t fetch_var(unsigned) { return {}; }
57};
58
69{
70public:
71 value_t run() { return run_nvi(); }
72 [[nodiscard]] double penalty() { return penalty_nvi(); }
73 [[nodiscard]] bool is_valid() const { return is_valid_nvi(); }
74
75private:
76 virtual value_t run_nvi() = 0;
77 virtual double penalty_nvi() = 0;
78 virtual bool is_valid_nvi() const = 0;
79};
80
87template<class T> value_t run(const T &ind)
88{
89 return interpreter<T>(&ind).run();
90}
91
92} // namespace vita
93
94#endif // include guard
Minimum interface of an interpreter.
An interface for parameter passing to functions / terminals.
virtual value_t fetch_arg(unsigned)=0
Fetches a specific input parameter assuming referential transparency.
virtual value_t fetch_opaque_arg(unsigned)=0
Fetches a specific input parameter without assuming referential transparency.
value_t operator[](unsigned i)
Equivalent to fetch_arg().
The main namespace for the project.
value_t run(const T &ind)
A handy short-cut for one-time execution of an individual.
std::variant< D_VOID, D_INT, D_DOUBLE, D_STRING > value_t
A variant containing the data types used by the interpreter for internal calculations / output value ...
Definition: value.h:45