diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-26 16:34:28 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-26 16:34:28 -0800 |
commit | 94ed7bbaa739995a9815b5f1c916d9e24575368c (patch) | |
tree | 587c4f268721cf156aab92c60aae4ec530c7ce17 /starts/meaning-vm/level2.cpp | |
parent | fe2a9b21e655041ef14e34c94509c6974f294866 (diff) | |
download | standingwithresilience-94ed7bbaa739995a9815b5f1c916d9e24575368c.tar.gz standingwithresilience-94ed7bbaa739995a9815b5f1c916d9e24575368c.zip |
level2 compiles, nothing visible yet
Diffstat (limited to 'starts/meaning-vm/level2.cpp')
-rw-r--r-- | starts/meaning-vm/level2.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/starts/meaning-vm/level2.cpp b/starts/meaning-vm/level2.cpp index c04a5cc..ebdf121 100644 --- a/starts/meaning-vm/level2.cpp +++ b/starts/meaning-vm/level2.cpp @@ -1,9 +1,54 @@ #include "level-2/level-2.hpp" +#include "level-1/level-1.hpp" #include <iostream> +#include <set> using namespace intellect::level2; +using namespace intellect::level2::concepts; int main() { + decls(dump, name, of, is, nothing); + ahabit(name-of, ((concept, c)), + { + if (linked(c, name)) { + result = get(c, name); + } else { + for (auto & group : c.getAll(is)) { + result = (name-of)(group); + if (result != nothing) { break; } + } + std::stringstream ss; + if (result != nothing) { + ss << result.val<std::string>(); + } else { + ss << "unnamed"; + } + ss << "-" << std::hex << (size_t)(c.ptr()); + intellect::level1::givename(c, ss.str()); + result = get(c, name); + } + }); + // I guess I'd better code dump as a behavior. + ahabit(dump, ((concept, c)), + { + decls(type, target); + static std::set<ref> dumped; + if (dumped.count(c) == 0) { + std::cout << (name-of)(c).val<std::string>() << ":" << std::endl; + dumped.insert(c); + ref le = (make-concept)().act(know-is-first-link-entry, c); + while (le.linked(target)) { + std::cout << " " << (name-of)(le.get(type)).val<std::string>() << ": " << (name-of)(le.get(target)).val<std::string>() << std::endl; + (next-link-entry)(le); + } + (know-is-first-link-entry)(le, c); + while (le.linked(target)) { + (dump)(le.get(target)); + (next-link-entry)(le); + } + (unmake-concept)(le); + } + }); } |