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

#include <ostream>

using namespace intellect::level0;
using namespace concepts;

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()) {
		if (link.first.linked(allocator(), level0allocations())) { continue; }
		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.linked(allocator(), level0allocations())) { continue; }
		if (link.first == skipmarkertype && link.second == skipmarkertarget) {
			continue;
		}
		ret += link.second.dump(skipmarkertype, skipmarkertarget);
	}
	return ret;
}