3 #ifndef LALA_CORE_INTERPRETATION_HPP
4 #define LALA_CORE_INTERPRETATION_HPP
19 template <
class L, IKind kind,
bool diagnose = false,
class F>
22 if constexpr(kind ==
IKind::ASK || L::preserve_top) {
26 const char* name = L::name;
34 template <IKind kind,
bool diagnose = false,
class A,
class F,
class Env,
class I>
36 const char* name = A::name;
38 return ginterpret_true<A, kind, diagnose>(f, diagnostics);
40 else if(f.is_false()) {
41 if constexpr(kind ==
IKind::TELL || A::preserve_bot) {
42 return a.template interpret<kind, diagnose>(f, env, intermediate, diagnostics);
48 else if(f.is(F::Seq) && f.sig() ==
AND) {
49 if constexpr(kind ==
IKind::ASK || A::preserve_meet) {
50 for(
int i = 0; i < f.seq().size(); ++i) {
51 if(!ginterpret_in<kind, diagnose>(a, f.seq(i), env, intermediate, diagnostics)) {
62 return a.template interpret<kind, diagnose>(f, env, intermediate, diagnostics);
67 template <IKind kind,
bool diagnose = false,
class F,
class Env,
class U>
69 const char* name = U::name;
71 return ginterpret_true<U, kind, diagnose>(f, diagnostics);
73 else if(f.is_false()) {
74 if constexpr(kind ==
IKind::TELL || U::preserve_bot) {
82 else if(f.is(F::Seq)) {
84 if constexpr(kind ==
IKind::ASK || U::preserve_meet) {
85 for(
int i = 0; i < f.seq().size(); ++i) {
86 if(!ginterpret_in<kind, diagnose>(f.seq(i), env, value, diagnostics)) {
96 else if(f.sig() ==
OR) {
97 if constexpr(kind ==
IKind::TELL || U::preserve_join) {
98 using U2 =
typename U::local_type;
99 U2 join_value = U2::bot();
100 for(
int i = 0; i < f.seq().size(); ++i) {
102 if(!ginterpret_in<kind, diagnose>(f.seq(i), env, x, diagnostics)) {
107 value.meet(join_value);
116 return U::template interpret<kind, diagnose>(f, env, value, diagnostics);
120 template <IKind kind,
bool diagnose = false,
class A,
class F,
class Env,
class I>
122 auto snap = env.snapshot();
123 I copy = intermediate;
124 if(ginterpret_in<kind, diagnose>(a, f, env, intermediate, diagnostics)) {
129 intermediate = std::move(copy);
134 template <
class A,
class Alloc = battery::standard_allocator,
class Env>
136 if constexpr(A::is_abstract_universe) {
140 return A::top(env, alloc);
144 template <
bool diagnose = false,
class TellAlloc = battery::standard_allocator,
class F,
class Env,
class L>
146 if constexpr(L::is_abstract_universe) {
147 return ginterpret_in<IKind::TELL, diagnose>(f, env, value, diagnostics);
150 typename L::template tell_type<TellAlloc> tell(tell_alloc);
151 if(top_level_ginterpret_in<IKind::TELL, diagnose>(value, f, env, tell, diagnostics)) {
161 template <
class A,
bool diagnose = false,
class F,
class Env,
class TellAlloc =
typename A::allocator_type>
164 typename A::allocator_type alloc =
typename A::allocator_type{},
165 TellAlloc tell_alloc = TellAlloc{})
167 auto snap = env.snapshot();
168 A a{make_top<A>(env, alloc)};
169 if(interpret_and_tell<diagnose>(f, env, a, diagnostics, tell_alloc)) {
170 return {std::move(a)};
Definition: diagnostics.hpp:19
#define RETURN_INTERPRETATION_ERROR(MSG)
Definition: diagnostics.hpp:155
Definition: abstract_deps.hpp:14
CUDA A make_top(Env &env, Alloc alloc=Alloc{})
Definition: interpretation.hpp:135
@ OR
Unary arithmetic function symbols.
Definition: ast.hpp:114
@ AND
Unary arithmetic function symbols.
Definition: ast.hpp:114
CUDA bool top_level_ginterpret_in(const A &a, const F &f, Env &env, I &intermediate, IDiagnostics &diagnostics)
Definition: interpretation.hpp:121
CUDA bool ginterpret_true(const F &f, IDiagnostics &diagnostics)
Definition: interpretation.hpp:20
CUDA std::optional< A > create_and_interpret_and_tell(const F &f, Env &env, IDiagnostics &diagnostics, typename A::allocator_type alloc=typename A::allocator_type{}, TellAlloc tell_alloc=TellAlloc{})
Definition: interpretation.hpp:162
CUDA bool interpret_and_tell(const F &f, Env &env, L &value, IDiagnostics &diagnostics, TellAlloc tell_alloc=TellAlloc{})
Definition: interpretation.hpp:145
CUDA bool ginterpret_in(const A &a, const F &f, Env &env, I &intermediate, IDiagnostics &diagnostics)
Definition: interpretation.hpp:35