git-svn-id: svn://ultimatepp.org/upp/trunk@8445 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-05-13 14:01:22 +00:00
parent 66ae191e91
commit 3d9e13e4e4
5 changed files with 31 additions and 15 deletions

View file

@ -2,7 +2,7 @@
NAMESPACE_UPP
#define LTIMING(x) RTIMING(x)
#define LTIMING(x) // RTIMING(x)
#define LLOG(x) // DLOG(x)
void Cpp::ParamAdd(Vector<String>& param, const char *s, const char *e)
@ -156,7 +156,7 @@ bool Cpp::Preprocess(const String& sourcefile, Stream& in, const String& current
bool get_macros)
{
LLOG("===== Preprocess " << sourcefile << " <- " << currentfile);
LTIMING("Cpp::Preprocess");
RTIMING("Cpp::Preprocess");
macro.Clear();
macro.Reserve(1000);
segment_id.Clear();
@ -192,6 +192,7 @@ bool Cpp::Preprocess(const String& sourcefile, Stream& in, const String& current
void Cpp::DoFlatInclude(const String& header_path)
{
RTIMING("DoFlatInclude");
LLOG("Flat include " << header_path);
if(header_path.GetCount()) {
const PPFile& pp = GetFlatPPFile(header_path);
@ -223,6 +224,7 @@ void Cpp::Do(const String& sourcefile, Stream& in, const String& currentfile,
String current_folder = GetFileFolder(currentfile);
bool notthefile = sourcefile != currentfile;
if(notthefile || get_macros) {
RTIMING("DO2");
const PPFile& pp = GetPPFile(currentfile);
for(int i = 0; i < pp.item.GetCount() && !done; i++) {
const PPItem& m = pp.item[i];
@ -268,7 +270,7 @@ void Cpp::Do(const String& sourcefile, Stream& in, const String& currentfile,
namespaces = Join(namespace_stack, ";");
if(!get_macros) {
LTIMING("Expand");
RTIMING("Expand");
incomment = false;
prefix_macro.Clear();
StringBuffer result;

View file

@ -2,7 +2,7 @@
NAMESPACE_UPP
#define LTIMING(x) RTIMING(x)
#define LTIMING(x) // RTIMING(x)
#define LLOG(x) // LOG(x)
bool IsCPPFile(const String& path)
@ -394,12 +394,13 @@ Time GetFileTimeCached(const String& p)
String GetIncludePath(const String& s, const String& filedir)
{
LTIMING("GetIncludePath");
RTIMING("GetIncludePath");
String key;
key << s << "#" << filedir << "#" << GetIncludePath();
key << s << "#" << filedir;
int q = sIncludePath.Find(key);
if(q >= 0)
return sIncludePath[q];
RTIMING("GetIncludePath 2");
String p = GetIncludePath0(s, filedir);
sIncludePath.Add(key, p);
return p;
@ -407,11 +408,12 @@ String GetIncludePath(const String& s, const String& filedir)
const PPFile& GetPPFile(const char *path)
{
RTIMING("GetPPFile");
Time tm = GetFileTimeCached(path);
PPFile& f = sPPfile.GetPut(path);
if(f.filetime != tm) {
f.filetime = tm;
LTIMING("PP read");
RTIMING("PP read");
FileIn in(path);
f.Parse(in);
}
@ -423,14 +425,18 @@ bool IsSameFile(const String& f1, const String& f2)
return NormalizePath(f1) == NormalizePath(f2);
}
bool IncludesFile(const String& parent_path, const String& path, Index<String>& visited)
bool IncludesFile0(const String& parent_path, const String& path, Index<String>& visited)
{
HITCOUNT("IncludesFile0");
RHITCOUNT("IncludesFile0");
if(visited.Find(parent_path) >= 0)
return false;
visited.Add(parent_path);
if(IsSameFile(parent_path, path))
return true;
{
RTIMING("GetPPFile");
GetPPFile(parent_path);
}
const PPFile& f = GetPPFile(parent_path);
for(int i = 0; i < f.includes.GetCount(); i++) {
String key = path + "#" + f.includes[i];
@ -443,7 +449,7 @@ bool IncludesFile(const String& parent_path, const String& path, Index<String>&
else {
HITCOUNT("IncludesFile getpath");
String p = GetIncludePath(f.includes[i], GetFileFolder(parent_path));
bool b = p.GetCount() && IncludesFile(p, path, visited);
bool b = p.GetCount() && IncludesFile0(p, path, visited);
sIncludes.Add(key, b);
if(b)
return true;
@ -454,9 +460,15 @@ bool IncludesFile(const String& parent_path, const String& path, Index<String>&
bool IncludesFile(const String& parent_path, const String& path)
{
LTIMING("IncludesFile");
RTIMING("IncludesFile");
Index<String> visited;
return IncludesFile(parent_path, path, visited);
String key = path + "#" + parent_path;
int q = sIncludes.Find(key);
if(q >= 0)
return sIncludes[q];
bool b = IncludesFile0(parent_path, path, visited);
sIncludes.Add(key, b);
return b;
}
void CreateFlatPP(PPFile& fp, const char *path, Index<String>& visited)
@ -481,6 +493,7 @@ void CreateFlatPP(PPFile& fp, const char *path, Index<String>& visited)
const PPFile& GetFlatPPFile(const char *path, Index<String>& visited)
{
RTIMING("GetFlatPPFile");
LLOG("GetFlatPPFile " << path);
int q = sFlatPP.Find(path);
if(q >= 0)

View file

@ -195,7 +195,7 @@ String GetSourceFilePath(int file)
bool CheckFile(const SourceFileInfo& f, const String& path)
{
LTIMING("CheckFile");
RTIMING("CheckFile");
LDUMP(f.time);
LDUMP(FileGetTime(path));
if(f.time != FileGetTime(path))

View file

@ -32,7 +32,7 @@ String PreprocessImlFile(const char *fn)
}
catch(CParser::Error) {}
String r;
String r = "using Upp;";
r << "struct " << GetFileTitle(fn) << "Img {\n";
if(iml.GetCount())
r << "enum {" << i_ml << "};\n" << iml;

View file

@ -19,7 +19,8 @@ Vector<String> PreprocessSchFile(const char *fn)
{
String s = LoadFile(fn);
CParser p(s);
String r, rr;
String r = "using Upp;";
String rr = "using Upp;";
String S_name;
int line;
while(!p.IsEof())