Support collecting ALL component declarations from a used scope.

This commit is contained in:
Stephen Williams 2011-04-13 19:55:18 -07:00
parent e017ccb5d2
commit 303f057de1
4 changed files with 16 additions and 1 deletions

View File

@ -91,7 +91,7 @@ void library_use(const YYLTYPE&loc, struct library_results&res,
// results into the "res" members. // results into the "res" members.
if (use_name == "all") { if (use_name == "all") {
sorrymsg(loc, "Don't support all from package\n"); pack->collect_components(res.components);
return; return;
} }

View File

@ -982,11 +982,13 @@ selected_name_use
: IDENTIFIER '.' K_all : IDENTIFIER '.' K_all
{ struct library_results res; { struct library_results res;
library_use(@1, res, 0, $1, 0); library_use(@1, res, 0, $1, 0);
collect_library_results(res);
delete[]$1; delete[]$1;
} }
| IDENTIFIER '.' IDENTIFIER '.' K_all | IDENTIFIER '.' IDENTIFIER '.' K_all
{ struct library_results res; { struct library_results res;
library_use(@1, res, $1, $3, 0); library_use(@1, res, $1, $3, 0);
collect_library_results(res);
delete[]$1; delete[]$1;
delete[]$3; delete[]$3;
} }

View File

@ -38,3 +38,13 @@ ComponentBase* Scope::find_component(perm_string by_name)
else else
return cur->second; return cur->second;
} }
void Scope::collect_components(list<ComponentBase*>&res)
{
for (map<perm_string,ComponentBase*>::const_iterator cur = components_.begin()
; cur != components_.end() ; ++cur) {
if (cur->second == 0)
continue;
res.push_back(cur->second);
}
}

View File

@ -19,6 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
# include <list>
# include <map> # include <map>
# include "StringHeap.h" # include "StringHeap.h"
@ -33,6 +34,8 @@ class Scope {
ComponentBase* find_component(perm_string by_name); ComponentBase* find_component(perm_string by_name);
void collect_components(std::list<ComponentBase*>&res);
void dump_scope(ostream&out) const; void dump_scope(ostream&out) const;
private: private: