-bool IsOutFileIndexCheckRequiredStr (const Init* CmdLine) {
- StrVector StrVec;
- TokenizeCmdLine(InitPtrToString(CmdLine), StrVec);
-
- for (StrVector::const_iterator I = StrVec.begin(), E = StrVec.end();
- I != E; ++I) {
- if (*I == "$OUTFILE")
- return false;
- }
-
- return true;
-}
-
-class IsOutFileIndexCheckRequiredStrCallback {
- bool* ret_;
-
-public:
- IsOutFileIndexCheckRequiredStrCallback(bool* ret) : ret_(ret)
- {}
-
- void operator()(const Init* CmdLine) {
- // Ignore nested 'case' DAG.
- if (typeid(*CmdLine) == typeid(DagInit))
- return;
-
- if (IsOutFileIndexCheckRequiredStr(CmdLine))
- *ret_ = true;
- }
-
- void operator()(const DagInit* Test, unsigned, bool) {
- this->operator()(Test);
- }
- void operator()(const Init* Statement, unsigned) {
- this->operator()(Statement);
- }
-};
-
-bool IsOutFileIndexCheckRequiredCase (Init* CmdLine) {
- bool ret = false;
- WalkCase(CmdLine, Id(), IsOutFileIndexCheckRequiredStrCallback(&ret));
- return ret;
-}
-
-/// IsOutFileIndexCheckRequired - Should we emit an "out_file_index != -1" check
-/// in EmitGenerateActionMethod() ?
-bool IsOutFileIndexCheckRequired (Init* CmdLine) {
- if (typeid(*CmdLine) == typeid(StringInit))
- return IsOutFileIndexCheckRequiredStr(CmdLine);
- else
- return IsOutFileIndexCheckRequiredCase(CmdLine);
-}
-