| … | … | @@ -46,6 +46,19 @@ IncrementValueLink::IncrementValueLink(const HandleSeq&& oset, Type t) |
| 46 | 46 | |
| 47 | 47 | // --------------------------------------------------------------- |
| 48 | 48 | |
| 49 | // IncrementValue must work in the local AtomSpace. This includes |
| 50 | // the evaluation of keys, as needed. |
| 51 | Handle IncrementValueLink::localize(AtomSpace* as, bool silent, const Handle& h) const |
| 52 | { |
| 53 | if (not h->is_executable()) |
| 54 | return as->add_atom(h); |
| 55 | |
| 56 | ValuePtr pap(h->execute(as, silent)); |
| 57 | if (pap and pap->is_atom()) |
| 58 | return as->add_atom(HandleCast(pap)); |
| 59 | return h; |
| 60 | } |
| 61 | |
| 49 | 62 | /// When executed, this will execute the third argument to obtain |
| 50 | 63 | /// a FloatValue or NumberNode, and then use those numbers to atomically |
| 51 | 64 | /// increment the FloatValue at the indicated key on the indicated |
| … | … | @@ -67,8 +80,8 @@ ValuePtr IncrementValueLink::execute(AtomSpace* as, bool silent) |
| 67 | 80 | "Expecting AtomSpace, got null pointer for %s\n", |
| 68 | 81 | to_string().c_str()); |
| 69 | 82 | |
| 70 | | Handle ah(as->add_atom(_outgoing[0])); |
| 71 | | Handle ak(as->add_atom(_outgoing[1])); |
| 83 | Handle ah(localize(as, silent, _outgoing[0])); |
| 84 | Handle ak(localize(as, silent, _outgoing[1])); |
| 72 | 85 | |
| 73 | 86 | // Copy-on-write semantics means as->increment_count() might return |
| 74 | 87 | // a different Atom than the current ah. |