summaryrefslogtreecommitdiff
path: root/intellect-framework-from-internet/starts/meaning-vm/level1.cpp
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2020-01-10 14:56:27 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2020-01-10 14:56:27 -0800
commit26c980d302adce8e3d802cb8db8ab1c69d58ce1a (patch)
treee296225f17370c9e472660396b3a51539f76ff28 /intellect-framework-from-internet/starts/meaning-vm/level1.cpp
parent2e01fed206e46a669ba56f57b4b943cfe661a0f1 (diff)
parentc8bb547bea279af2bb48c13260f98aa8add07131 (diff)
downloadstandingwithresilience-26c980d302adce8e3d802cb8db8ab1c69d58ce1a.tar.gz
standingwithresilience-26c980d302adce8e3d802cb8db8ab1c69d58ce1a.zip
Merge branch 'intellect-framework-from-internet'
Diffstat (limited to 'intellect-framework-from-internet/starts/meaning-vm/level1.cpp')
-rw-r--r--intellect-framework-from-internet/starts/meaning-vm/level1.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/intellect-framework-from-internet/starts/meaning-vm/level1.cpp b/intellect-framework-from-internet/starts/meaning-vm/level1.cpp
new file mode 100644
index 0000000..a2046d2
--- /dev/null
+++ b/intellect-framework-from-internet/starts/meaning-vm/level1.cpp
@@ -0,0 +1,86 @@
+#include "level-1/level-1.hpp"
+
+#include <iostream>
+
+using namespace intellect::level1;
+using namespace intellect::level1::concepts;
+
+int main()
+{
+ std::cout << intellect::level0::allocated() << " allocated" << std::endl;
+
+ ///*
+
+ decls(make, linked, habit);
+ std::cout << intellect::level0::allocated() << " allocated" << std::endl;
+ decls(needs, assumes, makes);
+ decls(not, topic);
+ decls(A, B, C);
+ decls(source, type, target);
+ decls(structure, function, argument, position);
+ decls(variable, provide);
+ decls(act);
+
+ (make-linked).link(
+ is, habit,
+ needs, a(structure).link(
+ is, function-argument,
+ argument-position, ref(1),
+ a(variable, A), provide,
+ a(variable, B), provide,
+ a(variable, C), provide
+ )
+ );
+ movetoname(a(link), A-B-C-linked).link(
+ link-source, A,
+ link-type, B,
+ link-target, C
+ );
+ a(not, not-A-B-C-linked).set(topic, A-B-C-linked);
+ (make-linked).link(
+ assumes, not-A-B-C-linked,
+ makes, A-B-C-linked
+ );
+ (make-linked).fset(
+ act,
+ (std::function<void(ref)>)[&](ref args)
+ {
+ ref source = args[A];
+ ref type = args[B];
+ ref target = args[C];
+ std::cout << "Linking " << source.name() << " by " << type.name() << " to " << target.name() << std::endl;
+ source.link(type, target);
+ }
+ );
+
+ std::cout << (make-linked).dump("dumped") << std::endl;
+
+ decls(apple, fruit);
+ (make-linked)[act]
+ (a(function-argument)
+ .link(
+ A, apple,
+ B, is,
+ C, fruit
+ ));
+
+ std::cout << apple.dump("dumped") << std::endl;
+
+ std::cout << intellect::level0::allocated() << " allocated" << std::endl;
+ while (true) {
+ try {
+ intellect::level0::dealloc(intellect::level0::concepts::allocations(), intellect::level0::concepts::level0allocations());
+ break;
+ } catch (intellect::level0::still_referenced_by &e) {
+ if (e.topic->linked(intellect::level0::concepts::allocates(), e.referrer)) {
+ intellect::level0::realloc(e.referrer, intellect::level0::concepts::allocations());
+ } else {
+ std::cout << "In deallocation, " << ref(e.topic).name() << " still referenced by " << ref(e.referrer).name() << std::endl;
+ throw;
+ }
+ }
+ }
+ std::cout << intellect::level0::allocated() << " allocated" << std::endl;
+
+ return 0;
+}