From dc2779f5a7ceb226620f39e728b73b028cb17c10 Mon Sep 17 00:00:00 2001 From: olpc user Date: Thu, 26 Dec 2019 08:26:40 -0800 Subject: start closing habit starts in level2 --- starts/meaning-vm/level-1/sugar.cpp | 1 + starts/meaning-vm/level-2/baseref.hpp | 13 +++++++------ starts/meaning-vm/level-2/habits.cpp | 15 ++++++++++++++- starts/meaning-vm/level-2/habits.hpp | 10 ++++++++++ starts/meaning-vm/level-2/level-2.hpp | 1 + starts/meaning-vm/level2.cpp | 9 +++++++++ 6 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 starts/meaning-vm/level-2/habits.hpp create mode 100644 starts/meaning-vm/level2.cpp (limited to 'starts/meaning-vm') diff --git a/starts/meaning-vm/level-1/sugar.cpp b/starts/meaning-vm/level-1/sugar.cpp index 025c68e..8585387 100644 --- a/starts/meaning-vm/level-1/sugar.cpp +++ b/starts/meaning-vm/level-1/sugar.cpp @@ -10,6 +10,7 @@ using namespace concepts; namespace intellect { namespace level1 { + // no way to specify allocator ref a(ref group) { static unsigned long long gid = 0; 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 @@ -21,10 +19,13 @@ struct baseref : public level1::baseref template ref operator()(ref first, Refs... rest) { return level2::dohabit(self, {first, rest...}); } - template - ref operator()(std::initializer_list first, Pairs... rest) { return level2::dohabit(self, {first, rest...}); } - + ref operator()(std::initializer_list> pairs) { return level2::dohabit(self, pairs); } ref operator()() { return level2::dohabit(self); } + + template + 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" diff --git a/starts/meaning-vm/level2.cpp b/starts/meaning-vm/level2.cpp new file mode 100644 index 0000000..c04a5cc --- /dev/null +++ b/starts/meaning-vm/level2.cpp @@ -0,0 +1,9 @@ +#include "level-2/level-2.hpp" + +#include + +using namespace intellect::level2; + +int main() +{ +} -- cgit v1.2.3