summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-2
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 03:26:04 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 03:26:04 -0800
commit8ceeb5f83f22ed3db06fc02bb23710ccc1dbbb90 (patch)
tree8defe85cd6af09cbe258ace239eb490a0b98651c /starts/meaning-vm/level-2
parent584ca7f9b6fca6da54608d3b28274273b2c9a4b8 (diff)
downloadstandingwithresilience-8ceeb5f83f22ed3db06fc02bb23710ccc1dbbb90.tar.gz
standingwithresilience-8ceeb5f83f22ed3db06fc02bb23710ccc1dbbb90.zip
use tls contexts for habits
Diffstat (limited to 'starts/meaning-vm/level-2')
-rw-r--r--starts/meaning-vm/level-2/common.hpp9
-rw-r--r--starts/meaning-vm/level-2/funcs.cpp9
-rw-r--r--starts/meaning-vm/level-2/sugar.hpp8
3 files changed, 19 insertions, 7 deletions
diff --git a/starts/meaning-vm/level-2/common.hpp b/starts/meaning-vm/level-2/common.hpp
index 6f70f09..aac072e 100644
--- a/starts/meaning-vm/level-2/common.hpp
+++ b/starts/meaning-vm/level-2/common.hpp
@@ -1 +1,10 @@
#pragma once
+
+namespace intellect {
+namespace level2 {
+
+template <typename T> struct baseref;
+struct ref;
+
+}
+}
diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp
index 4ee02a4..c25ead2 100644
--- a/starts/meaning-vm/level-2/funcs.cpp
+++ b/starts/meaning-vm/level-2/funcs.cpp
@@ -1,13 +1,16 @@
-#include "funcs.hp"
+#include "funcs.hpp"
#include "../level-1/sugar.hpp"
+#include "ref.hpp"
+
namespace intellect {
+using namespace level1;
namespace level2 {
-level2::ref context()
+ref context()
{
- static thread_local level1::ref ctx = level1::a("context");
+ static thread_local auto ctx = a("context");
return ctx;
}
diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp
index 3e94c97..6734eae 100644
--- a/starts/meaning-vm/level-2/sugar.hpp
+++ b/starts/meaning-vm/level-2/sugar.hpp
@@ -11,12 +11,12 @@
#undef self
#define ahabit(name, ...) \
a(habit, name); \
- (name).fun((std::function<ref(ref)>) \
- [=](ref ctx) -> ref\
+ (name).fun((std::function<void()>) \
+ [=]() -> ref\
{ \
habitdelay; \
- ref self = name; \
- (void)self; \
+ ref self = name; (void)self; \
+ ref ctx = intellect::level2::ref::context(); (void) ctx;\
__VA_ARGS__ \
return intellect::level1::concepts::nothing; \
});