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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#include "level-1/level-1.hpp"
#include <iostream>
using namespace intellect::level1;
using namespace intellect::level1::concepts;
int main()
{
std::cout << intellect::level0::allocated() << " allocated" << std::endl;
///*
decls(make, linked, habit);
std::cout << intellect::level0::allocated() << " allocated" << std::endl;
decls(needs, assumes, makes);
decls(not, topic);
decls(A, B, C);
decls(source, type, target);
decls(structure, function, argument, position);
decls(variable, provide);
decls(act);
(make-linked).link(
is, habit,
needs, a(structure).link(
is, function-argument,
argument-position, ref(1),
a(variable, A), provide,
a(variable, B), provide,
a(variable, C), provide
)
);
movetoname(a(link), A-B-C-linked).link(
link-source, A,
link-type, B,
link-target, C
);
a(not, not-A-B-C-linked).set(topic, A-B-C-linked);
(make-linked).link(
assumes, not-A-B-C-linked,
makes, A-B-C-linked
);
(make-linked).fset(
act,
(std::function<void(ref)>)[&](ref args)
{
ref source = args[A];
ref type = args[B];
ref target = args[C];
std::cout << "Linking " << source.name() << " by " << type.name() << " to " << target.name() << std::endl;
source.link(type, target);
}
);
std::cout << (make-linked).dump("dumped", true) << std::endl;
decls(apple, fruit);
(make-linked)[act]
(a(function-argument)
.link(
A, apple,
B, is,
C, fruit
));
std::cout << apple.dump("dumped", true) << std::endl;
std::cout << intellect::level0::allocated() << " allocated" << std::endl;
while (true) {
try {
intellect::level0::dealloc(intellect::level0::concepts::allocations(), intellect::level0::concepts::level0allocations());
break;
} catch (intellect::level0::still_referenced_by &e) {
if (e.topic->linked(intellect::level0::concepts::allocates(), e.referrer)) {
intellect::level0::realloc(e.referrer, intellect::level0::concepts::allocations());
} else {
std::cout << "In deallocation, " << ref(e.topic).name() << " still referenced by " << ref(e.referrer).name() << std::endl;
throw;
}
}
}
std::cout << intellect::level0::allocated() << " allocated" << std::endl;
return 0;
}
|