summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-0/ref.cpp
blob: 7e1052850e49443c9537581afe85271095012da9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "ref.hpp"
#include "concept.hpp"
#include "errors.hpp"

#include <ostream>

using namespace intellect::level0;

ref::ref(concept *p)
: ptr(p)
{
	if (p == 0) {
		throw null_reference();
	}
}

std::string ref::dump(ref skipmarkertype, ref skipmarkertarget) const
{
	if (self->linked(skipmarkertype, skipmarkertarget)) {
		return {};
	}
	std::string ret = std::to_string((unsigned long)ptr) + ":\n";
	for (auto & link : self->links) {
		ret += "  " + std::to_string((unsigned long)link.first.ptr) + ": " + std::to_string((unsigned long)link.second.ptr) + "\n"; 
	}
	self->link(skipmarkertype, skipmarkertarget);
	for (auto & link : self->links) {
		if (link.first == skipmarkertype && link.second == skipmarkertype) {
			continue;
		}
		ret += link.second.dump(skipmarkertype, skipmarkertarget);
	}
	return ret;
}