diff options
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); + } + }); } |