| … | … | @@ -120,7 +120,7 @@ AtomSpace::~AtomSpace() |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /// Set up a vector of pointers to the parent AtomSpaces. |
| 123 | void AtomSpace::do_install(void) | |
| 123 | void AtomSpace::install(void) | |
| 124 | 124 | { |
| 125 | 125 | if (0 == _environ.size()) |
| 126 | 126 | { |
| … | … | @@ -144,7 +144,7 @@ void AtomSpace::do_install(void) |
| 144 | 144 | { |
| 145 | 145 | Handle bh(base); |
| 146 | 146 | if (nullptr == base->getAtomSpace()) |
| 147 | bh = this->add_atom(base); | |
| 147 | bh = _atom_space->add_atom(base); | |
| 148 | 148 | |
| 149 | 149 | ValuePtr vp(bh->execute(this)); |
| 150 | 150 | AtomSpacePtr as(AtomSpaceCast(vp)); |
| … | … | @@ -162,12 +162,10 @@ void AtomSpace::do_install(void) |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | // XXX FIXME. I think this is installing into the wrong AtomSpace. | |
| 166 | // Maybe. I'm confused. But no unit test seems to fail as a result | |
| 167 | // of this, so I dunno. Go figure. | |
| 168 | setAtomSpace(this); | |
| 165 | // XXX FIXME: Frame::install loops over _outgoing but maybe it | |
| 166 | // should be looping over _environ, instead? Maybe we should copy | |
| 167 | // _environ to _outgoing? | |
| 169 | 168 | Frame::install(); |
| 170 | setAtomSpace(nullptr); | |
| 171 | 169 | } |
| 172 | 170 | |
| 173 | 171 | // ==================================================================== |
| … | … | @@ -80,7 +80,7 @@ class AtomSpace : public Frame |
| 80 | 80 | // result of this execution is stored in _environ; the original |
| 81 | 81 | // Atoms are in _outgoing. |
| 82 | 82 | std::vector<AtomSpacePtr> _environ; |
| 83 | void do_install(); | |
| 83 | virtual void install(void) override; | |
| 84 | 84 | |
| 85 | 85 | void init(); |
| 86 | 86 | void clear_all_atoms(); |
| … | … | @@ -539,10 +539,6 @@ template< class... Args > |
| 539 | 539 | AtomSpacePtr createAtomSpace( Args&&... args ) |
| 540 | 540 | { |
| 541 | 541 | AtomSpacePtr asp(std::make_shared<AtomSpace>(std::forward<Args>(args) ...)); |
| 542 | // Unfortunately, Frame::install() cannot be called in the ctor | |
| 543 | // because shared_from_this() cannot be called in the ctor. | |
| 544 | // So we do this after the ctor has finished. | |
| 545 | asp->do_install(); | |
| 546 | 542 | return asp; |
| 547 | 543 | } |
| 548 | 544 |
| … | … | @@ -76,28 +76,26 @@ SCM SchemeSmob::ss_new_as (SCM space_list) |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Create new AtomSpace with the indicated parents. |
| 79 | // This can throw an exception if the parents don't have | |
| 80 | // a valid form. Catch that exception and rethrow. | |
| 81 | AtomSpacePtr asp; | |
| 79 | AtomSpacePtr asp(createAtomSpace(spaces)); | |
| 80 | ||
| 81 | // If a name was provided, set that name. | |
| 82 | if (0 < name.size()) | |
| 83 | asp->set_name(name); | |
| 84 | ||
| 85 | Handle hasp(HandleCast(asp)); | |
| 82 | 86 | try |
| 83 | 87 | { |
| 84 | asp = createAtomSpace(spaces); | |
| 88 | // Insert it into the current AtomSpace | |
| 89 | // This can throw an exception if the parents don't have | |
| 90 | // a valid form. Catch that exception and rethrow. | |
| 91 | const AtomSpacePtr& env = ss_get_env_as("cog-new-atomspace"); | |
| 92 | if (env) hasp = env->add_atom(hasp); | |
| 85 | 93 | } |
| 86 | 94 | catch (const std::exception& ex) |
| 87 | 95 | { |
| 88 | 96 | throw_exception(ex, "cog-new-atomspace", space_list); |
| 89 | 97 | } |
| 90 | 98 | |
| 91 | // If a name was provided, set that name. | |
| 92 | if (0 < name.size()) | |
| 93 | asp->set_name(name); | |
| 94 | ||
| 95 | Handle hasp(HandleCast(asp)); | |
| 96 | ||
| 97 | // Insert it nto the current AtomSpace | |
| 98 | const AtomSpacePtr& env = ss_get_env_as("cog-new-atomspace"); | |
| 99 | if (env) hasp = env->add_atom(hasp); | |
| 100 | ||
| 101 | 99 | return protom_to_scm(hasp); |
| 102 | 100 | } |
| 103 | 101 |