From f5ec96b6f4f88065b4cc6c24057af15d1f025ad4 Mon Sep 17 00:00:00 2001 From: olpc user Date: Mon, 9 Dec 2019 02:38:38 -0800 Subject: move level-1 dump up into baseref so derived can use --- starts/meaning-vm/level-1/baseref.hpp | 2 +- starts/meaning-vm/level-1/funcs.cpp | 23 +++++++++++++++++++++++ starts/meaning-vm/level-1/funcs.hpp | 2 ++ starts/meaning-vm/level-1/ref.cpp | 31 ------------------------------- starts/meaning-vm/level-1/ref.hpp | 2 -- 5 files changed, 26 insertions(+), 34 deletions(-) delete mode 100644 starts/meaning-vm/level-1/ref.cpp diff --git a/starts/meaning-vm/level-1/baseref.hpp b/starts/meaning-vm/level-1/baseref.hpp index 6215225..187b5df 100644 --- a/starts/meaning-vm/level-1/baseref.hpp +++ b/starts/meaning-vm/level-1/baseref.hpp @@ -48,7 +48,7 @@ struct baseref : public level0::baseref template ref operator()(Ref... args) { return self.template fun()(args...); } - std::string dump(ref skipmarkertype, ref skipmarkertarget); + std::string dump(ref skipmarkertype, ref skipmarkertarget) { return level1::dump(self, skipmarkertype, skipmarkertarget); }; private: template diff --git a/starts/meaning-vm/level-1/funcs.cpp b/starts/meaning-vm/level-1/funcs.cpp index 07f0eba..72d3c27 100644 --- a/starts/meaning-vm/level-1/funcs.cpp +++ b/starts/meaning-vm/level-1/funcs.cpp @@ -89,5 +89,28 @@ concept* hyphenate(concept* a, concept* b) return getnamed(getname(a) + "-" + getname(b)); } +std::string dump(concept* what, concept* skipmarkertype, concept* skipmarkertarget) +{ + if (what->linked(skipmarkertype, skipmarkertarget)) { + return {}; + } + std::string ret; + for (auto & link : ref(what).links()) { + if (link.first == concepts::name) { continue; } + if (ret.size() == 0) { + ret = ref(what).name() + ":\n"; + } + ret += " " + link.first.name() + ": " + link.second.name() + "\n"; + } + what->link(skipmarkertype, skipmarkertarget); + for (auto & link : ref(what).links()) { + if (link.first.ptr() == skipmarkertype && link.second.ptr() == skipmarkertarget) { + continue; + } + ret += dump(link.second, skipmarkertype, skipmarkertarget); + } + return ret; +} + } } diff --git a/starts/meaning-vm/level-1/funcs.hpp b/starts/meaning-vm/level-1/funcs.hpp index 741a5af..4b53ddd 100644 --- a/starts/meaning-vm/level-1/funcs.hpp +++ b/starts/meaning-vm/level-1/funcs.hpp @@ -20,5 +20,7 @@ concept* hyphenate(concept* a, concept* b); concept* alloc(std::any val); +std::string dump(concept * what, concept * skipmarkertype, concept * skipmarkertarget); + } } diff --git a/starts/meaning-vm/level-1/ref.cpp b/starts/meaning-vm/level-1/ref.cpp deleted file mode 100644 index 8d74b50..0000000 --- a/starts/meaning-vm/level-1/ref.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "ref.hpp" - -#include "concepts.hpp" - - -using namespace intellect; -using namespace level1; -using namespace concepts; - -std::string ref::dump(ref skipmarkertype, ref skipmarkertarget) -{ - if (linked(skipmarkertype, skipmarkertarget)) { - return {}; - } - std::string ret; - for (auto & link : links()) { - if (link.first == concepts::name) { continue; } - if (ret.size() == 0) { - ret = name() + ":\n"; - } - ret += " " + link.first.name() + ": " + link.second.name() + "\n"; - } - link(skipmarkertype, skipmarkertarget); - for (auto & link : links()) { - if (link.first == skipmarkertype && link.second == skipmarkertarget) { - continue; - } - ret += link.second.dump(skipmarkertype, skipmarkertarget); - } - return ret; -} diff --git a/starts/meaning-vm/level-1/ref.hpp b/starts/meaning-vm/level-1/ref.hpp index 3f2214d..fdd7dfd 100644 --- a/starts/meaning-vm/level-1/ref.hpp +++ b/starts/meaning-vm/level-1/ref.hpp @@ -9,8 +9,6 @@ namespace level1 { struct ref : public baseref { using baseref::baseref; - - std::string dump(ref skipmarkertype, ref skipmarkertarget); }; } -- cgit v1.2.3