|
|
|
|
@@ -31,13 +31,13 @@ extern "C" int out_upper_case;
|
|
|
|
|
extern "C" int out_line_unlimit;
|
|
|
|
|
extern "C" int out_line_length;
|
|
|
|
|
extern "C" PTR_SYMB last_file_symbol;
|
|
|
|
|
extern "C" PTR_SYMB FileLastSymbol(...);
|
|
|
|
|
|
|
|
|
|
static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|
|
|
|
const set<string>& filesInProj, const set<string>& moduleDeclsInFiles)
|
|
|
|
|
static int convertFile(int argc, char* argv[], const set<string>& filesInProj, const set<string>& moduleDeclsInFiles)
|
|
|
|
|
{
|
|
|
|
|
FILE* fout = NULL;
|
|
|
|
|
FILE* fout_cuf = NULL, * fout_C_cu = NULL, * fout_info = NULL; /*ACC*/
|
|
|
|
|
const char* fout_name = "out.DVMH.f";
|
|
|
|
|
const char* fout_name = NULL;
|
|
|
|
|
char* fout_name_cuf; /*ACC*/
|
|
|
|
|
char* fout_name_C_cu; /*ACC*/
|
|
|
|
|
char* fout_name_info_C; /*ACC*/
|
|
|
|
|
@@ -54,7 +54,8 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|
|
|
|
while ((argc > 1) && (*argv)[0] == '-')
|
|
|
|
|
{
|
|
|
|
|
if ((*argv)[1] == 'o' && ((*argv)[2] == '\0')) {
|
|
|
|
|
fout_name = argv[1];
|
|
|
|
|
if (filesInProj.size() == 1)
|
|
|
|
|
fout_name = argv[1];
|
|
|
|
|
argv++;
|
|
|
|
|
argc--;
|
|
|
|
|
}
|
|
|
|
|
@@ -307,7 +308,8 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|
|
|
|
static int id = 0;
|
|
|
|
|
|
|
|
|
|
vector<char*> filesList;
|
|
|
|
|
filesList.push_back((char*)fileToConv.c_str());
|
|
|
|
|
for (auto& file : filesInProj)
|
|
|
|
|
filesList.push_back((char*)file.c_str());
|
|
|
|
|
|
|
|
|
|
SgProject project((proj_name + to_string(id++)).c_str(), filesList.data(), filesList.size());
|
|
|
|
|
|
|
|
|
|
@@ -317,7 +319,7 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|
|
|
|
removeExecutableFromModuleDeclaration(&(project.file(z)), filesInProj, tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SgFile* file;
|
|
|
|
|
SgFile* file = NULL;
|
|
|
|
|
addNumberOfFileToAttribute(&project);
|
|
|
|
|
|
|
|
|
|
//----------------------------
|
|
|
|
|
@@ -331,23 +333,27 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|
|
|
|
initF2C_FunctionCalls(); // for project, acc_f2c.cpp
|
|
|
|
|
for (int id = project.numberOfFiles() - 1; id >= 0; id--)
|
|
|
|
|
{
|
|
|
|
|
file = &(project.file(id)); //file->unparsestdout();
|
|
|
|
|
file = &(project.file(id));
|
|
|
|
|
fin_name = new char[strlen(project.fileName(id)) + 2];
|
|
|
|
|
sprintf(fin_name, "%s%s", project.fileName(id), " ");
|
|
|
|
|
fout_name = doOutFileName(file->filename()); //project.fileName(id);
|
|
|
|
|
|
|
|
|
|
if (fout_name == NULL)
|
|
|
|
|
fout_name = doOutFileName(file->filename());
|
|
|
|
|
|
|
|
|
|
if (fout_name && source_name && !strcmp(source_name, fout_name))
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "Output file has the same name as source file\n");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("convert %d to %s\n", id, fout_name);
|
|
|
|
|
|
|
|
|
|
fout_name_cuf = ChangeFtoCuf(fout_name); /*ACC*/
|
|
|
|
|
fout_name_C_cu = ChangeFto_C_Cu(fout_name); /*ACC*/
|
|
|
|
|
fout_name_info_C = ChangeFto_info_C(fout_name); /*ACC*/
|
|
|
|
|
|
|
|
|
|
//set the last symbol of file
|
|
|
|
|
last_file_symbol = CUR_FILE_CUR_SYMB();
|
|
|
|
|
last_file_symbol = FileLastSymbol(file->filename());
|
|
|
|
|
initLibNames(); //for every file
|
|
|
|
|
InitDVM(file); //for every file
|
|
|
|
|
current_file = file; // global variable (used in SgTypeComplex)
|
|
|
|
|
@@ -402,7 +408,22 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|
|
|
|
UnparseTo_CufAndCu_Files(file, fout_cuf, fout_C_cu, fout_info);
|
|
|
|
|
|
|
|
|
|
const string fileN = file->filename();
|
|
|
|
|
hideUnnecessary(file, fileN, moduleDeclsInFiles, true);
|
|
|
|
|
set<SgStatement*> toRemove;
|
|
|
|
|
|
|
|
|
|
for (SgStatement* st = file->firstStatement(); st; st = st->lexNext())
|
|
|
|
|
{
|
|
|
|
|
if (st->fileName() != fileN)
|
|
|
|
|
{
|
|
|
|
|
if (st->variant() == MODULE_STMT && moduleDeclsInFiles.find(st->fileName()) != moduleDeclsInFiles.end())
|
|
|
|
|
{
|
|
|
|
|
toRemove.insert(st);
|
|
|
|
|
st = st->lastNodeOfStmt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& toRem : toRemove)
|
|
|
|
|
toRem->extractStmt();
|
|
|
|
|
|
|
|
|
|
if (unparse_functions)
|
|
|
|
|
UnparseFunctionsOfFile(file, fout);
|
|
|
|
|
@@ -434,7 +455,7 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fout_name = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (v_print)
|
|
|
|
|
@@ -467,11 +488,11 @@ void convertFiles(int argc, char* argv[], const char* proj_name)
|
|
|
|
|
|
|
|
|
|
const string fileText = readFileToStr(proj_name);
|
|
|
|
|
vector<string> files;
|
|
|
|
|
set<string> filesinSet;
|
|
|
|
|
set<string> filesInSet;
|
|
|
|
|
splitString(fileText, '\n', files);
|
|
|
|
|
|
|
|
|
|
for (auto& file : files)
|
|
|
|
|
filesinSet.insert(file);
|
|
|
|
|
filesInSet.insert(file);
|
|
|
|
|
|
|
|
|
|
map<string, set<string>> moduleUsesByFile;
|
|
|
|
|
map<string, string> moduleDecls;
|
|
|
|
|
@@ -482,9 +503,9 @@ void convertFiles(int argc, char* argv[], const char* proj_name)
|
|
|
|
|
moduleDeclsInFiles.insert(elem.second);
|
|
|
|
|
|
|
|
|
|
int codes = 0;
|
|
|
|
|
for (auto& file : files)
|
|
|
|
|
{
|
|
|
|
|
codes += convertFile(args_v.size() - 1, args_v.data(), file, filesinSet, moduleDeclsInFiles);
|
|
|
|
|
//for (auto& file : files)
|
|
|
|
|
{
|
|
|
|
|
codes += convertFile(args_v.size(), args_v.data(), filesInSet, moduleDeclsInFiles);
|
|
|
|
|
|
|
|
|
|
cur_node = node_list = NULL;
|
|
|
|
|
InitializeTable();
|
|
|
|
|
|