summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-1/funcs.cpp
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 20:38:22 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-12-09 20:38:22 -0800
commit1b8c47a8b14f784f6605eee3a73713dbce6ca572 (patch)
tree9b7034b5e148ee8b0f9fbe0c6e89d7f9a656a27e /starts/meaning-vm/level-1/funcs.cpp
parent3e3aeddec840fed915b0fa748dcd2f56d6f682ef (diff)
downloadstandingwithresilience-1b8c47a8b14f784f6605eee3a73713dbce6ca572.tar.gz
standingwithresilience-1b8c47a8b14f784f6605eee3a73713dbce6ca572.zip
changed level-0 allocation to use groups
Diffstat (limited to 'starts/meaning-vm/level-1/funcs.cpp')
-rw-r--r--starts/meaning-vm/level-1/funcs.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/starts/meaning-vm/level-1/funcs.cpp b/starts/meaning-vm/level-1/funcs.cpp
index c1cf21a..cfb44b7 100644
--- a/starts/meaning-vm/level-1/funcs.cpp
+++ b/starts/meaning-vm/level-1/funcs.cpp
@@ -19,9 +19,9 @@ static auto & namestruct()
std::unordered_map<std::string,ref,std::hash<std::string>,std::equal_to<std::string>> conceptsByName;
ref nameref;
name_t()
- : nameref(level0::alloc())
+ : nameref(level0::alloc(level0::concepts::allocations()))
{
- level0::ref namestr = alloc((std::string)("name"));
+ level0::ref namestr = level0::alloc(nameref.ptr(), (std::string)("name"));
nameref.set(nameref, namestr);
conceptsByName.emplace(namestr.val<std::string>(), nameref);
}
@@ -32,9 +32,9 @@ static auto & namestruct()
void givename(concept* con, std::string const & name)
{
auto & ns = namestruct();
- level0::ref namestr = level0::alloc(name);
+ level0::ref namestr = level0::alloc(con, name);
ns.conceptsByName.emplace(namestr.val<std::string>(), con);
- con.set(ns.nameref, namestr);
+ con->set(ns.nameref, namestr);
}
concept* getnamed(std::string const & name)
@@ -44,10 +44,8 @@ concept* getnamed(std::string const & name)
if (res != ns.conceptsByName.end()) {
return res->second;
} else {
- level1::ref con = level0::alloc();
- level0::ref namestr = level0::alloc(name);
- ns.conceptsByName.emplace(namestr.val<std::string>(), con);
- con.set(ns.nameref, namestr);
+ level1::ref con = level0::alloc(level0::concepts::allocations());
+ givename(con, name);
return con.ptr();
}
}
@@ -71,10 +69,9 @@ bool isa(concept* member, concept* group)
return false;
}
-concept* alloc(std::any val)
+concept* alloc(concept* allocator, std::any val)
{
-
- ref ret = level0::alloc(val);
+ ref ret = level0::alloc(allocator, val);
std::stringstream ss;
ss << val.type().name() << "(";
if (false);
@@ -88,7 +85,7 @@ concept* alloc(std::any val)
#undef t
else { ss << "?"; }
ss << ")";
- ret.link(concepts::name, level0::alloc(ss.str()));
+ ret.link(concepts::name, level0::alloc(ret, ss.str()));
return ret;
}
@@ -104,6 +101,7 @@ std::string dump(concept* what, concept* skipmarkertype, concept* skipmarkertarg
}
std::string ret;
for (auto & link : ref(what).links()) {
+ if (link.first.linked(level0::concepts::allocator(), level0::concepts::level0allocations())) { continue; }
if (link.first == concepts::name) { continue; }
if (ret.size() == 0) {
ret = ref(what).name() + ":\n";
@@ -112,6 +110,7 @@ std::string dump(concept* what, concept* skipmarkertype, concept* skipmarkertarg
}
what->link(skipmarkertype, skipmarkertarget);
for (auto & link : ref(what).links()) {
+ if (link.first.linked(level0::concepts::allocator(), level0::concepts::level0allocations())) { continue; }
if (link.first.ptr() == skipmarkertype && link.second.ptr() == skipmarkertarget) {
continue;
}