text
stringlengths 0
252
|
---|
#define SCCORE "sc_core::"
|
#define CONST "const"
|
#define CT "const this;"
|
typedef pair<string, string> NT; //------N : name and T: type, which is for variable and function
|
const vector<string> CPlusPlus_type = {"char","char16_t","char32_t","wchar_t","signed char","short","int","long","long long","unsigned char","unsigned short","unsigned","unsigned long","unsigned long long","float","double","long double","bool","void"};
|
bool string_finder (string , string);
|
void GotoLine(ifstream& , unsigned int);
|
vector<string> split(const string &, char);
|
string replace_first_occurrence (string&, const string&, const string&);
|
bool findchar_exact (string, vector<string>);
|
void print_vector (vector<string>);
|
int find_in_vector (vector<string>, string);
|
void remove_element_vector(vector<string>&, string);
|
void set_NT_vector (vector<NT>&, NT);
|
void filter_element (string&, vector<string>);
|
string make_string (vector<NT>);
|
string make_XML (vector<NT>);
|
#endif
|
// Copyright (c) 2019 Group of Computer Architecture, university of Bremen. All Rights Reserved.
|
// Filename: SCmain.cpp
|
// Version 1 09-July-2019
|
#include "SCmain.h"
|
void ScMain::print_data(){
|
ofstream txtFile;
|
txtFile.open ("output.txt");
|
txtFile<<"--------------Extracted Static Information--------------"<<endl;
|
for (auto i: static_data_final){
|
txtFile<<"Module Name ----->\n"<<i.get_name()<<endl;
|
txtFile<<"Var List ----->\n"<<i.get_var()<<endl;
|
txtFile<<"Func List ----->\n"<<i.get_func()<<endl;
|
txtFile<<"----------------------------------------------------"<<endl;
|
}
|
}
|
//----------------------------------------------------------
|
void ScMain::print_data_XML(){
|
ofstream xmlFile;
|
xmlFile.open ("output.xml");
|
xmlFile<<"<ESL_ARCH>"<<endl;
|
for (auto i: static_data_final){
|
xmlFile<<i.get_name_XML()<<endl;
|
xmlFile<<i.get_var_XML()<<endl;
|
xmlFile<<i.get_func_XML()<<endl;
|
if (i.get_name() == "sc_main")
|
xmlFile<<"</Global_function>\n"<<endl;
|
else
|
xmlFile<<"</Module>\n"<<endl;
|
}
|
xmlFile<<"</ESL_ARCH>"<<endl;
|
xmlFile.close();
|
}
|
//----------------------------------------------------------
|
void ScMain::update_localVar (string m_name, string f_sig, vector<NT> local_var){
|
int index = find_element(m_name);
|
if (index != -1)
|
static_data_final[index].set_func_with_local(f_sig, local_var);
|
}
|
//----------------------------------------------------------
|
void ScMain::set_func_localVar(ifstream &debugSymbol){
|
unordered_map<string, vector<NT>> func_temp;
|
vector<string> vect_decod;
|
string temp, line;
|
vector<NT> Vect_NameType;
|
unsigned int lineNum = 0;
|
for (auto i: static_data_final){
|
func_temp = i.get_func_data();
|
for (auto j: func_temp){
|
lineNum = 0;
|
vect_decod = split(j.first,'+');
|
temp = "function " + i.get_name() + "::" + vect_decod[0];
|
GotoLine(debugSymbol, lineNum); //-------start from begining of file
|
if (debugSymbol.is_open()){
|
while (getline(debugSymbol, line)) {
|
lineNum++;
|
if (string_finder (line, temp)){
|
Vect_NameType = find_localVar_elements (debugSymbol, lineNum);
|
update_localVar(i.get_name(),j.first, Vect_NameType);
|
break;
|
}
|
}
|
}
|
else
|
cout << "\033[1;31mUnable to open Debug Symbol file\033[0m\n";
|
}
|
}
|
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.