From fed2ac694bd028d119581ea05a3376e791aee97d Mon Sep 17 00:00:00 2001 From: olpc user Date: Sat, 23 Nov 2019 09:11:28 -0800 Subject: more syntax sugar, building meaning --- starts/meaning-vm/memorystore.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'starts/meaning-vm/memorystore.cpp') diff --git a/starts/meaning-vm/memorystore.cpp b/starts/meaning-vm/memorystore.cpp index c759051..19e40db 100644 --- a/starts/meaning-vm/memorystore.cpp +++ b/starts/meaning-vm/memorystore.cpp @@ -16,26 +16,27 @@ ref alloc(concept * moved) { return r; } -bool referenced(ref r) { +concept* referenced(ref r) { for (ref r2 : concepts()) { if (r2 == r) { continue; } for (auto & l : r2->links) { if (ref(l.first) == r) { - return true; + return r2.ptr; } if (ref(l.second) == r) { - return true; + return r2.ptr; } } } - return false; + return 0; } void dealloc(ref r) { - if (referenced(r)) { - throw std::logic_error("concept is referenced"); + concept * referenced = ::referenced(r); + if (referenced) { + throw std::logic_error("concept '" + r.name() + "' is referenced by '" + ref(referenced).name() + '"'); } for ( auto it = concepts().begin(); -- cgit v1.2.3