diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-24 00:51:53 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-11-24 00:51:53 -0800 |
commit | b3dea01d1ad6803b96865a846b56494506ccc74e (patch) | |
tree | b6d21894711aff4d0fa1197434a03cacfaf0d594 /starts/meaning-vm/helpers.hpp | |
parent | fed2ac694bd028d119581ea05a3376e791aee97d (diff) | |
download | standingwithresilience-b3dea01d1ad6803b96865a846b56494506ccc74e.tar.gz standingwithresilience-b3dea01d1ad6803b96865a846b56494506ccc74e.zip |
changes didn't pan out; next change is big (merging statementevaluable with ref). saving work.
Diffstat (limited to 'starts/meaning-vm/helpers.hpp')
-rw-r--r-- | starts/meaning-vm/helpers.hpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/starts/meaning-vm/helpers.hpp b/starts/meaning-vm/helpers.hpp index 8c7e307..12d1e9c 100644 --- a/starts/meaning-vm/helpers.hpp +++ b/starts/meaning-vm/helpers.hpp @@ -27,8 +27,44 @@ // if there is an "is" link to the passed ref. #include "concept.hpp" +#include "memorystore.hpp" #include <sstream> +inline std::string operator+(vref<std::string> a, char const * b) { return std::string(a) + b; } +inline std::string operator+(vref<std::string> a, std::string b) { return std::string(a) + b; } +inline std::string operator+(char const * a, vref<std::string> b) { return a + std::string(b); } +inline std::string operator+(std::string a, vref<std::string> b) { return a + std::string(b); } + +// TODO TODO +// actually, get rid of this, and set the function as a value on a normal ref. +// then use ref destructor. +// have to delete ref copy constructor. use move constructor instead. +// could also alter ref copy constructor to tell copied ref is okay. +class statementevaluable : public ref +{ +public: + statementevaluable(ref r, std::function<void(ref)> evaluation) + : ref(r.ptr), + evaluation(evaluation) + { } + statementevaluable(statementevaluable const &) = delete; + ~statementevaluable() { if (evaluate) { evaluation(*this); } } +private: + std::function<void(ref)> evaluation; +}; + +template <> +vref<std::string>::vref(std::string const &); + +template <typename T> +vref<T>::vref(T const & v) +: ptr(valloc(v).ptr) +#include "memorystore.hpp" +{ + ptr->link(ref("name"), vref(std::to_string(v))); +} + + template <typename... T> void __helper_init_ref_names(std::string names, T &... refrefs) { |