unsigned Driver<Sage>::add(const boost::filesystem::path & path) { assert(boost::filesystem::exists(path)); assert(boost::filesystem::is_regular_file(path)); std::map<boost::filesystem::path, unsigned>::const_iterator it_file_id = path_to_id_map.find(path); if (it_file_id != path_to_id_map.end()) return it_file_id->second; else { SgSourceFile * file = isSgSourceFile(SageBuilder::buildFile(path.string(), path.string(), project)); assert(file != NULL); file->set_skip_unparse(true); file->set_skipfinalCompileStep(true); unsigned id = add(file); path_to_id_map.insert(std::pair<boost::filesystem::path, unsigned>(path, id)); return id; } }
SgSourceFile* FortranModuleInfo::createSgSourceFile(string modName) { int errorCode = 0; vector<string> argv; // DQ (11/12/2008): Modified to force filename to lower case. #if 0 printf ("In FortranModuleInfo::createSgSourceFile(): generating a module file %s using module name = %s \n",StringUtility::convertToLowerCase(modName).c_str(),modName.c_str()); #endif // modName = StringUtility::convertToLowerCase(modName); // current directory string rmodFileName = modName + MOD_FILE_SUFFIX; #if 0 printf ("In FortranModuleInfo::createSgSourceFile(): Searching for file rmodFileName = %s \n",rmodFileName.c_str()); printf ("In FortranModuleInfo::createSgSourceFile(): boost::filesystem::exists(rmodFileName.c_str()) = %s \n",boost::filesystem::exists(rmodFileName.c_str()) ? "true" : "false"); #endif if (boost::filesystem::exists(rmodFileName.c_str()) == false) { printf ("File rmodFileName = %s NOT FOUND (expected to be present) \n",rmodFileName.c_str()); return NULL; } argv.push_back(SKIP_SYNTAX_CHECK); argv.push_back(rmodFileName); nestedSgFile++; if (SgProject::get_verbose() > 1) printf ("START FortranModuleInfo::createSgSourceFile(%s): nestedSgFile = %d \n",rmodFileName.c_str(),nestedSgFile); SgProject* project = getCurrentProject(); SgSourceFile* newFile = isSgSourceFile(determineFileType(argv,errorCode,project)); // SgSourceFile* newFile = new SgSourceFile (argv, errorCode, 0, project); ROSE_ASSERT(newFile != NULL); #if 0 printf ("In FortranModuleInfo::createSgSourceFile(): Calling the fronend explicitly! \n"); #endif // DQ (6/13/2013): Since we seperated the construction of the SgFile IR nodes from the invocation of the frontend, we have to call the frontend explicitly. newFile->runFrontend(errorCode); // DQ (6/13/2013): At least report that the error code is not checked, this is just something that I noticed but don't want to modify just now. // I guess that the point is that it should compile since the module compiled previously, but it should still be enforced to be zero. if (errorCode != 0) { printf ("In FortranModuleInfo::createSgSourceFile(): errorCode != 0 is not checked \n"); ROSE_ASSERT(errorCode == 0); } ROSE_ASSERT (newFile != NULL); ROSE_ASSERT (newFile->get_startOfConstruct() != NULL); // Set the project as the parent newFile->set_parent(project); // DQ (11/12/2008): This rmod file should be explicitly marked to not be compiled. // printf ("Marking the new module file to not be compiled \n"); newFile->set_skipfinalCompileStep(true); newFile->set_skip_unparse(true); project->set_file(*newFile); if (SgProject::get_verbose() > 1) printf ("END FortranModuleInfo::createSgSourceFile(%s): nestedSgFile = %d \n",rmodFileName.c_str(),nestedSgFile); nestedSgFile--; return newFile; }