From 680af2ca0b1ced4c82bbce620d6c4fc97dae88d0 Mon Sep 17 00:00:00 2001 From: olpc user Date: Thu, 5 Dec 2019 04:12:23 -0800 Subject: add function syntaxes --- starts/meaning-vm/level-1/baseref.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (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 index e8bdcb9..63045fa 100644 --- a/starts/meaning-vm/level-1/baseref.hpp +++ b/starts/meaning-vm/level-1/baseref.hpp @@ -5,6 +5,8 @@ #include "../level-0/ref.hpp" +#include + namespace intellect { namespace level1 { @@ -27,7 +29,38 @@ struct baseref : public level0::baseref ref operator-(ref other) { return hyphenate(self.ptr(), other.ptr()); } + template + void vset(ref const & type, T const & v) { self.set(type, level1::alloc(v)); } + + template + std::function & fun() { return self.template val>(); } + template + void fun(std::function const & f) { val(f); } + template + void fun(std::function const & f) { 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 skipmarkertype, ref skipmarkertarget); + +private: + template + std::function voidtoret(std::function f) + { + return [f](Refs... args) -> ref + { + std::initializer_list({&args...}); + f(args...); + return concepts::nothing; + }; + } }; } -- cgit v1.2.3