[Compbench-devel] CompBenchmarks++/libcompbenchmarks/Compiler Compiler-Option-Logic.cpp, 1.3, 1.4 C
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-10-02 17:30:33
|
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14952 Modified Files: Compiler-Option-Logic.cpp Compiler-Option-Logic.h Log Message: removeAppended() and appendCommand() methods added to handle implied-by statements when the implied option comes first. Index: Compiler-Option-Logic.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler-Option-Logic.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Compiler-Option-Logic.h 4 Sep 2007 17:33:35 -0000 1.3 --- Compiler-Option-Logic.h 2 Oct 2007 17:30:29 -0000 1.4 *************** *** 18,21 **** --- 18,22 ---- Exclusive, /*!< Bijective exclusion operator */ ImpliedBy, /*!< Left item is implied by right one */ + RevImplied, /*!< Left item used first, yet, implied by right one */ Requires /*!< Left item requieres right one */ }; *************** *** 28,31 **** --- 29,33 ---- std::string internalVarValue; /*!< variable (desired) value */ std::string optionReferred; /*!< option's name */ + int rt_appended; /*!< Added (on run-time) by CompilerOptionLogic::appendCommand() */ }; *************** *** 51,54 **** --- 53,61 ---- std::vector<CompilerOptionLogicCommand*> commands; + /** Removes auto-added variables. + * See RevImplied for an example of commands that may emerge on run-time; + * they should be removed after option line check. + */ + virtual void removeAppended(void); public: /** Constructor. *************** *** 71,74 **** --- 78,96 ---- virtual std::string use(void); + + /** Append a command (run-time) in logics. + * + * Used by RevImplied for instance. + * \param id Operator identifier + * \param testOption 1 for option, 0 for an internal variable + * \param internalVarName variable name + * \param internalVarValue variable (desired) value + * \param optionReferred option's name */ + virtual void appendCommand(CompilerOptionLogicCommandID _id, + int _testOption, + std::string _internalVarName, + std::string _internalVarValue, + std::string _optionReferred); + /** Desctructor */ virtual ~CompilerOptionLogic(); Index: Compiler-Option-Logic.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Compiler/Compiler-Option-Logic.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Compiler-Option-Logic.cpp 16 Apr 2007 20:37:28 -0000 1.3 --- Compiler-Option-Logic.cpp 2 Oct 2007 17:30:29 -0000 1.4 *************** *** 17,21 **** { int i; ! int n = _from->nodeNumber(); CBM::XMLNode *N; CBM::XMLAttribute *A; --- 17,21 ---- { int i; ! int n; CBM::XMLNode *N; CBM::XMLAttribute *A; *************** *** 26,29 **** --- 26,32 ---- description=_description; + if (!_from) + return; + n=_from->nodeNumber(); for(i=0; i<n; i++) { N=_from->getNode(i); *************** *** 34,38 **** cmd=new CompilerOptionLogicCommand; cmd->id=Exclusive; ! cmd->internalVarName=A->Value(); A=N->getAttribute("value"); --- 37,41 ---- cmd=new CompilerOptionLogicCommand; cmd->id=Exclusive; ! cmd->rt_appended=0; cmd->internalVarName=A->Value(); A=N->getAttribute("value"); *************** *** 58,61 **** --- 61,65 ---- cmd->optionReferred=A->Value(); cmd->testOption=1; + cmd->rt_appended=0; commands.push_back(cmd); continue; *************** *** 67,70 **** --- 71,75 ---- continue; cmd=new CompilerOptionLogicCommand; + cmd->rt_appended=0; cmd->id=Requires; cmd->optionReferred=A->Value(); *************** *** 76,83 **** } std::string CompilerOptionLogic::use(void) { int i; ! int n = commands.size(); CBM::CompilerOptionLogicCommand *cmd; CBM::Compiler *C = context->Compiler(); --- 81,110 ---- } + void CompilerOptionLogic::removeAppended(void) + { + int i; + int n = commands.size(); + CompilerOptionLogicCommand *cmd; + std::vector<CompilerOptionLogicCommand*> ncommands; + int r = 0; + + for(i=0; i<n; i++) { + cmd=commands[i]; + if (!cmd->rt_appended) + ncommands.push_back(cmd); + else { + delete(cmd); + r=1; + } + } + + if (r) + commands=ncommands; + } + std::string CompilerOptionLogic::use(void) { int i; ! int n; CBM::CompilerOptionLogicCommand *cmd; CBM::Compiler *C = context->Compiler(); *************** *** 89,92 **** --- 116,120 ---- std::string varvalue; + n=commands.size(); for(i=0; i<n; i++) { cmd=commands[i]; *************** *** 117,120 **** --- 145,149 ---- tmp+=context->Description(var->lastWriter)->Option(); } + removeAppended(); return(tmp); } *************** *** 128,133 **** --- 157,173 ---- tmp+=context->Description(cmd->optionReferred)->Option(); return(tmp); + } else { + D=context->Description(cmd->optionReferred); + context->logicAppendImplied(D, description->Id()); } break; + case RevImplied: + tmp="Option "; + tmp+=context->Description(cmd->optionReferred)->Option(); + tmp+=" is implied by "; + tmp+=description->Option(); + removeAppended(); + return(tmp); + break; case Requires: if (!C->colOptionHas(cmd->optionReferred)) { *************** *** 136,143 **** --- 176,186 ---- tmp+=" requires "; tmp+=context->Description(cmd->optionReferred)->Option(); + removeAppended(); return(tmp); } break; default: + removeAppended(); + printf("Command ID %d ?\n", cmd->id); return("Unknown command in option analyzing"); break; *************** *** 147,150 **** --- 190,212 ---- } + void CompilerOptionLogic::appendCommand(CompilerOptionLogicCommandID _id, + int _testOption, + std::string _internalVarName, + std::string _internalVarValue, + std::string _optionReferred) + { + CompilerOptionLogicCommand *cmd; + + cmd=new CompilerOptionLogicCommand; + cmd->id=_id; + cmd->optionReferred=_optionReferred; + cmd->testOption=_testOption; + cmd->internalVarName=_internalVarName; + cmd->internalVarValue=_internalVarValue; + cmd->rt_appended=1; + commands.push_back(cmd); + } + + CompilerOptionLogic::~CompilerOptionLogic() { |