vhdlpp: Libraries are searched for subprograms during the ExpFunc elaboration.

This commit is contained in:
Maciej Suminski 2014-10-01 14:56:32 +02:00
parent 194a950f8d
commit fde6525acb
5 changed files with 56 additions and 5 deletions

View File

@ -34,8 +34,4 @@ extern StringHeapLex lex_strings;
extern StringHeapLex filename_strings;
extern void library_set_work_path(const char*work_path);
extern void library_add_directory(const char*directory);
extern int emit_packages(void);
#endif /* IVL_compiler_H */

View File

@ -24,6 +24,7 @@
# include "entity.h"
# include "vsignal.h"
# include "subprogram.h"
# include "library.h"
# include <iostream>
# include <typeinfo>
# include "parse_types.h"
@ -711,6 +712,9 @@ int ExpFunc::elaborate_expr(Entity*ent, Architecture*arc, const VType*)
ivl_assert(*this, arc);
Subprogram*prog = arc->find_subprogram(name_);
if(!prog)
prog = library_find_subprogram(name_);
ivl_assert(*this, def_==0);
def_ = prog;

View File

@ -69,7 +69,25 @@ void library_add_directory(const char*directory)
return;
}
library_search_path .push_front(directory);
library_search_path.push_front(directory);
}
Subprogram*library_find_subprogram(perm_string name)
{
Subprogram*subp = NULL;
map<perm_string,struct library_contents>::const_iterator lib_it;
for(lib_it = libraries.begin(); lib_it != libraries.end(); ++lib_it) {
const struct library_contents&lib = lib_it->second;
map<perm_string,Package*>::const_iterator pack_it;
for(pack_it = lib.packages.begin(); pack_it != lib.packages.end(); ++pack_it) {
if((subp = pack_it->second->find_subprogram(name)))
return subp;
}
}
return NULL;
}
static void store_package_in_work(const Package*pack);

32
vhdlpp/library.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef IVL_library_H
#define IVL_library_H
/*
* Copyright (c) 2011-2014 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
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Subprogram;
extern void library_set_work_path(const char*work_path);
extern void library_add_directory(const char*directory);
extern Subprogram*library_find_subprogram(perm_string name);
extern int emit_packages(void);
#endif /* IVL_library_H */

View File

@ -75,6 +75,7 @@ const char NOTICE[] =
;
# include "compiler.h"
# include "library.h"
# include "parse_api.h"
# include "vtype.h"
# include <fstream>