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

#include <iomanip>
#include <ostream>
#include <sstream>

using namespace intellect::level0;
using namespace concepts;

std::string ref::dump(ref skipmarkertype, ref skipmarkertarget)
{
	if (self.linked(skipmarkertype, skipmarkertarget)) {
		return {};
	}
	std::stringstream ss;
	ss << std::hex << (size_t)ptr() << ":" << std::endl;
	for (auto & link : self.links()) {
		if (link.first.linked(allocator(), level0allocations())) { continue; }
		ss << "  " << (size_t)link.first.ptr() << ": " << (size_t)link.second.ptr() << std::endl;
	}
	self.link(skipmarkertype, skipmarkertarget);
	for (auto & link : self.links()) {
		if (link.first.linked(allocator(), level0allocations())) { continue; }
		if (link.first == skipmarkertype && link.second == skipmarkertarget) {
			continue;
		}
		ss << link.second.dump(skipmarkertype, skipmarkertarget);
	}
	return ss.str();
}