This commit is contained in:
Hackerpilot 2014-09-12 14:32:58 -07:00
parent c7952880eb
commit a32086e066
3 changed files with 49 additions and 50 deletions

View File

@ -402,7 +402,7 @@ body
k++;
}
}
auto symbols = ModuleCache.getSymbolsInModule(ModuleCache.resolveImportLoctation(path));
auto symbols = ModuleCache.getModuleSymbol(ModuleCache.resolveImportLoctation(path));
import containers.hashset;
HashSet!string h;

View File

@ -152,7 +152,7 @@ private:
foreach (importInfo; currentScope.importInformation[])
{
string location = ModuleCache.resolveImportLoctation(importInfo.modulePath);
ACSymbol* symbol = location is null ? null : ModuleCache.getSymbolsInModule(location);
ACSymbol* symbol = location is null ? null : ModuleCache.getModuleSymbol(location);
if (symbol is null)
continue;
ACSymbol* moduleSymbol = createImportSymbols(importInfo, currentScope, symbol);

View File

@ -113,7 +113,7 @@ struct ModuleCache
{
import std.path: baseName;
if(fileName.baseName.startsWith(".#")) continue;
getSymbolsInModule(fileName);
getModuleSymbol(fileName);
}
}
}
@ -127,33 +127,33 @@ struct ModuleCache
* Returns:
* The symbols defined in the given module
*/
static ACSymbol* getSymbolsInModule(string location)
static ACSymbol* getModuleSymbol(string location)
{
import string_interning;
import std.stdio;
import std.typecons;
assert (location !is null);
if (!needsReparsing(location))
string cachedLocation = internString(location);
if (!needsReparsing(cachedLocation))
{
CacheEntry e;
e.path = location;
e.path = cachedLocation;
auto r = cache.equalRange(&e);
if (!r.empty)
return r.front.symbol;
return null;
}
string cachedLocation = internString(location);
Log.info("Getting symbols for ", cachedLocation);
recursionGuard.insert(cachedLocation);
ACSymbol* symbol;
// try
// {
import std.stdio;
import std.typecons;
File f = File(cachedLocation);
immutable fileSize = cast(size_t)f.size;
immutable fileSize = cast(size_t) f.size;
if (fileSize == 0)
return null;
ubyte[] source = cast(ubyte[]) Mallocator.it.allocate(fileSize);
@ -167,8 +167,6 @@ struct ModuleCache
config, &parseStringCache);
Mallocator.it.deallocate(source);
// StopWatch sw;
// sw.start();
Module m = parseModuleSimple(tokens[], cachedLocation, semanticAllocator);
assert (symbolAllocator);
@ -176,8 +174,6 @@ struct ModuleCache
semanticAllocator);
first.run();
// Log.trace(location, " finished in ", sw.peek.msecs, "msecs");
SecondPass second = SecondPass(first);
second.run();
@ -188,17 +184,20 @@ struct ModuleCache
typeid(Scope).destroy(third.moduleScope);
symbolsAllocated += first.symbolsAllocated;
// }
// catch (Exception ex)
// {
// Log.error("Couln't parse ", location, " due to exception: ", ex.msg);
// return [];
// }
SysTime access;
SysTime modification;
getTimes(cachedLocation, access, modification);
CacheEntry* c = allocate!CacheEntry(Mallocator.it, symbol,
modification, cachedLocation);
CacheEntry e;
e.path = cachedLocation;
auto r = cache.equalRange(&e);
CacheEntry* c = r.empty ? allocate!CacheEntry(Mallocator.it)
: r.front;
c.symbol = symbol;
c.modificationTime = modification;
c.path = cachedLocation;
if (r.empty)
cache.insert(c);
recursionGuard.remove(cachedLocation);
return symbol;