mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Improved comptime rebuilds when files and directories change
This commit is contained in:
parent
af8bd5a813
commit
915a8df50e
10 changed files with 236 additions and 70 deletions
|
@ -55,6 +55,12 @@ namespace IDE.Compiler
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern char8* BfCompiler_GetAutocompleteInfo(void* bfCompiler);
|
static extern char8* BfCompiler_GetAutocompleteInfo(void* bfCompiler);
|
||||||
|
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
static extern char8* BfCompiler_GetRebuildFileSet(void* bfCompiler);
|
||||||
|
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
static extern void BfCompiler_FileChanged(void* bfCompiler, char8* str);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern char8* BfCompiler_GetSymbolReferences(void* bfCompiler, void* bfPassInstance, void* bfResolvePassData);
|
static extern char8* BfCompiler_GetSymbolReferences(void* bfCompiler, void* bfPassInstance, void* bfResolvePassData);
|
||||||
|
|
||||||
|
@ -200,10 +206,17 @@ namespace IDE.Compiler
|
||||||
public int32 mHotIdx;
|
public int32 mHotIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RebuildFileChangedCommand : Command
|
||||||
|
{
|
||||||
|
public String mDir = new .() ~ delete _;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void* mNativeBfCompiler;
|
public void* mNativeBfCompiler;
|
||||||
public bool mIsResolveOnly;
|
public bool mIsResolveOnly;
|
||||||
public BfSystem mBfSystem;
|
public BfSystem mBfSystem;
|
||||||
bool mWantsRemoveOldData;
|
bool mWantsRemoveOldData;
|
||||||
|
public Dictionary<String, String> mRebuildWatchingFiles = new .() ~ delete _;
|
||||||
|
|
||||||
public this(void* nativeBfCompiler)
|
public this(void* nativeBfCompiler)
|
||||||
{
|
{
|
||||||
|
@ -214,6 +227,13 @@ namespace IDE.Compiler
|
||||||
{
|
{
|
||||||
BfCompiler_Delete(mNativeBfCompiler);
|
BfCompiler_Delete(mNativeBfCompiler);
|
||||||
mNativeBfCompiler = null;
|
mNativeBfCompiler = null;
|
||||||
|
|
||||||
|
for (var kv in mRebuildWatchingFiles)
|
||||||
|
{
|
||||||
|
gApp.mFileWatcher.RemoveWatch(kv.key, kv.value);
|
||||||
|
delete kv.key;
|
||||||
|
delete kv.value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Compile(BfPassInstance passInstance, String outputDirectory)
|
public bool Compile(BfPassInstance passInstance, String outputDirectory)
|
||||||
|
@ -249,6 +269,12 @@ namespace IDE.Compiler
|
||||||
outAutocompleteInfo.Append(StringView(result));
|
outAutocompleteInfo.Append(StringView(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetRebuildFileSet(String outDirInfo)
|
||||||
|
{
|
||||||
|
char8* result = BfCompiler_GetRebuildFileSet(mNativeBfCompiler);
|
||||||
|
outDirInfo.Append(StringView(result));
|
||||||
|
}
|
||||||
|
|
||||||
public void GetSymbolReferences(BfPassInstance passInstance, BfResolvePassData resolvePassData, String outSymbolReferences)
|
public void GetSymbolReferences(BfPassInstance passInstance, BfResolvePassData resolvePassData, String outSymbolReferences)
|
||||||
{
|
{
|
||||||
char8* result = BfCompiler_GetSymbolReferences(mNativeBfCompiler, passInstance.mNativeBfPassInstance, resolvePassData.mNativeResolvePassData);
|
char8* result = BfCompiler_GetSymbolReferences(mNativeBfCompiler, passInstance.mNativeBfPassInstance, resolvePassData.mNativeResolvePassData);
|
||||||
|
@ -531,6 +557,7 @@ namespace IDE.Compiler
|
||||||
{
|
{
|
||||||
var compileCommand = (CompileCommand)command;
|
var compileCommand = (CompileCommand)command;
|
||||||
Compile(passInstance, compileCommand.mOutputDirectory);
|
Compile(passInstance, compileCommand.mOutputDirectory);
|
||||||
|
UpdateRebuildFileWatches();
|
||||||
mBfSystem.RemoveOldParsers();
|
mBfSystem.RemoveOldParsers();
|
||||||
mBfSystem.RemoveOldData();
|
mBfSystem.RemoveOldData();
|
||||||
}
|
}
|
||||||
|
@ -547,7 +574,8 @@ namespace IDE.Compiler
|
||||||
// If we get canceled then try again after waiting a couple updates
|
// If we get canceled then try again after waiting a couple updates
|
||||||
if (!ClassifySource(passInstance, null, resolvePassData, null))
|
if (!ClassifySource(passInstance, null, resolvePassData, null))
|
||||||
QueueDeferredResolveAll();
|
QueueDeferredResolveAll();
|
||||||
|
UpdateRebuildFileWatches();
|
||||||
|
|
||||||
delete resolvePassData;
|
delete resolvePassData;
|
||||||
wantsRemoveOldData = true;
|
wantsRemoveOldData = true;
|
||||||
passKind = .Classify;
|
passKind = .Classify;
|
||||||
|
@ -570,6 +598,11 @@ namespace IDE.Compiler
|
||||||
{
|
{
|
||||||
mWantsActiveViewRefresh = true;
|
mWantsActiveViewRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (var dirChangedCommand = command as RebuildFileChangedCommand)
|
||||||
|
{
|
||||||
|
BfCompiler_FileChanged(mNativeBfCompiler, dirChangedCommand.mDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mBfSystem.Unlock();
|
mBfSystem.Unlock();
|
||||||
|
@ -842,5 +875,54 @@ namespace IDE.Compiler
|
||||||
{
|
{
|
||||||
return BfCompiler_GetLastHadComptimeRebuilds(mNativeBfCompiler);
|
return BfCompiler_GetLastHadComptimeRebuilds(mNativeBfCompiler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateRebuildFileWatches()
|
||||||
|
{
|
||||||
|
HashSet<StringView> curWatches = scope .();
|
||||||
|
|
||||||
|
var rebuildDirStr = GetRebuildFileSet(.. scope .());
|
||||||
|
for (var dir in rebuildDirStr.Split('\n', .RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
curWatches.Add(dir);
|
||||||
|
if (mRebuildWatchingFiles.TryAddAlt(dir, var keyPtr, var valuePtr))
|
||||||
|
{
|
||||||
|
*keyPtr = new String(dir);
|
||||||
|
String watchFile = *valuePtr = new .();
|
||||||
|
watchFile.Append(dir);
|
||||||
|
if ((watchFile.EndsWith(Path.DirectorySeparatorChar)) || (watchFile.EndsWith(Path.AltDirectorySeparatorChar)))
|
||||||
|
watchFile.Append("*");
|
||||||
|
gApp.mFileWatcher.WatchFile(watchFile, watchFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> oldKeys = scope .();
|
||||||
|
for (var kv in mRebuildWatchingFiles)
|
||||||
|
{
|
||||||
|
if (!curWatches.Contains(kv.key))
|
||||||
|
{
|
||||||
|
gApp.mFileWatcher.RemoveWatch(kv.key, kv.value);
|
||||||
|
oldKeys.Add(kv.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var key in oldKeys)
|
||||||
|
{
|
||||||
|
var kv = mRebuildWatchingFiles.GetAndRemove(key).Value;
|
||||||
|
delete kv.key;
|
||||||
|
delete kv.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasRebuildFileWatches()
|
||||||
|
{
|
||||||
|
return !mRebuildWatchingFiles.IsEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddChangedDirectory(StringView str)
|
||||||
|
{
|
||||||
|
var dirChangedCommand = new RebuildFileChangedCommand();
|
||||||
|
dirChangedCommand.mDir.Set(str);
|
||||||
|
QueueCommand(dirChangedCommand);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,8 @@ namespace IDE
|
||||||
Dictionary<String, DepInfo> mWatchedFiles = new Dictionary<String, DepInfo>() ~ DeleteDictionaryAndKeysAndValues!(_); // Including ref count
|
Dictionary<String, DepInfo> mWatchedFiles = new Dictionary<String, DepInfo>() ~ DeleteDictionaryAndKeysAndValues!(_); // Including ref count
|
||||||
List<ChangeRecord> mChangeList = new .() ~ DeleteContainerAndItems!(_);
|
List<ChangeRecord> mChangeList = new .() ~ DeleteContainerAndItems!(_);
|
||||||
Dictionary<String, ChangeRecord> mChangeMap = new .() ~ delete _;
|
Dictionary<String, ChangeRecord> mChangeMap = new .() ~ delete _;
|
||||||
List<Object> mDependencyChangeList = new List<Object>() ~ delete _;
|
HashSet<Object> mDependencyChangeSet = new .() ~ delete _;
|
||||||
|
List<Object> mDependencyChangeList = new .() ~ delete _;
|
||||||
List<QueuedRefreshEntry> mQueuedRefreshWatcherEntries = new List<QueuedRefreshEntry>() ~ delete _;
|
List<QueuedRefreshEntry> mQueuedRefreshWatcherEntries = new List<QueuedRefreshEntry>() ~ delete _;
|
||||||
public Monitor mMonitor = new Monitor() ~ delete _;
|
public Monitor mMonitor = new Monitor() ~ delete _;
|
||||||
List<QueuedFileChange> mQueuedFileChanges = new List<QueuedFileChange>() ~ DeleteContainerAndItems!(_);
|
List<QueuedFileChange> mQueuedFileChanges = new List<QueuedFileChange>() ~ DeleteContainerAndItems!(_);
|
||||||
|
@ -86,6 +87,14 @@ namespace IDE
|
||||||
{
|
{
|
||||||
bool isDirectory = filePath.EndsWith(Path.DirectorySeparatorChar);
|
bool isDirectory = filePath.EndsWith(Path.DirectorySeparatorChar);
|
||||||
|
|
||||||
|
if (!filePath.EndsWith('*'))
|
||||||
|
{
|
||||||
|
String starPath = Path.GetDirectoryPath(filePath, .. scope .());
|
||||||
|
starPath.Append(Path.DirectorySeparatorChar);
|
||||||
|
starPath.Append('*');
|
||||||
|
FileChanged(starPath, null, .Changed);
|
||||||
|
}
|
||||||
|
|
||||||
var newPath;
|
var newPath;
|
||||||
if (isDirectory)
|
if (isDirectory)
|
||||||
{
|
{
|
||||||
|
@ -194,9 +203,10 @@ namespace IDE
|
||||||
{
|
{
|
||||||
if (var tryProjectItem = dep as ProjectItem)
|
if (var tryProjectItem = dep as ProjectItem)
|
||||||
projectItem = tryProjectItem;
|
projectItem = tryProjectItem;
|
||||||
if ((dep != null) && (!mDependencyChangeList.Contains(dep)))
|
if (dep != null)
|
||||||
{
|
{
|
||||||
mDependencyChangeList.Add(dep);
|
if (mDependencyChangeSet.Add(dep))
|
||||||
|
mDependencyChangeList.Add(dep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +545,8 @@ namespace IDE
|
||||||
String outKey;
|
String outKey;
|
||||||
if (!mWatchedFiles.TryGet(fixedFilePath, out outKey, out depInfo))
|
if (!mWatchedFiles.TryGet(fixedFilePath, out outKey, out depInfo))
|
||||||
return;
|
return;
|
||||||
depInfo.mDependentObjects.Remove(dependentObject);
|
if (dependentObject != null)
|
||||||
|
depInfo.mDependentObjects.Remove(dependentObject);
|
||||||
|
|
||||||
if (depInfo.mDependentObjects.Count == 0)
|
if (depInfo.mDependentObjects.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -553,7 +564,8 @@ namespace IDE
|
||||||
delete depInfo;
|
delete depInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDependencyChangeList.Remove(dependentObject);
|
if (dependentObject != null)
|
||||||
|
mDependencyChangeSet.Remove(dependentObject);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -644,10 +656,10 @@ namespace IDE
|
||||||
{
|
{
|
||||||
using (mMonitor.Enter())
|
using (mMonitor.Enter())
|
||||||
{
|
{
|
||||||
if (mDependencyChangeList.Count == 0)
|
if (mDependencyChangeList.IsEmpty)
|
||||||
return null;
|
return null;
|
||||||
Object dep = mDependencyChangeList[0];
|
Object dep = mDependencyChangeList.PopFront();
|
||||||
mDependencyChangeList.RemoveAt(0);
|
mDependencyChangeSet.Remove(dep);
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -656,7 +668,7 @@ namespace IDE
|
||||||
{
|
{
|
||||||
using (mMonitor.Enter())
|
using (mMonitor.Enter())
|
||||||
{
|
{
|
||||||
mDependencyChangeList.Add(obj);
|
mDependencyChangeSet.Add(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13032,6 +13032,14 @@ namespace IDE
|
||||||
}
|
}
|
||||||
else if (changeType == .Failed)
|
else if (changeType == .Failed)
|
||||||
{
|
{
|
||||||
|
if (mBfResolveCompiler?.HasRebuildFileWatches() == true)
|
||||||
|
{
|
||||||
|
mBfResolveCompiler.AddChangedDirectory("*");
|
||||||
|
mBfResolveCompiler.QueueDeferredResolveAll();
|
||||||
|
}
|
||||||
|
if (mBfBuildCompiler?.HasRebuildFileWatches() == true)
|
||||||
|
mBfBuildCompiler.AddChangedDirectory("*");
|
||||||
|
|
||||||
if (mProjectPanel != null)
|
if (mProjectPanel != null)
|
||||||
{
|
{
|
||||||
if (let projectFolder = projectItem as ProjectFolder)
|
if (let projectFolder = projectItem as ProjectFolder)
|
||||||
|
@ -13115,13 +13123,29 @@ namespace IDE
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var dep = mFileWatcher.PopChangedDependency();
|
using (mFileWatcher.mMonitor.Enter())
|
||||||
if (dep == null)
|
|
||||||
break;
|
|
||||||
var projectSourceDep = dep as ProjectSource;
|
|
||||||
if (projectSourceDep != null)
|
|
||||||
{
|
{
|
||||||
// We process these projectSources directly from the filename below
|
var dep = mFileWatcher.PopChangedDependency();
|
||||||
|
if (dep == null)
|
||||||
|
break;
|
||||||
|
var projectSourceDep = dep as ProjectSource;
|
||||||
|
if (projectSourceDep != null)
|
||||||
|
{
|
||||||
|
// We process these projectSources directly from the filename below
|
||||||
|
}
|
||||||
|
if (var path = dep as String)
|
||||||
|
{
|
||||||
|
StringView usePath = path;
|
||||||
|
if (usePath.EndsWith('*'))
|
||||||
|
usePath.RemoveFromEnd(1);
|
||||||
|
if (mBfResolveCompiler != null)
|
||||||
|
{
|
||||||
|
mBfResolveCompiler.AddChangedDirectory(usePath);
|
||||||
|
mBfResolveCompiler.QueueDeferredResolveAll();
|
||||||
|
}
|
||||||
|
if (mBfBuildCompiler != null)
|
||||||
|
mBfBuildCompiler.AddChangedDirectory(usePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6565,6 +6565,8 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mRebuildFileSet.Clear();
|
||||||
|
|
||||||
// Inc revision for next run through Compile
|
// Inc revision for next run through Compile
|
||||||
mRevision++;
|
mRevision++;
|
||||||
mHasComptimeRebuilds = false;
|
mHasComptimeRebuilds = false;
|
||||||
|
@ -8149,7 +8151,7 @@ String BfCompiler::GetGeneratorString(BfTypeDef* typeDef, BfTypeInstance* typeIn
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mContext->mUnreifiedModule->mCurTypeInstance, typeInst);
|
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mContext->mUnreifiedModule->mCurTypeInstance, typeInst);
|
||||||
|
|
||||||
BfExprEvaluator exprEvaluator(mContext->mUnreifiedModule);
|
BfExprEvaluator exprEvaluator(mContext->mUnreifiedModule);
|
||||||
exprEvaluator.mBfEvalExprFlags = BfEvalExprFlags_Comptime;
|
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(BfEvalExprFlags_Comptime | BfEvalExprFlags_NoCeRebuildFlags);
|
||||||
|
|
||||||
SizedArray<BfIRValue, 1> irArgs;
|
SizedArray<BfIRValue, 1> irArgs;
|
||||||
if (args != NULL)
|
if (args != NULL)
|
||||||
|
@ -8189,7 +8191,7 @@ String BfCompiler::GetGeneratorTypeDefList()
|
||||||
BfProject* curProject = NULL;
|
BfProject* curProject = NULL;
|
||||||
Dictionary<BfProject*, int> projectIds;
|
Dictionary<BfProject*, int> projectIds;
|
||||||
|
|
||||||
BfResolvePassData resolvePassData;
|
BfResolvePassData resolvePassData;
|
||||||
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
||||||
BfPassInstance passInstance(mSystem);
|
BfPassInstance passInstance(mSystem);
|
||||||
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
||||||
|
@ -8226,7 +8228,7 @@ String BfCompiler::GetGeneratorTypeDefList()
|
||||||
|
|
||||||
String BfCompiler::GetGeneratorInitData(const StringImpl& typeName, const StringImpl& args)
|
String BfCompiler::GetGeneratorInitData(const StringImpl& typeName, const StringImpl& args)
|
||||||
{
|
{
|
||||||
BfResolvePassData resolvePassData;
|
BfResolvePassData resolvePassData;
|
||||||
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
||||||
BfPassInstance passInstance(mSystem);
|
BfPassInstance passInstance(mSystem);
|
||||||
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
||||||
|
@ -9444,6 +9446,22 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetAutocompleteInfo(BfCompiler* bfC
|
||||||
return autoCompleteResultString.c_str();
|
return autoCompleteResultString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetRebuildFileSet(BfCompiler* bfCompiler)
|
||||||
|
{
|
||||||
|
String& autoCompleteResultString = *gTLStrReturn.Get();
|
||||||
|
for (auto& val : bfCompiler->mRebuildFileSet)
|
||||||
|
{
|
||||||
|
autoCompleteResultString += val;
|
||||||
|
autoCompleteResultString += "\n";
|
||||||
|
}
|
||||||
|
return autoCompleteResultString.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
BF_EXPORT void BF_CALLTYPE BfCompiler_FileChanged(BfCompiler* bfCompiler, const char* dirPath)
|
||||||
|
{
|
||||||
|
bfCompiler->mRebuildChangedFileSet.Add(dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetSymbolReferences(BfCompiler* bfCompiler, BfPassInstance* bfPassInstance, BfResolvePassData* resolvePassData)
|
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetSymbolReferences(BfCompiler* bfCompiler, BfPassInstance* bfPassInstance, BfResolvePassData* resolvePassData)
|
||||||
{
|
{
|
||||||
BP_ZONE("BfCompiler_GetSymbolReferences");
|
BP_ZONE("BfCompiler_GetSymbolReferences");
|
||||||
|
|
|
@ -336,6 +336,8 @@ public:
|
||||||
int mHSPreserveIdx;
|
int mHSPreserveIdx;
|
||||||
BfModule* mLastAutocompleteModule;
|
BfModule* mLastAutocompleteModule;
|
||||||
CompileState mCompileState;
|
CompileState mCompileState;
|
||||||
|
HashSet<String> mRebuildFileSet;
|
||||||
|
HashSet<String> mRebuildChangedFileSet; // Files we had actual changes from
|
||||||
|
|
||||||
Array<BfVDataModule*> mVDataModules;
|
Array<BfVDataModule*> mVDataModules;
|
||||||
|
|
||||||
|
|
|
@ -1061,6 +1061,9 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
||||||
delete typeInst->mTypeInfoEx;
|
delete typeInst->mTypeInfoEx;
|
||||||
typeInst->mTypeInfoEx = NULL;
|
typeInst->mTypeInfoEx = NULL;
|
||||||
|
|
||||||
|
if (typeInst->mCeTypeInfo != NULL)
|
||||||
|
typeInst->mCeTypeInfo->mRebuildMap.Clear();
|
||||||
|
|
||||||
if (typeInst->mTypeDef->mEmitParent != NULL)
|
if (typeInst->mTypeDef->mEmitParent != NULL)
|
||||||
{
|
{
|
||||||
auto emitTypeDef = typeInst->mTypeDef;
|
auto emitTypeDef = typeInst->mTypeDef;
|
||||||
|
@ -1895,9 +1898,11 @@ void BfContext::UpdateRevisedTypes()
|
||||||
|
|
||||||
Dictionary<String, uint64> lastWriteTimeMap;
|
Dictionary<String, uint64> lastWriteTimeMap;
|
||||||
|
|
||||||
|
bool rebuildAllFilesChanged = mCompiler->mRebuildChangedFileSet.Contains("*");
|
||||||
|
|
||||||
// Do primary 'rebuild' scan
|
// Do primary 'rebuild' scan
|
||||||
for (auto type : mResolvedTypes)
|
for (auto type : mResolvedTypes)
|
||||||
{
|
{
|
||||||
auto typeInst = type->ToTypeInstance();
|
auto typeInst = type->ToTypeInstance();
|
||||||
if (type == NULL)
|
if (type == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1958,6 +1963,14 @@ void BfContext::UpdateRevisedTypes()
|
||||||
}
|
}
|
||||||
if (*valuePtr != kv.mValue.mInt)
|
if (*valuePtr != kv.mValue.mInt)
|
||||||
changed = true;
|
changed = true;
|
||||||
|
mCompiler->mRebuildFileSet.Add(kv.mKey.mString);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((kv.mKey.mKind == CeRebuildKey::Kind_File) || (kv.mKey.mKind == CeRebuildKey::Kind_Directory))
|
||||||
|
{
|
||||||
|
if ((rebuildAllFilesChanged) || (mCompiler->mRebuildChangedFileSet.Contains(kv.mKey.mString)))
|
||||||
|
changed = true;
|
||||||
|
mCompiler->mRebuildFileSet.Add(kv.mKey.mString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1984,20 +1997,15 @@ void BfContext::UpdateRevisedTypes()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mParser != NULL) && (!typeInst->IsSpecializedType()))
|
|
||||||
// {
|
|
||||||
// if (typeDef->HasSource(mCompiler->mResolvePassData->mParser))
|
|
||||||
// {
|
|
||||||
// HandleChangedTypeDef(typeDef);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (typeDef->mDefState != BfTypeDef::DefState_New)
|
if (typeDef->mDefState != BfTypeDef::DefState_New)
|
||||||
{
|
{
|
||||||
defStateChangedQueue.Add(typeInst);
|
defStateChangedQueue.Add(typeInst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We consumed this above
|
||||||
|
mCompiler->mRebuildChangedFileSet.Clear();
|
||||||
|
|
||||||
for (auto typeInst : defStateChangedQueue)
|
for (auto typeInst : defStateChangedQueue)
|
||||||
{
|
{
|
||||||
BP_ZONE("BfContext::UpdateRevisedTypes defStateChangedQueue");
|
BP_ZONE("BfContext::UpdateRevisedTypes defStateChangedQueue");
|
||||||
|
|
|
@ -5541,7 +5541,9 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, BfMethodInstance*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CeEvalFlags evalFlags = CeEvalFlags_None;
|
CeEvalFlags evalFlags = CeEvalFlags_None;
|
||||||
|
if ((mBfEvalExprFlags & BfEvalExprFlags_NoCeRebuildFlags) != 0)
|
||||||
|
evalFlags = (CeEvalFlags)(evalFlags | CeEvalFlags_NoRebuild);
|
||||||
auto constRet = mModule->mCompiler->mCEMachine->Call(targetSrc, mModule, methodInstance, irArgs, evalFlags, mExpectingType);
|
auto constRet = mModule->mCompiler->mCEMachine->Call(targetSrc, mModule, methodInstance, irArgs, evalFlags, mExpectingType);
|
||||||
if (constRet)
|
if (constRet)
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,6 +79,7 @@ enum BfEvalExprFlags
|
||||||
BfEvalExprFlags_WasMethodRef = 0x800000,
|
BfEvalExprFlags_WasMethodRef = 0x800000,
|
||||||
BfEvalExprFlags_DeclType = 0x1000000,
|
BfEvalExprFlags_DeclType = 0x1000000,
|
||||||
BfEvalExprFlags_AllowBase = 0x2000000,
|
BfEvalExprFlags_AllowBase = 0x2000000,
|
||||||
|
BfEvalExprFlags_NoCeRebuildFlags = 0x4000000,
|
||||||
|
|
||||||
BfEvalExprFlags_InheritFlags = BfEvalExprFlags_NoAutoComplete | BfEvalExprFlags_Comptime | BfEvalExprFlags_DeclType
|
BfEvalExprFlags_InheritFlags = BfEvalExprFlags_NoAutoComplete | BfEvalExprFlags_Comptime | BfEvalExprFlags_DeclType
|
||||||
};
|
};
|
||||||
|
|
|
@ -3028,16 +3028,38 @@ BfError* CeContext::Fail(const CeFrame& curFrame, const StringImpl& str)
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void CeContext::AddRebuild(const CeRebuildKey& key, const CeRebuildValue& value)
|
bool CeContext::AddRebuild(const CeRebuildKey& key, const CeRebuildValue& value)
|
||||||
{
|
{
|
||||||
if (mCurModule == NULL)
|
if (mCurModule == NULL)
|
||||||
return;
|
return false;
|
||||||
if (mCurModule->mCurTypeInstance == NULL)
|
if (mCurModule->mCurTypeInstance == NULL)
|
||||||
return;
|
return false;
|
||||||
|
if ((mCurEvalFlags & CeEvalFlags_NoRebuild) != 0)
|
||||||
|
return false;
|
||||||
if (mCurModule->mCurTypeInstance->mCeTypeInfo == NULL)
|
if (mCurModule->mCurTypeInstance->mCeTypeInfo == NULL)
|
||||||
mCurModule->mCurTypeInstance->mCeTypeInfo = new BfCeTypeInfo();
|
mCurModule->mCurTypeInstance->mCeTypeInfo = new BfCeTypeInfo();
|
||||||
mCurModule->mCurTypeInstance->mCeTypeInfo->mRebuildMap[key] = value;
|
mCurModule->mCurTypeInstance->mCeTypeInfo->mRebuildMap[key] = value;
|
||||||
mCurModule->mCompiler->mHasComptimeRebuilds = true;
|
mCurModule->mCompiler->mHasComptimeRebuilds = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CeContext::AddFileRebuild(const StringImpl& path)
|
||||||
|
{
|
||||||
|
auto timeStamp = BfpFile_GetTime_LastWrite(path.c_str());
|
||||||
|
if (timeStamp != 0)
|
||||||
|
{
|
||||||
|
String fixedPath = FixPathAndCase(path);
|
||||||
|
|
||||||
|
CeRebuildKey rebuildKey;
|
||||||
|
rebuildKey.mKind = CeRebuildKey::Kind_File;
|
||||||
|
rebuildKey.mString = fixedPath;
|
||||||
|
|
||||||
|
CeRebuildValue rebuildValue;
|
||||||
|
rebuildValue.mInt = timeStamp;
|
||||||
|
|
||||||
|
if (AddRebuild(rebuildKey, rebuildValue))
|
||||||
|
mCurModule->mCompiler->mRebuildFileSet.Add(fixedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8* CeContext::CeMalloc(int size)
|
uint8* CeContext::CeMalloc(int size)
|
||||||
|
@ -5243,21 +5265,7 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
if (bfpFile != NULL)
|
if (bfpFile != NULL)
|
||||||
{
|
{
|
||||||
if ((createKind == BfpFileCreateKind_OpenExisting) || (createKind == BfpFileCreateKind_OpenAlways))
|
if ((createKind == BfpFileCreateKind_OpenExisting) || (createKind == BfpFileCreateKind_OpenAlways))
|
||||||
{
|
AddFileRebuild(path);
|
||||||
auto timeStamp = BfpFile_GetTime_LastWrite(path.c_str());
|
|
||||||
if (timeStamp != 0)
|
|
||||||
{
|
|
||||||
CeRebuildKey rebuildKey;
|
|
||||||
rebuildKey.mKind = CeRebuildKey::Kind_File;
|
|
||||||
rebuildKey.mString = path;
|
|
||||||
|
|
||||||
CeRebuildValue rebuildValue;
|
|
||||||
rebuildValue.mInt = timeStamp;
|
|
||||||
|
|
||||||
AddRebuild(rebuildKey, rebuildValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CeInternalData* internalData = new CeInternalData();
|
CeInternalData* internalData = new CeInternalData();
|
||||||
internalData->mKind = CeInternalData::Kind_File;
|
internalData->mKind = CeInternalData::Kind_File;
|
||||||
internalData->mFile = bfpFile;
|
internalData->mFile = bfpFile;
|
||||||
|
@ -5351,6 +5359,7 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
addr_ce nameAddr = *(addr_ce*)((uint8*)stackPtr + 8);
|
addr_ce nameAddr = *(addr_ce*)((uint8*)stackPtr + 8);
|
||||||
String path;
|
String path;
|
||||||
CE_CHECKADDR_STR(path, nameAddr);
|
CE_CHECKADDR_STR(path, nameAddr);
|
||||||
|
AddFileRebuild(path);
|
||||||
result = BfpFile_GetTime_LastWrite(path.c_str());
|
result = BfpFile_GetTime_LastWrite(path.c_str());
|
||||||
}
|
}
|
||||||
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpFile_GetAttributes)
|
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpFile_GetAttributes)
|
||||||
|
@ -5363,7 +5372,7 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
|
|
||||||
String path;
|
String path;
|
||||||
CE_CHECKADDR_STR(path, nameAddr);
|
CE_CHECKADDR_STR(path, nameAddr);
|
||||||
|
AddFileRebuild(path);
|
||||||
result = BfpFile_GetAttributes(path.c_str(), (outResultAddr == 0) ? NULL : (BfpFileResult*)(memStart + outResultAddr));
|
result = BfpFile_GetAttributes(path.c_str(), (outResultAddr == 0) ? NULL : (BfpFileResult*)(memStart + outResultAddr));
|
||||||
}
|
}
|
||||||
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpFile_SetAttributes)
|
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpFile_SetAttributes)
|
||||||
|
@ -5425,6 +5434,7 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
|
|
||||||
String path;
|
String path;
|
||||||
CE_CHECKADDR_STR(path, nameAddr);
|
CE_CHECKADDR_STR(path, nameAddr);
|
||||||
|
AddFileRebuild(path);
|
||||||
result = BfpFile_Exists(path.c_str());
|
result = BfpFile_Exists(path.c_str());
|
||||||
}
|
}
|
||||||
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpFile_GetTempPath)
|
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpFile_GetTempPath)
|
||||||
|
@ -5551,9 +5561,12 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
addr_ce outStdOutAddr = *(addr_ce*)((uint8*)stackPtr + ptrSize + ptrSize);
|
addr_ce outStdOutAddr = *(addr_ce*)((uint8*)stackPtr + ptrSize + ptrSize);
|
||||||
addr_ce outStdErrAddr = *(addr_ce*)((uint8*)stackPtr + ptrSize + ptrSize + ptrSize);
|
addr_ce outStdErrAddr = *(addr_ce*)((uint8*)stackPtr + ptrSize + ptrSize + ptrSize);
|
||||||
|
|
||||||
CE_CHECKADDR(outStdInAddr, ptrSize);
|
if (outStdInAddr != 0)
|
||||||
CE_CHECKADDR(outStdOutAddr, ptrSize);
|
CE_CHECKADDR(outStdInAddr, ptrSize);
|
||||||
CE_CHECKADDR(outStdErrAddr, ptrSize);
|
if (outStdOutAddr != 0)
|
||||||
|
CE_CHECKADDR(outStdOutAddr, ptrSize);
|
||||||
|
if (outStdErrAddr != NULL)
|
||||||
|
CE_CHECKADDR(outStdErrAddr, ptrSize);
|
||||||
|
|
||||||
BfpFile* outStdIn = NULL;
|
BfpFile* outStdIn = NULL;
|
||||||
BfpFile* outStdOut = NULL;
|
BfpFile* outStdOut = NULL;
|
||||||
|
@ -5580,9 +5593,12 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_SetHandle(outStdInAddr, outStdIn);
|
if (outStdInAddr != NULL)
|
||||||
_SetHandle(outStdOutAddr, outStdOut);
|
_SetHandle(outStdInAddr, outStdIn);
|
||||||
_SetHandle(outStdErrAddr, outStdErr);
|
if (outStdOutAddr != NULL)
|
||||||
|
_SetHandle(outStdOutAddr, outStdOut);
|
||||||
|
if (outStdErrAddr != NULL)
|
||||||
|
_SetHandle(outStdErrAddr, outStdErr);
|
||||||
}
|
}
|
||||||
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpSpawn_Kill)
|
else if (checkFunction->mFunctionKind == CeFunctionKind_BfpSpawn_Kill)
|
||||||
{
|
{
|
||||||
|
@ -5665,19 +5681,17 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
|
||||||
|
|
||||||
auto bfpFindFileData = BfpFindFileData_FindFirstFile(path.c_str(), (BfpFindFileFlags)flags, (outResultAddr == 0) ? NULL : (BfpFileResult*)(memStart + outResultAddr));
|
auto bfpFindFileData = BfpFindFileData_FindFirstFile(path.c_str(), (BfpFindFileFlags)flags, (outResultAddr == 0) ? NULL : (BfpFileResult*)(memStart + outResultAddr));
|
||||||
if (bfpFindFileData != NULL)
|
if (bfpFindFileData != NULL)
|
||||||
{
|
{
|
||||||
// auto timeStamp = BfpFile_GetTime_LastWrite(path.c_str());
|
String dir = GetFileDir(path);
|
||||||
// if (timeStamp != 0)
|
dir = FixPathAndCase(dir);
|
||||||
// {
|
dir.Append(DIR_SEP_CHAR);
|
||||||
// CeRebuildKey rebuildKey;
|
|
||||||
// rebuildKey.mKind = CeRebuildKey::Kind_File;
|
CeRebuildKey rebuildKey;
|
||||||
// rebuildKey.mString = path;
|
rebuildKey.mKind = CeRebuildKey::Kind_Directory;
|
||||||
//
|
rebuildKey.mString = dir;
|
||||||
// CeRebuildValue rebuildValue;
|
CeRebuildValue rebuildValue;
|
||||||
// rebuildValue.mInt = timeStamp;
|
if (AddRebuild(rebuildKey, rebuildValue))
|
||||||
//
|
mCurModule->mCompiler->mRebuildFileSet.Add(dir);
|
||||||
// AddRebuild(rebuildKey, rebuildValue);
|
|
||||||
// }
|
|
||||||
|
|
||||||
CeInternalData* internalData = new CeInternalData();
|
CeInternalData* internalData = new CeInternalData();
|
||||||
internalData->mKind = CeInternalData::Kind_FindFileData;
|
internalData->mKind = CeInternalData::Kind_FindFileData;
|
||||||
|
|
|
@ -530,6 +530,7 @@ enum CeEvalFlags
|
||||||
CeEvalFlags_Cascade = 1,
|
CeEvalFlags_Cascade = 1,
|
||||||
CeEvalFlags_PersistantError = 2,
|
CeEvalFlags_PersistantError = 2,
|
||||||
CeEvalFlags_DeferIfNotOnlyError = 4,
|
CeEvalFlags_DeferIfNotOnlyError = 4,
|
||||||
|
CeEvalFlags_NoRebuild = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CeOperandKind
|
enum CeOperandKind
|
||||||
|
@ -766,7 +767,8 @@ public:
|
||||||
enum Kind
|
enum Kind
|
||||||
{
|
{
|
||||||
Kind_None,
|
Kind_None,
|
||||||
Kind_File
|
Kind_File,
|
||||||
|
Kind_Directory
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -866,7 +868,8 @@ public:
|
||||||
BfError* Fail(const StringImpl& error);
|
BfError* Fail(const StringImpl& error);
|
||||||
BfError* Fail(const CeFrame& curFrame, const StringImpl& error);
|
BfError* Fail(const CeFrame& curFrame, const StringImpl& error);
|
||||||
|
|
||||||
void AddRebuild(const CeRebuildKey& key, const CeRebuildValue& value);
|
bool AddRebuild(const CeRebuildKey& key, const CeRebuildValue& value);
|
||||||
|
void AddFileRebuild(const StringImpl& filePath);
|
||||||
uint8* CeMalloc(int size);
|
uint8* CeMalloc(int size);
|
||||||
bool CeFree(addr_ce addr);
|
bool CeFree(addr_ce addr);
|
||||||
addr_ce CeAllocArray(BfArrayType* arrayType, int count, addr_ce& elemsAddr);
|
addr_ce CeAllocArray(BfArrayType* arrayType, int count, addr_ce& elemsAddr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue