From c8bb547bea279af2bb48c13260f98aa8add07131 Mon Sep 17 00:00:00 2001 From: olpc user Date: Fri, 10 Jan 2020 14:55:19 -0800 Subject: move intellect-framework-from-internet into folder --- starts/meaning-vm/level-1/baseref.hpp | 67 ----------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 starts/meaning-vm/level-1/baseref.hpp (limited to 'starts/meaning-vm/level-1/baseref.hpp') diff --git a/starts/meaning-vm/level-1/baseref.hpp b/starts/meaning-vm/level-1/baseref.hpp deleted file mode 100644 index ac6ff9c..0000000 --- a/starts/meaning-vm/level-1/baseref.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#pragma once - -#include "common.hpp" -#include "funcs.hpp" - -#include "../level-0/ref.hpp" - -#include - -namespace intellect { -namespace level1 { - -template -struct baseref : public level0::baseref -{ - baseref(concept * p) : level0::baseref(p) { } - baseref(level0::ref const & other) : baseref(other.ptr()) { } - baseref(std::string const & name, concept* allocator = nullptr) : baseref(getnamed(name, allocator)) { } - baseref(const char *name, concept* allocator = nullptr) : baseref(std::string(name), allocator) { } - baseref(bool b) : baseref(b ? "true" : "false") { } - baseref() : baseref("nothing") { } - - bool isa(ref group) const { return level1::isa(self, group); } - bool isan(ref group) const { return isa(group); } - - std::string name() const { return getname(self); } - explicit operator char const *() const { return getname(self)->data.c_str(); } - - ref operator-(ref other) const { return hyphenate(self, other); } - ref operator[](ref subref) const { return self.get(subref); } - - template - void vset(ref const & type, T const & v) { self.set(type, level1::alloc(level0::concepts::allocations(), v)); } - - template - std::function & fun() { return self.template val>(); } - template - void fun(std::function const & f) { self.val(f); } - template - void fun(std::function const & f) { self.val(voidtoret(f)); } - template - void fget(ref const & type) { return self.template vget>(type); } - template - void fset(ref const & type, std::function f) { self.vset(type, f); } - template - void fset(ref const & type, std::function f) { fset(type, voidtoret(f)); } - - template - ref operator()(Ref... args) { return self.template fun()(args...); } - - std::string dump(ref set) { return level1::dump(self, set); }; - -private: - template - std::function voidtoret(std::function f) - { - return [f](Refs... args) -> ref - { - std::initializer_list({&args...}); - f(args...); - return "nothing"; - }; - } -}; - -} -} -- cgit v1.2.3