summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-0/ref.cpp
blob: f4684568a58c139e1ecbe326c419837fccbaeb49 (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)
{
	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 == skipmarkertarget) {
			continue;
		}
		ret += link.second.dump(skipmarkertype, skipmarkertarget);
	}
	return ret;
}