diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-25 17:35:09 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-25 17:35:09 -0800 |
commit | 8172f109ed55b8a02e7e498566b7ba12e346f7e2 (patch) | |
tree | d23b6279d34b03d7cebc987808c74a3cf49cecf8 /starts/meaning-vm/level0.cpp | |
parent | 684ac69af192670bb6547ec01df19a3159e7d8e6 (diff) | |
download | standingwithresilience-8172f109ed55b8a02e7e498566b7ba12e346f7e2.tar.gz standingwithresilience-8172f109ed55b8a02e7e498566b7ba12e346f7e2.zip |
add vset
Diffstat (limited to 'starts/meaning-vm/level0.cpp')
-rw-r--r-- | starts/meaning-vm/level0.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/starts/meaning-vm/level0.cpp b/starts/meaning-vm/level0.cpp index 1efd33e..1dcc4f7 100644 --- a/starts/meaning-vm/level0.cpp +++ b/starts/meaning-vm/level0.cpp @@ -12,10 +12,6 @@ int main() 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(); @@ -25,11 +21,13 @@ int main() a.link(d, e); e.link(b, a); c.link(b, e); - a.link(numlink, num); - a.link(codelink, code); + a.vset<int>(numlink, 3); + a.vset<std::function<void()>>(codelink, [](){ + std::cout << "Hello, world." << std::endl; + }); - std::cout << "Num: " << ref(num).dump(skip, skip); - std::cout << "Code: " << ref(code).dump(skip, skip); + std::cout << "Num: " << a.get(numlink).dump(skip, skip); + std::cout << "Code: " << a.get(codelink).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)(); @@ -37,15 +35,17 @@ int main() std::cout << allocated() << " allocated" << std::endl; e.unlink(b, a); + auto num = a.get(numlink); + auto code = a.get(codelink); dealloc(a); + dealloc(num); + dealloc(code); + dealloc(numlink); + dealloc(codelink); dealloc(c); dealloc(e); dealloc(b); dealloc(d); - dealloc(numlink); - dealloc(codelink); - dealloc(num); - dealloc(code); dealloc(skip); std::cout << allocated() << " allocated" << std::endl; |