summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-0/ref.cpp
blob: d4758bde8d4c5e206f8eeeb5e126cfbcc84ef158 (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
#include "ref.hpp"
#include "concept.hpp"
#include "errors.hpp"

#include <ostream>

using namespace intellect::level0;

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;
}