Thread: [Compbench-devel] CompBenchmarks++/libcompbenchmarks/Compiler Compiler-Options.cpp, 1.6, 1.7 Compil
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-09-10 16:40:24
|
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18036 Modified Files: Compiler-Options.cpp Compiler-Options.h Log Message: SF's TID #141918: Plan and incompatible options. Index: Compiler-Options.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler-Options.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Compiler-Options.h 4 Sep 2007 20:02:55 -0000 1.6 --- Compiler-Options.h 10 Sep 2007 16:40:10 -0000 1.7 *************** *** 11,14 **** --- 11,16 ---- #include <Compiler/Compiler-Option.h> + #include <Plan/Plan-Batch.h> + #include <Base/XML.h> *************** *** 31,34 **** --- 33,55 ---- std::string id; + + /** Checks compatibility of an added option. + * + * Returns a string like CBM::Compiler::analyzeOptions() does. + * \parma _batch Batch file (checks for existing options and compiler compatibility) + * \param _option Option to add + * \return String with warning/errors */ + virtual std::string checkCompatibilityInternal(CBM::PlanBatch *_batch, + std::string option); + + /** Checks compatibility of an added option. + * + * Returns a more suitable string. + * \parma _batch Batch file (checks for existing options and compiler compatibility) + * \param _option Option to add + * \return String with warning/errors */ + virtual std::string checkCompatibility(CBM::PlanBatch *_batch, + std::string option); + protected: /** Add an option. *************** *** 46,53 **** /** Add an option. * * \param _option Option to add * \return 1 on success, 0 otherwise */ ! virtual int addSingle(std::string _option); /** Remove an option. --- 67,76 ---- /** Add an option. * + * \parma _batch Batch file (checks for existing options and compiler compatibility) * \param _option Option to add * \return 1 on success, 0 otherwise */ ! virtual int addSingle(CBM::PlanBatch *_batch, ! std::string _option); /** Remove an option. *************** *** 62,69 **** * * \param id Instance's identifier - * \param _options Options to manage in current object */ ! CompilerOptions(std::string id, ! std::string _options = ""); /** Retrieve identifier. --- 85,90 ---- * * \param id Instance's identifier */ ! CompilerOptions(std::string id); /** Retrieve identifier. *************** *** 89,95 **** /** Add a bunch of options * * \param _options Options to add * \return 1 on success, 0 otherwise */ ! virtual int add(std::string _options); /** Remove a bunch of options --- 110,118 ---- /** Add a bunch of options * + * \parma _batch Batch file (checks for existing options and compiler compatibility) * \param _options Options to add * \return 1 on success, 0 otherwise */ ! virtual int add(CBM::PlanBatch *_batch, ! std::string _options); /** Remove a bunch of options Index: Compiler-Options.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler-Options.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Compiler-Options.cpp 31 Jul 2007 17:23:13 -0000 1.6 --- Compiler-Options.cpp 10 Sep 2007 16:40:10 -0000 1.7 *************** *** 8,20 **** #include <Compiler/Compiler-Options.h> #include <System/System.h> using namespace CBM; ! CompilerOptions::CompilerOptions(std::string _id, ! std::string _options) { id=_id; ! add(_options); } --- 8,91 ---- #include <Compiler/Compiler-Options.h> + #include <Compiler/Compiler.h> + #include <System/System.h> + #include <UI/UI.h> using namespace CBM; ! CompilerOptions::CompilerOptions(std::string _id) { id=_id; ! } ! ! std::string CompilerOptions::checkCompatibilityInternal(CBM::PlanBatch *_batch, ! std::string option) ! { ! int i; ! int n = optionNumber(); ! CBM::Compiler *C; ! std::string cr; ! std::string opts; ! std::string r; ! ! if (!_batch) ! return("1\n"); ! ! for(i=0; i<n; i++) { ! opts+=Option(i)->Option(); ! opts+=" "; ! } ! opts+=option; ! ! n= _batch->compilerNumber(); ! for(i=0; i<n; i++) { ! C=_batch->getCompiler(i); ! cr=C->analyzeOptions(opts); ! if (cr!="1\n") { ! r+=C->Name(); ! r+=": "; ! r+=cr; ! } ! } ! if (r=="") ! r="1\n"; ! ! return(r); ! } ! ! std::string CompilerOptions::checkCompatibility(CBM::PlanBatch *_batch, ! std::string option) ! { ! std::string rin = checkCompatibilityInternal(_batch, option); ! int i = 0; ! std::string o = "!"; ! std::string r; ! int times = 0; ! int ok = 0; ! ! if (rin=="1\n") ! return("1\n"); ! ! ! while (o!="") { ! o=cbmSystem->Split(rin, "\n", i++); ! if (o=="") { ! if ((!times) && (rin!="")) ! o=rin; ! else ! break; ! } ! times++; ! ! if (o=="1") ! ok++; ! else { ! r+=o; ! r+=". "; ! } ! } ! ! return(r); } *************** *** 47,56 **** } ! int CompilerOptions::addSingle(std::string _option) { if (!Option(_option)) { ! add(new CompilerOption(_option)); return(1); } else { return(0); } --- 118,138 ---- } ! int CompilerOptions::addSingle(CBM::PlanBatch *_batch, std::string _option) { + std::string comp; + + cbmUI->msgPlanOptionRegister(_option); if (!Option(_option)) { ! comp=checkCompatibility(_batch, _option); ! if (comp=="1\n") { ! add(new CompilerOption(_option)); ! cbmUI->outputOK(); ! } else { ! cbmUI->outputKO(comp); ! return(0); ! } return(1); } else { + cbmUI->outputKO("Option already presents"); return(0); } *************** *** 96,104 **** } ! int CompilerOptions::add(std::string _options) { std::string o = "!"; int i = 0; int r = 0; if (_options=="") --- 178,187 ---- } ! int CompilerOptions::add(CBM::PlanBatch *_batch, std::string _options) { std::string o = "!"; int i = 0; int r = 0; + int c; if (_options=="") *************** *** 108,117 **** o=cbmSystem->Split(_options, " ", i++); if ((o=="") && (i==1)) { ! r+=addSingle(_options); } if (o!="") { ! r+=addSingle(o); } } return(r); } --- 191,203 ---- o=cbmSystem->Split(_options, " ", i++); if ((o=="") && (i==1)) { ! cbmUI->msgPlanOptionRegister(o); ! c=addSingle(_batch, _options); ! r+=c; } if (o!="") { ! r+=addSingle(_batch, o); } } + return(r); } |