BfCompiler.bf 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Threading.Tasks;
  5. using System.Threading;
  6. using System.Diagnostics;
  7. using Beefy.widgets;
  8. using Beefy;
  9. using Beefy.utils;
  10. using IDE.Util;
  11. namespace IDE.Compiler
  12. {
  13. //public class Bf
  14. public class BfCompiler : CompilerBase
  15. {
  16. enum OptionFlags : int32
  17. {
  18. EmitDebugInfo = 1,
  19. EmitLineInfo = 2,
  20. WriteIR = 4,
  21. GenerateOBJ = 8,
  22. GenerateBitcode = 0x10,
  23. ClearLocalVars = 0x20,
  24. RuntimeChecks = 0x40,
  25. EmitDynamicCastCheck = 0x80,
  26. EnableObjectDebugFlags = 0x100,
  27. EmitObjectAccessCheck = 0x200,
  28. EnableCustodian = 0x400,
  29. EnableRealtimeLeakCheck = 0x800,
  30. EnableSideStack = 0x1000,
  31. EnableHotSwapping = 0x2000,
  32. IncrementalBuild = 0x4000,
  33. DebugAlloc = 0x8000,
  34. OmitDebugHelpers = 0x10000,
  35. NoFramePointerElim = 0x20000,
  36. }
  37. [StdCall, CLink]
  38. static extern bool BfCompiler_Compile(void* bfCompiler, void* bfPassInstance, char8* outputDirectory);
  39. [StdCall, CLink]
  40. static extern bool BfCompiler_ClearResults(void* bfCompiler);
  41. [StdCall, CLink]
  42. static extern bool BfCompiler_VerifyTypeName(void* bfCompiler, char8* typeName, int32 cursorPos);
  43. [StdCall, CLink]
  44. static extern bool BfCompiler_ClassifySource(void* bfCompiler, void* bfPassInstance, void* bfParser, void* bfResolvePassData, void* char8Data);
  45. [StdCall, CLink]
  46. static extern char8* BfCompiler_GetAutocompleteInfo(void* bfCompiler);
  47. [StdCall, CLink]
  48. static extern char8* BfCompiler_GetSymbolReferences(void* bfCompiler, void* bfPassInstance, void* bfResolvePassData);
  49. [StdCall, CLink]
  50. static extern void BfCompiler_Cancel(void* bfCompiler);
  51. [StdCall, CLink]
  52. static extern void BfCompiler_ClearCompletionPercentage(void* bfCompiler);
  53. [StdCall, CLink]
  54. static extern float BfCompiler_GetCompletionPercentage(void* bfCompiler);
  55. [StdCall, CLink]
  56. static extern int32 BfCompiler_GetCompileRevision(void* bfCompiler);
  57. [StdCall, CLink]
  58. static extern void BfCompiler_Delete(void* bfCompiler);
  59. [StdCall, CLink]
  60. static extern void BfCompiler_ClearBuildCache(void* bfCompiler);
  61. [StdCall, CLink]
  62. static extern void BfCompiler_SetBuildValue(void* bfCompiler, char8* cacheDir, char8* key, char8* value);
  63. [StdCall, CLink]
  64. static extern char8* BfCompiler_GetBuildValue(void* bfCompiler, char8* cacheDir, char8* key);
  65. [StdCall, CLink]
  66. static extern void BfCompiler_WriteBuildCache(void* bfCompiler, char8* cacheDir);
  67. [StdCall, CLink]
  68. static extern char8* BfCompiler_GetOutputFileNames(void* bfCompiler, void* bfProject, out bool hadOutputChanges);
  69. [StdCall, CLink]
  70. static extern char8* BfCompiler_GetUsedOutputFileNames(void* bfCompiler, void* bfProject, bool flushQueuedHotFiles, out bool hadOutputChanges);
  71. [StdCall, CLink]
  72. static extern char8* BfCompiler_GetTypeDefList(void* bfCompiler);
  73. [StdCall, CLink]
  74. static extern char8* BfCompiler_GetTypeDefMatches(void* bfCompiler, char8* searchStr);
  75. [StdCall, CLink]
  76. static extern char8* BfCompiler_GetTypeDefInfo(void* bfCompiler, char8* typeDefName);
  77. [StdCall, CLink]
  78. static extern void BfCompiler_SetOptions(void* bfCompiler,
  79. void* hotProject, int32 hotIdx, char8* targetTriple, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
  80. OptionFlags optionsFlags, char8* mallocName, char8* freeName);
  81. [StdCall, CLink]
  82. static extern void BfCompiler_ForceRebuild(void* bfCompiler);
  83. public enum HotTypeFlags
  84. {
  85. None = 0,
  86. UserNotUsed = 1,
  87. UserUsed = 2,
  88. Heap = 4,
  89. };
  90. [StdCall, CLink]
  91. static extern bool BfCompiler_GetHasHotPendingDataChanges(void* bfCompiler);
  92. [StdCall, CLink]
  93. static extern void BfCompiler_HotCommit(void* bfCompiler);
  94. public enum HotResolveFlags
  95. {
  96. None = 0,
  97. HadDataChanges = 1
  98. }
  99. [StdCall, CLink]
  100. static extern void BfCompiler_HotResolve_Start(void* bfCompiler, int32 flags);
  101. [StdCall, CLink]
  102. static extern void BfCompiler_HotResolve_AddActiveMethod(void* bfCompiler, char8* methodName);
  103. [StdCall, CLink]
  104. static extern void BfCompiler_HotResolve_AddDelegateMethod(void* bfCompiler, char8* methodName);
  105. [StdCall, CLink]
  106. static extern void BfCompiler_HotResolve_ReportType(void* bfCompiler, int typeId, int usageKind);
  107. [StdCall, CLink]
  108. static extern void BfCompiler_HotResolve_ReportTypeRange(void* bfCompiler, char8* typeName, int usageKind);
  109. [StdCall, CLink]
  110. static extern char8* BfCompiler_HotResolve_Finish(void* bfCompiler);
  111. class SetPassInstanceCommand : Command
  112. {
  113. public BfPassInstance mPassInstance;
  114. }
  115. class SetupProjectSettingsCommand : Command
  116. {
  117. public Project mProject;
  118. }
  119. class DeleteBfProjectCommand : Command
  120. {
  121. public BfProject mBfProject;
  122. }
  123. class RefreshViewCommand : Command
  124. {
  125. }
  126. class SetWorkspaceOptionsCommand : Command
  127. {
  128. public BfProject mHotBfProject;
  129. public int32 mHotIdx;
  130. }
  131. public void* mNativeBfCompiler;
  132. public bool mIsResolveOnly;
  133. public BfSystem mBfSystem;
  134. bool mWantsRemoveOldData;
  135. public this(void* nativeBfCompiler)
  136. {
  137. mNativeBfCompiler = nativeBfCompiler;
  138. }
  139. public ~this()
  140. {
  141. BfCompiler_Delete(mNativeBfCompiler);
  142. mNativeBfCompiler = null;
  143. }
  144. public bool Compile(BfPassInstance passInstance, String outputDirectory)
  145. {
  146. bool success = BfCompiler_Compile(mNativeBfCompiler, passInstance.mNativeBfPassInstance, outputDirectory);
  147. passInstance.mCompileSucceeded = success;
  148. passInstance.mDidCompile = true;
  149. return success;
  150. }
  151. public void ClearResults()
  152. {
  153. BfCompiler_ClearResults(mNativeBfCompiler);
  154. }
  155. public bool ClassifySource(BfPassInstance bfPassInstance, BfParser parser, BfResolvePassData resolvePassData, EditWidgetContent.CharData[] char8Data)
  156. {
  157. void* nativeResolvePassData = null;
  158. if (resolvePassData != null)
  159. nativeResolvePassData = resolvePassData.mNativeResolvePassData;
  160. EditWidgetContent.CharData* char8DataPtr = (char8Data != null) ? char8Data.CArray() : null;
  161. return BfCompiler_ClassifySource(mNativeBfCompiler, bfPassInstance.mNativeBfPassInstance, (parser != null) ? parser.mNativeBfParser : null, nativeResolvePassData, char8DataPtr);
  162. }
  163. public bool VerifyTypeName(String typeName, int cursorPos)
  164. {
  165. return BfCompiler_VerifyTypeName(mNativeBfCompiler, typeName, (.)cursorPos);
  166. }
  167. public void GetAutocompleteInfo(String outAutocompleteInfo)
  168. {
  169. char8* result = BfCompiler_GetAutocompleteInfo(mNativeBfCompiler);
  170. scope String(result).MoveTo(outAutocompleteInfo);
  171. }
  172. public void GetSymbolReferences(BfPassInstance passInstance, BfResolvePassData resolvePassData, String outSymbolReferences)
  173. {
  174. char8* result = BfCompiler_GetSymbolReferences(mNativeBfCompiler, passInstance.mNativeBfPassInstance, resolvePassData.mNativeResolvePassData);
  175. scope String(result).MoveTo(outSymbolReferences);
  176. }
  177. /*public void UpdateRenameSymbols(BfPassInstance passInstance, BfResolvePassData resolvePassData)
  178. {
  179. BfCompiler_UpdateRenameSymbols(mNativeBfCompiler, passInstance.mNativeBfPassInstance, resolvePassData.mNativeResolvePassData);
  180. }*/
  181. public void GetOutputFileNames(BfProject project, bool flushQueuedHotFiles, out bool hadOutputChanges, List<String> outFileNames)
  182. {
  183. char8* result = BfCompiler_GetUsedOutputFileNames(mNativeBfCompiler, project.mNativeBfProject, flushQueuedHotFiles, out hadOutputChanges);
  184. if (result == null)
  185. return;
  186. String fileNamesStr = scope String();
  187. fileNamesStr.Append(result);
  188. if (fileNamesStr.Length == 0)
  189. return;
  190. List<StringView> stringViews = scope List<StringView>(fileNamesStr.Split('\n'));
  191. for (var strView in stringViews)
  192. outFileNames.Add(new String(strView));
  193. }
  194. public void SetOptions(BfProject hotProject, int32 hotIdx,
  195. String targetTriple, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
  196. OptionFlags optionFlags, String mallocFuncName, String freeFuncName)
  197. {
  198. BfCompiler_SetOptions(mNativeBfCompiler,
  199. (hotProject != null) ? hotProject.mNativeBfProject : null, hotIdx,
  200. targetTriple, toolsetType, simdSetting, allocStackCount, maxWorkerThreads, optionFlags, mallocFuncName, freeFuncName);
  201. }
  202. public void ForceRebuild()
  203. {
  204. BfCompiler_ForceRebuild(mNativeBfCompiler);
  205. }
  206. public void QueueSetPassInstance(BfPassInstance passInstance)
  207. {
  208. SetPassInstanceCommand command = new SetPassInstanceCommand();
  209. command.mPassInstance = passInstance;
  210. QueueCommand(command);
  211. }
  212. public void QueueSetupProjectSettings(Project project)
  213. {
  214. SetupProjectSettingsCommand command = new SetupProjectSettingsCommand();
  215. command.mProject = project;
  216. QueueCommand(command);
  217. }
  218. public void QueueDeleteBfProject(BfProject bfProject)
  219. {
  220. DeleteBfProjectCommand command = new DeleteBfProjectCommand();
  221. command.mBfProject = bfProject;
  222. QueueCommand(command);
  223. }
  224. public void QueueRefreshViewCommand()
  225. {
  226. QueueCommand(new RefreshViewCommand());
  227. }
  228. public void QueueSetWorkspaceOptions(Project hotProject, int32 hotIdx)
  229. {
  230. BfProject hotBfProject = null;
  231. if (hotProject != null)
  232. hotBfProject = mBfSystem.GetBfProject(hotProject);
  233. var command = new SetWorkspaceOptionsCommand();
  234. command.mHotBfProject = hotBfProject;
  235. command.mHotIdx = hotIdx;
  236. QueueCommand(command);
  237. }
  238. protected override void DoProcessQueue()
  239. {
  240. BfPassInstance passInstance = null;
  241. bool didPassInstanceAlloc = false;
  242. mBfSystem.Lock(0);
  243. //Debug.WriteLine("Starting Beef Thread {0}", Thread.CurrentThread.Id);
  244. while (true)
  245. {
  246. Command command = null;
  247. using (mMonitor.Enter())
  248. {
  249. if (mCommandQueue.Count == 0)
  250. break;
  251. command = mCommandQueue[0];
  252. }
  253. if (command is SetPassInstanceCommand)
  254. {
  255. var setPassInstanceCommand = (SetPassInstanceCommand)command;
  256. passInstance = setPassInstanceCommand.mPassInstance;
  257. }
  258. else if (passInstance == null)
  259. {
  260. passInstance = mBfSystem.CreatePassInstance("ProcessQueue");
  261. didPassInstanceAlloc = true;
  262. }
  263. if (command is SetupProjectSettingsCommand)
  264. {
  265. var setupProjectSettingsCommand = (SetupProjectSettingsCommand)command;
  266. gApp.SetupBeefProjectSettings(mBfSystem, this, setupProjectSettingsCommand.mProject);
  267. }
  268. if (command is DeleteBfProjectCommand)
  269. {
  270. var deleteBfProjectCommand = (DeleteBfProjectCommand)command;
  271. deleteBfProjectCommand.mBfProject.Dispose();
  272. delete deleteBfProjectCommand.mBfProject;
  273. }
  274. if (command is ProjectSourceCommand)
  275. ProjectSourceCommandBlock:
  276. {
  277. var projectSourceCommand = (ProjectSourceCommand)command;
  278. bool worked = true;
  279. String sourceFilePath = scope String();
  280. var projectSource = projectSourceCommand.mProjectSource;
  281. if (projectSource.mIncludeKind != .Ignore)
  282. {
  283. using (projectSource.mProject.mMonitor.Enter())
  284. {
  285. projectSourceCommand.mProjectSource.GetFullImportPath(sourceFilePath);
  286. }
  287. bool canMoveSourceString = true;
  288. IdSpan char8IdData = projectSourceCommand.mSourceCharIdData;
  289. String data = projectSourceCommand.mSourceString;
  290. if (char8IdData.IsEmpty)
  291. {
  292. data = scope:ProjectSourceCommandBlock String();
  293. if (gApp.LoadTextFile(sourceFilePath, data) case .Err)
  294. data = null;
  295. if (data != null)
  296. {
  297. data.EnsureNullTerminator();
  298. char8IdData = IdSpan.GetDefault((int32)data.Length);
  299. defer:ProjectSourceCommandBlock char8IdData.Dispose();
  300. var editData = gApp.GetEditData(projectSource, false);
  301. using (gApp.mMonitor.Enter())
  302. {
  303. editData.SetSavedData(data, char8IdData);
  304. }
  305. canMoveSourceString = false;
  306. }
  307. }
  308. if (data == null)
  309. {
  310. String msg = new String();
  311. msg.AppendF("FAILED TO LOAD FILE: {0}", sourceFilePath);
  312. mQueuedOutput.Add(msg);
  313. passInstance.mFailed = true;
  314. }
  315. if ((!mIsResolveOnly) && (data != null))
  316. IDEApp.sApp.mWorkspace.ProjectSourceCompiled(projectSource, data, char8IdData, canMoveSourceString);
  317. var bfParser = mBfSystem.CreateParser(projectSourceCommand.mProjectSource);
  318. if (data != null)
  319. bfParser.SetSource(data, sourceFilePath);
  320. else
  321. bfParser.SetSource("", sourceFilePath);
  322. bfParser.SetCharIdData(ref char8IdData);
  323. worked &= bfParser.Parse(passInstance, false);
  324. worked &= bfParser.Reduce(passInstance);
  325. worked &= bfParser.BuildDefs(passInstance, null, false);
  326. // Do this to make sure we re-trigger errors in parse/reduce/builddefs
  327. if (!worked)
  328. projectSource.HasChangedSinceLastCompile = true;
  329. }
  330. }
  331. if (command is ProjectSourceRemovedCommand)
  332. {
  333. var fileRemovedCommand = (ProjectSourceRemovedCommand)command;
  334. var bfParser = mBfSystem.FileRemoved(fileRemovedCommand.mProjectSource);
  335. if (bfParser != null)
  336. {
  337. bfParser.RemoveDefs();
  338. delete bfParser;
  339. mWantsRemoveOldData = true;
  340. }
  341. }
  342. if (command is CompileCommand)
  343. {
  344. var compileCommand = (CompileCommand)command;
  345. Compile(passInstance, compileCommand.mOutputDirectory);
  346. mBfSystem.RemoveOldParsers();
  347. mBfSystem.RemoveOldData();
  348. }
  349. if (command is ResolveAllCommand)
  350. {
  351. var resolvePassData = BfResolvePassData.Create(ResolveType.Classify);
  352. // If we get canceled then try again after waiting a couple updates
  353. if (!ClassifySource(passInstance, null, resolvePassData, null))
  354. QueueDeferredResolveAll();
  355. delete resolvePassData;
  356. mBfSystem.RemoveOldParsers();
  357. mBfSystem.RemoveOldData();
  358. }
  359. if (command is SetWorkspaceOptionsCommand)
  360. {
  361. var setWorkspaceOptionsCommand = (SetWorkspaceOptionsCommand)command;
  362. var workspace = IDEApp.sApp.mWorkspace;
  363. using (workspace.mMonitor.Enter())
  364. {
  365. HandleOptions(setWorkspaceOptionsCommand.mHotBfProject, setWorkspaceOptionsCommand.mHotIdx);
  366. }
  367. }
  368. if (command is RefreshViewCommand)
  369. {
  370. mWantsActiveViewRefresh = true;
  371. }
  372. using (mMonitor.Enter())
  373. {
  374. delete command;
  375. if (!mShuttingDown)
  376. {
  377. var poppedCmd = mCommandQueue.PopFront();
  378. Debug.Assert(poppedCmd == command);
  379. }
  380. }
  381. }
  382. mBfSystem.Unlock();
  383. if (didPassInstanceAlloc)
  384. delete passInstance;
  385. }
  386. void HandleOptions(BfProject hotBfProject, int32 hotIdx)
  387. {
  388. //Debug.WriteLine("HandleOptions");
  389. var options = IDEApp.sApp.GetCurWorkspaceOptions();
  390. String targetTriple = scope .();
  391. if (TargetTriple.IsTargetTriple(gApp.mPlatformName))
  392. targetTriple.Set(gApp.mPlatformName);
  393. else
  394. Workspace.PlatformType.GetTargetTripleByName(gApp.mPlatformName, options.mToolsetType, targetTriple);
  395. bool enableObjectDebugFlags = options.mEnableObjectDebugFlags;
  396. bool emitObjectAccessCheck = options.mEmitObjectAccessCheck && enableObjectDebugFlags;
  397. OptionFlags optionFlags = default;
  398. void SetOpt(bool val, OptionFlags optionFlag)
  399. {
  400. if (val)
  401. optionFlags |= optionFlag;
  402. //Debug.WriteLine(" SetOpt {0:X} {1:X}", (int)optionFlags, (int)optionFlag);
  403. }
  404. SetOpt(options.mIncrementalBuild, .IncrementalBuild);
  405. SetOpt(options.mEmitDebugInfo == .Yes, .EmitDebugInfo);
  406. SetOpt((options.mEmitDebugInfo == .Yes) || (options.mEmitDebugInfo == .LinesOnly), .EmitLineInfo);
  407. if (gApp.mConfig_NoIR)
  408. {
  409. SetOpt(true, .GenerateOBJ);
  410. }
  411. else
  412. {
  413. SetOpt((options.mIntermediateType == .IRCode) || (options.mIntermediateType == .ObjectAndIRCode) || (options.mIntermediateType == .BitcodeAndIRCode), .WriteIR);
  414. SetOpt((options.mIntermediateType == .Object) || (options.mIntermediateType == .ObjectAndIRCode) ||
  415. (options.mIntermediateType == .Bitcode) || (options.mIntermediateType == .BitcodeAndIRCode), .GenerateOBJ);
  416. SetOpt((options.mIntermediateType == .Bitcode) || (options.mIntermediateType == .BitcodeAndIRCode), .GenerateBitcode);
  417. }
  418. SetOpt(options.mNoOmitFramePointers, .NoFramePointerElim);
  419. SetOpt(options.mInitLocalVariables, .ClearLocalVars);
  420. SetOpt(options.mRuntimeChecks, .RuntimeChecks);
  421. SetOpt(options.mEmitDynamicCastCheck, .EmitDynamicCastCheck);
  422. SetOpt(enableObjectDebugFlags, .EnableObjectDebugFlags);
  423. SetOpt(emitObjectAccessCheck, .EmitObjectAccessCheck);
  424. #if BF_PLATFORM_WINDOWS
  425. SetOpt(options.mEnableRealtimeLeakCheck, .EnableRealtimeLeakCheck);
  426. #endif
  427. SetOpt(options.mEnableSideStack, .EnableSideStack);
  428. #if !CLI
  429. SetOpt(options.mAllowHotSwapping, .EnableHotSwapping);
  430. #endif
  431. String mallocLinkName;
  432. String freeLinkName;
  433. switch (options.mAllocType)
  434. {
  435. case .Debug:
  436. optionFlags |= .DebugAlloc;
  437. mallocLinkName = "";
  438. freeLinkName = "";
  439. case .CRT:
  440. mallocLinkName = "malloc";
  441. freeLinkName = "free";
  442. case .JEMalloc:
  443. mallocLinkName = "je_malloc";
  444. freeLinkName = "je_free";
  445. case .TCMalloc:
  446. mallocLinkName = "tcmalloc";
  447. freeLinkName = "tcfree";
  448. case .Custom:
  449. mallocLinkName = options.mAllocMalloc;
  450. freeLinkName = options.mAllocFree;
  451. }
  452. //Debug.WriteLine("HandleOptions SetOptions:{0:X}", (int)optionFlags);
  453. SetOptions(hotBfProject, hotIdx,
  454. targetTriple, (int32)options.mToolsetType, (int32)options.mBfSIMDSetting, (int32)options.mAllocStackTraceDepth, (int32)gApp.mSettings.mCompilerSettings.mWorkerThreads,
  455. optionFlags, mallocLinkName, freeLinkName);
  456. if (!mIsResolveOnly)
  457. {
  458. for (let typeOption in gApp.mWorkspace.mBeefGlobalOptions.mDistinctBuildOptions)
  459. mBfSystem.AddTypeOptions(typeOption);
  460. for (let typeOption in options.mDistinctBuildOptions)
  461. mBfSystem.AddTypeOptions(typeOption);
  462. }
  463. }
  464. public override void StartQueueProcessThread()
  465. {
  466. // This causes the current view to do a full refresh every keystroke.
  467. // I think it's not needed...
  468. //mWantsActiveViewRefresh = true;
  469. base.StartQueueProcessThread();
  470. }
  471. public override void RequestCancelBackground()
  472. {
  473. if ([Friend]mThreadWorker.mThreadRunning)
  474. {
  475. if (mNativeBfCompiler != null)
  476. BfCompiler_Cancel(mNativeBfCompiler);
  477. }
  478. }
  479. public void ClearCompletionPercentage()
  480. {
  481. BfCompiler_ClearCompletionPercentage(mNativeBfCompiler);
  482. }
  483. public float GetCompletionPercentage()
  484. {
  485. return BfCompiler_GetCompletionPercentage(mNativeBfCompiler);
  486. }
  487. public int32 GetCompileRevision()
  488. {
  489. return BfCompiler_GetCompileRevision(mNativeBfCompiler);
  490. }
  491. public void GetTypeDefList(String outStr)
  492. {
  493. outStr.Append(BfCompiler_GetTypeDefList(mNativeBfCompiler));
  494. }
  495. public void GetTypeDefMatches(String searchStr, String outStr)
  496. {
  497. outStr.Append(BfCompiler_GetTypeDefMatches(mNativeBfCompiler, searchStr));
  498. }
  499. public void GetTypeDefInfo(String typeDefName, String outStr)
  500. {
  501. outStr.Append(BfCompiler_GetTypeDefInfo(mNativeBfCompiler, typeDefName));
  502. }
  503. public void ClearBuildCache()
  504. {
  505. BfCompiler_ClearBuildCache(mNativeBfCompiler);
  506. }
  507. public void SetBuildValue(String cacheDir, String key, String value)
  508. {
  509. BfCompiler_SetBuildValue(mNativeBfCompiler, cacheDir, key, value);
  510. }
  511. public void GetBuildValue(String cacheDir, String key, String outValue)
  512. {
  513. char8* cStr = BfCompiler_GetBuildValue(mNativeBfCompiler, cacheDir, key);
  514. outValue.Append(cStr);
  515. }
  516. public void WriteBuildCache(String cacheDir)
  517. {
  518. BfCompiler_WriteBuildCache(mNativeBfCompiler, cacheDir);
  519. }
  520. public bool GetHasHotPendingDataChanges()
  521. {
  522. return BfCompiler_GetHasHotPendingDataChanges(mNativeBfCompiler);
  523. }
  524. public void HotCommit()
  525. {
  526. BfCompiler_HotCommit(mNativeBfCompiler);
  527. }
  528. public void HotResolve_Start(HotResolveFlags flags)
  529. {
  530. BfCompiler_HotResolve_Start(mNativeBfCompiler, (.)flags);
  531. }
  532. public void HotResolve_AddActiveMethod(char8* methodName)
  533. {
  534. BfCompiler_HotResolve_AddActiveMethod(mNativeBfCompiler, methodName);
  535. }
  536. public void HotResolve_AddDelegateMethod(char8* methodName)
  537. {
  538. BfCompiler_HotResolve_AddDelegateMethod(mNativeBfCompiler, methodName);
  539. }
  540. public void HotResolve_ReportType(int typeId, HotTypeFlags flags)
  541. {
  542. BfCompiler_HotResolve_ReportType(mNativeBfCompiler, typeId, (int32)flags);
  543. }
  544. public void HotResolve_ReportTypeRange(char8* typeName, HotTypeFlags flags)
  545. {
  546. BfCompiler_HotResolve_ReportTypeRange(mNativeBfCompiler, typeName, (int32)flags);
  547. }
  548. public void HotResolve_Finish(String result)
  549. {
  550. char8* resultCStr = BfCompiler_HotResolve_Finish(mNativeBfCompiler);
  551. result.Append(resultCStr);
  552. }
  553. public override void Update()
  554. {
  555. base.Update();
  556. if (!ThreadRunning)
  557. {
  558. if (mWantsRemoveOldData)
  559. {
  560. mBfSystem.RemoveOldData();
  561. mWantsRemoveOldData = false;
  562. }
  563. }
  564. }
  565. }
  566. }