diff options
Diffstat (limited to 'starts/meaning-vm/level-2')
-rw-r--r-- | starts/meaning-vm/level-2/baseref.hpp | 25 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/common.hpp | 1 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/concepts.hpp | 15 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/funcs.cpp | 15 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/funcs.hpp | 11 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/level-2.hpp | 3 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/ref.hpp | 15 | ||||
-rw-r--r-- | starts/meaning-vm/level-2/sugar.hpp | 21 |
8 files changed, 105 insertions, 1 deletions
diff --git a/starts/meaning-vm/level-2/baseref.hpp b/starts/meaning-vm/level-2/baseref.hpp new file mode 100644 index 0000000..c2bc0d1 --- /dev/null +++ b/starts/meaning-vm/level-2/baseref.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "common.hpp" + +#include "funcs.hpp" + +#include "../level-1/common.hpp" + +#include <functional> + +namespace intellect { +namespace level2 { + +template <typename ref> +struct baseref : public level1::baseref<ref> +{ + using level1::template baseref<ref>::baseref; + + // thread-local context + static ref context() { return level2::context(); } + +}; + +} +} diff --git a/starts/meaning-vm/level-2/common.hpp b/starts/meaning-vm/level-2/common.hpp new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/starts/meaning-vm/level-2/common.hpp @@ -0,0 +1 @@ +#pragma once diff --git a/starts/meaning-vm/level-2/concepts.hpp b/starts/meaning-vm/level-2/concepts.hpp new file mode 100644 index 0000000..a8cfb0d --- /dev/null +++ b/starts/meaning-vm/level-2/concepts.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "ref.hpp" + +namespace intellect { +namespace level2 { + +namespace concepts { + +static ref context("context"); + +} + +} +} diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp new file mode 100644 index 0000000..4ee02a4 --- /dev/null +++ b/starts/meaning-vm/level-2/funcs.cpp @@ -0,0 +1,15 @@ +#include "funcs.hp" + +#include "../level-1/sugar.hpp" + +namespace intellect { +namespace level2 { + +level2::ref context() +{ + static thread_local level1::ref ctx = level1::a("context"); + return ctx; +} + +} +} diff --git a/starts/meaning-vm/level-2/funcs.hpp b/starts/meaning-vm/level-2/funcs.hpp new file mode 100644 index 0000000..52c041d --- /dev/null +++ b/starts/meaning-vm/level-2/funcs.hpp @@ -0,0 +1,11 @@ +#pragma once + +#include "common.hpp" + +namespace intellect { +namespace level2 { + +ref context(); + +} +} diff --git a/starts/meaning-vm/level-2/level-2.hpp b/starts/meaning-vm/level-2/level-2.hpp index 29ab89e..7c7dd9a 100644 --- a/starts/meaning-vm/level-2/level-2.hpp +++ b/starts/meaning-vm/level-2/level-2.hpp @@ -1,3 +1,6 @@ #pragma once +#include "common.hpp" +#include "concepts.hpp" #include "sugar.hpp" +#include "ref.hpp" diff --git a/starts/meaning-vm/level-2/ref.hpp b/starts/meaning-vm/level-2/ref.hpp new file mode 100644 index 0000000..7a2d58d --- /dev/null +++ b/starts/meaning-vm/level-2/ref.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "common.hpp" +#include "baseref.hpp" + +namespace intellect { +namespace level2 { + +struct ref : public baseref<ref> +{ + using baseref<ref>::baseref; +}; + +} +} diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp index 2fa9414..3e94c97 100644 --- a/starts/meaning-vm/level-2/sugar.hpp +++ b/starts/meaning-vm/level-2/sugar.hpp @@ -12,7 +12,7 @@ #define ahabit(name, ...) \ a(habit, name); \ (name).fun((std::function<ref(ref)>) \ - [=](ref ctx) \ + [=](ref ctx) -> ref\ { \ habitdelay; \ ref self = name; \ @@ -21,6 +21,25 @@ return intellect::level1::concepts::nothing; \ }); +// thinking on handling arguments with less boilerplate, more positional sugar +// transfer argslist to a context for calling? +// possibly transfer argslist to a function signature for the call +// transfer context to the argslist for handling call +// for each item of argslist, make a local variable, and set it to its value +/* +#define _positionalhabitarg(local, arg) \ + ref local = ctx.get(arg); +#define _ph + +#define apositionalhabit(name, argslist, ...) \ + a(habit, name); \ + (name).fun((std::function<ref(ref)>) \ + [=](ref ctx) \ + { \ + \ + }); +*/ + // seed random number generator statically, for habitdelay namespace __internal { static struct timespec __tp; |