From 9a14918abec434d8463e07635daef380ad630649 Mon Sep 17 00:00:00 2001 From: olpc user Date: Sun, 24 Nov 2019 13:22:55 -0800 Subject: breaking into levels --- starts/meaning-vm/level-0/vref.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 starts/meaning-vm/level-0/vref.hpp (limited to 'starts/meaning-vm/level-0/vref.hpp') diff --git a/starts/meaning-vm/level-0/vref.hpp b/starts/meaning-vm/level-0/vref.hpp new file mode 100644 index 0000000..7fe2045 --- /dev/null +++ b/starts/meaning-vm/level-0/vref.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "common.hpp" +#include "memorystore.hpp" +#include "ref.hpp" +#include "value.hpp" + +namespace intellect { +namespace level0 { + +template +struct vref +{ + vref(value *p) : ptr(p) { } + value* operator->() { return ptr; } + operator T const &() const { return *ptr; } + + vref(T const & val) : ptr(alloc(new value(val))) { } + + vref(ref const & other) : ptr(static_cast*>(other.ptr)) { } + operator ref() { return ptr; } + + // for use by containers + bool operator<(vref const & other) const { return self.ptr < other.ptr; } + + value * const ptr; +}; + + +} +} -- cgit v1.2.3