diff options
author | John Wiegley <johnw@newartisans.com> | 2009-11-25 00:05:22 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-11-25 00:05:22 -0500 |
commit | 98ea23cd59cf959f3561632cc38043ab2d89f164 (patch) | |
tree | 18157b0191c83dcec9042c5ebfb4a70e48893169 /src/scope.cc | |
parent | f01fa1a5131c287a4efe2708ffe3c9bc57b79468 (diff) | |
parent | f81b563339598a6075fa5c9ec6cb61bbffc9ba38 (diff) | |
download | fork-ledger-98ea23cd59cf959f3561632cc38043ab2d89f164.tar.gz fork-ledger-98ea23cd59cf959f3561632cc38043ab2d89f164.tar.bz2 fork-ledger-98ea23cd59cf959f3561632cc38043ab2d89f164.zip |
Merge branch 'next'
Diffstat (limited to 'src/scope.cc')
-rw-r--r-- | src/scope.cc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/scope.cc b/src/scope.cc index 99f6b669..64736ca3 100644 --- a/src/scope.cc +++ b/src/scope.cc @@ -42,15 +42,18 @@ void symbol_scope_t::define(const symbol_t::kind_t kind, { DEBUG("scope.symbols", "Defining '" << name << "' = " << def); + if (! symbols) + symbols = symbol_map(); + std::pair<symbol_map::iterator, bool> result - = symbols.insert(symbol_map::value_type(symbol_t(kind, name, def), def)); + = symbols->insert(symbol_map::value_type(symbol_t(kind, name, def), def)); if (! result.second) { - symbol_map::iterator i = symbols.find(symbol_t(kind, name)); - assert(i != symbols.end()); - symbols.erase(i); + symbol_map::iterator i = symbols->find(symbol_t(kind, name)); + assert(i != symbols->end()); + symbols->erase(i); - result = symbols.insert(symbol_map::value_type(symbol_t(kind, name, def), - def)); + result = symbols->insert(symbol_map::value_type(symbol_t(kind, name, def), + def)); if (! result.second) throw_(compile_error, _("Redefinition of '%1' in the same scope") << name); @@ -60,10 +63,11 @@ void symbol_scope_t::define(const symbol_t::kind_t kind, expr_t::ptr_op_t symbol_scope_t::lookup(const symbol_t::kind_t kind, const string& name) { - symbol_map::const_iterator i = symbols.find(symbol_t(kind, name)); - if (i != symbols.end()) - return (*i).second; - + if (symbols) { + symbol_map::const_iterator i = symbols->find(symbol_t(kind, name)); + if (i != symbols->end()) + return (*i).second; + } return child_scope_t::lookup(kind, name); } |