|
|
|
#include "debug.h"
|
|
|
|
#include "init.h"
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
if(argc!=2) return 1;
|
|
|
|
int ret;
|
|
|
|
DepTree* DPTree;
|
|
|
|
|
|
|
|
SetDebugLevel(INFO);
|
|
|
|
|
|
|
|
COUT(INFO)<<"Parse config file "<<argv[1]<<" ";
|
|
|
|
ret=ParseConfigFile(argv[1]); if(ret!=0) { ClearGlobals(); return 1;}
|
|
|
|
COUT(INFO)<<"Ok"<<std::endl;
|
|
|
|
if(G_tosave.size()==0 && G_toprint.size()==0)
|
|
|
|
{
|
|
|
|
COUT(WARNING)<<"No actions needed, exiting"<<std::endl;
|
|
|
|
ClearGlobals();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
UsedType used, all;
|
|
|
|
for(auto& i:G_vars) all.insert(i.first);
|
|
|
|
unsigned int tot=G_vars.size();
|
|
|
|
|
|
|
|
DPTree=new DepTree;
|
|
|
|
COUT(INFO)<<"Building dependency tree ";
|
|
|
|
ret=BuildDepTree(DPTree,used); if(ret!=0) { ClearGlobals(); delete DPTree; return 1;}
|
|
|
|
COUT(INFO)<<"Ok"<<std::endl;
|
|
|
|
|
|
|
|
COUT(INFO)<<"Remove unneeded definitions: ";
|
|
|
|
for(auto& i:all) if(used.count(i)==0) { delete G_vars[i]; G_vars.erase(i);};
|
|
|
|
COUT(INFO)<<(tot-G_vars.size())<<" removed, "<<G_vars.size()<<" remains."<<std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegisterArifmeticFunctions();
|
|
|
|
|
|
|
|
COUT(INFO)<<"Checking functions ";
|
|
|
|
ret=CheckFunctions(); if(ret!=0) { ClearGlobals(); delete DPTree; return 1;}
|
|
|
|
COUT(INFO)<<"Ok"<<std::endl;
|
|
|
|
|
|
|
|
DumpConfig();
|
|
|
|
|
|
|
|
COUT(INFO)<<sizeof(DepTree)<<" "<<sizeof(ObjectList)<<std::endl;
|
|
|
|
|
|
|
|
ClearGlobals();
|
|
|
|
delete DPTree;
|
|
|
|
return 0;
|
|
|
|
}
|