|
FAUST compiler
0.9.9.6b8
|
#include <sourcereader.hh>
Public Member Functions | |
| bool | cached (string fname) |
| Check if a file as been read and is in the "cache". | |
| Tree | getlist (string fname) |
| Return the list of definitions file contains. | |
| Tree | expandlist (Tree ldef) |
| Return the list of definitions where all imports have been expanded. | |
| vector< string > | listSrcFiles () |
| Return a vector of pathnames representing the list of all the source files that have been required to evaluate process (those in fFileCache) | |
Private Member Functions | |
| Tree | parse (string fname) |
| Parse a single faust source file. | |
| Tree | expandrec (Tree ldef, set< string > &visited, Tree lresult) |
Private Attributes | |
| map< string, Tree > | fFileCache |
| vector< string > | fFilePathnames |
Definition at line 16 of file sourcereader.hh.
| bool SourceReader::cached | ( | string | fname | ) |
Check if a file as been read and is in the "cache".
| fname | the name of the file to check |
Definition at line 222 of file sourcereader.cpp.
{
return fFileCache.find(fname) != fFileCache.end();
}
| Tree SourceReader::expandlist | ( | Tree | ldef | ) |
Return the list of definitions where all imports have been expanded.
| ldef | the list of definitions to expand |
Definition at line 271 of file sourcereader.cpp.
References nil.
Referenced by main(), and realeval().

| Tree SourceReader::expandrec | ( | Tree | ldef, |
| set< string > & | visited, | ||
| Tree | lresult | ||
| ) | [private] |
Definition at line 277 of file sourcereader.cpp.
References cons(), hd(), isImportFile(), isNil(), tl(), and tree2str().
{
for (;!isNil(ldef); ldef = tl(ldef)) {
Tree d = hd(ldef);
Tree fname;
if (isNil(d)) {
// skill null definitions produced by declarations
} else if (isImportFile(d,fname)) {
string f = tree2str(fname);
//cerr << "import(" << f << ")" << endl;
//string f = tree2str(fname);
if (visited.find(f) == visited.end()) {
visited.insert(f);
//Tree l = getlist(f);
lresult = expandrec(getlist(f), visited, lresult);
}
} else {
lresult = cons(d, lresult);
}
}
return lresult;
}

| Tree SourceReader::getlist | ( | string | fname | ) |
Return the list of definitions file contains.
Cache the result.
| fname | the name of the file to check |
Definition at line 235 of file sourcereader.cpp.
Referenced by realeval().
{
if (!cached(fname)) {
fFileCache[fname] = parse(fname);
}
if (fFileCache[fname] == 0) exit(1);
return fFileCache[fname];
}

| vector< string > SourceReader::listSrcFiles | ( | ) |
Return a vector of pathnames representing the list of all the source files that have been required to evaluate process (those in fFileCache)
Definition at line 251 of file sourcereader.cpp.
Referenced by declareAutoDoc(), main(), printDoc(), and printfaustlistings().
{
// vector<string> srcfiles;
// for (map<string, Tree>::const_iterator p = fFileCache.begin(); p != fFileCache.end(); p++) {
// srcfiles.push_back(p->first);
// }
// return srcfiles;
return fFilePathnames;
}

| Tree SourceReader::parse | ( | string | fname | ) | [private] |
Parse a single faust source file.
returns the list of definitions it contains.
| fname | the name of the file to parse |
Definition at line 186 of file sourcereader.cpp.
References fopensearch(), gResult, yyerr, yyfilename, yyin, yylineno, and yyparse().
{
string fullpath;
yyerr = 0;
yyfilename = fname.c_str();
yyin = fopensearch(yyfilename, fullpath);
if (yyin == NULL) {
fprintf(stderr, "ERROR : Unable to open file %s \n", yyfilename);
exit(1);
}
yylineno = 1;
int r = yyparse();
if (r) {
fprintf(stderr, "Parse error : code = %d \n", r);
}
if (yyerr > 0) {
//fprintf(stderr, "Erreur de parsing 2, count = %d \n", yyerr);
exit(1);
}
// we have parsed a valid file
fFilePathnames.push_back(fullpath);
return gResult;
}

map<string, Tree> SourceReader::fFileCache [private] |
Definition at line 18 of file sourcereader.hh.
vector<string> SourceReader::fFilePathnames [private] |
Definition at line 19 of file sourcereader.hh.
1.8.0