X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/c7f552fd8888da2f0d8cfb228fe0f28d3df3a12c..b4b6f2ea75b9f0f3ca918f5b84016610bf7a4d4f:/interpretor/faust-0.9.47mr3/compiler/preprocess/preprocess.cpp diff --git a/interpretor/faust-0.9.47mr3/compiler/preprocess/preprocess.cpp b/interpretor/faust-0.9.47mr3/compiler/preprocess/preprocess.cpp deleted file mode 100644 index f74de94..0000000 --- a/interpretor/faust-0.9.47mr3/compiler/preprocess/preprocess.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/************************************************************************ - ************************************************************************ - FAUST compiler - Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale - --------------------------------------------------------------------- - This program is free software; you can redistribute it and/or modify - it 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., 675 Mass Ave, Cambridge, MA 02139, USA. - ************************************************************************ - ************************************************************************/ - -#include "preprocess.hh" - - - - -/**************************************************************** - Parser variables -*****************************************************************/ - - -int yyparse(); - -int yyerr; -extern int yydebug; -extern FILE* yyin; -Tree gResult; -Tree gResult2; - -SourceReader gReader; - -map > gMetaDataSet; -extern vector gDocVector; -extern string gDocLang; - - -/**************************************************************** - Command line tools and arguments -*****************************************************************/ - -//-- globals -string gFaustSuperSuperDirectory; -string gFaustSuperDirectory; -string gFaustDirectory; -string gMasterDocument; -string gMasterDirectory; -string gMasterName; -string gDocName; -Tree gExpandedDefList; - -//-- command line arguments - -bool gHelpSwitch = false; -bool gVersionSwitch = false; -bool gDetailsSwitch = false; -bool gDrawSignals = false; -bool gShadowBlur = false; // note: svg2pdf doesn't like the blur filter -bool gGraphSwitch = false; -bool gDrawPSSwitch = false; -bool gDrawSVGSwitch = false; -bool gPrintXMLSwitch = false; -bool gPrintDocSwitch = false; -bool gLatexDocSwitch = true; // Only LaTeX outformat is handled for the moment. -bool gStripDocSwitch = false; // Strip content from doc listings. -int gBalancedSwitch = 0; -int gFoldThreshold = 25; -int gMaxNameSize = 40; -bool gSimpleNames = false; -bool gSimplifyDiagrams = false; -bool gLessTempSwitch = false; -int gMaxCopyDelay = 16; -string gArchFile; -string gOutputFile; -list gInputFiles; - -bool gPatternEvalMode = false; - -bool gVectorSwitch = false; -bool gDeepFirstSwitch= false; -int gVecSize = 32; -int gVectorLoopVariant = 0; - -bool gOpenMPSwitch = false; -bool gOpenMPLoop = false; -bool gSchedulerSwitch = false; -bool gGroupTaskSwitch= false; - -bool gUIMacroSwitch = false; -bool gDumpNorm = false; - -int gTimeout = 120; // time out to abort compiler (in seconds) - -int gFloatSize = 1; - -bool gPrintFileListSwitch = false; - -string gClassName = "mydsp"; - -//-- command line tools - -static bool isCmd(const char* cmd, const char* kw1) -{ - return (strcmp(cmd, kw1) == 0); -} - -static bool isCmd(const char* cmd, const char* kw1, const char* kw2) -{ - return (strcmp(cmd, kw1) == 0) || (strcmp(cmd, kw2) == 0); -} - -bool process_cmdline(int argc, char* argv[]) -{ - int i=1; int err=0; - - while (i\t\tload --mathdoc-lang if translation file exists ( = en, fr, ...)\n"; - cout << "-stripdoc \t\tapply --strip-mdoc-tags when printing Faust -mdoc listings\n"; - cout << "-sd \t\ttry to further --simplify-diagrams before drawing them\n"; - cout << "-f \t\t--fold threshold during block-diagram generation (default 25 elements) \n"; - cout << "-mns \t--max-name-size threshold during block-diagram generation (default 40 char)\n"; - cout << "-sn \t\tuse --simple-names (without arguments) during block-diagram generation\n"; - cout << "-xml \t\tgenerate an --xml description file\n"; - cout << "-blur \t\tadd a --shadow-blur to SVG boxes\n"; - cout << "-lb \t\tgenerate --left-balanced expressions\n"; - cout << "-mb \t\tgenerate --mid-balanced expressions (default)\n"; - cout << "-rb \t\tgenerate --right-balanced expressions\n"; - cout << "-lt \t\tgenerate --less-temporaries in compiling delays\n"; - cout << "-mcd \t--max-copy-delay threshold between copy and ring buffer implementation (default 16 samples)\n"; - cout << "-a \tC++ architecture file\n"; - cout << "-cn \t--class-name specify the name of the dsp class to be used instead of mydsp \n"; - cout << "-t \t--timeout , abort compilation after seconds (default 120)\n"; - cout << "-o \tC++ output file\n"; - cout << "-vec \t--vectorize generate easier to vectorize code\n"; - cout << "-vs \t--vec-size size of the vector (default 32 samples)\n"; - cout << "-lv \t--loop-variant [0:fastest (default), 1:simple] \n"; - cout << "-omp \t--openMP generate OpenMP pragmas, activates --vectorize option\n"; - cout << "-pl \t--par-loop generate parallel loops in --openMP mode\n"; - cout << "-sch \t--scheduler generate tasks and use a Work Stealing scheduler, activates --vectorize option\n"; - cout << "-dfs \t--deepFirstScheduling schedule vector loops in deep first order\n"; - cout << "-g \t\t--groupTasks group single-threaded sequential tasks together when -omp or -sch is used\n"; - cout << "-uim \t--user-interface-macros add user interface macro definitions in the C++ code\n"; - cout << "-single \tuse --single-precision-floats for internal computations (default)\n"; - cout << "-double \tuse --double-precision-floats for internal computations\n"; - cout << "-quad \t\tuse --quad-precision-floats for internal computations\n"; - cout << "-flist \t\tuse --file-list used to eval process\n"; - cout << "-norm \t\t--normalized-form prints signals in normalized form and exits\n"; - - cout << "\nexample :\n"; - cout << "---------\n"; - - cout << "faust -a jack-gtk.cpp -o myfx.cpp myfx.dsp\n"; -} - - -void printheader(ostream& dst) -{ - // defines the metadata we want to print as comments at the begin of in the C++ file - set selectedKeys; - selectedKeys.insert(tree("name")); - selectedKeys.insert(tree("author")); - selectedKeys.insert(tree("copyright")); - selectedKeys.insert(tree("license")); - selectedKeys.insert(tree("version")); - - dst << "//-----------------------------------------------------" << endl; - for (map >::iterator i = gMetaDataSet.begin(); i != gMetaDataSet.end(); i++) { - if (selectedKeys.count(i->first)) { - dst << "// " << *(i->first); - const char* sep = ": "; - for (set::iterator j = i->second.begin(); j != i->second.end(); ++j) { - dst << sep << **j; - sep = ", "; - } - dst << endl; - } - } - - dst << "//" << endl; - dst << "// Code generated with Faust " << FAUSTVERSION << " (http://faust.grame.fr)" << endl; - dst << "//-----------------------------------------------------" << endl; -} - - - - -/**************************************************************** - MAIN -*****************************************************************/ - - - -/** - * transform a filename "faust/example/noise.dsp" into - * the corresponding fx name "noise" - */ -static string fxname(const string& filename) -{ - // determine position right after the last '/' or 0 - unsigned int p1 = 0; - for (unsigned int i=0; i::iterator s; - gResult2 = nil; - yyerr = 0; - - if (gInputFiles.begin() == gInputFiles.end()) { - cerr << "ERROR: no files specified;" << endl; - cerr << "interpreter [input.wav]." << endl; - exit(1); - } - for (s = gInputFiles.begin(); s != gInputFiles.end(); s++) { - if (s == gInputFiles.begin()) gMasterDocument = *s; - gResult2 = cons(importFile(tree(s->c_str())), gResult2); - } - if (yyerr > 0) { - //fprintf(stderr, "Erreur de parsing 2, count = %d \n", yyerr); - exit(1); - } - gExpandedDefList = gReader.expandlist(gResult2); - - endTiming("parser"); - - /**************************************************************** - 3 - evaluate 'process' definition - *****************************************************************/ - - startTiming("evaluation"); - - Tree process = evalprocess(gExpandedDefList); - - if (gErrorCount > 0) { - // cerr << "Total of " << gErrorCount << " errors during evaluation of : process = " << boxpp(process) << ";\n"; - cerr << "Total of " << gErrorCount << " errors during the compilation of " << gMasterDocument << ";\n"; - exit(1); - } - - endTiming("evaluation"); - - ostringstream result_stream; - result_stream << boxpp(process); - string result_string = result_stream.str(); - char* result_char = new char [result_string.length()+1]; - strcpy(result_char, result_string.c_str());; - - //cout << result_string.length() << endl; - //cout << result_char << endl; - - // Karim Barkati: printing globals value - //list faustGlobals = { - //cout << "gFaustSuperSuperDirectory = " << gFaustSuperSuperDirectory << endl; - //cout << "gFaustSuperDirectory = " << gFaustSuperDirectory << endl; - //cout << "gFaustDirectory = " << gFaustDirectory << endl; - //cout << "gMasterDocument = " << gMasterDocument << endl; - //cout << "gMasterDirectory = " << gMasterDirectory << endl; - //cout << "gMasterName = " << gMasterName << endl; - - return result_char; -}