summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level0.cpp
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-11-24 14:09:27 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-11-24 14:09:27 -0800
commitf80b3ce2b52f568bb04005c24ad11c3a05cf7a15 (patch)
tree5744aa421d92a2887898900ea70924b30f015e82 /starts/meaning-vm/level0.cpp
parent9a14918abec434d8463e07635daef380ad630649 (diff)
downloadstandingwithresilience-f80b3ce2b52f568bb04005c24ad11c3a05cf7a15.tar.gz
standingwithresilience-f80b3ce2b52f568bb04005c24ad11c3a05cf7a15.zip
level0 few more checks
Diffstat (limited to 'starts/meaning-vm/level0.cpp')
-rw-r--r--starts/meaning-vm/level0.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/starts/meaning-vm/level0.cpp b/starts/meaning-vm/level0.cpp
index 71c18b7..8cb60f9 100644
--- a/starts/meaning-vm/level0.cpp
+++ b/starts/meaning-vm/level0.cpp
@@ -1,5 +1,6 @@
#include "level-0/level-0.hpp"
+#include <functional>
#include <iostream>
using namespace intellect::level0;
@@ -11,6 +12,12 @@ int main()
ref c = alloc();
ref d = alloc();
ref e = alloc();
+ vref<int> num(3);
+ vref<std::function<void()>> code([](){
+ std::cout << "Hello, world." << std::endl;
+ });
+ auto numlink = alloc();
+ auto codelink = alloc();
ref skip = alloc();
@@ -18,8 +25,30 @@ int main()
a->link(d, e);
e->link(b, a);
c->link(b, e);
+ a->link(numlink, num);
+ a->link(codelink, code);
- std::cout << a.dump(skip, skip) << std::endl;
+ 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).val() << std::endl;
+ std::cout << "Code: "; a->vget<std::function<void()>>(codelink).val()();
+
+ 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;
}