diff --git a/vhdlpp/architec.cc b/vhdlpp/architec.cc index acf9eafad..f223e8b90 100644 --- a/vhdlpp/architec.cc +++ b/vhdlpp/architec.cc @@ -26,7 +26,7 @@ using namespace std; -Architecture::Architecture(perm_string name, const ScopeBase&ref, +Architecture::Architecture(perm_string name, const ActiveScope&ref, list&s) : Scope(ref), name_(name) { diff --git a/vhdlpp/architec.h b/vhdlpp/architec.h index 33224f485..594f350eb 100644 --- a/vhdlpp/architec.h +++ b/vhdlpp/architec.h @@ -63,7 +63,7 @@ class Architecture : public Scope, public LineInfo { public: // Create an architecture from its name and its statements. // NOTE: The statement list passed in is emptied. - Architecture(perm_string name, const ScopeBase&ref, + Architecture(perm_string name, const ActiveScope&ref, std::list&s); ~Architecture(); diff --git a/vhdlpp/architec_elaborate.cc b/vhdlpp/architec_elaborate.cc index 0e85dd05d..e7308f96e 100644 --- a/vhdlpp/architec_elaborate.cc +++ b/vhdlpp/architec_elaborate.cc @@ -32,12 +32,12 @@ int Architecture::elaborate(Entity*entity) // from the constant declaration itself. Elaborate the value // expression with the declared type. - for (map::iterator cur = old_constants_.begin() - ; cur != old_constants_.end() ; ++cur) { + for (map::iterator cur = use_constants_.begin() + ; cur != use_constants_.end() ; ++cur) { cur->second->val->elaborate_expr(entity, this, cur->second->typ); } - for (map::iterator cur = new_constants_.begin() - ; cur != new_constants_.end() ; ++cur) { + for (map::iterator cur = cur_constants_.begin() + ; cur != cur_constants_.end() ; ++cur) { cur->second->val->elaborate_expr(entity, this, cur->second->typ); } diff --git a/vhdlpp/architec_emit.cc b/vhdlpp/architec_emit.cc index 0f517294b..b53f94acf 100644 --- a/vhdlpp/architec_emit.cc +++ b/vhdlpp/architec_emit.cc @@ -69,8 +69,8 @@ int Architecture::emit(ostream&out, Entity*entity) // of the full definition. typedef_context_t typedef_ctx; - for (map::iterator cur = old_types_.begin() - ; cur != old_types_.end() ; ++cur) { + for (map::iterator cur = cur_types_.begin() + ; cur != cur_types_.end() ; ++cur) { const VTypeDef*def = dynamic_cast(cur->second); if (def == 0) @@ -79,15 +79,15 @@ int Architecture::emit(ostream&out, Entity*entity) errors += def->emit_typedef(out, typedef_ctx); } - for (map::iterator cur = old_constants_.begin() - ; cur != old_constants_.end() ; ++cur) { + for (map::iterator cur = use_constants_.begin() + ; cur != use_constants_.end() ; ++cur) { out << "localparam " << cur->first << " = "; errors += cur->second->val->emit(out, entity, this); out << ";" << endl; } - for (map::iterator cur = new_constants_.begin() - ; cur != new_constants_.end() ; ++cur) { + for (map::iterator cur = cur_constants_.begin() + ; cur != cur_constants_.end() ; ++cur) { out << "localparam " << cur->first << " = "; errors += cur->second->val->emit(out, entity, this); diff --git a/vhdlpp/debug.cc b/vhdlpp/debug.cc index c85b868c3..0a5dfc6c8 100644 --- a/vhdlpp/debug.cc +++ b/vhdlpp/debug.cc @@ -101,31 +101,36 @@ void ComponentBase::dump_ports(ostream&out, int indent) const void Scope::dump_scope(ostream&out) const { // Dump types - for (map::const_iterator cur = old_types_.begin() - ; cur != old_types_.end() ; ++cur) { + out << " -- imported types" << endl; + for (map::const_iterator cur = use_types_.begin() + ; cur != use_types_.end() ; ++cur) { out << " " << cur->first << ": "; cur->second->show(out); out << endl; } - for (map::const_iterator cur = new_types_.begin() - ; cur != new_types_.end() ; ++cur) { + out << " -- Types from this scope" << endl; + for (map::const_iterator cur = cur_types_.begin() + ; cur != cur_types_.end() ; ++cur) { out << " " << cur->first << ": "; cur->second->show(out); out << endl; } // Dump constants - for (map::const_iterator cur = old_constants_.begin() - ; cur != old_constants_.end() ; ++cur) { + out << " -- imported constants" << endl; + for (map::const_iterator cur = use_constants_.begin() + ; cur != use_constants_.end() ; ++cur) { out << " constant " << cur->first << " = "; out << endl; } - for (map::const_iterator cur = new_constants_.begin() - ; cur != new_constants_.end() ; ++cur) { + out << " -- Constants from this scope" << endl; + for (map::const_iterator cur = cur_constants_.begin() + ; cur != cur_constants_.end() ; ++cur) { out << " constant " << cur->first << " = "; out << endl; } // Dump signal declarations + out << " -- Signals" << endl; for (map::const_iterator cur = old_signals_.begin() ; cur != old_signals_.end() ; ++cur) { if (cur->second) @@ -141,6 +146,7 @@ void Scope::dump_scope(ostream&out) const out << " signal " << cur->first.str() << ": ???" << endl; } // Dump subprograms + out << " -- Subprograms" << endl; for (map::const_iterator cur = old_subprograms_.begin() ; cur != old_subprograms_.end() ; ++cur) { out << " subprogram " << cur->first << " is" << endl; @@ -154,6 +160,7 @@ void Scope::dump_scope(ostream&out) const out << " end subprogram " << cur->first << endl; } // Dump component declarations + out << " -- Components" << endl; for (map::const_iterator cur = old_components_.begin() ; cur != old_components_.end() ; ++cur) { out << " component " << cur->first << " is" << endl; diff --git a/vhdlpp/expression.h b/vhdlpp/expression.h index 0271abe37..6d24335f0 100644 --- a/vhdlpp/expression.h +++ b/vhdlpp/expression.h @@ -90,6 +90,10 @@ class Expression : public LineInfo { // class fills in the details of what exactly happened. virtual int emit(ostream&out, Entity*ent, Architecture*arc) =0; + // The emit_package virtual message is similar, but is called + // in a package context and to emit SV packages. + virtual int emit_package(std::ostream&out); + // The evaluate virtual method tries to evaluate expressions // to constant literal values. Return true and set the val // argument if the evaluation works, or return false if it @@ -478,6 +482,7 @@ class ExpInteger : public Expression { int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype); void write_to_stream(std::ostream&fd); int emit(ostream&out, Entity*ent, Architecture*arc); + int emit_package(std::ostream&out); bool is_primary(void) const; bool evaluate(ScopeBase*scope, int64_t&val) const; void dump(ostream&out, int indent = 0) const; diff --git a/vhdlpp/expression_emit.cc b/vhdlpp/expression_emit.cc index c0d22210b..2c1b43114 100644 --- a/vhdlpp/expression_emit.cc +++ b/vhdlpp/expression_emit.cc @@ -37,6 +37,14 @@ int Expression::emit(ostream&out, Entity*, Architecture*) return 1; } +int Expression::emit_package(ostream&out) +{ + out << " /* " << get_fileline() << ": internal error: " + << "I don't know how to emit_package this expression! " + << "type=" << typeid(*this).name() << " */ "; + return 1; +} + bool Expression::is_primary(void) const { return false; @@ -565,6 +573,12 @@ int ExpInteger::emit(ostream&out, Entity*, Architecture*) return 0; } +int ExpInteger::emit_package(ostream&out) +{ + out << value_; + return 0; +} + bool ExpInteger::is_primary(void) const { return true; diff --git a/vhdlpp/library.cc b/vhdlpp/library.cc index d95a7b47b..01b5e0ee4 100644 --- a/vhdlpp/library.cc +++ b/vhdlpp/library.cc @@ -1,5 +1,6 @@ /* - * Copyright (c) 2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com) + * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -256,7 +257,7 @@ static void import_ieee_use_std_logic_1164(ActiveScope*res, perm_string name) if (all_flag || name == "std_logic_vector") { vector dims (1); - res->bind_name(perm_string::literal("std_logic_vector"), + res->use_name(perm_string::literal("std_logic_vector"), new VTypeArray(primitive_STDLOGIC, dims, false)); } } @@ -271,12 +272,12 @@ static void import_ieee_use_numeric_bit(ActiveScope*res, perm_string name) if (all_flag || name == "signed") { vector dims (1); - res->bind_name(perm_string::literal("signed"), + res->use_name(perm_string::literal("signed"), new VTypeArray(primitive_STDLOGIC, dims, true)); } if (all_flag || name == "unsigned") { vector dims (1); - res->bind_name(perm_string::literal("unsigned"), + res->use_name(perm_string::literal("unsigned"), new VTypeArray(primitive_BIT, dims, false)); } } @@ -287,12 +288,12 @@ static void import_ieee_use_numeric_std(ActiveScope*res, perm_string name) if (all_flag || name == "signed") { vector dims (1); - res->bind_name(perm_string::literal("signed"), + res->use_name(perm_string::literal("signed"), new VTypeArray(primitive_STDLOGIC, dims, true)); } if (all_flag || name == "unsigned") { vector dims (1); - res->bind_name(perm_string::literal("unsigned"), + res->use_name(perm_string::literal("unsigned"), new VTypeArray(primitive_STDLOGIC, dims, false)); } } @@ -334,14 +335,14 @@ static const VTypeArray* primitive_STRING = new VTypeArray(primitive_CHARACTER, void generate_global_types(ActiveScope*res) { - res->bind_name(perm_string::literal("boolean"), primitive_BOOLEAN); - res->bind_name(perm_string::literal("bit"), primitive_BIT); - res->bind_name(perm_string::literal("integer"), primitive_INTEGER); - res->bind_name(perm_string::literal("std_logic"), primitive_STDLOGIC); - res->bind_name(perm_string::literal("character"), primitive_CHARACTER); - res->bind_name(perm_string::literal("bit_vector"),primitive_BOOL_VECTOR); - res->bind_name(perm_string::literal("string"), primitive_STRING); - res->bind_name(perm_string::literal("natural"), primitive_NATURAL); + res->use_name(perm_string::literal("boolean"), primitive_BOOLEAN); + res->use_name(perm_string::literal("bit"), primitive_BIT); + res->use_name(perm_string::literal("integer"), primitive_INTEGER); + res->use_name(perm_string::literal("std_logic"), primitive_STDLOGIC); + res->use_name(perm_string::literal("character"), primitive_CHARACTER); + res->use_name(perm_string::literal("bit_vector"),primitive_BOOL_VECTOR); + res->use_name(perm_string::literal("string"), primitive_STRING); + res->use_name(perm_string::literal("natural"), primitive_NATURAL); } bool is_global_type(perm_string name) diff --git a/vhdlpp/package.cc b/vhdlpp/package.cc index 6541b2be8..aea43c1bf 100644 --- a/vhdlpp/package.cc +++ b/vhdlpp/package.cc @@ -1,5 +1,6 @@ /* - * Copyright (c) 2011-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com) + * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -22,7 +23,7 @@ # include "parse_misc.h" # include "ivl_assert.h" -Package::Package(perm_string n, const ScopeBase&ref) +Package::Package(perm_string n, const ActiveScope&ref) : Scope(ref), name_(n) { } @@ -45,29 +46,30 @@ void Package::set_library(perm_string lname) */ void Package::write_to_stream(ostream&fd) const { + ivl_assert(*this, new_subprograms_.size() == 0); + fd << "package " << name_ << " is" << endl; // Start out pre-declaring all the type definitions so that // there is no confusion later in the package between types // and identifiers. - for (map::const_iterator cur = old_types_.begin() - ; cur != old_types_.end() ; ++cur) { + for (map::const_iterator cur = use_types_.begin() + ; cur != use_types_.end() ; ++cur) { + const VTypeDef*def = dynamic_cast (cur->second); + if (def == 0) + continue; + fd << "type " << cur->first << ";" << endl; + } + for (map::const_iterator cur = cur_types_.begin() + ; cur != cur_types_.end() ; ++cur) { const VTypeDef*def = dynamic_cast (cur->second); if (def == 0) continue; fd << "type " << cur->first << ";" << endl; } - for (map::const_iterator cur = new_types_.begin() - ; cur != new_types_.end() ; ++cur) { - const VTypeDef*def = dynamic_cast (cur->second); - if (def == 0) - continue; - fd << "type " << cur->first << ";" << endl; - } - - for (map::const_iterator cur = old_constants_.begin() - ; cur != old_constants_.end() ; ++ cur) { + for (map::const_iterator cur = cur_constants_.begin() + ; cur != cur_constants_.end() ; ++ cur) { fd << "constant " << cur->first << ": "; cur->second->typ->write_to_stream(fd); fd << " := "; @@ -75,17 +77,8 @@ void Package::write_to_stream(ostream&fd) const fd << ";" << endl; } - for (map::const_iterator cur = new_constants_.begin() - ; cur != new_constants_.end() ; ++ cur) { - fd << "constant " << cur->first << ": "; - cur->second->typ->write_to_stream(fd); - fd << " := "; - cur->second->val->write_to_stream(fd); - fd << ";" << endl; - } - - for (map::const_iterator cur = old_types_.begin() - ; cur != old_types_.end() ; ++cur) { + for (map::const_iterator cur = use_types_.begin() + ; cur != use_types_.end() ; ++cur) { // Do not include global types in types dump if (is_global_type(cur->first)) @@ -95,12 +88,12 @@ void Package::write_to_stream(ostream&fd) const fd << "type " << cur->first << " is "; cur->second->write_type_to_stream(fd); - fd << ";" << endl; + fd << "; -- imported" << endl; } - for (map::const_iterator cur = new_types_.begin() - ; cur != new_types_.end() ; ++cur) { + for (map::const_iterator cur = cur_types_.begin() + ; cur != cur_types_.end() ; ++cur) { - // Do not include primitive types in type dump + // Do not include global types in types dump if (is_global_type(cur->first)) continue; if (cur->first == "std_logic_vector") @@ -115,10 +108,6 @@ void Package::write_to_stream(ostream&fd) const ; cur != old_subprograms_.end() ; ++cur) { cur->second->write_to_stream(fd); } - for (map::const_iterator cur = new_subprograms_.begin() - ; cur != new_subprograms_.end() ; ++cur) { - cur->second->write_to_stream(fd); - } for (map::const_iterator cur = old_components_.begin() ; cur != old_components_.end() ; ++cur) { diff --git a/vhdlpp/package.h b/vhdlpp/package.h index bec82a606..484bea53b 100644 --- a/vhdlpp/package.h +++ b/vhdlpp/package.h @@ -2,6 +2,7 @@ #define __package_H /* * Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com) + * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -26,7 +27,7 @@ class Package : public Scope, public LineInfo { public: - Package(perm_string name, const ScopeBase&ref); + Package(perm_string name, const ActiveScope&ref); ~Package(); // The the library from which this package came. Having a diff --git a/vhdlpp/package_emit.cc b/vhdlpp/package_emit.cc index f0b2751b6..b4b0836a2 100644 --- a/vhdlpp/package_emit.cc +++ b/vhdlpp/package_emit.cc @@ -20,14 +20,17 @@ # include "package.h" # include +# include "ivl_assert.h" using namespace std; int Package::emit_package(ostream&fd) const { + ivl_assert(*this, new_subprograms_.empty()); + // Don't emit the package if there is nothing in it that SV // cares about. - if (new_types_.empty() && old_subprograms_.empty() && new_subprograms_.empty()) + if (cur_types_.empty() && cur_constants_.empty() && old_subprograms_.empty()) return 0; // If this package was imported from a library, then do not @@ -44,10 +47,24 @@ int Package::emit_package(ostream&fd) const // Only emit types that were defined within this package. Skip // the types that were imported from elsewhere. - for (map::const_iterator cur = new_types_.begin() - ; cur != new_types_.end() ; ++ cur) { + for (map::const_iterator cur = cur_types_.begin() + ; cur != cur_types_.end() ; ++ cur) { + fd << "typedef "; errors += cur->second->emit_def(fd); - fd << " " << cur->first << " ;" << endl; + fd << " \\" << cur->first << " ;" << endl; + } + + for (map::const_iterator cur = use_constants_.begin() + ; cur != use_constants_.end() ; ++cur) { + fd << "localparam \\" << cur->first << " = "; + errors += cur->second->val->emit_package(fd); + fd << ";" << endl; + } + for (map::const_iterator cur = cur_constants_.begin() + ; cur != cur_constants_.end() ; ++cur) { + fd << "localparam " << cur->first << " = "; + errors += cur->second->val->emit_package(fd); + fd << ";" << endl; } for (map::const_iterator cur = old_subprograms_.begin() @@ -55,11 +72,6 @@ int Package::emit_package(ostream&fd) const errors += cur->second->emit_package(fd); } - for (map::const_iterator cur = new_subprograms_.begin() - ; cur != new_subprograms_.end() ; ++ cur) { - errors += cur->second->emit_package(fd); - } - fd << "endpackage" << endl; return errors; diff --git a/vhdlpp/scope.cc b/vhdlpp/scope.cc index 7d5ed1c8b..33fdeb2f4 100644 --- a/vhdlpp/scope.cc +++ b/vhdlpp/scope.cc @@ -30,13 +30,11 @@ using namespace std; * "old_*_" variables. This clears up the "new_*_" variables to * accumulate new scope values. */ -ScopeBase::ScopeBase(const ScopeBase&ref) +ScopeBase::ScopeBase(const ActiveScope&ref) { - merge(ref.old_constants_.begin(), ref.old_constants_.end(), - ref.new_constants_.begin(), ref.new_constants_.end(), - insert_iterator >( - old_constants_, old_constants_.end()) - ); + use_constants_ = ref.use_constants_; + cur_constants_ = ref.cur_constants_; + merge(ref.old_signals_.begin(), ref.old_signals_.end(), ref.new_signals_.begin(), ref.new_signals_.end(), insert_iterator >( @@ -52,11 +50,8 @@ ScopeBase::ScopeBase(const ScopeBase&ref) insert_iterator >( old_components_, old_components_.end()) ); - merge(ref.old_types_.begin(), ref.old_types_.end(), - ref.new_types_.begin(), ref.new_types_.end(), - insert_iterator >( - old_types_, old_types_.end()) - ); + use_types_ = ref.use_types_; + cur_types_ = ref.cur_types_; merge(ref.old_subprograms_.begin(), ref.old_subprograms_.end(), ref.new_subprograms_.begin(), ref.new_subprograms_.end(), insert_iterator >( @@ -79,17 +74,17 @@ void ScopeBase::cleanup() */ delete_all(new_signals_); delete_all(new_components_); - delete_all(new_types_); - delete_all(new_constants_); + delete_all(cur_types_); + delete_all(cur_constants_); delete_all(new_subprograms_); } const VType*ScopeBase::find_type(perm_string by_name) { - map::const_iterator cur = new_types_.find(by_name); - if (cur == new_types_.end()) { - cur = old_types_.find(by_name); - if (cur == old_types_.end()) + map::const_iterator cur = cur_types_.find(by_name); + if (cur == cur_types_.end()) { + cur = use_types_.find(by_name); + if (cur == use_types_.end()) return 0; else return cur->second; @@ -99,10 +94,10 @@ const VType*ScopeBase::find_type(perm_string by_name) bool ScopeBase::find_constant(perm_string by_name, const VType*&typ, Expression*&exp) { - map::const_iterator cur = new_constants_.find(by_name); - if (cur == new_constants_.end()) { - cur = old_constants_.find(by_name); - if (cur == old_constants_.end()) + map::const_iterator cur = cur_constants_.find(by_name); + if (cur == cur_constants_.end()) { + cur = use_constants_.find(by_name); + if (cur == use_constants_.end()) return false; else { typ = cur->second->typ; @@ -144,6 +139,10 @@ Variable* ScopeBase::find_variable(perm_string by_name) const } } +/* + * This method is only used by the ActiveScope derived class to import + * definition from another scope. + */ void ScopeBase::do_use_from(const ScopeBase*that) { for (map::const_iterator cur = that->old_components_.begin() @@ -172,26 +171,16 @@ void ScopeBase::do_use_from(const ScopeBase*that) old_subprograms_[cur->first] = cur->second; } - for (map::const_iterator cur = that->old_types_.begin() - ; cur != that->old_types_.end() ; ++ cur) { + for (map::const_iterator cur = that->cur_types_.begin() + ; cur != that->cur_types_.end() ; ++ cur) { if (cur->second == 0) continue; - old_types_[cur->first] = cur->second; - } - for (map::const_iterator cur = that->new_types_.begin() - ; cur != that->new_types_.end() ; ++ cur) { - if (cur->second == 0) - continue; - old_types_[cur->first] = cur->second; + use_types_[cur->first] = cur->second; } - for (map::const_iterator cur = that->old_constants_.begin() - ; cur != that->old_constants_.end() ; ++ cur) { - old_constants_[cur->first] = cur->second; - } - for (map::const_iterator cur = that->new_constants_.begin() - ; cur != that->new_constants_.end() ; ++ cur) { - old_constants_[cur->first] = cur->second; + for (map::const_iterator cur = that->cur_constants_.begin() + ; cur != that->cur_constants_.end() ; ++ cur) { + use_constants_[cur->first] = cur->second; } } @@ -208,7 +197,7 @@ bool ActiveScope::is_vector_name(perm_string name) const return false; } -Scope::Scope(const ScopeBase&ref) +Scope::Scope(const ActiveScope&ref) : ScopeBase(ref) { } diff --git a/vhdlpp/scope.h b/vhdlpp/scope.h index e07e06ff6..7c0644817 100644 --- a/vhdlpp/scope.h +++ b/vhdlpp/scope.h @@ -1,7 +1,8 @@ #ifndef __scope_H #define __scope_H /* - * Copyright (c) 2011-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com) + * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -28,8 +29,10 @@ # include "subprogram.h" # include "vsignal.h" +class ActiveScope; class Architecture; class ComponentBase; +class Package; class Subprogram; class VType; @@ -47,7 +50,7 @@ class ScopeBase { public: ScopeBase() { } - explicit ScopeBase(const ScopeBase&ref); + explicit ScopeBase(const ActiveScope&ref); virtual ~ScopeBase() =0; const VType* find_type(perm_string by_name); @@ -68,6 +71,12 @@ class ScopeBase { for_each(c.begin(), c.end(), ::delete_pair_second()); } + // The new_*_ maps below are managed only by the ActiveScope + // derived class. When any scope is constructed from the + // ActiveScope, the new_*_ and old_*_ maps are merged and + // installed into the old_*_ maps. Thus, all other derived + // classes should only use the old_*_ maps. + // Signal declarations... std::map old_signals_; //previous scopes std::map new_signals_; //current scope @@ -78,8 +87,8 @@ class ScopeBase { std::map old_components_; //previous scopes std::map new_components_; //current scope // Type declarations... - std::map old_types_; //previous scopes - std::map new_types_; //current scope + std::map use_types_; //imported types + std::map cur_types_; //current types // Constant declarations... struct const_t { ~const_t() {delete typ; delete val;} @@ -88,8 +97,8 @@ class ScopeBase { const VType*typ; Expression*val; }; - std::map old_constants_; //previous scopes - std::map new_constants_; //current scope + std::map use_constants_; //imported constants + std::map cur_constants_; //current constants std::map old_subprograms_; //previous scopes std::map new_subprograms_; //current scope @@ -100,7 +109,7 @@ class ScopeBase { class Scope : public ScopeBase { public: - explicit Scope(const ScopeBase&ref); + explicit Scope(const ActiveScope&ref); ~Scope(); ComponentBase* find_component(perm_string by_name); @@ -128,7 +137,7 @@ class ActiveScope : public ScopeBase { ~ActiveScope() { } - void use_from(const ScopeBase*that) { do_use_from(that); } + void use_from(const Scope*that) { do_use_from(that); } // This function returns true if the name is a vectorable // name. The parser uses this to distinguish between function @@ -164,16 +173,19 @@ class ActiveScope : public ScopeBase { void bind_name(perm_string name, const VType* t) { map::iterator it; - if((it = old_types_.find(name)) != old_types_.end() ) - old_types_.erase(it); - new_types_[name] = t; + if((it = use_types_.find(name)) != use_types_.end() ) + use_types_.erase(it); + cur_types_[name] = t; } + inline void use_name(perm_string name, const VType* t) + { use_types_[name] = t; } + void bind_name(perm_string name, const VType*obj, Expression*val) { map::iterator it; - if((it = old_constants_.find(name)) != old_constants_.end() ) - old_constants_.erase(it); - new_constants_[name] = new const_t(obj, val); + if((it = use_constants_.find(name)) != use_constants_.end() ) + use_constants_.erase(it); + cur_constants_[name] = new const_t(obj, val); } void bind_name(perm_string name, Subprogram*obj)