summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/meaning.hpp
blob: c358d691e9c9e52e182049d8fea30da2a8579a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#include "concept.hpp"
#include "helpers.hpp"

// get a named variable
ref avariable(ref name);

template <typename... T>
ref and(T... refs)
{
	std::initializer_list<ref> rs = { refs... };
	declrefs(and);
	decllnks(what);
	ref ret = a(and);
	ref name; int count = 0;
	for (auto r : rs) {
		ret[what] = r;
		if (count == 0) {
			name.ptr = r.ptr;
		} else {
			name.ptr = (name-and-r).ptr;
		}
		++ count;
	}
	if (count == 1) {
		throw std::logic_error("and needs at least two subjects");
	}
	return name = ret;
}

// make a reference to a link
ref link(ref sourceref, ref typeref, ref targetref);

// invert a meaning
ref not(ref whatref);