diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-26 08:26:40 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-26 08:26:40 -0800 |
commit | dc2779f5a7ceb226620f39e728b73b028cb17c10 (patch) | |
tree | 5053af30bb6e49a9c17291626a5cb375df260bcf /starts/meaning-vm/level-2 | |
parent | ff4aecf759ce565b77575ad8eabcf60c94ee6a29 (diff) | |
download | standingwithresilience-dc2779f5a7ceb226620f39e728b73b028cb17c10.tar.gz standingwithresilience-dc2779f5a7ceb226620f39e728b73b028cb17c10.zip |
start closing habit starts in level2
Diffstat (limited to 'starts/meaning-vm/level-2')
-rw-r--r-- | starts/meaning-vm/level-2/baseref.hpp | 13 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/habits.cpp | 15 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/habits.hpp | 10 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/level-2.hpp | 1 |
4 files changed, 32 insertions, 7 deletions
diff --git a/starts/meaning-vm/level-2/baseref.hpp b/starts/meaning-vm/level-2/baseref.hpp index 8fbcc91..644f4b8 100644 --- a/starts/meaning-vm/level-2/baseref.hpp +++ b/starts/meaning-vm/level-2/baseref.hpp @@ -1,10 +1,8 @@ #pragma once #include "common.hpp" - #include "funcs.hpp" - -#include "../level-1/common.hpp" +#include "../level-1/baseref.hpp" #include <functional> @@ -21,10 +19,13 @@ struct baseref : public level1::baseref<ref> template <typename... Refs> ref operator()(ref first, Refs... rest) { return level2::dohabit(self, {first, rest...}); } - template <typename... Pairs> - ref operator()(std::initializer_list<ref> first, Pairs... rest) { return level2::dohabit(self, {first, rest...}); } - + ref operator()(std::initializer_list<std::initializer_list<ref>> pairs) { return level2::dohabit(self, pairs); } ref operator()() { return level2::dohabit(self); } + + template <typename... Refs> + ref act(ref habit, Refs... rest) { return level2::dohabit(habit, {self, rest...}); } + + void replace(ref other) { *self.ptr() = *other.ptr(); } }; } diff --git a/starts/meaning-vm/level-2/habits.cpp b/starts/meaning-vm/level-2/habits.cpp index 13589cc..dfb9014 100644 --- a/starts/meaning-vm/level-2/habits.cpp +++ b/starts/meaning-vm/level-2/habits.cpp @@ -2,7 +2,9 @@ #include "../level-1/sugar.hpp" #include "sugar.hpp" -using namespace intellect::level2; +namespace intellect { +namespace level2 { + int createhabits() { decls(link, source, type, target); @@ -375,3 +377,14 @@ int createhabits() }); return 0; } + +void ensurehabitscreated() +{ + static int sentinel = createhabits(); + (void)(sentinel); +} + +static int sentinel = (ensurehabitscreated(), 1); + +} +} diff --git a/starts/meaning-vm/level-2/habits.hpp b/starts/meaning-vm/level-2/habits.hpp new file mode 100644 index 0000000..0bff7f7 --- /dev/null +++ b/starts/meaning-vm/level-2/habits.hpp @@ -0,0 +1,10 @@ +#include "common.hpp" + +namespace intellect { +namespace level2 { + +void ensurehabitscreated(); // for running from static code, for construction order + + +} +} diff --git a/starts/meaning-vm/level-2/level-2.hpp b/starts/meaning-vm/level-2/level-2.hpp index 7c7dd9a..88b4474 100644 --- a/starts/meaning-vm/level-2/level-2.hpp +++ b/starts/meaning-vm/level-2/level-2.hpp @@ -4,3 +4,4 @@ #include "concepts.hpp" #include "sugar.hpp" #include "ref.hpp" +#include "habits.hpp" |