OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace commits / c2bda74

Refactor value fetching into two steps
c2bda74da6186876666d341b2f96e5588a0f549a
by Linas Vepštas <linasvepstas@gmail.com> · 2026-01-22T20:12:33.000Z

Changed files (2) +12 -5

opencog/atoms/flow/ValueOfLink.cc +11 -5
……@@ -64,8 +64,8 @@ void ValueOfLink::init(void)
6464
6565// ---------------------------------------------------------------
6666
67/// When executed, this will return the value at the indicated key.
68ValuePtr ValueOfLink::do_execute(AtomSpace* as, bool silent)
67/// Return the literal value at the indicated key.
68ValuePtr ValueOfLink::get_literal(AtomSpace* as, bool silent)
6969{
7070 // We cannot know the Value of the Atom unless we are
7171 // working with the unique version that sits in the
……@@ -85,6 +85,7 @@ ValuePtr ValueOfLink::do_execute(AtomSpace* as, bool silent)
8585 Handle ah(as->add_atom(_outgoing[0]));
8686 Handle ak(as->add_atom(_outgoing[1]));
8787
88 // Get the concrete Atom
8889 if (ah->is_executable())
8990 {
9091 ValuePtr pap(ah->execute(as, silent));
……@@ -102,7 +103,13 @@ ValuePtr ValueOfLink::do_execute(AtomSpace* as, bool silent)
102103 ak = as->add_atom(HandleCast(pap));
103104 }
104105
105 ValuePtr pap = ah->getValue(ak);
106 return ah->getValue(ak);
107}
108
109/// When executed, this will return the value at the indicated key.
110ValuePtr ValueOfLink::do_execute(AtomSpace* as, bool silent)
111{
112 ValuePtr pap(get_literal(as, silent));
106113 if (pap)
107114 {
108115 if (not pap->is_atom())
……@@ -149,8 +156,7 @@ ValuePtr ValueOfLink::do_execute(AtomSpace* as, bool silent)
149156 throw SilentException();
150157
151158 throw InvalidParamException(TRACE_INFO,
152 "No value at key %s on atom %s",
153 ak->to_string().c_str(), ah->to_string().c_str());
159 "No value for %s", to_string().c_str());
154160
155161 return createVoidValue();
156162}
opencog/atoms/flow/ValueOfLink.h +1 -0
……@@ -53,6 +53,7 @@ private:
5353 void init(void);
5454
5555protected:
56 ValuePtr get_literal(AtomSpace*, bool);
5657 ValuePtr do_execute(AtomSpace*, bool);
5758
5859public: