blob: 1efd33e0b34805c0ad292c335a93f5b87128e473 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include "level-0/level-0.hpp"
#include <functional>
#include <iostream>
using namespace intellect::level0;
int main()
{
ref a = alloc();
ref b = alloc();
ref c = alloc();
ref d = alloc();
ref e = alloc();
ref num = valloc<int>(3);
ref code = valloc<std::function<void()>>([](){
std::cout << "Hello, world." << std::endl;
});
auto numlink = alloc();
auto codelink = alloc();
ref skip = alloc();
a.set(b, c);
a.link(d, e);
e.link(b, a);
c.link(b, e);
a.link(numlink, num);
a.link(codelink, code);
std::cout << "Num: " << ref(num).dump(skip, skip);
std::cout << "Code: " << ref(code).dump(skip, skip);
std::cout << a.dump(skip, skip);
std::cout << "Num: " << a.vget<int>(numlink) << std::endl;
std::cout << "Code: "; a.vget<std::function<void()>>(codelink)();
std::cout << allocated() << " allocated" << std::endl;
e.unlink(b, a);
dealloc(a);
dealloc(c);
dealloc(e);
dealloc(b);
dealloc(d);
dealloc(numlink);
dealloc(codelink);
dealloc(num);
dealloc(code);
dealloc(skip);
std::cout << allocated() << " allocated" << std::endl;
return 0;
}
|