From 9ce89ac77dd37e0993ca8de7c6ff3815d357823a Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 12 Dec 2019 16:23:03 +0200 Subject: [PATCH 01/43] removed tester from custom-build --- _GenerateAllSetups.bat | 6 ------ 1 file changed, 6 deletions(-) diff --git a/_GenerateAllSetups.bat b/_GenerateAllSetups.bat index 1be7acccc..043075682 100644 --- a/_GenerateAllSetups.bat +++ b/_GenerateAllSetups.bat @@ -40,12 +40,6 @@ ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll @IF %ERRORLEVEL% NEQ 0 GOTO ERROR cd ..\bin -TestRunner.exe 1 -TestRunner.exe 2 -TestRunner.exe 3 -TestRunner.exe 4 -TestRunner.exe 5 -TestRunner.exe 6 cd ..\ReleaseGenerators call PascalABCNET_ALL.bat From 30d7156c29c61724161be374d9ed6548f5f8b1f0 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 06:25:48 +0300 Subject: [PATCH 02/43] uses-in fix --- CodeCompletion/CodeCompletion.cs | 2 +- CodeCompletion/DomSyntaxTreeVisitor.cs | 4 +- Compiler/Compiler.cs | 363 ++++++++---------- Compiler/PCU/PCUReader.cs | 4 +- Localization/DefaultLang.resources | Bin 93745 -> 92284 bytes TestSuite/usesunits/uses_in1.pas | 3 + TestSuite/usesunits/uses_in2.pas | 3 + .../TreeRealization/CompilerDirective.cs | 3 +- bin/Lng/Eng/CompilerErrors.dat | 1 + bin/Lng/Rus/CompilerErrors.dat | 1 + bin/Lng/Ukr/CompilerErrors.dat | 1 + 11 files changed, 166 insertions(+), 219 deletions(-) create mode 100644 TestSuite/usesunits/uses_in1.pas create mode 100644 TestSuite/usesunits/uses_in2.pas diff --git a/CodeCompletion/CodeCompletion.cs b/CodeCompletion/CodeCompletion.cs index d17c57988..36ec2f658 100644 --- a/CodeCompletion/CodeCompletion.cs +++ b/CodeCompletion/CodeCompletion.cs @@ -372,7 +372,7 @@ namespace CodeCompletion Dirs.Add(CodeCompletionController.comp.CompilerOptions.SearchDirectory); if (CodeCompletionController.StandartDirectories.ContainsKey(LibSourceDirectoryIdent)) Dirs.Add((string)CodeCompletionController.StandartDirectories[LibSourceDirectoryIdent]); - return CodeCompletionController.comp.FindSourceFileName(unit_name, Dirs.ToArray()); + return CodeCompletionController.comp.FindSourceFileNameInDirs(unit_name, Dirs.ToArray()); } public static CodeCompletionNameHelper Helper diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 489ea137a..2b7a0ee73 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -2414,7 +2414,7 @@ namespace CodeCompletion public string FindPCUFileName(string UnitName) { - return CodeCompletionController.comp.FindPCUFileNameWithoutSources(UnitName,System.IO.Path.GetDirectoryName(doc.file_name)); + return CodeCompletionController.comp.FindPCUFileName(UnitName,System.IO.Path.GetDirectoryName(doc.file_name)); } private void add_system_unit() @@ -5145,7 +5145,7 @@ namespace CodeCompletion } else { - string unit_name = CodeCompletionController.comp.FindSourceFileName(str); + string unit_name = CodeCompletionController.comp.FindSourceFileName(str, System.IO.Path.GetDirectoryName(_c_module.file_name)); if (unit_name == null) { unit_name = Path.Combine(System.IO.Path.GetDirectoryName(_c_module.file_name), str) + System.IO.Path.GetExtension(_c_module.file_name); diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index a0ee62c23..ef307b12a 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -352,6 +352,19 @@ namespace PascalABCCompiler } } + public class UsesInWrongName : CompilerCompilationError + { + public string UnitName1; + public string UnitName2; + public UsesInWrongName(string FileName, string UnitName1, string UnitName2, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_USES_IN_WRONG_NAME"), UnitName1, UnitName2), FileName) + { + this.UnitName1 = UnitName1; + this.UnitName2 = UnitName2; + this.source_context = sc; + } + } + public class SourceFileNotFound : CompilerCompilationError { public SourceFileNotFound(string FileName) @@ -958,26 +971,9 @@ namespace PascalABCCompiler } } - private Dictionary sourceFileNamesDictionary = new Dictionary(); - - public Dictionary SourceFileNamesDictionary - { - get - { - return sourceFileNamesDictionary; - } - } - - private Dictionary pcuFileNamesDictionary = new Dictionary(); - - public Dictionary PCUFileNamesDictionary - { - get - { - return pcuFileNamesDictionary; - } - } + public Dictionary, string> SourceFileNamesDictionary { get; } = new Dictionary, string>(); + public Dictionary, string> PCUFileNamesDictionary { get; } = new Dictionary, string>(); public void AddWarnings(List WarningList) { @@ -1313,7 +1309,7 @@ namespace PascalABCCompiler }*/ else { - string source_file = FindSourceFileInDirectories(s+".vb",Path.GetDirectoryName(CompilerOptions.SourceFileName),Path.Combine(this.CompilerOptions.SystemDirectory,"lib"), + string source_file = FindFileInDirs(s+".vb",Path.GetDirectoryName(CompilerOptions.SourceFileName),Path.Combine(this.CompilerOptions.SystemDirectory,"lib"), Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); if (!string.IsNullOrEmpty(source_file)) { @@ -1633,8 +1629,8 @@ namespace PascalABCCompiler parser.Dispose(); if (info != null) sources.AddRange(info.addit_project_files); - string redirect_base_fname = FindSourceFileInDirectories("__RedirectIOMode.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); - string system_unit_name = FindSourceFileInDirectories("VBSystem.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); + string redirect_base_fname = FindFileInDirs("__RedirectIOMode.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); + string system_unit_name = FindFileInDirs("VBSystem.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); string redirect_fname = Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"_RedirectIOMode.vb"); StreamReader sr = File.OpenText(redirect_base_fname); string redirect_module = sr.ReadToEnd(); @@ -1726,7 +1722,7 @@ namespace PascalABCCompiler if (info != null && info.modules.Count > 0) { comp_opt.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),PascalABCCompiler.TreeConverter.compiler_string_consts.pabc_rtl_dll_name)); - string mod_file_name = FindSourceFileInDirectories("PABCRtl.dll",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib")); + string mod_file_name = FindFileInDirs("PABCRtl.dll",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib")); File.Copy(mod_file_name,Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"PABCRtl.dll"),true); /*foreach (string mod in info.modules) { @@ -1819,12 +1815,10 @@ namespace PascalABCCompiler { PrepareCompileOptionsForProject(); } - Environment.CurrentDirectory = CompilerOptions.SourceFileDirectory; // нужно для подключения *.inc и *.resources Units = new PascalABCCompiler.TreeRealization.unit_node_list(); - CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(new SyntaxTree.string_const(CompilerOptions.SourceFileName)); + CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(null, new SyntaxTree.string_const(CompilerOptions.SourceFileName)); CompileUnit(Units, CurrentSyntaxUnit); - //Environment.CurrentDirectory = CompilerOptions.SourceFileDirectory; // 02.10.19 SunSerega: CompileUnit меняет CurrentDirectory чтоб работало относительное uses-in //Console.WriteLine(timer.ElapsedMilliseconds / 1000.0); ////// foreach (CompilationUnit CurrentUnit in UnitsToCompile) @@ -1850,7 +1844,6 @@ namespace PascalABCCompiler if (!IsPossibleNamespace(SyntaxUsesList[i], true)) { CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i]); - //Environment.CurrentDirectory = CompilerOptions.SourceFileDirectory; // 02.10.19 SunSerega: CompileUnit меняет CurrentDirectory чтоб работало относительное uses-in } else { @@ -1987,29 +1980,18 @@ namespace PascalABCCompiler ResourceFiles = new List(); List ResourceDirectives = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_resource]; foreach (TreeRealization.compiler_directive cd in ResourceDirectives) - if (!File.Exists(cd.directive)) - { - if (cd.location.doc == null) - { - ErrorsList.Add(new ResourceFileNotFound(cd.directive)); - continue; - } - - try - { - string fileName = Path.Combine(cd.location.doc.file_name, cd.directive); - if (File.Exists(fileName)) - ResourceFiles.Add(fileName); - else - ErrorsList.Add(new ResourceFileNotFound(cd.directive, cd.location)); - } - catch (Exception e) - { - ErrorsList.Add(new ResourceFileNotFound(cd.directive, cd.location)); - } - } + { + //ToDo раньше тут была проверка "d.location.doc==null", но я не вижу от чего оно может быть null + // если это что то типа ресурса в ".pabcproj" файле - надо использовать "compilerOptions.SourceFileDirectory" в качестве базового пути + // но только когда "d.location.doc==null", иначе сломаются ресурсы в модулях uses-in + var resource_fname = Path.Combine(Path.GetDirectoryName(cd.location.doc.file_name), cd.directive); + + if (File.Exists(resource_fname)) + ResourceFiles.Add(resource_fname); else - ResourceFiles.Add(cd.directive); + ErrorsList.Add(new ResourceFileNotFound(resource_fname)); + + } } string res_file = null; if (project != null) @@ -2268,7 +2250,6 @@ namespace PascalABCCompiler #endif } } - //Environment.CurrentDirectory = CompilerOptions.SourceFileDirectory; // 03.10.19 SunSerega: CompileUnit меняет CurrentDirectory чтоб работало относительное uses-in //удаляем лишние ошибки /*foreach(Error er in errorsList) @@ -2472,104 +2453,66 @@ namespace PascalABCCompiler return null; } - private string FindFileInDirectories(string FileName, params string[] Dirs) + public string FindPCUFileName(string fname, string curr_path) { - FileName = Path.GetFileName(FileName); - string temp; - foreach (string Dir in Dirs) - { - temp = Path.Combine(Dir, FileName); - if (File.Exists(temp)) - //if (!(CompilerOptions.UseDllForSystemUnits && Path.GetDirectoryName(temp) == CompilerOptions.SearchDirectory)) - return temp; - } - return null; - } - private string FindSourceFileInDirectories(string FileName, params string[] Dirs) - { - FileName = Path.GetFileName(FileName); - string temp; - foreach (string Dir in Dirs) - { - temp = Path.Combine(Dir, FileName); - if (SourceFileExists(temp)) - return temp; - } - return null; + var ext = Path.GetExtension(fname); + + if (string.IsNullOrEmpty(ext)) + fname += CompilerOptions.CompiledUnitExtension; + else if (ext != CompilerOptions.CompiledUnitExtension) + // Чтоб "uses u in 'u.pas';" видело и "u.pcu" тоже + fname = Path.ChangeExtension(fname, CompilerOptions.CompiledUnitExtension); + + if (PCUFileNamesDictionary.ContainsKey(Tuple.Create(fname,curr_path))) + return PCUFileNamesDictionary[Tuple.Create(fname, curr_path)]; + + string res = FindFileInDirs(fname, CompilerOptions.OutputDirectory, curr_path, CompilerOptions.SearchDirectory); + + PCUFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; + return res; } - public string FindPCUFileName(string UnitName) + public string FindSourceFileName(string fname, string curr_path) { - if (PCUFileNamesDictionary.ContainsKey(UnitName)) - return PCUFileNamesDictionary[UnitName]; - string fpfn = null; - fpfn = FindFileInDirectories(UnitName + CompilerOptions.CompiledUnitExtension, CompilerOptions.OutputDirectory, CompilerOptions.SourceFileDirectory, CompilerOptions.SearchDirectory); + if (SourceFileNamesDictionary.ContainsKey(Tuple.Create(fname, curr_path))) + return SourceFileNamesDictionary[Tuple.Create(fname, curr_path)]; - PCUFileNamesDictionary[UnitName] = fpfn; - return fpfn; - } + string res = FindSourceFileNameInDirs(fname, curr_path, CompilerOptions.SearchDirectory); - public string FindPCUFileNameWithoutSources(string UnitName, string FileDir) - { - return FindFileInDirectories(UnitName + CompilerOptions.CompiledUnitExtension, FileDir, CompilerOptions.OutputDirectory, CompilerOptions.SourceFileDirectory, CompilerOptions.SearchDirectory); + SourceFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; + return res; } - public string FindPCUFileName(string UnitName, string SourceFileName) + public string FindSourceFileNameInDirs(string fname, params string[] Dirs) { - if (PCUFileNamesDictionary.ContainsKey(UnitName)) - return PCUFileNamesDictionary[UnitName]; + var fname_ext = Path.GetExtension(fname); + var need_ext = string.IsNullOrEmpty(fname_ext); - string fpfn = null; - if (SourceFileName == null) - fpfn = FindPCUFileName(UnitName); - else - fpfn = FindFileInDirectories(UnitName + CompilerOptions.CompiledUnitExtension, Path.GetDirectoryName(SourceFileName)); - - PCUFileNamesDictionary[UnitName] = fpfn; - return fpfn; - } - - public string FindSourceFileName(string UnitName) - { - // Если есть в кеше, то пользуемся кешем - if (SourceFileNamesDictionary.ContainsKey(UnitName)) - return SourceFileNamesDictionary[UnitName]; - - - string d = CompilerOptions.SourceFileDirectory; - if (CurrentCompilationUnit != null && CurrentCompilationUnit.SyntaxTree != null) - d = Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name); - if (Path.GetDirectoryName(UnitName) != string.Empty) - d = Path.GetDirectoryName(UnitName); - - //string d = Environment.CurrentDirectory; // 03.10.19 SunSerega: вообще использовать Environment.CurrentDirectory всюду - говнокод, но если без него - надо очень много переписывать, проще уже всюду его использовать - - string fsfn = null; - if (d.Equals(CompilerOptions.SourceFileDirectory)) - fsfn = FindSourceFileName(UnitName, CompilerOptions.SourceFileDirectory, CompilerOptions.SearchDirectory); - else fsfn = FindSourceFileName(UnitName, d, CompilerOptions.SourceFileDirectory, CompilerOptions.SearchDirectory); - - // Кешируем исходники файлов и их полные имена - SourceFileNamesDictionary[UnitName] = fsfn; - - return fsfn; - } - - public string FindSourceFileName(string UnitName, params string[] Dirs) - { - string temp = null; foreach (SupportedSourceFile sf in SupportedSourceFiles) - { foreach (string ext in sf.Extensions) - temp = FindSourceFileInDirectories(UnitName + ext, Dirs); - if (temp != null) - //if (!(CompilerOptions.UseDllForSystemUnits && Path.GetDirectoryName(temp) == CompilerOptions.SearchDirectory)) - return temp;//.ToLower();?????? + if (need_ext || fname_ext==ext) + { + var res = FindFileInDirs(need_ext ? fname + ext : fname, Dirs); + //if (!(CompilerOptions.UseDllForSystemUnits && Path.GetDirectoryName(res) == CompilerOptions.SearchDirectory)) + if (res != null) + return res; + } + + return null; + } + + private string FindFileInDirs(string FileName, params string[] Dirs) + { + foreach (string Dir in Dirs) + { + var res = Path.Combine(Dir, FileName); + if (File.Exists(res)) + return res; } return null; } - + public static string GetReferenceFileName(string FileName) { // Вначале - кешированные стандартные dll @@ -2586,7 +2529,7 @@ namespace PascalABCCompiler } } - private string GetReferenceFileName(string FileName, SyntaxTree.SourceContext sc) + private string GetReferenceFileName(string FileName, SyntaxTree.SourceContext sc, string curr_path) { if (standart_assembly_dict.ContainsKey(FileName)) return standart_assembly_dict[FileName]; @@ -2603,14 +2546,12 @@ namespace PascalABCCompiler } //\MikhailoMMX - if (System.IO.File.Exists(FileName)) // для отладки с *.inc файлами + var FullFileName = Path.Combine(curr_path, FileName); + if (System.IO.File.Exists(FullFileName)) // для отладки с *.inc файлами { - if (FileName.IndexOf(Path.DirectorySeparatorChar) != -1) - { - File.Copy(Path.Combine(Environment.CurrentDirectory, FileName), Path.Combine(Environment.CurrentDirectory, Path.GetFileName(FileName)), true); - return Path.Combine(Environment.CurrentDirectory, Path.GetFileName(FileName)); - } - return Path.Combine(Environment.CurrentDirectory, FileName);//.ToLower();//? а надо ли tolover? + var NewFileName = Path.Combine(compilerOptions.OutputDirectory, Path.GetFileName(FullFileName)); + if (FullFileName != NewFileName) File.Copy(FullFileName, NewFileName, true); + return NewFileName; } else { @@ -2627,66 +2568,68 @@ namespace PascalABCCompiler public string GetUnitFileName(SyntaxTree.unit_or_namespace SyntaxUsesUnit) { - string PCUFileName = null; - bool PCUFileExists = false; - string SourceFileName = null; - bool SourceFileExists = false; - string UnitName = null; + //ToDo В корневом Compile() создаётся uses_unit_in без name. Выглядит как костыль + if (SyntaxUsesUnit is SyntaxTree.uses_unit_in && (SyntaxUsesUnit as SyntaxTree.uses_unit_in).name == null) return (SyntaxUsesUnit as SyntaxTree.uses_unit_in).in_file.Value; - if (SyntaxUsesUnit is SyntaxTree.uses_unit_in) + var curr_path = Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name); + + string UnitName; + string SourceFileName; + string PCUFileName; + + if (SyntaxUsesUnit is SyntaxTree.uses_unit_in uui) { - SyntaxTree.uses_unit_in uui = (SyntaxUsesUnit as SyntaxTree.uses_unit_in); - string file_ext = System.IO.Path.GetExtension(uui.in_file.Value).ToLower(); - if (file_ext == ".dll" || file_ext == ".exe") - return GetReferenceFileName(uui.in_file.Value, uui.in_file.source_context); - if (uui.name == null) - return uui.in_file.Value;//.ToLower(); - UnitName = uui.name.idents[0].name;//.ToLower(); - SourceFileName = uui.in_file.Value;//.ToLower(); - SourceFileExists = this.SourceFileExists(SourceFileName); - PCUFileName = Path.ChangeExtension(SourceFileName, CompilerOptions.CompiledUnitExtension); - PCUFileExists = File.Exists(PCUFileName); - /*if (!PCUFileExists) + + // Подключение .dll в uses-in. Зачем - не понятно, но было до меня, поэтому просто оставил + switch (Path.GetExtension(uui.in_file.Value).ToLower()) { - PCUFileName = FindPCUFileName(UnitName); - PCUFileExists = PCUFileName!=null && File.Exists(PCUFileName); - }*/ + case ".dll": + case ".exe": + return GetReferenceFileName(uui.in_file.Value, uui.in_file.source_context, curr_path); + } + + if (uui.name.idents[0].name.ToLower() != Path.GetFileNameWithoutExtension(uui.in_file.Value).ToLower()) + throw new UsesInWrongName(CurrentCompilationUnit.SyntaxTree.file_name, uui.name.idents[0].name, Path.GetFileNameWithoutExtension(uui.in_file.Value), uui.in_file.source_context); + + UnitName = uui.name.idents[0].name; + + SourceFileName = FindSourceFileName(uui.in_file.Value, curr_path); + PCUFileName = FindPCUFileName(uui.in_file.Value, curr_path); } else { - UnitName = SyntaxUsesUnit.name.idents[0].name;//.ToLower();? - SourceFileName = FindSourceFileName(UnitName); - if (SourceFileName != null ) - SourceFileExists = SourceFileName != null; - PCUFileName = FindPCUFileName(UnitName, SourceFileName); - PCUFileExists = PCUFileName != null; - if (SourceFileExists && PCUFileExists) - if (Path.GetDirectoryName(SourceFileName) != Path.GetDirectoryName(PCUFileName)) - { - PCUFileName = null; - PCUFileExists = false; - } + UnitName = SyntaxUsesUnit.name.idents[0].name; + + SourceFileName = FindSourceFileName(UnitName, curr_path); + PCUFileName = FindPCUFileName(UnitName, curr_path); + } - if (SourceFileExists && UnitTable[SourceFileName] != null) - return Path.GetFullPath(SourceFileName); - if (PCUFileExists && !SourceFileExists) - return Path.GetFullPath(PCUFileName); - if (!CompilerOptions.Rebuild && RecompileList[UnitName] == null && PCUFileExists && (File.GetLastWriteTime(PCUFileName) > SourceFileGetLastWriteTime(SourceFileName))) - return Path.GetFullPath(PCUFileName); + var SourceFileExists = SourceFileName!=null && File.Exists(SourceFileName); + var PCUFileExists = !CompilerOptions.Rebuild && PCUFileName !=null && File.Exists(PCUFileName); + if (!PCUFileExists && !SourceFileExists) + throw new UnitNotFound(SourceFileName, UnitName, SyntaxUsesUnit.source_context); - if (SourceFileExists) - return Path.GetFullPath(SourceFileName); + if (PCUFileExists && SourceFileExists) + { - //dll по uses??? странно. хотя сам же писал - string DLLFileName = Path.Combine(CompilerOptions.SourceFileDirectory, UnitName+".dll");//(string.Format("{0}\\{1}.{2}", CompilerOptions.SourceFileDirectory, UnitName, "dll")).ToLower(); - if (File.Exists(DLLFileName)) - return DLLFileName.ToLower(); - DLLFileName = get_assembly_path(UnitName + ".dll", false); - if ((DLLFileName != null) && (File.Exists(DLLFileName))) return DLLFileName; - - return UnitName; + if (CompilerOptions.Rebuild && !RecompileList.ContainsKey(UnitName)) + PCUFileExists = false; + + else if (File.GetLastWriteTime(PCUFileName) < File.GetLastWriteTime(SourceFileName)) + PCUFileExists = false; + + // На случай если есть своя версия стандартного модуля в папке с программой, но .pcu ещё не создан + else if (Path.GetDirectoryName(SourceFileName) != Path.GetDirectoryName(PCUFileName)) + PCUFileExists = false; + + } + + if (PCUFileExists) + return Path.Combine(curr_path, PCUFileName); + else + return Path.Combine(curr_path, SourceFileName); } @@ -2730,18 +2673,15 @@ namespace PascalABCCompiler PascalABCCompiler.SyntaxTree.unit_or_namespace to_add; if (Path.GetExtension(Module.Name) != "" /*&& Path.GetExtension(ModuleFileName).ToLower() != ".dll"*/) { - uses_unit_in = new SyntaxTree.uses_unit_in(); - uses_unit_in.in_file = new PascalABCCompiler.SyntaxTree.string_const(Module.Name); - uses_unit_in.name = new PascalABCCompiler.SyntaxTree.ident_list(); - uses_unit_in.name.idents.Add(new SyntaxTree.ident(ModuleName)); + uses_unit_in = new SyntaxTree.uses_unit_in( + _name: new SyntaxTree.ident_list(new SyntaxTree.ident(ModuleName)), + _in_file: new SyntaxTree.string_const(Module.Name)); //uses_unit_in.source_context = uses_unit_in.in_file.source_context = uses_unit_in.name.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1); to_add = uses_unit_in; } else { - uses_unit = new SyntaxTree.unit_or_namespace(); - uses_unit.name = new PascalABCCompiler.SyntaxTree.ident_list(); - uses_unit.name.idents.Add(new SyntaxTree.ident(ModuleName)); + uses_unit = new SyntaxTree.unit_or_namespace(new SyntaxTree.ident_list(new SyntaxTree.ident(ModuleName))); //uses_unit.source_context = uses_unit.name.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1); to_add = uses_unit; } @@ -2767,12 +2707,15 @@ namespace PascalABCCompiler string UnitName = null; try { - UnitName = GetReferenceFileName(cd.directive, sc); + // "loc == null" для стандартных .dll, как "System.dll" + //ToDo а loc.doc было null в тестранере, но я так и не понял почему. не смог воспроизвести в дебаг режиме + UnitName = GetReferenceFileName(cd.directive, sc, loc?.doc?.file_name == null ? CompilerOptions.OutputDirectory : Path.GetDirectoryName(loc.doc.file_name)); } catch (AssemblyNotFound ex) { throw; } + //ToDo плохо, пока дебажил - тут постоянно ловились другие исключения, не связанные с неправильным знаками в путик сборке catch (Exception ex) { throw new InvalidAssemblyPathError(CurrentCompilationUnit.SyntaxTree.file_name, sc); @@ -2994,8 +2937,8 @@ namespace PascalABCCompiler return false; if (name_space.name.idents.Count > 1) return true; - string src = FindSourceFileName(name_space.name.idents[0].name); - string pcu = FindPCUFileName(name_space.name.idents[0].name); + string src = FindSourceFileName(name_space.name.idents[0].name, Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); + string pcu = FindPCUFileName(name_space.name.idents[0].name, Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); if (src == null && pcu == null) return true; if (CompilerOptions.UseDllForSystemUnits && src != null && string.Compare(Path.GetDirectoryName(src), Path.Combine(CompilerOptions.SystemDirectory, "Lib"), true) == 0 @@ -3149,9 +3092,6 @@ namespace PascalABCCompiler public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, SyntaxTree.unit_or_namespace SyntaxUsesUnit) { string UnitName = GetUnitFileName(SyntaxUsesUnit); - if (!UnitName.Contains("\\")) UnitName = Path.GetFullPath(UnitName); - //Environment.CurrentDirectory = Path.GetDirectoryName(UnitName); // 02.10.19 SunSerega: Эта строчка нужна чтоб работало рекурсивное uses-in - //if (UnitName == null) throw new UnitNotFound(SyntaxUsesUnit.name, CompilationUnit CurrentUnit = UnitTable[UnitName]; if (CurrentUnit != null && CurrentUnit.SemanticTree is PascalABCCompiler.TreeRealization.dot_net_unit_node && SyntaxUsesUnit is PascalABCCompiler.SyntaxTree.uses_unit_in ui && ui.in_file != null) // значит, это пространство имен и секция in у него должна отсутствовать @@ -3159,10 +3099,9 @@ namespace PascalABCCompiler ErrorsList.Add(new NamespaceCannotHaveInSection(ui.in_file.source_context)); } - string name = Path.GetFileNameWithoutExtension(UnitName); if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) { - string sfn = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName)); + string sfn = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); if (sfn != null && UnitTable[sfn] != null) CurrentUnit = UnitTable[sfn]; } @@ -3193,7 +3132,7 @@ namespace PascalABCCompiler if (File.Exists(UnitName)) { if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); - string SourceFileName = FindSourceFileName(Path.Combine(Path.GetDirectoryName(UnitName), Path.GetFileNameWithoutExtension(UnitName))); + string SourceFileName = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); try { if ((CurrentUnit = ReadPCU(UnitName)) != null) @@ -3368,14 +3307,13 @@ namespace PascalABCCompiler { //если сначало взали pcu а потом решили его перекомпилировать, поэтому в таблице его нет if (UnitTable[CurrentSyntaxUnitNameCurrentUsesUnit] == null) - UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit = FindSourceFileName(Path.GetFileNameWithoutExtension(CurrentSyntaxUnitNameCurrentUsesUnit)); + UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit = FindSourceFileName(Path.GetFileNameWithoutExtension(CurrentSyntaxUnitNameCurrentUsesUnit), Path.GetDirectoryName(CurrentSyntaxUnitNameCurrentUsesUnit)); //далее финальная поверка на зацикливание if (UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit != null && UnitTable[UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit].State == UnitState.BeginCompilation) throw new CycleUnitReference(UnitName, SyntaxUsesList[i]); } } CompileUnit(CurrentUnit.InterfaceUsedUnits, SyntaxUsesList[i]); - //Environment.CurrentDirectory = Path.GetDirectoryName(UnitName); // 02.10.19 SunSerega: CompileUnit меняет CurrentDirectory чтоб работало относительное uses-in if (CurrentUnit.State == UnitState.Compiled) { Units.AddElement(CurrentUnit.SemanticTree); @@ -3450,7 +3388,6 @@ namespace PascalABCCompiler else { CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i]); - //Environment.CurrentDirectory = Path.GetDirectoryName(UnitName); // 02.10.19 SunSerega: CompileUnit меняет CurrentDirectory чтоб работало относительное uses-in } } else @@ -3840,8 +3777,8 @@ namespace PascalABCCompiler }*/ public bool NeedRecompiled(string name, string dir, string[] included, PCUReader pr) { - string pas_name = FindSourceFileName(Path.Combine(dir,name)); - string pcu_name = FindPCUFileName(name,pas_name); + string pas_name = FindSourceFileName(name, dir); + string pcu_name = FindPCUFileName(name, dir); if (UnitTable[pas_name] != null) return true; bool need = false; @@ -3849,8 +3786,8 @@ namespace PascalABCCompiler { //if (included[i].Contains("$")) // continue; - string pas_name2 = FindSourceFileName(Path.Combine(dir,included[i])); - string pcu_name2 = FindPCUFileName(included[i],pas_name2); + string pas_name2 = FindSourceFileName(included[i], dir); + string pcu_name2 = FindPCUFileName(included[i], dir); if (UnitTable[pas_name2] != null) return true; if (!File.Exists(pcu_name2)) @@ -3872,7 +3809,7 @@ namespace PascalABCCompiler //Console.WriteLine("{0} {1}",name,RecompileList.Count); for (int i = 0; i < included.Length; i++) { - string pcu_name2 = FindPCUFileName(included[i]); + string pcu_name2 = FindPCUFileName(included[i], dir); //TODO: Спросить у Сащи насчет < и <=. if ((File.Exists(pcu_name2) && File.GetLastWriteTime(pcu_name) < File.GetLastWriteTime(pcu_name2) && !pr.AlreadyCompiled(pcu_name2))) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index dd219069a..76a2eef75 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -330,7 +330,7 @@ namespace PascalABCCompiler.PCU { //if (pcu_file.incl_modules[i].Contains("$")) // continue; - string source_file_name = comp.FindSourceFileName(Path.Combine(dir, pcu_file.incl_modules[i])); + string source_file_name = comp.FindSourceFileName(pcu_file.incl_modules[i], dir); if (source_file_name != null && comp.UnitTable[source_file_name] != null) return true; PCUReader pr = (PCUReader)units[pcu_file.incl_modules[i]]; @@ -341,7 +341,7 @@ namespace PascalABCCompiler.PCU { used_units[pcu_file.incl_modules[i]] = used_units; if (already_compiled[pcu_file.incl_modules[i]] == null) - pr.GetCompilationUnit(comp.FindPCUFileName(pcu_file.incl_modules[i], source_file_name), this.readDebugInfo); + pr.GetCompilationUnit(comp.FindPCUFileName(pcu_file.incl_modules[i], dir), this.readDebugInfo); } if (need == false) need = pr.need; } diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index e81858615cd5a0fddc9c2fa137e6860e62ffff7b..990428e1377d3b0c72f1332d53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ef^zo$h5le%+m73TD~MxKFt*&4co>rDILrIT!vKuk2rPutN1X_%e8GK400d&u3wMK3`0Su-4|YXBSk!!fGjCowvDwg{-DP;9W!s zE@T}wt58h8_6C=&A|KaqgZp}+h=$LSPFC?#R|EgX3b%Xs37T@ekS*4wLP0^J6yR*k zfQ#)?Z}dHG?FIUUk48zJ#op4aS%QK?yIkXvA47H=KiZ)iKFo%v{vc?z&Yv%Kxn2UR zT&qbsesrU_W{G)NVwZsna$!6(FrH<$y7AeJurFr|SR^HI4&!vp97fpeIU)(pOBbK* zApQ8K<%+u*zq@RvAII^zHpA@furYXFx{d9OmOXaV;1@PXn(dM`hsst|LCDQi%VSd21f4+@te&PZ#DfJ4Vds4!QH$H(WKJJ3OO)4$o)z9-nYUTEHg!mIY!K zX8U@9$cJX`O-7rDHcY5#gLKYjFB%u`KU%u9Y?F~4HnP{Jpk zIVEBXMmbf&c#@U^GpS2>sFEe(ZPbJ=d diff --git a/TestSuite/usesunits/uses_in1.pas b/TestSuite/usesunits/uses_in1.pas new file mode 100644 index 000000000..8e3cd8270 --- /dev/null +++ b/TestSuite/usesunits/uses_in1.pas @@ -0,0 +1,3 @@ +uses u1 in 'UsesInUnits\u1.pas'; + +begin end. \ No newline at end of file diff --git a/TestSuite/usesunits/uses_in2.pas b/TestSuite/usesunits/uses_in2.pas new file mode 100644 index 000000000..3c9b0f331 --- /dev/null +++ b/TestSuite/usesunits/uses_in2.pas @@ -0,0 +1,3 @@ +uses u0 in 'UsesInUnits2\u0.pas'; + +begin end. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/CompilerDirective.cs b/TreeConverter/TreeRealization/CompilerDirective.cs index ed386b47f..abf9c1128 100644 --- a/TreeConverter/TreeRealization/CompilerDirective.cs +++ b/TreeConverter/TreeRealization/CompilerDirective.cs @@ -10,7 +10,8 @@ namespace PascalABCCompiler.TreeRealization { public string name; public string directive; - public location location; + public location location; + public compiler_directive(string name,string directive,location loc) { this.name = name; diff --git a/bin/Lng/Eng/CompilerErrors.dat b/bin/Lng/Eng/CompilerErrors.dat index ad5a5bbbc..cde250d65 100644 --- a/bin/Lng/Eng/CompilerErrors.dat +++ b/bin/Lng/Eng/CompilerErrors.dat @@ -18,6 +18,7 @@ FILE_{0}_NOT_FOUND=File '{0}' not found NAMESPACE_CAN_BE_COMPILED_ONLY_IN_PROJECTS=Files with namespaces can be compiled only inside projects NAMESPACE_CANNOT_HAVE_IN_SECTION=Namespace cannot have 'in' section APPTYPE_DLL_IS_ALLOWED_ONLY_FOR_LIBRARIES= {$apptype dll} directive is allowed only for libraries +USES_IN_WRONG_NAME=Unit name in uses-in ({0}) must be same as file name ({1}) %PREFIX%= COMPILER_INTERNAL_ERROR_IN_UNIT_{0}_:{1}=Internal compiler error in module {0} :'{1}' \ No newline at end of file diff --git a/bin/Lng/Rus/CompilerErrors.dat b/bin/Lng/Rus/CompilerErrors.dat index b62ae7ed4..0ab6b9458 100644 --- a/bin/Lng/Rus/CompilerErrors.dat +++ b/bin/Lng/Rus/CompilerErrors.dat @@ -18,6 +18,7 @@ NAMESPACE_CAN_BE_COMPILED_ONLY_IN_PROJECTS=Компиляция файлов с FILE_{0}_NOT_FOUND=Файл '{0}' не найден NAMESPACE_CANNOT_HAVE_IN_SECTION=Для пространства имен не может указываться секция in APPTYPE_DLL_IS_ALLOWED_ONLY_FOR_LIBRARIES=Директива {$apptype dll} возможна только для библиотек +USES_IN_WRONG_NAME=Имя модуля в uses-in ({0}) должно совпадать с именем файла ({1}) %PREFIX%= COMPILER_INTERNAL_ERROR_IN_UNIT_{0}_:{1}=Внутренняя ошибка компилятора в модуле {0} :'{1}' \ No newline at end of file diff --git a/bin/Lng/Ukr/CompilerErrors.dat b/bin/Lng/Ukr/CompilerErrors.dat index 2fbf70d9e..44b41dfda 100644 --- a/bin/Lng/Ukr/CompilerErrors.dat +++ b/bin/Lng/Ukr/CompilerErrors.dat @@ -16,6 +16,7 @@ MAINRESOURCE_NOT_ALLOWED=Неприпустимо сумісне викорис DUPLICATE_DIRECTIVE{0}=Повторное объявление директивы {0} FILE_{0}_NOT_FOUND=Файл '{0}' не знайдено NAMESPACE_CAN_BE_COMPILED_ONLY_IN_PROJECTS=Компиляция файлов с пространствами имен допустима только в проектах +USES_IN_WRONG_NAME=Ім'я модуля в uses-in ({0}) має збігатися з ім'ям файлу ({1}) %PREFIX%= COMPILER_INTERNAL_ERROR_IN_UNIT_{0}_:{1}=Внутрішня помилка компілятора в модулі {0} :'{1}' \ No newline at end of file From 2670546602e8442bbc544180cc2da2e34d04d4c7 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 06:59:17 +0300 Subject: [PATCH 03/43] revert "Localization/DefaultLang.resources" for compatibility --- Localization/DefaultLang.resources | Bin 92284 -> 93745 bytes TestSuite/usesunits/UsesInUnits/u1.pas | 1 + pabcnetc.sln | 567 +++++++++++++------------ 3 files changed, 293 insertions(+), 275 deletions(-) diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index 990428e1377d3b0c72f1332d53d9f36f94c1f885..e81858615cd5a0fddc9c2fa137e6860e62ffff7b 100644 GIT binary patch delta 15606 zcmcJ0d0dp`+W+S^S9B6Zc9a1H6j|I?9(7;_7?}lT25=t{QAq>^)Xd7X-A-9P)sxjJ z%eG^yZFY_=rdA#;(dx9H9FUQbWgKuVOyBQyJp-ck`@Mg?`r&%+eYy7gzOT7-w8ySr zdOYmvW?u0~-H3jgfXdbMmu$<|$b-c61WkY@ATHNt$TZH1lL~TkojQB2!&czb1Xy%t zgS5Bxw7apbU88)|M?}aEi{2@kfK02+d`)G5*_obiH0h-pZ)=;+>uI~Bb@}_r`^B(u zO@LijV33Y^&-q*}*VJAX@iCf!44XmcFgP6sbFK*qG;FAMVUUZi+9q#{M$YJ#AT;t# z-AVv!x`jn(0;&aj$uGprVe4Y<|>$h~{e%8z#+26#h{7{FmYMgcl{WB@8XCIcSrkpy_D z$7sOhp6P%UJ(mOi)H7;`Ccu_&aq82vGE6q<3)ks0t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o>2kQaAHN)`@~_L;9en#*AyU`E+8k5MUgmphF&~)1LL zWtXA?kI<;|pP*4?Fl;__Nl_*<(vSR7)PR Date: Mon, 1 Jun 2020 08:06:33 +0300 Subject: [PATCH 04/43] cleanup --- Compiler/Compiler.cs | 46 ++++++++++++-------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index ef307b12a..1f621da90 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1818,14 +1818,14 @@ namespace PascalABCCompiler Units = new PascalABCCompiler.TreeRealization.unit_node_list(); CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(null, new SyntaxTree.string_const(CompilerOptions.SourceFileName)); - CompileUnit(Units, CurrentSyntaxUnit); + CompileUnit(Units, CurrentSyntaxUnit, null); //Console.WriteLine(timer.ElapsedMilliseconds / 1000.0); ////// foreach (CompilationUnit CurrentUnit in UnitsToCompile) if (CurrentUnit.State != UnitState.Compiled) { CurrentCompilationUnit = CurrentUnit; - string UnitName = GetUnitFileName(CurrentUnit.SyntaxUnitName); + string UnitName = GetUnitFileName(CurrentUnit.SyntaxUnitName, Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); //if(CurrentUnit.State!=UnitState.InterfaceCompiled) //DEBUG //Console.WriteLine("ERROR! interface not compiled "+GetUnitFileName(CurrentUnit.SyntaxUnitName));//DEBUG System.Collections.Generic.List SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); @@ -1843,7 +1843,7 @@ namespace PascalABCCompiler for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) if (!IsPossibleNamespace(SyntaxUsesList[i], true)) { - CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i]); + CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); } else { @@ -2566,13 +2566,11 @@ namespace PascalABCCompiler } } - public string GetUnitFileName(SyntaxTree.unit_or_namespace SyntaxUsesUnit) + public string GetUnitFileName(SyntaxTree.unit_or_namespace SyntaxUsesUnit, string curr_path) { //ToDo В корневом Compile() создаётся uses_unit_in без name. Выглядит как костыль if (SyntaxUsesUnit is SyntaxTree.uses_unit_in && (SyntaxUsesUnit as SyntaxTree.uses_unit_in).name == null) return (SyntaxUsesUnit as SyntaxTree.uses_unit_in).in_file.Value; - var curr_path = Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name); - string UnitName; string SourceFileName; string PCUFileName; @@ -3049,28 +3047,6 @@ namespace PascalABCCompiler return cu; } - private bool IsAssemblyReference(SyntaxTree.unit_or_namespace SyntaxUsesUnit) - { - string UnitName = GetUnitFileName(SyntaxUsesUnit); - if (UnitName.ToLower().LastIndexOf(".dll") >= 0 || UnitName.ToLower().LastIndexOf(".exe") >= 0) - if (File.Exists(UnitName)) - return true; - return false; - } - - private CompilationUnit GetAssemblyReference(SyntaxTree.unit_or_namespace SyntaxUsesUnit) - { - string UnitName = GetUnitFileName(SyntaxUsesUnit); - if (UnitTable.Count == 0) - throw new ProgramModuleExpected(UnitName, null); - CompilationUnit res = ReadDLL(UnitName); - if (res != null) - return res; - else - //throw new DLLReadingError(UnitName); - throw new AssemblyReadingError(CurrentCompilationUnit.SyntaxTree.file_name,UnitName,SyntaxUsesUnit.source_context); - } - /*private bool check_for_library(List directives) { foreach (compiler_directive cd in directives) @@ -3089,9 +3065,11 @@ namespace PascalABCCompiler return false; } - public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, SyntaxTree.unit_or_namespace SyntaxUsesUnit) + public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) { - string UnitName = GetUnitFileName(SyntaxUsesUnit); + string UnitName = GetUnitFileName(SyntaxUsesUnit, prev_path); + var curr_path = Path.GetDirectoryName(UnitName); + CompilationUnit CurrentUnit = UnitTable[UnitName]; if (CurrentUnit != null && CurrentUnit.SemanticTree is PascalABCCompiler.TreeRealization.dot_net_unit_node && SyntaxUsesUnit is PascalABCCompiler.SyntaxTree.uses_unit_in ui && ui.in_file != null) // значит, это пространство имен и секция in у него должна отсутствовать @@ -3297,7 +3275,7 @@ namespace PascalABCCompiler } else { - string CurrentSyntaxUnitName = GetUnitFileName(SyntaxUsesList[i]); + string CurrentSyntaxUnitName = GetUnitFileName(SyntaxUsesList[i], curr_path); CurrentUnit.CurrentUsesUnit = CurrentSyntaxUnitName; if (UnitTable[CurrentSyntaxUnitName] != null) if (UnitTable[CurrentSyntaxUnitName].State == UnitState.BeginCompilation) @@ -3313,7 +3291,7 @@ namespace PascalABCCompiler throw new CycleUnitReference(UnitName, SyntaxUsesList[i]); } } - CompileUnit(CurrentUnit.InterfaceUsedUnits, SyntaxUsesList[i]); + CompileUnit(CurrentUnit.InterfaceUsedUnits, SyntaxUsesList[i], curr_path); if (CurrentUnit.State == UnitState.Compiled) { Units.AddElement(CurrentUnit.SemanticTree); @@ -3376,7 +3354,7 @@ namespace PascalABCCompiler for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) if (!IsPossibleNamespace(SyntaxUsesList[i], true)) { - cu = UnitTable[GetUnitFileName(SyntaxUsesList[i])]; + cu = UnitTable[GetUnitFileName(SyntaxUsesList[i], curr_path)]; if (cu != null && cu.State == UnitState.BeginCompilation) { UnitsToCompile.Add(cu); @@ -3387,7 +3365,7 @@ namespace PascalABCCompiler } else { - CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i]); + CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], curr_path); } } else From 3bf5ec5ff44492ed776c061fc3a86c3bdc5a243c Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 09:07:36 +0300 Subject: [PATCH 05/43] $resource cleanup --- Compiler/Compiler.cs | 30 +++++++++---------- Compiler/PCU/PCUReader.cs | 2 +- .../TreeConversion/syntax_tree_visitor.cs | 2 +- .../TreeRealization/CompilerDirective.cs | 4 ++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 1f621da90..d39f945a3 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1154,7 +1154,7 @@ namespace PascalABCCompiler System.Collections.Generic.List list = new System.Collections.Generic.List(); foreach (SyntaxTree.compiler_directive sncd in cu.compiler_directives) { - list.Add(new TreeRealization.compiler_directive(sncd.Name.text, sncd.Directive!=null?sncd.Directive.text:"", get_location_from_treenode(sncd,cu.file_name))); + list.Add(new TreeRealization.compiler_directive(sncd.Name.text, sncd.Directive!=null?sncd.Directive.text:"", get_location_from_treenode(sncd,cu.file_name), cu.file_name)); } return list; } @@ -1984,7 +1984,7 @@ namespace PascalABCCompiler //ToDo раньше тут была проверка "d.location.doc==null", но я не вижу от чего оно может быть null // если это что то типа ресурса в ".pabcproj" файле - надо использовать "compilerOptions.SourceFileDirectory" в качестве базового пути // но только когда "d.location.doc==null", иначе сломаются ресурсы в модулях uses-in - var resource_fname = Path.Combine(Path.GetDirectoryName(cd.location.doc.file_name), cd.directive); + var resource_fname = Path.Combine(Path.GetDirectoryName(cd.source_file), cd.directive); if (File.Exists(resource_fname)) ResourceFiles.Add(resource_fname); @@ -2889,23 +2889,23 @@ namespace PascalABCCompiler directives = ConvertDirectives(Unit.SyntaxTree); if (CompilerOptions.UseDllForSystemUnits) { - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PABCRtl.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\mscorlib.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Core.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Numerics.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Windows.Forms.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Drawing.dll", null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PABCRtl.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\mscorlib.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Core.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Numerics.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Windows.Forms.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Drawing.dll", null, null)); if (Unit.SyntaxTree is SyntaxTree.program_module && (Unit.SyntaxTree as SyntaxTree.program_module).used_units != null) foreach (SyntaxTree.unit_or_namespace uui in (Unit.SyntaxTree as SyntaxTree.program_module).used_units.units) { if (uui.name.ToString() == "Graph3D") { - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationFramework.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\WindowsBase.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationCore.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.Wpf.dll", null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.dll", null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationFramework.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\WindowsBase.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationCore.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.Wpf.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.dll", null, null)); } } } @@ -2923,7 +2923,7 @@ namespace PascalABCCompiler { foreach (ReferenceInfo ri in project.references) { - CompileReference(res,new TreeRealization.compiler_directive("reference",ri.full_assembly_name,null)); + CompileReference(res,new TreeRealization.compiler_directive("reference",ri.full_assembly_name,null,null)); } } return res; diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 76a2eef75..41009a1af 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -582,7 +582,7 @@ namespace PascalABCCompiler.PCU pcu_file.compiler_directives = new List(); for (int i = 0; i < num_directives; i++) { - pcu_file.compiler_directives.Add(new compiler_directive(br.ReadString(),br.ReadString(),ReadDebugInfo())); + pcu_file.compiler_directives.Add(new compiler_directive(br.ReadString(),br.ReadString(),ReadDebugInfo(), pcu_file.SourceFileName)); } int num_imp_entity = br.ReadInt32(); diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index b1bf4ff7b..21c50ad9e 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -10721,7 +10721,7 @@ namespace PascalABCCompiler.TreeConverter System.Collections.Generic.List list = new System.Collections.Generic.List(); foreach (SyntaxTree.compiler_directive sncd in cu.compiler_directives) { - list.Add(new compiler_directive(sncd.Name.text, sncd.Directive!=null?sncd.Directive.text:"", get_location(sncd))); + list.Add(new compiler_directive(sncd.Name.text, sncd.Directive!=null?sncd.Directive.text:"", get_location(sncd), cu.file_name)); } return list; } diff --git a/TreeConverter/TreeRealization/CompilerDirective.cs b/TreeConverter/TreeRealization/CompilerDirective.cs index abf9c1128..9e9916400 100644 --- a/TreeConverter/TreeRealization/CompilerDirective.cs +++ b/TreeConverter/TreeRealization/CompilerDirective.cs @@ -11,12 +11,14 @@ namespace PascalABCCompiler.TreeRealization public string name; public string directive; public location location; + public string source_file; // файл из которого загрузили директиву. в отличии от location - может указывать на .pcu - public compiler_directive(string name,string directive,location loc) + public compiler_directive(string name, string directive, location loc, string source_file) { this.name = name; this.directive = directive; this.location = loc; + this.source_file = source_file; } } } \ No newline at end of file From 2f2bf0902fdbf5a6b8ef3ccf4b2c2fc055333c79 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 09:46:05 +0300 Subject: [PATCH 06/43] comments cleanup --- Compiler/Compiler.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index d39f945a3..2e5cf150d 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1981,9 +1981,6 @@ namespace PascalABCCompiler List ResourceDirectives = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_resource]; foreach (TreeRealization.compiler_directive cd in ResourceDirectives) { - //ToDo раньше тут была проверка "d.location.doc==null", но я не вижу от чего оно может быть null - // если это что то типа ресурса в ".pabcproj" файле - надо использовать "compilerOptions.SourceFileDirectory" в качестве базового пути - // но только когда "d.location.doc==null", иначе сломаются ресурсы в модулях uses-in var resource_fname = Path.Combine(Path.GetDirectoryName(cd.source_file), cd.directive); if (File.Exists(resource_fname)) From aff14c5cc7dac057ccc5c33b5c3f790e253a182b Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 12:02:45 +0300 Subject: [PATCH 07/43] fix #2083 --- Compiler/Compiler.cs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 2e5cf150d..fc6654ebe 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -627,7 +627,7 @@ namespace PascalABCCompiler internal string outputDirectory = null; internal bool useOutputDirectory = false; //для поиска pcu во вторую очередь - //для сохранения сюда pcu и pdb файлов + //для сохранения сюда .exe, .dll и .pdb файлов public string OutputDirectory { get @@ -1835,15 +1835,15 @@ namespace PascalABCCompiler if (SyntaxUsesList != null) { for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) - if (!IsPossibleNamespace(SyntaxUsesList[i], false)) + if (!IsPossibleNamespace(SyntaxUsesList[i], false, Path.GetDirectoryName(UnitName))) { compilerOptions.UseDllForSystemUnits = false; break; } for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) - if (!IsPossibleNamespace(SyntaxUsesList[i], true)) + if (!IsPossibleNamespace(SyntaxUsesList[i], true, Path.GetDirectoryName(UnitName))) { - CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); + CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], Path.GetDirectoryName(UnitName)); } else { @@ -2814,7 +2814,7 @@ namespace PascalABCCompiler checkDuplicateUsesUnit(unit.interface_part.uses_modules.units); foreach (SyntaxTree.unit_or_namespace name_space in unit.interface_part.uses_modules.units) { - if (IsPossibleNamespace(name_space, false)) + if (IsPossibleNamespace(name_space, false, Path.GetDirectoryName(file))) { ns.referenced_units.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(name_space), get_location_from_treenode(name_space, tree.file_name))); } @@ -2926,14 +2926,14 @@ namespace PascalABCCompiler return res; } - private bool IsPossibleNamespace(SyntaxTree.unit_or_namespace name_space, bool add_to_standard_modules) + private bool IsPossibleNamespace(SyntaxTree.unit_or_namespace name_space, bool add_to_standard_modules, string curr_path) { if (name_space is SyntaxTree.uses_unit_in) return false; if (name_space.name.idents.Count > 1) return true; - string src = FindSourceFileName(name_space.name.idents[0].name, Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); - string pcu = FindPCUFileName(name_space.name.idents[0].name, Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); + string src = FindSourceFileName(name_space.name.idents[0].name, curr_path); + string pcu = FindPCUFileName(name_space.name.idents[0].name, curr_path); if (src == null && pcu == null) return true; if (CompilerOptions.UseDllForSystemUnits && src != null && string.Compare(Path.GetDirectoryName(src), Path.Combine(CompilerOptions.SystemDirectory, "Lib"), true) == 0 @@ -3065,6 +3065,8 @@ namespace PascalABCCompiler public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) { string UnitName = GetUnitFileName(SyntaxUsesUnit, prev_path); + // имя папки, в которой лежит текущий модуль + // используется для подключения модулей, $include и т.п. из модуля, подключённого с uses-in var curr_path = Path.GetDirectoryName(UnitName); CompilationUnit CurrentUnit = UnitTable[UnitName]; @@ -3251,7 +3253,7 @@ namespace PascalABCCompiler { for (int i = SyntaxUsesList.Count - 1 - CurrentUnit.InterfaceUsedUnits.Count; i >= 0; i--) { - if (!IsPossibleNamespace(SyntaxUsesList[i], false)) + if (!IsPossibleNamespace(SyntaxUsesList[i], false, curr_path)) { compilerOptions.UseDllForSystemUnits = false; break; @@ -3265,7 +3267,7 @@ namespace PascalABCCompiler for (int i = SyntaxUsesList.Count - 1 - CurrentUnit.InterfaceUsedUnits.Count; i >= 0; i--) { - if (IsPossibleNamespace(SyntaxUsesList[i], true) || namespaces.ContainsKey(SyntaxUsesList[i].name.idents[0].name)) + if (IsPossibleNamespace(SyntaxUsesList[i], true, curr_path) || namespaces.ContainsKey(SyntaxUsesList[i].name.idents[0].name)) { CurrentUnit.InterfaceUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); @@ -3349,7 +3351,7 @@ namespace PascalABCCompiler if (SyntaxUsesList != null) { for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) - if (!IsPossibleNamespace(SyntaxUsesList[i], true)) + if (!IsPossibleNamespace(SyntaxUsesList[i], true, curr_path)) { cu = UnitTable[GetUnitFileName(SyntaxUsesList[i], curr_path)]; if (cu != null && cu.State == UnitState.BeginCompilation) @@ -3514,15 +3516,12 @@ namespace PascalABCCompiler Unit.State == UnitState.Compiled) { writer = new PCUWriter(this, pr_ChangeState); + if (FileInSearchDirectory(TagertFileName)) TagertFileName = Path.ChangeExtension(TagertFileName, CompilerOptions.CompiledUnitExtension); else - { - if(CompilerOptions.useOutputDirectory) - TagertFileName = Path.Combine(CompilerOptions.OutputDirectory, Path.GetFileName(Path.ChangeExtension(TagertFileName, CompilerOptions.CompiledUnitExtension))); - else - TagertFileName = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), Path.GetFileName(Path.ChangeExtension(TagertFileName, CompilerOptions.CompiledUnitExtension))); - } + TagertFileName = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), Path.GetFileNameWithoutExtension(TagertFileName) + CompilerOptions.CompiledUnitExtension); + bool dbginfo = true;/*CompilerOptions.Debug*/ #if DEBUG dbginfo = InternalDebug.IncludeDebugInfoInPCU; From 1a51d2ad6cafdd0b59a223e357d9b39ea4c3e9c9 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 12:03:30 +0300 Subject: [PATCH 08/43] uses-in + directives tests --- TestSuite/usesunits/UsesInUnits3/1.txt | 1 + TestSuite/usesunits/UsesInUnits3/u.pas | 8 ++++++++ TestSuite/usesunits/UsesInUnits3/uui3_lib.dll | Bin 0 -> 54784 bytes TestSuite/usesunits/UsesInUnits3/uui3_lib.pas | 3 +++ TestSuite/usesunits/uses_in3_derectives.pas | 3 +++ 5 files changed, 15 insertions(+) create mode 100644 TestSuite/usesunits/UsesInUnits3/1.txt create mode 100644 TestSuite/usesunits/UsesInUnits3/u.pas create mode 100644 TestSuite/usesunits/UsesInUnits3/uui3_lib.dll create mode 100644 TestSuite/usesunits/UsesInUnits3/uui3_lib.pas create mode 100644 TestSuite/usesunits/uses_in3_derectives.pas diff --git a/TestSuite/usesunits/UsesInUnits3/1.txt b/TestSuite/usesunits/UsesInUnits3/1.txt new file mode 100644 index 000000000..f2ba8f84a --- /dev/null +++ b/TestSuite/usesunits/UsesInUnits3/1.txt @@ -0,0 +1 @@ +abc \ No newline at end of file diff --git a/TestSuite/usesunits/UsesInUnits3/u.pas b/TestSuite/usesunits/UsesInUnits3/u.pas new file mode 100644 index 000000000..1acb4397c --- /dev/null +++ b/TestSuite/usesunits/UsesInUnits3/u.pas @@ -0,0 +1,8 @@ +unit u; + +{$resource '1.txt'} +{$reference 'uui3_lib.dll'} + +begin + Assert('abc' = System.IO.StreamReader.Create(GetResourceStream('1.txt')).ReadToEnd); +end. \ No newline at end of file diff --git a/TestSuite/usesunits/UsesInUnits3/uui3_lib.dll b/TestSuite/usesunits/UsesInUnits3/uui3_lib.dll new file mode 100644 index 0000000000000000000000000000000000000000..c2f6bbe8fcb3686320437d27bc3bc35ea17e4e1e GIT binary patch literal 54784 zcmdSC3w&HvwLiYjIrBU-Ni#F)q@^jDLMT&PYFY|RN?ZCafj((cT3%_IOxuApC(I0kprBj@1p!~6paP;4MMbSzujobL3MyVvvHZSk?R{p>Op>VPXaErz8aUR1ZA0FT1S|@MU|Epv>D>K=Lm|w0>$n z+wF9c$RK^^zP+f*-E=O|d^i7Yzt^)~@sDLQ$xkzGAbRLrrDZ92mr0_@q#){G6k=u? zsr?@M-@z$Cp`KWxN#$YJ#XQU7;{X4WhfNn{_T~>IKgvb_@4+|sxg0iWJn#YVj#GLK za;BtYT03p{k?GqB&-1Ce2cd;iFl|+l))0GV*)+rVB$~qXJ}nE4q8-eBlp$XSjN}2M znGGfRo(xhh=4MgMU&9r1gDB>&;fh%h6!X`R;ySj$!;q!!;Ifp8hn1yNJgh9bILWf8 z5XHJ8D4P8vsr6(gcfxFa`114D=$#lS9*jhjk0yZzF(pQ38k)1sbe)VIQ1(vn@|h_f z>T4!q#CO6E^cV&uzDZlAxkKo7aA{JgoiNwtM$8?Y3i5!j8LY_^I*sSa;dU7+EgSd4 zrt6uGWlCReP@wrFfT$<33%>(C9%$%`OlK^conoOmGu;h2JF|?d?K**_0yQjv(pP|; zOUxRnbJ^^GEBNfp5nRQrQ`$NQy7-W__!`>hrdBGN*x(`Rt%@{P8R4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xSK_-v5a@syCHY8m?bG%J889)k+Nzp?HljtbvQ5 z7{6q|&Y_5_0%R2-OH)<@YZkGl!j9LiC~0e0K8O@TYe5T1h%4FgMv=GC#cnU!@9)6h@r&7)nzFG484Z%nH_>+C5qq|Zzc*kdZ-i?@Txt$1Qu<@v-LK9Z5pqy zH)}#BO6u#m7(GY)3BekwIZ*DbM;*M&kHXwy$QOtYe2|lCe1X`&^}w0cxTqMP z1fL6yw?ZLMhS=o>Zs(qvmh_bST~!?)cn~Q3Q4cbFoCG)tauVjm<|M+TQ6@!2=m;Xj zj^To8W@l7~I6#ax5->Vk=Vb5Y{>6~`;p_w708ywujJ_K+uuS$GlU3zMs4=UdPY|^Q z!E@jT@iySCdQgP8^L|czoFKG7EKb6l*qlU|PHd$f5dk8a@is63F62iO3H+Q3k<1lk z6aXcZO7VBhtE=nlK?%X}b{r{8(3lz?A;?}NMhriajx-=(ye&338l>angH^G?@vPCo zs%nh4iEsSx$CyD9GT|Gs!Aact!Q-k@{`zWA#|Nj0N0=D#U|0rJreX+TkI|P`0!5gP$0-%u!2Dz zrrY7zm>`3gCBdT#A2R?C$I2iTtQucmFWK?vqWaGZr-CsT&EKJr3%NOFq^8CF zb$k|t8^gklLA!ny@N1lW1L*Obc_taO$NPZ|0a+g(4-EcCq=3+4LeU^*P*nhv3i`}Y zD1`pGxcaJ~9jir%urN)+>4HePE#^Fk^-ri83g zi!?c>4RNtWh%v^_RpH>$r^y4{6Qs^Nqz~oxw;K)3^<5oz?XdW(KySD1YT-7zdlEb>|GQDcQ52i~p% zY<+;4<0BpGgRHGw_;OR#s8bS80#$T?-qFm&Wp8epvSh{$66(7=y)|APi@0hq(h9RL6T literal 0 HcmV?d00001 diff --git a/TestSuite/usesunits/UsesInUnits3/uui3_lib.pas b/TestSuite/usesunits/UsesInUnits3/uui3_lib.pas new file mode 100644 index 000000000..1a579a5cc --- /dev/null +++ b/TestSuite/usesunits/UsesInUnits3/uui3_lib.pas @@ -0,0 +1,3 @@ +library uui3_lib; + +end. \ No newline at end of file diff --git a/TestSuite/usesunits/uses_in3_derectives.pas b/TestSuite/usesunits/uses_in3_derectives.pas new file mode 100644 index 000000000..42bc7f13b --- /dev/null +++ b/TestSuite/usesunits/uses_in3_derectives.pas @@ -0,0 +1,3 @@ +uses u in 'UsesInUnits3\u'; + +begin end. \ No newline at end of file From 091b3e5a32c8b76f3ca6c35e6882269da35c31ca Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 12:15:39 +0300 Subject: [PATCH 09/43] =?UTF-8?q?$savepcu=20false=20in=20uses-in=20tests?= =?UTF-8?q?=20=D0=95=D1=81=D0=BB=D0=B8=20.pcu=20=D1=81=D1=83=D1=89=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D1=83=D0=B5=D1=82=20-=20=D0=B0=D0=BB=D0=B3?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D1=82=D0=BC=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B8?= =?UTF-8?q?=D0=BB=D1=8F=D0=B8=D0=B8=20=D1=81=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE?= =?UTF-8?q?=20=D1=83=D0=BF=D1=80=D0=BE=D1=89=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= =?UTF-8?q?=20=D0=B8=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B3=D1=83=D1=82=20=D0=BD=D0=B5=20=D0=BF=D1=80=D0=BE=D1=8F?= =?UTF-8?q?=D0=B2=D0=BB=D1=8F=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestSuite/usesunits/UsesInUnits/2/u2.pas | 2 ++ TestSuite/usesunits/UsesInUnits/u1.pas | 2 ++ TestSuite/usesunits/UsesInUnits/u3.pas | 2 ++ TestSuite/usesunits/UsesInUnits/u4.pas | 2 ++ TestSuite/usesunits/UsesInUnits2/u0.pas | 2 ++ TestSuite/usesunits/UsesInUnits2/u1.pas | 2 ++ TestSuite/usesunits/UsesInUnits2_F2/u2.pas | 2 ++ TestSuite/usesunits/UsesInUnits3/u.pas | 2 ++ 8 files changed, 16 insertions(+) diff --git a/TestSuite/usesunits/UsesInUnits/2/u2.pas b/TestSuite/usesunits/UsesInUnits/2/u2.pas index e8f55c863..1487a1530 100644 --- a/TestSuite/usesunits/UsesInUnits/2/u2.pas +++ b/TestSuite/usesunits/UsesInUnits/2/u2.pas @@ -1,3 +1,5 @@ unit u2; +{$savepcu false} + end. \ No newline at end of file diff --git a/TestSuite/usesunits/UsesInUnits/u1.pas b/TestSuite/usesunits/UsesInUnits/u1.pas index 15b7b4479..c1d13cc2f 100644 --- a/TestSuite/usesunits/UsesInUnits/u1.pas +++ b/TestSuite/usesunits/UsesInUnits/u1.pas @@ -1,5 +1,7 @@ unit u1; +{$savepcu false} + uses u2 in '2\u2.pas'; uses u3; uses u4; diff --git a/TestSuite/usesunits/UsesInUnits/u3.pas b/TestSuite/usesunits/UsesInUnits/u3.pas index d387f9d4b..7d877f394 100644 --- a/TestSuite/usesunits/UsesInUnits/u3.pas +++ b/TestSuite/usesunits/UsesInUnits/u3.pas @@ -1,3 +1,5 @@ unit u3; +{$savepcu false} + end. \ No newline at end of file diff --git a/TestSuite/usesunits/UsesInUnits/u4.pas b/TestSuite/usesunits/UsesInUnits/u4.pas index cb2311002..7ff769506 100644 --- a/TestSuite/usesunits/UsesInUnits/u4.pas +++ b/TestSuite/usesunits/UsesInUnits/u4.pas @@ -1,5 +1,7 @@ unit u4; +{$savepcu false} + {$include test.h} begin diff --git a/TestSuite/usesunits/UsesInUnits2/u0.pas b/TestSuite/usesunits/UsesInUnits2/u0.pas index 4374c4442..3d2b76bc9 100644 --- a/TestSuite/usesunits/UsesInUnits2/u0.pas +++ b/TestSuite/usesunits/UsesInUnits2/u0.pas @@ -1,5 +1,7 @@ unit u0; +{$savepcu false} + uses u1; uses u2 in '..\UsesInUnits2_F2\u2.pas'; diff --git a/TestSuite/usesunits/UsesInUnits2/u1.pas b/TestSuite/usesunits/UsesInUnits2/u1.pas index 91c7e1fa5..5c83f42c7 100644 --- a/TestSuite/usesunits/UsesInUnits2/u1.pas +++ b/TestSuite/usesunits/UsesInUnits2/u1.pas @@ -1,3 +1,5 @@ unit u1; +{$savepcu false} + end. \ No newline at end of file diff --git a/TestSuite/usesunits/UsesInUnits2_F2/u2.pas b/TestSuite/usesunits/UsesInUnits2_F2/u2.pas index e8f55c863..1487a1530 100644 --- a/TestSuite/usesunits/UsesInUnits2_F2/u2.pas +++ b/TestSuite/usesunits/UsesInUnits2_F2/u2.pas @@ -1,3 +1,5 @@ unit u2; +{$savepcu false} + end. \ No newline at end of file diff --git a/TestSuite/usesunits/UsesInUnits3/u.pas b/TestSuite/usesunits/UsesInUnits3/u.pas index 1acb4397c..be8da2841 100644 --- a/TestSuite/usesunits/UsesInUnits3/u.pas +++ b/TestSuite/usesunits/UsesInUnits3/u.pas @@ -1,5 +1,7 @@ unit u; +{$savepcu false} + {$resource '1.txt'} {$reference 'uui3_lib.dll'} From 7f73c6a24bf33f5aebaa07149e199c524d3b9978 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 1 Jun 2020 12:22:02 +0300 Subject: [PATCH 10/43] cleanup --- pabcnetc.sln | 567 +++++++++++++++++++++++++-------------------------- 1 file changed, 275 insertions(+), 292 deletions(-) diff --git a/pabcnetc.sln b/pabcnetc.sln index 90d928fc1..eb6f3a5dd 100644 --- a/pabcnetc.sln +++ b/pabcnetc.sln @@ -1,292 +1,275 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30104.148 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualPascalABCNET", "VisualPascalABCNET", "{26843C5D-9D7E-4C2C-AC14-2D227FA5592E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{F8CE2712-826B-450B-A72F-D32D80C99858}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compiler", "Compiler\Compiler.csproj", "{1E42361A-EDA3-4872-88AF-A3AAF600D36D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompilerTools", "CompilerTools\CompilerTools.csproj", "{A25D26FB-3043-4BCF-833E-E3F4C3BE795E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NETGenerator", "NETGenerator\NETGenerator.csproj", "{7FE7173B-22EB-46E5-897B-02F422662E51}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PABCNETC", "pabcnetc\PABCNETC.csproj", "{2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeConverter", "TreeConverter\TreeConverter.csproj", "{1C9C945A-586D-42A2-A06B-65D84FA7FF78}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParserTools", "ParserTools\ParserTools.csproj", "{AF2EFD7B-69DD-4B43-AF65-B59B29349C23}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Errors", "Errors\Errors.csproj", "{44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Optimizer", "Optimizer\Optimizer.csproj", "{10679470-FE1B-4193-A203-D940CF0AEA54}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Parsers", "Parsers", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNETParser", "Parsers\VBNETParser\VBNETParser.csproj", "{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Trees", "Trees", "{94EED2FF-0641-4562-8167-CBC280A733AF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTree", "SyntaxTree\SyntaxTree.csproj", "{C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticTree", "SemanticTree\SemanticTree.csproj", "{613E0DDA-AA8A-437C-AC45-507B47429FF9}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Localization", "Localization\Localization.csproj", "{2DE2842F-0912-4251-BC0F-480854C44A13}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PABCNETCclear", "pabcnetc_clear\PABCNETCclear.csproj", "{146083AD-6684-4EBC-A539-AAD749A16364}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCSaushkinParser", "Parsers\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj", "{1443F539-DCC7-4491-B4FD-B716C739DB3C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DA0402DA-D618-47B4-8BF0-2959D16F2160}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldHelpers", "Yield\YieldHelpers\YieldHelpers.csproj", "{CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTreeConverters", "SyntaxTreeConverters\SyntaxTreeConverters.csproj", "{F10A5330-DCF4-4533-877C-7B1B1BE23884}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxVisitors", "SyntaxVisitors\SyntaxVisitors.csproj", "{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldConversionSyntax", "Yield\YieldConversionSyntax\YieldConversionSyntax.csproj", "{276EE073-60F6-46D2-8811-1B8026BCAADA}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{775C9D4B-26F9-4579-8782-404970D57103}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|Mixed Platforms = Debug|Mixed Platforms - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|Mixed Platforms = Release|Mixed Platforms - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|x86.ActiveCfg = Debug|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Any CPU.Build.0 = Release|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|x86.ActiveCfg = Release|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|x86.ActiveCfg = Debug|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Any CPU.Build.0 = Release|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|x86.ActiveCfg = Release|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|x86.ActiveCfg = Debug|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Any CPU.Build.0 = Release|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|x86.ActiveCfg = Release|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|x86.ActiveCfg = Debug|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Any CPU.Build.0 = Release|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|x86.ActiveCfg = Release|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|x86.ActiveCfg = Debug|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Any CPU.Build.0 = Release|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|x86.ActiveCfg = Release|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|x86.ActiveCfg = Debug|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Any CPU.Build.0 = Release|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|x86.ActiveCfg = Release|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|x86.ActiveCfg = Debug|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Any CPU.Build.0 = Release|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|x86.ActiveCfg = Release|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|x86.ActiveCfg = Debug|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Any CPU.Build.0 = Release|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|x86.ActiveCfg = Release|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|x86.ActiveCfg = Debug|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.Build.0 = Release|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|x86.ActiveCfg = Release|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|x86.ActiveCfg = Debug|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Any CPU.Build.0 = Release|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|x86.ActiveCfg = Release|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|x86.ActiveCfg = Debug|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Any CPU.Build.0 = Release|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|x86.ActiveCfg = Release|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|x86.ActiveCfg = Debug|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Any CPU.Build.0 = Release|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|x86.ActiveCfg = Release|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Any CPU.Build.0 = Debug|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|x86.ActiveCfg = Debug|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Any CPU.ActiveCfg = Release|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Any CPU.Build.0 = Release|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {146083AD-6684-4EBC-A539-AAD749A16364}.Release|x86.ActiveCfg = Release|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|x86.ActiveCfg = Debug|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.Build.0 = Release|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.ActiveCfg = Release|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|x86.ActiveCfg = Debug|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|x86.Build.0 = Debug|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Any CPU.Build.0 = Release|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|x86.ActiveCfg = Release|Any CPU - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|x86.Build.0 = Release|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.ActiveCfg = Debug|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.Build.0 = Debug|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.Build.0 = Release|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.ActiveCfg = Release|Any CPU - {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.Build.0 = Release|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|x86.ActiveCfg = Debug|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|x86.Build.0 = Debug|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Any CPU.Build.0 = Release|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|x86.ActiveCfg = Release|Any CPU - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|x86.Build.0 = Release|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|x86.ActiveCfg = Debug|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|x86.Build.0 = Debug|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Any CPU.Build.0 = Release|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|x86.ActiveCfg = Release|Any CPU - {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|x86.Build.0 = Release|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Debug|Any CPU.Build.0 = Debug|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Debug|x86.ActiveCfg = Debug|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Debug|x86.Build.0 = Debug|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Release|Any CPU.ActiveCfg = Release|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Release|Any CPU.Build.0 = Release|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Release|x86.ActiveCfg = Release|Any CPU - {775C9D4B-26F9-4579-8782-404970D57103}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {1E42361A-EDA3-4872-88AF-A3AAF600D36D} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {A25D26FB-3043-4BCF-833E-E3F4C3BE795E} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {7FE7173B-22EB-46E5-897B-02F422662E51} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {1C9C945A-586D-42A2-A06B-65D84FA7FF78} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {AF2EFD7B-69DD-4B43-AF65-B59B29349C23} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {10679470-FE1B-4193-A203-D940CF0AEA54} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {BB6973BA-B3A2-4B31-A986-7CB008F22C4F} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F} - {94EED2FF-0641-4562-8167-CBC280A733AF} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A} = {94EED2FF-0641-4562-8167-CBC280A733AF} - {613E0DDA-AA8A-437C-AC45-507B47429FF9} = {94EED2FF-0641-4562-8167-CBC280A733AF} - {146083AD-6684-4EBC-A539-AAD749A16364} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {1443F539-DCC7-4491-B4FD-B716C739DB3C} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F} - {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {F10A5330-DCF4-4533-877C-7B1B1BE23884} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2} = {F8CE2712-826B-450B-A72F-D32D80C99858} - {276EE073-60F6-46D2-8811-1B8026BCAADA} = {F8CE2712-826B-450B-A72F-D32D80C99858} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4D1910EC-E132-4894-B869-6BF9991EA2D2} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VisualPascalABCNET", "VisualPascalABCNET", "{26843C5D-9D7E-4C2C-AC14-2D227FA5592E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{F8CE2712-826B-450B-A72F-D32D80C99858}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compiler", "Compiler\Compiler.csproj", "{1E42361A-EDA3-4872-88AF-A3AAF600D36D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompilerTools", "CompilerTools\CompilerTools.csproj", "{A25D26FB-3043-4BCF-833E-E3F4C3BE795E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NETGenerator", "NETGenerator\NETGenerator.csproj", "{7FE7173B-22EB-46E5-897B-02F422662E51}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PABCNETC", "pabcnetc\PABCNETC.csproj", "{2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeConverter", "TreeConverter\TreeConverter.csproj", "{1C9C945A-586D-42A2-A06B-65D84FA7FF78}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParserTools", "ParserTools\ParserTools.csproj", "{AF2EFD7B-69DD-4B43-AF65-B59B29349C23}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Errors", "Errors\Errors.csproj", "{44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Optimizer", "Optimizer\Optimizer.csproj", "{10679470-FE1B-4193-A203-D940CF0AEA54}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Parsers", "Parsers", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNETParser", "Parsers\VBNETParser\VBNETParser.csproj", "{1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Trees", "Trees", "{94EED2FF-0641-4562-8167-CBC280A733AF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTree", "SyntaxTree\SyntaxTree.csproj", "{C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SemanticTree", "SemanticTree\SemanticTree.csproj", "{613E0DDA-AA8A-437C-AC45-507B47429FF9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Localization", "Localization\Localization.csproj", "{2DE2842F-0912-4251-BC0F-480854C44A13}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PABCNETCclear", "pabcnetc_clear\PABCNETCclear.csproj", "{146083AD-6684-4EBC-A539-AAD749A16364}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCSaushkinParser", "Parsers\PascalABCParserNewSaushkin\PascalABCSaushkinParser.csproj", "{1443F539-DCC7-4491-B4FD-B716C739DB3C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DA0402DA-D618-47B4-8BF0-2959D16F2160}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldHelpers", "Yield\YieldHelpers\YieldHelpers.csproj", "{CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxTreeConverters", "SyntaxTreeConverters\SyntaxTreeConverters.csproj", "{F10A5330-DCF4-4533-877C-7B1B1BE23884}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SyntaxVisitors", "SyntaxVisitors\SyntaxVisitors.csproj", "{A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YieldConversionSyntax", "Yield\YieldConversionSyntax\YieldConversionSyntax.csproj", "{276EE073-60F6-46D2-8811-1B8026BCAADA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Debug|x86.ActiveCfg = Debug|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Any CPU.Build.0 = Release|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1E42361A-EDA3-4872-88AF-A3AAF600D36D}.Release|x86.ActiveCfg = Release|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Debug|x86.ActiveCfg = Debug|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Any CPU.Build.0 = Release|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E}.Release|x86.ActiveCfg = Release|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Debug|x86.ActiveCfg = Debug|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Any CPU.Build.0 = Release|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7FE7173B-22EB-46E5-897B-02F422662E51}.Release|x86.ActiveCfg = Release|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Debug|x86.ActiveCfg = Debug|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Any CPU.Build.0 = Release|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6}.Release|x86.ActiveCfg = Release|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Any CPU.Build.0 = Release|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1C9C945A-586D-42A2-A06B-65D84FA7FF78}.Release|x86.ActiveCfg = Release|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Debug|x86.ActiveCfg = Debug|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Any CPU.Build.0 = Release|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23}.Release|x86.ActiveCfg = Release|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Debug|x86.ActiveCfg = Debug|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Any CPU.Build.0 = Release|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B}.Release|x86.ActiveCfg = Release|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Debug|x86.ActiveCfg = Debug|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Any CPU.Build.0 = Release|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {10679470-FE1B-4193-A203-D940CF0AEA54}.Release|x86.ActiveCfg = Release|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Debug|x86.ActiveCfg = Debug|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Any CPU.Build.0 = Release|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE}.Release|x86.ActiveCfg = Release|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Debug|x86.ActiveCfg = Debug|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Any CPU.Build.0 = Release|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A}.Release|x86.ActiveCfg = Release|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Debug|x86.ActiveCfg = Debug|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Any CPU.Build.0 = Release|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {613E0DDA-AA8A-437C-AC45-507B47429FF9}.Release|x86.ActiveCfg = Release|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Debug|x86.ActiveCfg = Debug|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Any CPU.Build.0 = Release|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2DE2842F-0912-4251-BC0F-480854C44A13}.Release|x86.ActiveCfg = Release|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Any CPU.Build.0 = Debug|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Debug|x86.ActiveCfg = Debug|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Any CPU.ActiveCfg = Release|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Any CPU.Build.0 = Release|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {146083AD-6684-4EBC-A539-AAD749A16364}.Release|x86.ActiveCfg = Release|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Debug|x86.ActiveCfg = Debug|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Any CPU.Build.0 = Release|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {1443F539-DCC7-4491-B4FD-B716C739DB3C}.Release|x86.ActiveCfg = Release|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|x86.ActiveCfg = Debug|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Debug|x86.Build.0 = Debug|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Any CPU.Build.0 = Release|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|x86.ActiveCfg = Release|Any CPU + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09}.Release|x86.Build.0 = Release|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.ActiveCfg = Debug|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Debug|x86.Build.0 = Debug|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Any CPU.Build.0 = Release|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.ActiveCfg = Release|Any CPU + {F10A5330-DCF4-4533-877C-7B1B1BE23884}.Release|x86.Build.0 = Release|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|x86.ActiveCfg = Debug|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Debug|x86.Build.0 = Debug|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Any CPU.Build.0 = Release|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|x86.ActiveCfg = Release|Any CPU + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2}.Release|x86.Build.0 = Release|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|x86.ActiveCfg = Debug|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Debug|x86.Build.0 = Debug|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Any CPU.Build.0 = Release|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|x86.ActiveCfg = Release|Any CPU + {276EE073-60F6-46D2-8811-1B8026BCAADA}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {1E42361A-EDA3-4872-88AF-A3AAF600D36D} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {A25D26FB-3043-4BCF-833E-E3F4C3BE795E} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {7FE7173B-22EB-46E5-897B-02F422662E51} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {2AEF58A1-2BCF-4C4B-AB03-F44BBB2628E6} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {1C9C945A-586D-42A2-A06B-65D84FA7FF78} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {AF2EFD7B-69DD-4B43-AF65-B59B29349C23} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {44A01F9E-DCE7-470C-AAE5-C3DE0CCBEE3B} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {10679470-FE1B-4193-A203-D940CF0AEA54} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {BB6973BA-B3A2-4B31-A986-7CB008F22C4F} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {1D51D03C-FB74-4AB2-84B4-09EB077BEAFE} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F} + {94EED2FF-0641-4562-8167-CBC280A733AF} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {C2CAC65A-B2AE-4CCC-B067-E6B8E75DF73A} = {94EED2FF-0641-4562-8167-CBC280A733AF} + {613E0DDA-AA8A-437C-AC45-507B47429FF9} = {94EED2FF-0641-4562-8167-CBC280A733AF} + {146083AD-6684-4EBC-A539-AAD749A16364} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {1443F539-DCC7-4491-B4FD-B716C739DB3C} = {BB6973BA-B3A2-4B31-A986-7CB008F22C4F} + {CE5C55C2-A11C-4E94-A9FA-3FC6CA3E4C09} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {F10A5330-DCF4-4533-877C-7B1B1BE23884} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {A9AB4282-83B4-41A7-86C3-E5BF6A45E7E2} = {F8CE2712-826B-450B-A72F-D32D80C99858} + {276EE073-60F6-46D2-8811-1B8026BCAADA} = {F8CE2712-826B-450B-A72F-D32D80C99858} + EndGlobalSection +EndGlobal From b02c5eefdd3d98f187a2e207faea062b7e0a9693 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Tue, 2 Jun 2020 00:11:04 +0300 Subject: [PATCH 11/43] TagertFileName => TargetFileName --- Compiler/Compiler.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index fc6654ebe..442c90cc1 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -3485,7 +3485,7 @@ namespace PascalABCCompiler return unl; } - public void SavePCU(CompilationUnit Unit,string TagertFileName) + public void SavePCU(CompilationUnit Unit, string TargetFileName) { //#if DEBUG try @@ -3517,23 +3517,23 @@ namespace PascalABCCompiler { writer = new PCUWriter(this, pr_ChangeState); - if (FileInSearchDirectory(TagertFileName)) - TagertFileName = Path.ChangeExtension(TagertFileName, CompilerOptions.CompiledUnitExtension); + if (FileInSearchDirectory(TargetFileName)) + TargetFileName = Path.ChangeExtension(TargetFileName, CompilerOptions.CompiledUnitExtension); else - TagertFileName = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), Path.GetFileNameWithoutExtension(TagertFileName) + CompilerOptions.CompiledUnitExtension); + TargetFileName = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), Path.GetFileNameWithoutExtension(TargetFileName) + CompilerOptions.CompiledUnitExtension); bool dbginfo = true;/*CompilerOptions.Debug*/ #if DEBUG dbginfo = InternalDebug.IncludeDebugInfoInPCU; #endif - writer.SaveSemanticTree(Unit, TagertFileName, dbginfo); + writer.SaveSemanticTree(Unit, TargetFileName, dbginfo); } } catch (Exception err) { //ErrorsList.Add(new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err)); - OnChangeCompilerState(this, CompilerState.PCUWritingError, TagertFileName); + OnChangeCompilerState(this, CompilerState.PCUWritingError, TargetFileName); #if DEBUG if (!InternalDebug.SkipPCUErrors) throw new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err); From c4402ba563047aa0715e1fa9f5aaaee52a2e9fb9 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Wed, 10 Jun 2020 22:09:56 +0300 Subject: [PATCH 12/43] Better ResourceFileNotFound error output --- Compiler/Compiler.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 442c90cc1..d266e6e67 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1888,8 +1888,6 @@ namespace PascalABCCompiler compilerDirectives = GetCompilerDirectives(UnitsSortedList); - - TreeRealization.compiler_directive compilerDirective; if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.compiler_directive_apptype)) { string directive = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_apptype][0].directive; @@ -1986,7 +1984,7 @@ namespace PascalABCCompiler if (File.Exists(resource_fname)) ResourceFiles.Add(resource_fname); else - ErrorsList.Add(new ResourceFileNotFound(resource_fname)); + ErrorsList.Add(new ResourceFileNotFound(cd.directive, cd.location)); } } From 0332816c75f9b5ab2c7826febdbea5eef6c81c93 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Fri, 12 Jun 2020 18:13:07 +0300 Subject: [PATCH 13/43] Revert "removed tester from custom-build" This reverts commit 9ce89ac77dd37e0993ca8de7c6ff3815d357823a. --- _GenerateAllSetups.bat | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_GenerateAllSetups.bat b/_GenerateAllSetups.bat index 387d881c7..8fbbdcc34 100644 --- a/_GenerateAllSetups.bat +++ b/_GenerateAllSetups.bat @@ -40,6 +40,12 @@ ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll @IF %ERRORLEVEL% NEQ 0 GOTO ERROR cd ..\bin +TestRunner.exe 1 +TestRunner.exe 2 +TestRunner.exe 3 +TestRunner.exe 4 +TestRunner.exe 5 +TestRunner.exe 6 cd ..\ReleaseGenerators call PascalABCNET_ALL.bat From 84c83b4aaeb7993fc4837c0c3dcd6a42c8d96d4c Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 15 Jun 2020 23:01:46 +0300 Subject: [PATCH 14/43] cleanup --- Compiler/Compiler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index d266e6e67..0c6d635d3 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2602,7 +2602,7 @@ namespace PascalABCCompiler var PCUFileExists = !CompilerOptions.Rebuild && PCUFileName !=null && File.Exists(PCUFileName); if (!PCUFileExists && !SourceFileExists) - throw new UnitNotFound(SourceFileName, UnitName, SyntaxUsesUnit.source_context); + throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); if (PCUFileExists && SourceFileExists) { From 19ddeecbe559e08113dbacfa50a16d9cc820e590 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 18 Jun 2020 04:51:32 +0300 Subject: [PATCH 15/43] proper path combining --- Compiler/Compiler.cs | 21 ++++++++++++++++++--- TestSuite/usesunits/UsesInUnits4/u2.pas | 12 ++++++++++++ TestSuite/usesunits/uses_in3_cycle_uses.pas | 12 ++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 TestSuite/usesunits/UsesInUnits4/u2.pas create mode 100644 TestSuite/usesunits/uses_in3_cycle_uses.pas diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 0c6d635d3..6b5db5146 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1825,7 +1825,7 @@ namespace PascalABCCompiler if (CurrentUnit.State != UnitState.Compiled) { CurrentCompilationUnit = CurrentUnit; - string UnitName = GetUnitFileName(CurrentUnit.SyntaxUnitName, Path.GetDirectoryName(CurrentCompilationUnit.SyntaxTree.file_name)); + string UnitName = CurrentCompilationUnit.SyntaxTree.file_name; //if(CurrentUnit.State!=UnitState.InterfaceCompiled) //DEBUG //Console.WriteLine("ERROR! interface not compiled "+GetUnitFileName(CurrentUnit.SyntaxUnitName));//DEBUG System.Collections.Generic.List SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); @@ -2488,7 +2488,7 @@ namespace PascalABCCompiler foreach (string ext in sf.Extensions) if (need_ext || fname_ext==ext) { - var res = FindFileInDirs(need_ext ? fname + ext : fname, Dirs); + var res = FindFileInDirs(need_ext ? fname+ext : fname, Dirs); //if (!(CompilerOptions.UseDllForSystemUnits && Path.GetDirectoryName(res) == CompilerOptions.SearchDirectory)) if (res != null) return res; @@ -2497,11 +2497,26 @@ namespace PascalABCCompiler return null; } + private static string CombinePath(string dir, string path) + { + int i = 0; + + for (; i < path.Length && path[i] == '.' && path[i + 1] == '.'; ) + { + dir = Path.GetDirectoryName(dir); + if (string.IsNullOrEmpty(dir)) return null; + i += 2; + if (path[i] == Path.DirectorySeparatorChar || path[i] == Path.AltDirectorySeparatorChar) i += 1; + } + + return Path.Combine(dir, path.Substring(i)); + } + private string FindFileInDirs(string FileName, params string[] Dirs) { foreach (string Dir in Dirs) { - var res = Path.Combine(Dir, FileName); + var res = CombinePath(Dir, FileName); if (File.Exists(res)) return res; } diff --git a/TestSuite/usesunits/UsesInUnits4/u2.pas b/TestSuite/usesunits/UsesInUnits4/u2.pas new file mode 100644 index 000000000..8f48fbbd0 --- /dev/null +++ b/TestSuite/usesunits/UsesInUnits4/u2.pas @@ -0,0 +1,12 @@ +unit u2; +{$savepcu false} + +interface + + + +implementation + +uses uses_in3_cycle_uses in '..\uses_in3_cycle_uses'; + +end. \ No newline at end of file diff --git a/TestSuite/usesunits/uses_in3_cycle_uses.pas b/TestSuite/usesunits/uses_in3_cycle_uses.pas new file mode 100644 index 000000000..8d82d2305 --- /dev/null +++ b/TestSuite/usesunits/uses_in3_cycle_uses.pas @@ -0,0 +1,12 @@ +unit uses_in3_cycle_uses; +{$savepcu false} + +interface + +uses u2 in 'UsesInUnits4\u2'; + +implementation + + + +end. \ No newline at end of file From 3021193c3ed6fd232a07fdac98156097f61a9f22 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 18 Jun 2020 04:52:47 +0300 Subject: [PATCH 16/43] fix pascalabcnet/pascalabcnetide#179 --- CodeCompletion/DomSyntaxTreeVisitor.cs | 37 +++++--------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 2b7a0ee73..0c54b4eac 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -2612,20 +2612,9 @@ namespace CodeCompletion NamespaceScope ns_scope = null; if (i == 0) { - string unit_name = null; string pcu_unit_name = FindPCUFileName(str); - if (s is uses_unit_in) - { - string unit_in_file = (s as uses_unit_in).in_file.Value; - string unit_in_dir = null; - if (Path.IsPathRooted(unit_in_file)) - unit_in_dir = Path.GetDirectoryName(unit_in_file); - else - unit_in_dir = Path.Combine(Path.GetDirectoryName(_program_module.file_name),Path.GetDirectoryName(unit_in_file)); - unit_name = CodeCompletionNameHelper.FindSourceFileName(Path.GetFileNameWithoutExtension(unit_in_file), unit_in_dir); - } - else - unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(_program_module.file_name)); + string unit_name = CodeCompletionNameHelper.FindSourceFileName(s is uses_unit_in uui ? uui.in_file.Value : str, Path.GetDirectoryName(_program_module.file_name)); + /*if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0 && string.Compare(System.IO.Path.GetDirectoryName(_program_module.file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0) unit_name = null;*/ @@ -4353,20 +4342,9 @@ namespace CodeCompletion { try { - string unit_name = null; string pcu_unit_name = FindPCUFileName(str); - if (s is uses_unit_in) - { - string unit_in_file = (s as uses_unit_in).in_file.Value; - string unit_in_dir = null; - if (Path.IsPathRooted(unit_in_file)) - unit_in_dir = Path.GetDirectoryName(unit_in_file); - else - unit_in_dir = Path.Combine(Path.GetDirectoryName(this.cur_unit_file_name),Path.GetDirectoryName(unit_in_file)); - unit_name = CodeCompletionNameHelper.FindSourceFileName(Path.GetFileNameWithoutExtension(unit_in_file), unit_in_dir); - } - else - unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(this.cur_unit_file_name)); + string unit_name = CodeCompletionNameHelper.FindSourceFileName(s is uses_unit_in uui ? uui.in_file.Value : str, Path.GetDirectoryName(this.cur_unit_file_name)); + /*if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0 && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0) unit_name = null;*/ @@ -4486,12 +4464,9 @@ namespace CodeCompletion { try { - string unit_name = null; string pcu_unit_name = FindPCUFileName(str); - if (s is uses_unit_in) - unit_name = (s as uses_unit_in).in_file.Value; - else - unit_name = CodeCompletionNameHelper.FindSourceFileName(str, System.IO.Path.GetDirectoryName(this.cur_unit_file_name)); + string unit_name = CodeCompletionNameHelper.FindSourceFileName(s is uses_unit_in uui ? uui.in_file.Value : str, Path.GetDirectoryName(this.cur_unit_file_name)); + /*if (pcu_unit_name != null && unit_name != null && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(pcu_unit_name), true) == 0 && string.Compare(System.IO.Path.GetDirectoryName(this.cur_unit_file_name), System.IO.Path.GetDirectoryName(unit_name), true) != 0) unit_name = null;*/ From 7185f8d30bcc7193f4f27e25c0c6bbb08ddd1439 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 18 Jun 2020 18:31:46 +0300 Subject: [PATCH 17/43] cleanup for fix of #2256 --- .../TreeConversion/syntax_tree_visitor.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index dca39a1f5..bf5cf6474 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -5274,10 +5274,18 @@ namespace PascalABCCompiler.TreeConverter else { sil = exp.type.find_in_type(id_right.name, context.CurrentScope); - sil = sil.Distinct(new SymInfoComparer()).ToList(); // SSM 16/06/20 - удалил дубли для порядка - if (sil != null && sil.FirstOrDefault().sym_info != null && sil.FirstOrDefault().sym_info.semantic_node_type == semantic_node_type.wrap_def) + + if (sil != null) { - BasePCUReader.RestoreSymbols(sil, id_right.name); + // SSM 16/06/20 - удалил дубли для порядка + var sil_hs = new HashSet(new SymInfoComparer()); + sil.RemoveAll(si => !sil_hs.Add(si)); + + if (sil.FirstOrDefault().sym_info != null && sil.FirstOrDefault().sym_info.semantic_node_type == semantic_node_type.wrap_def) + { + BasePCUReader.RestoreSymbols(sil, id_right.name); + } + } } From 8e620d8a23911cf63535fc8d303a1fbd0b6b8148 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 18 Jun 2020 20:01:55 +0300 Subject: [PATCH 18/43] =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestSuite/errors/err0364_invalid_method_name.pas | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 TestSuite/errors/err0364_invalid_method_name.pas diff --git a/TestSuite/errors/err0364_invalid_method_name.pas b/TestSuite/errors/err0364_invalid_method_name.pas new file mode 100644 index 000000000..7bcc583bb --- /dev/null +++ b/TestSuite/errors/err0364_invalid_method_name.pas @@ -0,0 +1,6 @@ +type t1 = class end; + +begin + var a := new t1; + a.НеСуществующийМетод; +end. \ No newline at end of file From 38f9f21c71a47103d82e0a872de4640740c0dddd Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 22 Jun 2020 23:21:11 +0300 Subject: [PATCH 19/43] =?UTF-8?q?Revert=20"=D1=82=D0=B5=D1=81=D1=82"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 8e620d8a23911cf63535fc8d303a1fbd0b6b8148. Revert "cleanup for fix of #2256" This reverts commit 7185f8d30bcc7193f4f27e25c0c6bbb08ddd1439. --- TestSuite/errors/err0364_invalid_method_name.pas | 6 ------ .../TreeConversion/syntax_tree_visitor.cs | 14 +++----------- 2 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 TestSuite/errors/err0364_invalid_method_name.pas diff --git a/TestSuite/errors/err0364_invalid_method_name.pas b/TestSuite/errors/err0364_invalid_method_name.pas deleted file mode 100644 index 7bcc583bb..000000000 --- a/TestSuite/errors/err0364_invalid_method_name.pas +++ /dev/null @@ -1,6 +0,0 @@ -type t1 = class end; - -begin - var a := new t1; - a.НеСуществующийМетод; -end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index ee2d89729..725032014 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -5274,18 +5274,10 @@ namespace PascalABCCompiler.TreeConverter else { sil = exp.type.find_in_type(id_right.name, context.CurrentScope); - - if (sil != null) + sil = sil.Distinct(new SymInfoComparer()).ToList(); // SSM 16/06/20 - удалил дубли для порядка + if (sil != null && sil.FirstOrDefault().sym_info != null && sil.FirstOrDefault().sym_info.semantic_node_type == semantic_node_type.wrap_def) { - // SSM 16/06/20 - удалил дубли для порядка - var sil_hs = new HashSet(new SymInfoComparer()); - sil.RemoveAll(si => !sil_hs.Add(si)); - - if (sil.FirstOrDefault().sym_info != null && sil.FirstOrDefault().sym_info.semantic_node_type == semantic_node_type.wrap_def) - { - BasePCUReader.RestoreSymbols(sil, id_right.name); - } - + BasePCUReader.RestoreSymbols(sil, id_right.name); } } From 23c662a0edf2e3f306844e7dedc464a331a7e0e4 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 9 Jul 2020 05:37:07 +0300 Subject: [PATCH 20/43] cleanup --- Compiler/Compiler.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 6b5db5146..760581e22 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1816,7 +1816,7 @@ namespace PascalABCCompiler PrepareCompileOptionsForProject(); } Units = new PascalABCCompiler.TreeRealization.unit_node_list(); - CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(null, new SyntaxTree.string_const(CompilerOptions.SourceFileName)); + CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(null, new SyntaxTree.string_const(Path.GetFullPath(CompilerOptions.SourceFileName))); CompileUnit(Units, CurrentSyntaxUnit, null); @@ -2499,6 +2499,7 @@ namespace PascalABCCompiler private static string CombinePath(string dir, string path) { + if (Path.IsPathRooted(path)) return path; int i = 0; for (; i < path.Length && path[i] == '.' && path[i + 1] == '.'; ) From c2dd2d75fd6a3f26a4b96c2d4ebb7e549eb5b521 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 9 Jul 2020 05:54:55 +0300 Subject: [PATCH 21/43] reverted github's auto line break fix --- Compiler/Compiler.cs | 7690 +++++++++++++++++++++--------------------- 1 file changed, 3845 insertions(+), 3845 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index f884114d6..760581e22 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1,3845 +1,3845 @@ -// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - /*************************************************************************** - * - * Управляющий блок компилятора, алгоритм компиляции модулей - * Зависит от Errors,SyntaxTree,SemanticTree,Parsers,TreeConvertor, - * CodeGenerators - * - ***************************************************************************/ - -//TODO разобраться с ToLower()!!! - -#region algorithm -/*************************************************************************** - * Рекурсивный алгоритм компиляции модулей - * версия 1.4 - * - * CompileUnit(ИмяФайла) - * 1.CompileUnit(new СписокМодулей,ИмяФайла) - * 2.Докомпилировать модули из СписокОтложенойКомпиляции; - * - * CompileUnit(СписокМодулей,ИмяФайла) - * 1.ТекущийМодуль=ТаблицаМодулей[ИмяФайла]; - * Если (ТекущийМодуль!=0) то - * Если (ТекущийМодуль.Состояние==BeginCompilation) - * СписокМодулей.Добавить(ТекущийМодуль); - * Выход; - * иначе перейти к пункту 5 - * - * 2.Если ЭтоФайлDLL(ИмяФайла) то - * Если ((ТекущийМодуль=СчитатьDLL(ИмяФайла))!=0) то - * СписокМодулей.Добавить(ТекущийМодуль); - * ТаблицаМодулей.Добавить(ТекущийМодуль); - * Выход; - * иначе - * Ошибка("Не могу подключить сборку"); - * Выход; - * - * 3.Если ЭтоФайлPCU(ИмяФайла) то - * Если ((ТекущийМодуль=СчитатьPCU(ИмяФайла))!=0) то - * СписокМодулей.Добавить(ТекущийМодуль); - * ТаблицаМодулей.Добавить(ТекущийМодуль); - * Выход; - * иначе - * иначе перейти к пункту 4; - * - * 4.ТекущийМодуль=новыйМодуль(); - * ТекущийМодуль.СинтаксическоеДерево=Парасеры.Парсить(ИмяФайла,ТекущийМодуль.СписокОшибок); - * Если (ТекущийМодуль.СинтаксическоеДерево==0) то - * Если (ТекущийМодуль.СписокОшибок.Количество==0) то - * Ошибка("Модуль не неайден"); - * иначе - * Ошибка(ТекущийМодуль.СписокОшибок[0]); - * ТаблицаМодулей[ИмяФайла]=ТекущийМодуль; - * ТекущийМодуль.Состояние=BeginCompilation; - * - * 5.СинтаксическийСписокМодулей=ТекущийМодуль.СинтаксическоеДерево.Interface.UsesList; - * Для(i=СинтаксическийСписокМодулей.Количество-1-ТекущийМодуль.КомпилированыеВInterface.Количество;i>=0;i--) - * ТекушийМодуль.ТекущийUsesМодуль=СинтаксическийСписокМодулей[i].ИмяФайла; - * ИмяUsesФайла=СинтаксическийСписокМодулей[i].ИмяФайла; - * Если (ТаблицаМодулей[ИмяUsesФайла]!=0) - * Если (ТаблицаМодулей[ИмяUsesФайла].Состояние==BeginCompilation) - * Если (ТаблицаМодулей[ТаблицаМодулей[ИмяUsesФайла].ТекущийUsesМодуль].Состояние=BeginCompilation) - * Ошибка("Циклическая связь модулей"); - * CompileUnit(ТекущийМодуль.КомпилированыеВInterface,ИмяUsesФайла); - * Если (ТекушийМодуль.Состояние==Compiled) то - * СписокМодулей.Добавить(ТекушийМодуль); - * Выход; - * - * 6.ТекущийМодуль.СемантическоеДерево=КонверторДерева.КонвертироватьInterfaceЧасть( - * ТекущийМодуль.СинтаксическоеДерево, - * ТекущийМодуль.КомпилированыеВInterface, - * ТекущийМодуль.СписокОшибок); - * СписокМодулей.Добавить(ТекущийМодуль); - * СинтаксическийСписокМодулей=ТекущийМодуль.СинтаксическоеДерево.Implementation.UsesList; - * Для(i=СинтаксическийСписокМодулей.Количество-1;i>=0;i--) - * Если (ТаблицаМодулей[СинтаксическийСписокМодулей[i].ИмяФайла].Состояние=BeginCompilation) - * СписокОтложенойКомпиляции.Добавить(ТаблицаМодулей[СинтаксическийСписокМодулей[i].ИмяФайла]); - * иначе - * CompileUnit(ТекущийМодуль.КомпилированыеВImplementation,СинтаксическийСписокМодулей[i].ИмяФайла); - * Если(ДобавлялиХотябыОдинВСписокОтложенойКомпиляции) - * СписокОтложенойКомпиляции.Добавить(ТекущийМодуль); - * выход; - * иначе - * КонверторДерева.КонвертироватьImplementationЧасть( - * ТекущийМодуль.СинтаксическоеДерево, - * ТекущийМодуль.СемантическоеДерево, - * ТекущийМодуль.КомпилированыеВImplementation - * ТекущийМодуль.СписокОшибок); - * ТекущийМодуль.Состояние=Compiled; - * СохранитьPCU(ТекущийМодуль); - * - * - * - * [краткая верcия алгоритма компиляции модулей] - * CompileUnit(ИмяФайла) - * 1.CompileUnit(new СписокМодулей,ИмяФайла) - * 2.Докомпилировать модули из СписокОтложенойКомпиляции; - * - * CompileUnit(СписокМодулей,ИмяФайла); - * 1.Если у этого модуля откомпилирован хотябы интерфейс то - * добавить его в СписокМодулей - * выход - * 2.Если это DLL то - * считать - * добавить его в СписокМодулей - * выход - * 3.Если это PCU то - * считать - * добавить его в СписокМодулей - * выход - * 4.создать новый компилируемыйМодуль - * РаспарситьТекст(ИмяФайла) - * Состояние компилируемогоМодуля установить на BeginCompilation - * 5.Для всех модулей из Interface части компилируемогоМодуля справа налево - * Если мы уже начаинали компилировать этот модуль - * Если состояние модуля BeginCompilation - * Если состояние последнего компилируемого им модуля BeginCompilation - * ошибка("Циклическая связь модулей") - * выход - * CompileUnit(Список из Interface части компилируемогоМодуля,модуль.имя) - * Если компилируемыйМодуль.Состояние Compiled то - * добавить его в СписокМодулей - * выход - * 6.Откомпилировать Interface часть компилируемогоМодуля - * Для всех модулей из Implementation части компилируемогоМодуля справа налево - * Если состояние очередного модуля BeginCompilation то - * добавить его в список отложеной компиляции; - * иначе - * CompileUnit(Список из Implementation части компилируемогоМодуля,модуль.имя) - * Если Добавляли Хотябы Один В Список Отложеной Компиляции то - * добавить компилируемыйМодуль в список отложеной компиляции - * выход - * Откомпилировать Implementation часть компилируемогоМодуля - * Состояние компилируемогоМодуля установить на Compiled - * добавить его в СписокМодулей - * Сохранить компилируемыйМодуль в виде PCU файла на диск - * - * - * - ***************************************************************************/ -#endregion - -#define DEBUG -//#undef DEBUG - -using System; -using System.IO; -using System.Collections; -using System.Collections.Generic; -using System.Xml; - -using PascalABCCompiler.Errors; -using PascalABCCompiler.PCU; -using PascalABCCompiler.SemanticTreeConverters; -using ICSharpCode.NRefactory; -using ICSharpCode.NRefactory.Parser.VB; -using System.CodeDom.Compiler; - -//using IronPython.Hosting; -using Microsoft.Scripting.Hosting; -using Microsoft.Scripting; -using System.Reflection; -//using SyntaxTreeChanger; -using PascalABCCompiler.SyntaxTreeConverters; - - -namespace PascalABCCompiler -{ - public class CompilerCompilationError : LocatedError - { - public CompilerCompilationError(string message) - : base(message) - { - } - public CompilerCompilationError(string message, string FileName) - : base(message, FileName) - { - } - public override string ToString() - { - return Message; - } - } - - public class ReadPCUError : CompilerCompilationError - { - public ReadPCUError(string FileName) - : base(string.Format(StringResources.Get("COMPILATIONERROR_READ_PCU{0}_ERROR"),FileName)) - { - } - } - - public class NamespaceCannotHaveInSection : CompilerCompilationError - { - public NamespaceCannotHaveInSection(SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_NAMESPACE_CANNOT_HAVE_IN_SECTION"))) - { - this.source_context = sc; - } - } - - public class ProgramModuleExpected : CompilerCompilationError - { - public ProgramModuleExpected(string FileName, SyntaxTree.SourceContext sc) - : base(StringResources.Get("COMPILATIONERROR_PROGRAM_MODULE_EXPECTED"), FileName) - { - this.source_context = sc; - } - } - - public class UnitModuleExpected : CompilerCompilationError - { - public UnitModuleExpected(string FileName, SyntaxTree.SourceContext sc) - : base(StringResources.Get("COMPILATIONERROR_UNIT_MODULE_EXPECTED"), FileName) - { - this.source_context = sc; - } - } - - public class AppTypeDllIsAllowedOnlyForLibraries : CompilerCompilationError - { - public AppTypeDllIsAllowedOnlyForLibraries(string FileName, SyntaxTree.SourceContext sc) - : base(StringResources.Get("COMPILATIONERROR_APPTYPE_DLL_IS_ALLOWED_ONLY_FOR_LIBRARIES"), FileName) - { - this.source_context = sc; - } - } - - public class UnitModuleExpectedLibraryFound : CompilerCompilationError - { - public UnitModuleExpectedLibraryFound(string FileName, SyntaxTree.SourceContext sc) - : base(StringResources.Get("COMPILATIONERROR_UNIT_MODULE_EXPECTED_LIBRARY_FOUND"), FileName) - { - this.source_context = sc; - } - } - - public class AssemblyNotFound : CompilerCompilationError - { - public string AssemblyFileName; - public AssemblyNotFound(string FileName,string AssemblyFileName, SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_ASSEMBLY_{0}_NOT_FOUND"), AssemblyFileName), FileName) - { - this.AssemblyFileName = AssemblyFileName; - this.source_context = sc; - } - - } - - public class AssemblyReadingError : CompilerCompilationError - { - public string AssemblyFileName; - public AssemblyReadingError(string FileName,string AssemblyFileName, SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_ASSEMBLY_{0}_READING_ERROR"), AssemblyFileName), FileName) - { - this.AssemblyFileName = AssemblyFileName; - this.source_context = sc; - } - } - - public class InvalidAssemblyPathError : CompilerCompilationError - { - public InvalidAssemblyPathError(string FileName,SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_INVALID_ASSEMBLY_PATH")), FileName) - { - this.source_context = sc; - } - } - - public class ResourceFileNotFound : CompilerCompilationError - { - public ResourceFileNotFound(string ResFileName, TreeRealization.location sl) - : base(string.Format(StringResources.Get("COMPILATIONERROR_RESOURCEFILE_{0}_NOT_FOUND"), ResFileName), sl.doc.file_name) - { - this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num,sl.end_column_num); - } - - public ResourceFileNotFound(string ResFileName) - : base(string.Format(StringResources.Get("COMPILATIONERROR_RESOURCEFILE_{0}_NOT_FOUND"), ResFileName), null) - { - //this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num, sl.end_column_num); - } - } - - public class IncludeNamespaceInUnit: CompilerCompilationError - { - public IncludeNamespaceInUnit(string FileName, SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_INCLUDE_NAMESPACE_IN_UNIT")), FileName) - { - this.source_context = sc; - } - } - - public class NamespaceModuleExpected : CompilerCompilationError - { - public NamespaceModuleExpected(SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_NAMESPACE_MODULE_EXPECTED"))) - { - this.source_context = sc; - } - } - - public class MainResourceNotAllowed : CompilerCompilationError - { - public MainResourceNotAllowed(TreeRealization.location sl) - : base(string.Format(StringResources.Get("COMPILATIONERROR_MAINRESOURCE_NOT_ALLOWED")), sl.doc.file_name) - { - this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num, sl.end_column_num); - } - - } - - public class DuplicateUsesUnit : CompilerCompilationError - { - public string UnitName; - public DuplicateUsesUnit(string FileName, string UnitName, SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_DUPLICATE_USES_UNIT{0}"), UnitName), FileName) - { - this.UnitName = UnitName; - this.source_context = sc; - } - } - public class DuplicateDirective : CompilerCompilationError - { - public string DirectiveName; - public DuplicateDirective(string FileName, string DirectiveName, SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_DUPLICATE_DIRECTIVE{0}"), DirectiveName), FileName) - { - this.DirectiveName = DirectiveName; - this.source_context = sc; - } - } - - public class NamespacesCanBeCompiledOnlyInProjects: CompilerCompilationError - { - public NamespacesCanBeCompiledOnlyInProjects(SyntaxTree.SourceContext sc) - : base(StringResources.Get("COMPILATIONERROR_NAMESPACE_CAN_BE_COMPILED_ONLY_IN_PROJECTS")) - { - this.source_context = sc; - } - } - - public class UnitNotFound : CompilerCompilationError - { - public string UnitName; - public UnitNotFound(string FileName, string UnitName, SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_UNIT_{0}_NOT_FOUND"), UnitName), FileName) - { - this.UnitName = UnitName; - this.source_context = sc; - } - } - - public class UsesInWrongName : CompilerCompilationError - { - public string UnitName1; - public string UnitName2; - public UsesInWrongName(string FileName, string UnitName1, string UnitName2, SyntaxTree.SourceContext sc) - : base(string.Format(StringResources.Get("COMPILATIONERROR_USES_IN_WRONG_NAME"), UnitName1, UnitName2), FileName) - { - this.UnitName1 = UnitName1; - this.UnitName2 = UnitName2; - this.source_context = sc; - } - } - - public class SourceFileNotFound : CompilerCompilationError - { - public SourceFileNotFound(string FileName) - : base(string.Format(StringResources.Get("COMPILATIONERROR_SOURCE_FILE_{0}_NOT_FOUND"),FileName)) - { - } - } - - public class UnauthorizedAccessToFile : CompilerCompilationError - { - public UnauthorizedAccessToFile(string FileName) - : base(string.Format(StringResources.Get("COMPILATIONERROR_NO_ACCESS_TO_FILE{0}"),FileName)) - { - } - } - public class CycleUnitReference : CompilerCompilationError - { - public SyntaxTree.unit_or_namespace SyntaxUsesUnit; - public CycleUnitReference(string FileName, SyntaxTree.unit_or_namespace SyntaxUsesUnit) - : base(string.Format(StringResources.Get("COMPILATIONERROR_CYCLIC_UNIT_REFERENCE_WITH_UNIT_{0}"), SyntaxTree.Utils.IdentListToString(SyntaxUsesUnit.name.idents,".")), FileName) - { - this.SyntaxUsesUnit = SyntaxUsesUnit; - this.source_context = SyntaxUsesUnit.source_context; - } - } - - - public enum UnitState { BeginCompilation, InterfaceCompiled, Compiled } - - public class CompilationUnit - { - internal bool CaseSensitive = false; - public string CurrentUsesUnit; - public PascalABCCompiler.Errors.SyntaxError syntax_error; - public string UnitName; - public List ErrorList=new List(); - public bool Documented; - internal List PossibleNamespaces = new List(); - //internal List AssemblyReferences = new List(); - - //private SemanticTree.compilation_unitArrayList _interfaceUsedUnits=new SemanticTree.compilation_unitArrayList(); - - private PascalABCCompiler.TreeRealization.unit_node_list _interfaceUsedUnits = new PascalABCCompiler.TreeRealization.unit_node_list(); - public PascalABCCompiler.TreeRealization.unit_node_list InterfaceUsedUnits - { - get {return _interfaceUsedUnits;} - } - - private PascalABCCompiler.TreeRealization.unit_node_list _implementationUsedUnits = new PascalABCCompiler.TreeRealization.unit_node_list(); - public PascalABCCompiler.TreeRealization.unit_node_list ImplementationUsedUnits - { - get {return _implementationUsedUnits;} - } - - private SyntaxTree.compilation_unit _syntaxTree=null; - public SyntaxTree.compilation_unit SyntaxTree - { - get {return _syntaxTree;} - set {_syntaxTree=value;} - } - - private PascalABCCompiler.TreeRealization.unit_node _semanticTree = null; - public PascalABCCompiler.TreeRealization.unit_node SemanticTree - { - get {return _semanticTree;} - set {_semanticTree=value;} - } - - private SyntaxTree.unit_or_namespace _syntaxUnitName=null; - public SyntaxTree.unit_or_namespace SyntaxUnitName - { - get {return _syntaxUnitName;} - set {_syntaxUnitName=value;} - } - - private TreeRealization.using_namespace_list _interface_using_namespace_list = new TreeRealization.using_namespace_list(); - public TreeRealization.using_namespace_list InterfaceUsingNamespaceList - { - get { return _interface_using_namespace_list; } - set { _interface_using_namespace_list = value; } - } - - private TreeRealization.using_namespace_list _implementation_using_namespace_list = new TreeRealization.using_namespace_list(); - public TreeRealization.using_namespace_list ImplementationUsingNamespaceList - { - get { return _implementation_using_namespace_list; } - set { _implementation_using_namespace_list = value; } - } - - public UnitState State=UnitState.BeginCompilation; - } - - public class CompilationUnitHashTable:Hashtable - { - public CompilationUnitHashTable() - //DarkStar: fixed error in test_standartuses.pas at rebuild - :base(StringComparer.InvariantCultureIgnoreCase) - { - } - public CompilationUnit this [string key] - { - get - { - if (key != null) - return (base[key] as CompilationUnit); - return null; - } - set - { - base[key]=value; - } - } - } - - ///

- /// Опции компиляции - /// - //[Serializable()] - public class CompilerOptions : MarshalByRefObject - { - public enum OutputType {ClassLibrary=0, ConsoleApplicaton=1, WindowsApplication=2, PascalCompiledUnit=3, SemanticTree=4 } - - public bool Debug = false; - public bool ForDebugging = false; - public bool Rebuild = false; - public bool Optimise = false; - public bool SavePCUInThreadPull = false; - public bool RunWithEnvironment = false; - public string CompiledUnitExtension=".pcu"; - public bool ProjectCompiled = false; - public IProjectInfo CurrentProject = null; - public OutputType OutputFileType = OutputType.ConsoleApplicaton; - public bool GenerateCode = true; - public bool SaveDocumentation = true; - public bool SavePCU = true; - public bool IgnoreRtlErrors = true; - public bool Only32Bit = false; - public string Locale = "ru"; - private string sourceFileName = null; - ///имя исходного файла - ///при измененнии меняется OutputFileName,OutputDirectory,SourceFileDirectory - public string SourceFileName - { - get { return sourceFileName; } - set - { - sourceFileName = value; - OutputFileName = value; - sourceFileDirectory = Path.GetDirectoryName(value); - if (sourceFileDirectory == "") sourceFileDirectory = Environment.CurrentDirectory; - outputDirectory = SourceFileDirectory; - useOutputDirectory = false; - } - } - - - private string sourceFileDirectory = null; - public string SourceFileDirectory - { - get { return sourceFileDirectory; } - } - - private string outputFileName=null; - //имя выходного файла без расширения - //ели имя указано без пути то в качестве пути используетя OutputDirectory - public string OutputFileName - { - get - { - string FileName = outputFileName; - switch (OutputFileType) - { - case OutputType.ConsoleApplicaton: - case OutputType.WindowsApplication: FileName = FileName + ".exe"; break; - case OutputType.ClassLibrary: FileName = FileName + ".dll"; break; - case OutputType.PascalCompiledUnit: FileName = FileName + CompiledUnitExtension; break; - } - if (Path.GetDirectoryName(FileName) == "") FileName = Path.Combine(OutputDirectory, FileName); - return FileName; - } - set - { - outputFileName = Path.GetFileNameWithoutExtension(value); - } - } - - // - public string SystemDirectory; - - public string SearchDirectory; - - private bool useDllForSystemUnits = false; - - public bool UseDllForSystemUnits - { - get - { - return useDllForSystemUnits; - } - set - { - useDllForSystemUnits = value; - PascalABCCompiler.NetHelper.NetHelper.UsePABCRtl = value; - } - } - - public string[] ParserSearchPatchs; - - public enum StandartModuleAddMethod {LeftToAll, RightToMain}; - [Serializable()] - public class StandartModule : MarshalByRefObject - { - public string Name = null; - public StandartModuleAddMethod AddMethod = StandartModuleAddMethod.LeftToAll; - public SyntaxTree.LanguageId AddToLanguages = SyntaxTree.LanguageId.PascalABCNET; - public StandartModule(string Name, StandartModuleAddMethod AddMethod) - { - this.Name = Name; - this.AddMethod = AddMethod; - } - public StandartModule(string Name, StandartModuleAddMethod AddMethod, SyntaxTree.LanguageId AddToLanguages) - { - this.Name = Name; - this.AddToLanguages = AddToLanguages; - this.AddMethod = AddMethod; - } - public StandartModule(string Name) - { - this.Name = Name; - } - public StandartModule(string Name, SyntaxTree.LanguageId AddToLanguages) - { - this.AddToLanguages = AddToLanguages; - this.Name = Name; - } - } - /// - /// Module at index 0 is System module - /// - public List StandartModules; - public void RemoveStandartModule(string Name) - { - StandartModule module_to_del=null; - foreach (StandartModule module in StandartModules) - if (module.Name == Name) - { - module_to_del = module; - break; - } - if (module_to_del != null) - StandartModules.Remove(module_to_del); - } - public void RemoveStandartModuleAtIndex(int index) - { - if(index(); - StandartModules.Add(new StandartModule("PABCSystem", SyntaxTree.LanguageId.PascalABCNET | SyntaxTree.LanguageId.C)); - StandartModules.Add(new StandartModule("PABCExtensions", SyntaxTree.LanguageId.PascalABCNET | SyntaxTree.LanguageId.C)); - } - - private void SetDirectories() - { - SystemDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); - SearchDirectory = Path.Combine(SystemDirectory,"Lib"); - StandartDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase); - StandartDirectories.Add("%PABCSYSTEM%", SystemDirectory); - ParserSearchPatchs = new string[1]; - ParserSearchPatchs[0] = SearchDirectory; - } - - - public CompilerOptions() - { - SetDirectories(); - SetStandartModules(); - } - - public CompilerOptions(string SourceFileName, OutputType OutputFileType) - { - SetDirectories(); - SetStandartModules(); - this.SourceFileName = SourceFileName; - this.OutputFileType = OutputFileType; - } - - } - - public enum CompilerState - { - Ready, CompilationStarting, Reloading, ParserConnected, - BeginCompileFile, BeginParsingFile, EndParsingFile, CompileInterface, CompileImplementation, EndCompileFile, - ReadDLL, ReadPCUFile, SavePCUFile, CodeGeneration, CompilationFinished, PCUReadingError, PCUWritingError, - SemanticTreeConverterConnected, SemanticTreeConversion, SyntaxTreeConversion, SyntaxTreeConverterConnected - } - - [Serializable()] - public class CompilerInternalDebug - { - public bool CodeGeneration = true; - public bool SemanticAnalysis = true; - public bool PCUGenerate = true; - public bool AddStandartUnits = true; - public bool SkipPCUErrors = true; - public bool IncludeDebugInfoInPCU = true; - public bool AlwaysGenerateXMLDoc=false; - public bool SkipInternalErrorsIfSyntaxTreeIsCorrupt = true; - public bool UseStandarParserForIntellisense = true; - public bool RunOnMono = false; - public List DocumentedUnits=new List(); - -#if DEBUG - public bool DebugVersion - { - get { return true; } - } -#elif !DEBUG - public bool DebugVersion - { - get { return false; } - } -#endif - } - - public class SupportedSourceFile - { - private string[] extensions; - public string[] Extensions - { - get { return extensions; } - } - private string languageName; - public string LanguageName - { - get { return languageName; } - } - public SupportedSourceFile(string[] extensions, string lname) - { - this.extensions = extensions; languageName = lname; - } - public static SupportedSourceFile Make(Parsers.IParser parser) - { - List ext = new List(); - foreach (string ex in parser.FilesExtensions) - if (ex[ex.Length - 1] != Parsers.Controller.HideParserExtensionPostfixChar) - ext.Add(ex); - if (ext.Count > 0) - return new SupportedSourceFile(ext.ToArray(), parser.Name); - return null; - } - public override string ToString() - { - return string.Format("{0} ({1})", LanguageName, FormatTools.ExtensionsToString(Extensions, "*", ";")); - } - } - - public delegate void ChangeCompilerStateEventDelegate(ICompiler sender, CompilerState State, string FileName); - - public class Compiler : MarshalByRefObject, ICompiler - { - //public ISyntaxTreeChanger SyntaxTreeChanger = null; // SSM 17/08/15 - для операций над синтаксическим деревом после его построения - - public static string Version - { - get - { - return RevisionClass.FullVersion; - } - } - public static string ShortVersion - { - get - { - if (RevisionClass.Build == "0") - return RevisionClass.MainVersion; - else return RevisionClass.MainVersion + "." + RevisionClass.Build; - } - } - public static DateTime VersionDateTime - { - get - { - return File.GetLastWriteTime(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); - } - } - public static string Banner - { - get - { - return "PascalABCCompiler.Core v" + Version; - } - } - public override string ToString() - { - return Banner; - } - - private SyntaxTreeConvertersController syntaxTreeConvertersController = null; - public SyntaxTreeConvertersController SyntaxTreeConvertersController - { - get - { - return syntaxTreeConvertersController; - } - } - - private SemanticTreeConvertersController semanticTreeConvertersController = null; - public SemanticTreeConvertersController SemanticTreeConvertersController - { - get - { - return semanticTreeConvertersController; - } - } - - private Hashtable BadNodesInSyntaxTree = new Hashtable(); - - TreeRealization.program_node _semantic_tree = null; - public SemanticTree.IProgramNode SemanticTree - { - get - { - return _semantic_tree; - } - } - - private Dictionary> compilerDirectives = null; - - //public Hashtable CompilerDirectives - //{ - // get { return compilerDirectives; } - //} - - private uint linesCompiled; - public uint LinesCompiled - { - get { return linesCompiled; } - } - - private CompilerInternalDebug internalDebug; - public CompilerInternalDebug InternalDebug - { - get - { - return internalDebug; - } - set - { - internalDebug = value; - } - } - - private CompilerState state = CompilerState.Ready; - public CompilerState State - { - get { return state; } - } - - private void SetSupportedSourceFiles() - { - List supportedSourceFilesList = new List(); - for (int i = 0; i < ParsersController.Parsers.Count; i++) - { - SupportedSourceFile sf = SupportedSourceFile.Make(ParsersController.Parsers[i]); - if (sf != null) - supportedSourceFilesList.Add(sf); - } - supportedSourceFiles = supportedSourceFilesList.ToArray(); - } - - private void SetSupportedProjectFiles() - { - List supportedProjectFilesList = new List(); - /*for (int i = 0; i < ParsersController.Parsers.Count; i++) - { - SupportedSourceFile sf = SupportedSourceFile.Make(ParsersController.Parsers[i]); - if (sf != null) - supportedSourceFilesList.Add(sf); - }*/ - //vremenno - supportedProjectFilesList.Add(new SupportedSourceFile(new string[1]{".pabcproj"},"PascalABC.NET")); - supportedProjectFiles = supportedProjectFilesList.ToArray(); - } - - private SupportedSourceFile[] supportedSourceFiles = null; - public SupportedSourceFile[] SupportedSourceFiles - { - get { return supportedSourceFiles; } - set { supportedSourceFiles = value; } - } - - private SupportedSourceFile[] supportedProjectFiles = null; - public SupportedSourceFile[] SupportedProjectFiles - { - get { return supportedProjectFiles; } - } - - private CompilationUnitHashTable unitTable=new CompilationUnitHashTable(); - public CompilationUnitHashTable UnitTable{ get { return unitTable; } } - public List UnitsSortedList = new List(); - - private List StandarModules = new List(); - - private CompilerOptions compilerOptions = new CompilerOptions(); - public CompilerOptions CompilerOptions - { - get - { - return compilerOptions; - } - set - { - compilerOptions = value; - } - } - - internal Dictionary DLLCashe = new Dictionary(); - - private Parsers.Controller parsersController = null; - public Parsers.Controller ParsersController - { - get - { - return parsersController; - } - set - { - parsersController = value; - } - } - public TreeConverter.SyntaxTreeToSemanticTreeConverter SyntaxTreeToSemanticTreeConverter = null; - public CodeGenerators.Controller CodeGeneratorsController = null; - //public LLVMConverter.Controller LLVMCodeGeneratorsController = null; - //public PascalToCppConverter.Controller PABCToCppCodeGeneratorsController = null; - private SyntaxTree.unit_or_namespace CurrentSyntaxUnit; - private List UnitsToCompile = new List(); - public Hashtable RecompileList = new Hashtable(StringComparer.OrdinalIgnoreCase); - private PascalABCCompiler.TreeRealization.unit_node_list Units; - private Hashtable CycleUnits = new Hashtable(); - private CompilationUnit CurrentCompilationUnit = null; - private CompilationUnit FirstCompilationUnit = null; - private bool PCUReadersAndWritersClosed; - public int beginOffset; - public int varBeginOffset; - private bool _clear_after_compilation = true; - - public bool ClearAfterCompilation - { - get - { - return _clear_after_compilation; - } - set - { - _clear_after_compilation = value; - } - } - - public int BeginOffset - { - get - { - return beginOffset; - } - } - public int VarBeginOffset - { - get - { - return varBeginOffset; - } - } - private List warnings = new List(); - public List Warnings - { - get - { - return warnings; - } - } - - public Dictionary, string> SourceFileNamesDictionary { get; } = new Dictionary, string>(); - - public Dictionary, string> PCUFileNamesDictionary { get; } = new Dictionary, string>(); - - public void AddWarnings(List WarningList) - { - foreach (CompilerWarning cw in WarningList) - warnings.Add(cw); - } - - public event ChangeCompilerStateEventDelegate OnChangeCompilerState; - private void ChangeCompilerStateEvent(ICompiler sender, CompilerState State, string FileName) - { - this.state=State; - } - - private bool SourceFileExists(string FileName) - { - if (FileName == null) return false; - return (bool)SourceFilesProvider(FileName, SourceFileOperation.Exists); - } - private DateTime SourceFileGetLastWriteTime(string FileName) - { - return (DateTime)SourceFilesProvider(FileName, SourceFileOperation.GetLastWriteTime); - } - private SourceFilesProviderDelegate sourceFilesProvider = SourceFilesProviders.DefaultSourceFilesProvider; - public SourceFilesProviderDelegate SourceFilesProvider - { - get - { - return sourceFilesProvider; - } - } - - private List errorsList = new List(); - public List ErrorsList - { - get{return errorsList;} - } - - public Compiler() - { - //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); - - OnChangeCompilerState += ChangeCompilerStateEvent; - Reload(); - } - - public Compiler(ICompiler comp, SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) - { - //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); // SSM 01/05/16 - подключение изменяльщика синтаксического дерева - - this.ParsersController = comp.ParsersController; - this.internalDebug = comp.InternalDebug; - OnChangeCompilerState += ChangeCompilerStateEvent; - if (SourceFilesProvider != null) - this.sourceFilesProvider = SourceFilesProvider; - if (ChangeCompilerState != null) - OnChangeCompilerState += ChangeCompilerState; - this.supportedSourceFiles = comp.SupportedSourceFiles; - this.supportedProjectFiles = comp.SupportedProjectFiles; - } - - public Compiler(SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) - { - //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); // SSM 01/05/16 - подключение изменяльщика синтаксического дерева - OnChangeCompilerState += ChangeCompilerStateEvent; - if (SourceFilesProvider != null) - this.sourceFilesProvider = SourceFilesProvider; - if (ChangeCompilerState != null) - OnChangeCompilerState += ChangeCompilerState; - Reload(); - } - - public void Reload() - { - OnChangeCompilerState(this, CompilerState.Reloading, null); - - //А это что? - TreeRealization.type_node tn = SystemLibrary.SystemLibrary.void_type; - - ClearAll(); - errorsList.Clear(); - Warnings.Clear(); - InternalDebug = new CompilerInternalDebug(); - ParsersController = new Parsers.Controller(); - ParsersController.ParserConnected += new PascalABCCompiler.Parsers.Controller.ParserConnectedDeleagte(ParsersController_ParserConnected); - ParsersController.SourceFilesProvider = sourceFilesProvider; - ParsersController.Reload(); - SyntaxTreeToSemanticTreeConverter = new TreeConverter.SyntaxTreeToSemanticTreeConverter(); - CodeGeneratorsController = new CodeGenerators.Controller(); - //PABCToCppCodeGeneratorsController = new PascalToCppConverter.Controller(); - SetSupportedSourceFiles(); - SetSupportedProjectFiles(); - - syntaxTreeConvertersController = new SyntaxTreeConvertersController(this); - syntaxTreeConvertersController.ChangeState += syntaxTreeConvertersController_ChangeState; - syntaxTreeConvertersController.AddConverters(); - - semanticTreeConvertersController = new SemanticTreeConvertersController(this); - semanticTreeConvertersController.ChangeState += semanticTreeConvertersController_ChangeState; - semanticTreeConvertersController.AddConverters(); - - OnChangeCompilerState(this, CompilerState.Ready, null); - } - - void ParsersController_ParserConnected(PascalABCCompiler.Parsers.IParser Parser) - { - if (OnChangeCompilerState != null) - OnChangeCompilerState(this, CompilerState.ParserConnected, Parser.GetType().Assembly.ManifestModule.FullyQualifiedName); - } - - void syntaxTreeConvertersController_ChangeState(SyntaxTreeConvertersController.State State, ISyntaxTreeConverter SyntaxTreeConverter) - { - switch (State) - { - case SyntaxTreeConvertersController.State.Convert: - OnChangeCompilerState(this, CompilerState.SyntaxTreeConversion, SyntaxTreeConverter.Name); - break; - case SyntaxTreeConvertersController.State.ConnectConverter: - OnChangeCompilerState(this, CompilerState.SyntaxTreeConverterConnected, SyntaxTreeConverter.Name); - break; - } - } - - void semanticTreeConvertersController_ChangeState(SemanticTreeConvertersController.State State, ISemanticTreeConverter SemanticTreeConverter) - { - switch (State) - { - case SemanticTreeConvertersController.State.Convert: - OnChangeCompilerState(this, CompilerState.SemanticTreeConversion, SemanticTreeConverter.Name); - break; - case SemanticTreeConvertersController.State.ConnectConverter: - OnChangeCompilerState(this, CompilerState.SemanticTreeConverterConnected, SemanticTreeConverter.Name); - break; - } - } - - private Dictionary> GetCompilerDirectives(List Units) - { - Dictionary> Directives = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); - - for (int i = 0; i < Units.Count; i++) - { - TreeRealization.common_unit_node cun = Units[i].SemanticTree as TreeRealization.common_unit_node; - if (cun != null) - foreach (TreeRealization.compiler_directive cd in cun.compiler_directives) - { - if (!Directives.ContainsKey(cd.name)) - Directives.Add(cd.name, new List()); - else if (string.Compare(cd.name, "mainresource", true) == 0) - throw new DuplicateDirective(cd.location.doc.file_name, "mainresource", cd.location); - Directives[cd.name].Insert(0, cd); - } - } - return Directives; - } - - private Hashtable GetCompilerDirectives(CompilationUnit Unit) - { - Hashtable Directives = new Hashtable(StringComparer.CurrentCultureIgnoreCase); - TreeRealization.common_unit_node cun = Unit.SemanticTree as TreeRealization.common_unit_node; - if (cun != null) - foreach (TreeRealization.compiler_directive cd in cun.compiler_directives) - Directives[cd.name] = cd; - return Directives; - } - - private TreeRealization.location get_location_from_treenode(SyntaxTree.syntax_tree_node tn, string FileName) - { - if (tn.source_context == null) - { - return null; - } - return new TreeRealization.location(tn.source_context.begin_position.line_num, tn.source_context.begin_position.column_num, - tn.source_context.end_position.line_num, tn.source_context.end_position.column_num, new TreeRealization.document(FileName)); - } - - private System.Collections.Generic.List ConvertDirectives(SyntaxTree.compilation_unit cu) - { - System.Collections.Generic.List list = new System.Collections.Generic.List(); - foreach (SyntaxTree.compiler_directive sncd in cu.compiler_directives) - { - list.Add(new TreeRealization.compiler_directive(sncd.Name.text, sncd.Directive!=null?sncd.Directive.text:"", get_location_from_treenode(sncd,cu.file_name), cu.file_name)); - } - return list; - } - - void syncStartCompile() - { - Compile(); - } - - public void StartCompile() - { - System.Threading.Thread th = new System.Threading.Thread(syncStartCompile); - th.SetApartmentState(System.Threading.ApartmentState.STA); - th.Start(); - } - - public string Compile(CompilerOptions CompilerOptions) - { - this.CompilerOptions = CompilerOptions; - return Compile(); - } - - internal void Reset() - { - SourceFileNamesDictionary.Clear(); - PCUFileNamesDictionary.Clear(); - Warnings.Clear(); - errorsList.Clear(); - //if (!File.Exists(CompilerOptions.SourceFileName)) throw new SourceFileNotFound(CompilerOptions.SourceFileName); - CurrentCompilationUnit = null; - FirstCompilationUnit = null; - linesCompiled = 0; - PCUReadersAndWritersClosed = false; - ParsersController.Reset(); - SyntaxTreeToSemanticTreeConverter.Reset(); - CodeGeneratorsController.Reset(); - //PABCToCppCodeGeneratorsController.Reset(); - UnitsToCompile.Clear(); - DLLCashe.Clear(); - project = null; - } - - void CheckErrors() - { - if (ErrorsList.Count > 0) - throw ErrorsList[0]; - } - - private void moveSystemUnitToForwardUnitSortedList() - { - if(CompilerOptions.StandartModules.Count==0) - return; - CompilationUnit system_unit = null; - foreach (CompilationUnit cu in UnitsSortedList) - if (cu.SemanticTree != null && cu.SemanticTree is PascalABCCompiler.TreeRealization.common_unit_node) - if ((cu.SemanticTree as PascalABCCompiler.TreeRealization.common_unit_node).unit_name == CompilerOptions.StandartModules[0].Name) - { - system_unit = cu; - break; - } - if (system_unit != null && system_unit != UnitsSortedList[0]) - { - UnitsSortedList.Remove(system_unit); - UnitsSortedList.Insert(0, system_unit); - } - - } - - private uint get_compiled_lines(string FileName) - { - StreamReader sr = File.OpenText(FileName); - uint line = 0; - while (!sr.EndOfStream) - { - sr.ReadLine(); - line++; - } - sr.Close(); - return line; - } - - class ProgInfo - { - public string entry_module; - public int entry_method_name_pos; - public int entry_method_line; - public int using_pos=-1; - public List modules = new List(); - public List addit_imports = new List(); - public List addit_project_files = new List(); - } - - private void add_import_info(ProgInfo info, List imports) - { - Hashtable ht = new Hashtable(StringComparer.CurrentCultureIgnoreCase); - ht["GraphABC"] = "GraphABC"; - ht["GraphABCHelper"] = "GraphABCHelper"; - ht["ABCObjects"] = "ABCObjects"; - ht["Robot"] = "Robot"; - ht["Drawman"] = "Drawman"; - ht["DrawManField"] = "DrawManField"; - foreach (string s in imports) - { - string low_s = s.ToLower(); - //string mod_file = FindSourceFileInDirectories(s+".mod",Path.Combine(this.CompilerOptions.SystemDirectory,"lib")); - if (ht[s] != null) - { - string name = ht[s] as string; - if (!info.modules.Contains(name)) - { - info.modules.Add(name); - info.addit_imports.Add(name+"."+name); - } - } - /*if (!string.IsNullOrEmpty(mod_file)) - { - switch (low_s) - { - case "graphabc" : - if (!info.modules.Contains("GraphABC") && !info.modules.Contains("ABCObjects") && !info.modules.Contains("ABCButtons") && !info.modules.Contains("ABCHouse") - && !info.modules.Contains("ABCSprites") && !info.modules.Contains("RobotField")) - { - info.modules.Add("GraphABC"); - info.addit_imports.Add("GraphABC.GraphABC"); - } - else if (!info.addit_imports.Contains("GraphABC.GraphABC")) - { - info.addit_imports.Add("GraphABC.GraphABC"); - } - break; - case "abcobjects" : - if (!info.modules.Contains("ABCObjects") && !info.modules.Contains("ABCButtons") && !info.modules.Contains("ABCHouse") - && !info.modules.Contains("ABCSprites") && !info.modules.Contains("RobotField")) - { - info.modules.Add("ABCObjects"); - info.addit_imports.Add("ABCObjects.ABCObjects"); - if (info.modules.Contains("GraphABC")) - { - info.modules.Remove("GraphABC"); - //info.addit_imports.Remove("GraphABC.GraphABC"); - } - } - break; - default: - if (!info.modules.Contains(s)) - { - info.modules.Add(s); - info.addit_imports.Add(s+"."+s); - } - break; - } - }*/ - else - { - string source_file = FindFileInDirs(s+".vb",Path.GetDirectoryName(CompilerOptions.SourceFileName),Path.Combine(this.CompilerOptions.SystemDirectory,"lib"), - Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); - if (!string.IsNullOrEmpty(source_file)) - { - if (!info.addit_project_files.Contains(source_file)) - { - info.addit_project_files.Add(source_file); - } - } - } - } - /*List mods = new List(); - List inds = new List(); - for (int i=0; i usings = new List(); - foreach (ICSharpCode.NRefactory.Ast.INode node in cu.Children) - { - if (node is ICSharpCode.NRefactory.Ast.TypeDeclaration) - { - ICSharpCode.NRefactory.Ast.TypeDeclaration td = node as ICSharpCode.NRefactory.Ast.TypeDeclaration; - if (td.Type == ICSharpCode.NRefactory.Ast.ClassType.Module) - { - foreach (ICSharpCode.NRefactory.Ast.INode node2 in td.Children) - { - if (node2 is ICSharpCode.NRefactory.Ast.MethodDeclaration) - { - ICSharpCode.NRefactory.Ast.MethodDeclaration meth = node2 as ICSharpCode.NRefactory.Ast.MethodDeclaration; - if (string.Compare(meth.Name,"Main",true)==0 && (meth.Parameters == null || meth.Parameters.Count == 0)) - { - //info = new ProgInfo(); - info.entry_module = (meth.Parent as ICSharpCode.NRefactory.Ast.TypeDeclaration).Name; - //info.entry_method_name_line = meth.StartLocation.Line; - //info.entry_method_name_col = meth.StartLocation.Column; - info.entry_method_name_pos = find_pos(source,meth.StartLocation.Line,meth.StartLocation.Column,true); - if (meth.Body.Children.Count > 0) - { - for (int i=0; i 0) - { - for (int i = 0; i < res.Errors.Count; i++) - { - if (!res.Errors[i].IsWarning && errorsList.Count == 0 /*&& res.Errors[i].FileName != redirect_fname*/) - { - if (File.Exists(res.Errors[i].FileName)) - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); - else - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, CompilerOptions.SourceFileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); - } - else if (res.Errors[i].IsWarning) - { - warnings.Add(new Errors.CommonWarning(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line, res.Errors[i].Column)); - } - } - } - - //linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); - - OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); - ClearAll(); - OnChangeCompilerState(this, CompilerState.Ready, null); - - if (errorsList.Count > 0) - return null; - else - return res.PathToAssembly; - } - - class PyErrorHandler : ErrorListener - { - Compiler c; - public PyErrorHandler(Compiler cc) {c=cc;} - public override void ErrorReported(ScriptSource source, string message, SourceSpan span, int errorCode, Severity severity) - { - if (severity==Severity.Warning) - c.warnings.Add(new Errors.CommonWarning(message, c.compilerOptions.SourceFileName, span.Start.Line, span.Start.Column)); - else - c.errorsList.Add(new Errors.CommonCompilerError(message, c.compilerOptions.SourceFileName, span.Start.Line, span.Start.Column)); - } - } - - private Assembly IronPythonAssembly; - private MethodInfo PythonCreateEngineMethod; - public string CompilePy() - { - OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); - OnChangeCompilerState(this, CompilerState.BeginCompileFile, CompilerOptions.SourceFileName); - Reset(); - - if (IronPythonAssembly == null) - { - IronPythonAssembly = Assembly.LoadFrom("IronPython.dll"); - PythonCreateEngineMethod = IronPythonAssembly.GetType("IronPython.Hosting.Python").GetMethod("CreateEngine"); - } - string source = GetSourceFileText(CompilerOptions.SourceFileName); - - ScriptEngine pyEngine = (ScriptEngine)PythonCreateEngineMethod.Invoke(null, new object[0]); ; - - ScriptSource src = pyEngine.CreateScriptSourceFromString(source); - CompiledCode compiled = src.Compile(new PyErrorHandler(this)); - if (compiled != null) - compiled.Execute(); - - linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); - - OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); - ClearAll(); - OnChangeCompilerState(this, CompilerState.Ready, null); - - //if (errorsList.Count > 0) - return null; - //else return res.PathToAssembly; - } - - public string CompileCS() - { - OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); - OnChangeCompilerState(this, CompilerState.BeginCompileFile, CompilerOptions.SourceFileName); - Reset(); - var d = new Dictionary(); - d["CompilerVersion"] = "v4.0"; - var cscp = new Microsoft.CSharp.CSharpCodeProvider(d); - - //var cscp = new Microsoft.CSharp.CSharpCodeProvider(); - var comp_opt = new CompilerParameters(); - comp_opt.IncludeDebugInformation = CompilerOptions.Debug; - comp_opt.GenerateExecutable = true; - comp_opt.WarningLevel = 3; - comp_opt.OutputAssembly = CompilerOptions.OutputFileName; - - //comp_opt.ReferencedAssemblies.Add() - - string source = GetSourceFileText(CompilerOptions.SourceFileName); - - using (StringReader sr = new StringReader(source)) - { - do - { - var s = sr.ReadLine(); - - if (s == null) - break; - - if (s.ToLower().StartsWith("//#reference ")) - { - s = s.Remove(0, 13); - s = s.Trim(); - comp_opt.ReferencedAssemblies.Add(s); - } - else break; - - } while (true); - } - - - var res = cscp.CompileAssemblyFromSource(comp_opt, source); - if (res.Errors.Count > 0) - { - for (int i = 0; i < res.Errors.Count; i++) - { - if (!res.Errors[i].IsWarning && errorsList.Count == 0 /*&& res.Errors[i].FileName != redirect_fname*/) - { - if (File.Exists(res.Errors[i].FileName)) - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); - else - errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, CompilerOptions.SourceFileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); - } - else if (res.Errors[i].IsWarning) - { - warnings.Add(new Errors.CommonWarning(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line, res.Errors[i].Column)); - } - } - } - - linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); - - OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); - ClearAll(); - OnChangeCompilerState(this, CompilerState.Ready, null); - - if (errorsList.Count > 0) - return null; - else - return res.PathToAssembly; - } - - public string CompileVB() - { - OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); - OnChangeCompilerState(this,CompilerState.BeginCompileFile,CompilerOptions.SourceFileName); - Reset(); - Microsoft.VisualBasic.VBCodeProvider vbcp = new Microsoft.VisualBasic.VBCodeProvider(); - List sources = new List(); - sources.Add(CompilerOptions.SourceFileName); - System.CodeDom.Compiler.CompilerParameters comp_opt = new System.CodeDom.Compiler.CompilerParameters(); - comp_opt.OutputAssembly = CompilerOptions.OutputFileName; - comp_opt.WarningLevel = 3; - comp_opt.ReferencedAssemblies.Add("System.Windows.Forms.dll"); - comp_opt.ReferencedAssemblies.Add("System.Drawing.dll"); - comp_opt.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll"); - comp_opt.IncludeDebugInformation = CompilerOptions.Debug; - comp_opt.GenerateExecutable = true; - string fname = Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"_temp$"+Path.GetFileName(CompilerOptions.SourceFileName)); - File.Copy(CompilerOptions.SourceFileName,fname,true); - string source = GetSourceFileText(CompilerOptions.SourceFileName); - - IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.VBNet,new StringReader(source)); - parser.Parse(); - ProgInfo info = get_programm_info(parser.CompilationUnit, source); - parser.Dispose(); - if (info != null) - sources.AddRange(info.addit_project_files); - string redirect_base_fname = FindFileInDirs("__RedirectIOMode.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); - string system_unit_name = FindFileInDirs("VBSystem.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); - string redirect_fname = Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"_RedirectIOMode.vb"); - StreamReader sr = File.OpenText(redirect_base_fname); - string redirect_module = sr.ReadToEnd(); - sr.Close(); - if (info != null) - { - System.Text.StringBuilder tmp_sb = new System.Text.StringBuilder(); - if (info.modules.Count > 0) - { - tmp_sb.AppendLine("GetType(Fictive.Fictive).Assembly.GetType(\"PABCSystem_implementation$.PABCSystem_implementation$\").GetMethod(\"$Initialization\").Invoke(Nothing,Nothing)"); - } - for (int i=0; i 0) - { - comp_opt.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),PascalABCCompiler.TreeConverter.compiler_string_consts.pabc_rtl_dll_name)); - string mod_file_name = FindFileInDirs("PABCRtl.dll",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib")); - File.Copy(mod_file_name,Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"PABCRtl.dll"),true); - /*foreach (string mod in info.modules) - { - comp_opt.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),mod+".dll")); - string mod_file_name = FindSourceFileInDirectories(mod+".mod",Path.Combine(this.CompilerOptions.SystemDirectory,"lib")); - File.Copy(mod_file_name,Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),mod+".dll"),true); - }*/ - } - sources.Add(redirect_fname); - sources.Add(system_unit_name); - System.CodeDom.Compiler.CompilerResults res = vbcp.CompileAssemblyFromFile(comp_opt,sources.ToArray()); - if (res.Errors.Count > 0) - { - for (int i=0; i 0) - return null; - else - return res.PathToAssembly; - } - - private ProjectInfo project; - - private void PrepareCompileOptionsForProject() - { - project = new ProjectInfo(); - project.Load(CompilerOptions.SourceFileName); - //LoadProject(CompilerOptions.SourceFileName); - switch (project.ProjectType) - { - case ProjectType.ConsoleApp: CompilerOptions.OutputFileType = CompilerOptions.OutputType.ConsoleApplicaton; break; - case ProjectType.WindowsApp: CompilerOptions.OutputFileType = CompilerOptions.OutputType.WindowsApplication; break; - case ProjectType.Library: CompilerOptions.OutputFileType = CompilerOptions.OutputType.ClassLibrary; break; - } - CompilerOptions.SourceFileName = project.main_file; - CompilerOptions.Debug = project.include_debug_info; - CompilerOptions.OutputFileName = project.output_file_name; - - CompilerOptions.OutputDirectory = project.output_directory; - } - - public string Compile() - { - - try - { - //var timer = System.Diagnostics.Stopwatch.StartNew(); ////// - - if (Path.GetExtension(CompilerOptions.SourceFileName) == ".vb") - { - return CompileVB(); - } - - if (Path.GetExtension(CompilerOptions.SourceFileName) == ".cs") - { - return CompileCS(); - } - - OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); - - Reset(); - //Console.WriteLine(timer.ElapsedMilliseconds / 1000.0); ////// - if (CompilerOptions.ProjectCompiled) - { - PrepareCompileOptionsForProject(); - } - Units = new PascalABCCompiler.TreeRealization.unit_node_list(); - CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(null, new SyntaxTree.string_const(Path.GetFullPath(CompilerOptions.SourceFileName))); - - CompileUnit(Units, CurrentSyntaxUnit, null); - - //Console.WriteLine(timer.ElapsedMilliseconds / 1000.0); ////// - foreach (CompilationUnit CurrentUnit in UnitsToCompile) - if (CurrentUnit.State != UnitState.Compiled) - { - CurrentCompilationUnit = CurrentUnit; - string UnitName = CurrentCompilationUnit.SyntaxTree.file_name; - //if(CurrentUnit.State!=UnitState.InterfaceCompiled) //DEBUG - //Console.WriteLine("ERROR! interface not compiled "+GetUnitFileName(CurrentUnit.SyntaxUnitName));//DEBUG - System.Collections.Generic.List SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); - CurrentUnit.PossibleNamespaces.Clear(); - if (HasIncludeNamespacesDirective(CurrentUnit)) - compilerOptions.UseDllForSystemUnits = false; - if (SyntaxUsesList != null) - { - for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) - if (!IsPossibleNamespace(SyntaxUsesList[i], false, Path.GetDirectoryName(UnitName))) - { - compilerOptions.UseDllForSystemUnits = false; - break; - } - for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) - if (!IsPossibleNamespace(SyntaxUsesList[i], true, Path.GetDirectoryName(UnitName))) - { - CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], Path.GetDirectoryName(UnitName)); - } - else - { - CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); - CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); - } - } - //Console.WriteLine("Compile Implementation "+UnitName);//DEBUG - //TODO: Избавиться от преобразования типа. - - AddNamespaces(CurrentUnit.ImplementationUsingNamespaceList, CurrentUnit.PossibleNamespaces, true, null); - -#if DEBUG - if (InternalDebug.SemanticAnalysis) -#endif - { - OnChangeCompilerState(this, CompilerState.CompileImplementation, UnitName); - PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; - SyntaxTreeToSemanticTreeConverter.CompileImplementation( - (PascalABCCompiler.TreeRealization.common_unit_node)CurrentUnit.SemanticTree, - CurrentUnit.SyntaxTree, - buildImplementationUsesList(CurrentUnit), - ErrorsList,Warnings, - CurrentUnit.syntax_error, BadNodesInSyntaxTree, - CurrentUnit.InterfaceUsingNamespaceList, - CurrentUnit.ImplementationUsingNamespaceList, - null, - CompilerOptions.Debug, - CompilerOptions.ForDebugging - ); - CheckErrors(); - } - CurrentUnit.State = UnitState.Compiled; - OnChangeCompilerState(this, CompilerState.EndCompileFile, UnitName); - //SavePCU(CurrentUnit, UnitName); - CurrentUnit.UnitName = UnitName; - } - - ClosePCUReadersAndWriters(); - if (CompilerOptions.SaveDocumentation) - SaveDocumentations(); - - compilerDirectives = GetCompilerDirectives(UnitsSortedList); - - if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.compiler_directive_apptype)) - { - string directive = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_apptype][0].directive; - if (string.Compare(directive,"console",true)==0) - CompilerOptions.OutputFileType = CompilerOptions.OutputType.ConsoleApplicaton; - else - if (string.Compare(directive,"windows",true)==0) - CompilerOptions.OutputFileType = CompilerOptions.OutputType.WindowsApplication; - else - if (string.Compare(directive,"dll",true)==0) - CompilerOptions.OutputFileType = CompilerOptions.OutputType.ClassLibrary; - else - if (string.Compare(directive,"pcu",true)==0) - CompilerOptions.OutputFileType = CompilerOptions.OutputType.PascalCompiledUnit; - } - - moveSystemUnitToForwardUnitSortedList(); - PascalABCCompiler.TreeRealization.common_unit_node system_unit = null; - if (UnitsSortedList.Count>0) - system_unit = UnitsSortedList[0].SemanticTree as PascalABCCompiler.TreeRealization.common_unit_node; - if (system_unit != null) - system_unit.IsConsoleApplicationVariable = CompilerOptions.OutputFileType == CompilerOptions.OutputType.ConsoleApplicaton; - - TreeRealization.program_node pn = null; - NETGenerator.CompilerOptions cdo = new NETGenerator.CompilerOptions(); - List cds; - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.compiler_directive_platformtarget, out cds)) - { - string plt = cds[0].directive.ToLower(); - if (plt.Equals("x86")) - cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.x86; - else if (plt.Equals("x64")) - cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.x64; - else if (plt.Equals("anycpu")) - cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.AnyCPU; - } - if (this.compilerOptions.Only32Bit) - cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.x86; - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.product_string, out cds)) - { - cdo.Product = cds[0].directive; - } - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.version_string, out cds)) - { - cdo.ProductVersion = cds[0].directive; - } - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.company_string, out cds)) - { - cdo.Company = cds[0].directive; - } - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.trademark_string, out cds)) - { - cdo.TradeMark = cds[0].directive; - } - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.copyright_string, out cds)) - { - cdo.Copyright = cds[0].directive; - } - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.title_string, out cds)) - { - cdo.Title = cds[0].directive; - } - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.description_string, out cds)) - { - cdo.Description = cds[0].directive; - } - if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.main_resource_string, out cds)) - { - if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.product_string) || - compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.version_string) || - compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.company_string) || - compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.trademark_string) || - compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.title_string) || - compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.description_string)) - { - ErrorsList.Add(new MainResourceNotAllowed(cds[0].location)); - } - cdo.MainResourceFileName = cds[0].directive; - if (!File.Exists(cdo.MainResourceFileName)) - { - ErrorsList.Add(new ResourceFileNotFound(cds[0].directive, cds[0].location)); - } - } - - List ResourceFiles = null; - if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.compiler_directive_resource)) - { - ResourceFiles = new List(); - List ResourceDirectives = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_resource]; - foreach (TreeRealization.compiler_directive cd in ResourceDirectives) - { - var resource_fname = Path.Combine(Path.GetDirectoryName(cd.source_file), cd.directive); - - if (File.Exists(resource_fname)) - ResourceFiles.Add(resource_fname); - else - ErrorsList.Add(new ResourceFileNotFound(cd.directive, cd.location)); - - } - } - string res_file = null; - if (project != null) - { - if (!(project.major_version == 0 && project.minor_version == 0 && project.build_version == 0 && project.revision_version == 0)) - cdo.ProductVersion = project.major_version + "." + project.minor_version + "." + project.build_version + "." + project.revision_version; - if (!string.IsNullOrEmpty(project.product)) - cdo.Product = project.product; - if (!string.IsNullOrEmpty(project.company)) - cdo.Company = project.company; - if (!string.IsNullOrEmpty(project.trademark)) - cdo.TradeMark = project.trademark; - if (!string.IsNullOrEmpty(project.copyright)) - cdo.Copyright = project.copyright; - if (!string.IsNullOrEmpty(project.title)) - cdo.Title = project.title; - if (!string.IsNullOrEmpty(project.description)) - cdo.Description = project.description; - if (!string.IsNullOrEmpty(project.app_icon) && false) - { - //cdo.MainResourceFileName = project.app_icon; - string rc_file = Path.GetFileNameWithoutExtension(project.app_icon) + ".rc"; - StreamWriter sw = File.CreateText(rc_file); - sw.WriteLine("1 ICON \"" + project.app_icon.Replace("\\", "\\\\") + "\""); - if (cdo.NeedDefineVersionInfo) - { - cdo.NeedDefineVersionInfo = false; - sw.WriteLine("1 VERSIONINFO"); - string ver = project.major_version + "," + project.minor_version + "," + project.build_version + "," + project.revision_version; - sw.WriteLine("FILEVERSION " + ver); - /*sw.WriteLine("FILEFLAGSMASK VS_FFI_FILEFLAGSMASK"); - sw.WriteLine("FILEFLAGS VER_DEBUG"); - sw.WriteLine("FILEOS VOS__WINDOWS32"); - if (project.project_type != ProjectType.Library) - sw.WriteLine("FILETYPE VFT_APP"); - else - sw.WriteLine("FILETYPE VFT_DLL"); - sw.WriteLine("FILESUBTYPE VFT2_UNKNOWN");*/ - sw.WriteLine("BEGIN \r\n BLOCK \"StringFileInfo\"\r\n BEGIN \r\n BLOCK \"041904E3\"\r\nBEGIN"); - sw.WriteLine("VALUE \"ProductName\"," + "\"" + cdo.Product + "\""); - sw.WriteLine("VALUE \"FileVersion\"," + "\"" + ver + "\""); - sw.WriteLine("VALUE \"ProductVersion\"," + "\"" + ver + "\""); - sw.WriteLine("VALUE \"FileDescription\"," + "\"" + cdo.Description + "\""); - sw.WriteLine("VALUE \"OriginalFileName\"," + "\"" + Path.GetFileName(CompilerOptions.OutputFileName) + "\""); - sw.WriteLine("VALUE \"InternalName\"," + "\"" + Path.GetFileNameWithoutExtension(CompilerOptions.OutputFileName) + "\""); - sw.WriteLine("VALUE \"CompanyName\"," + "\"" + cdo.Company + "\""); - sw.WriteLine("VALUE \"LegalTrademarks1\"," + "\"" + cdo.TradeMark + "\""); - sw.WriteLine("VALUE \"LegalCopyright\"," + "\"" + cdo.Copyright + "\""); - sw.WriteLine("END"); - sw.WriteLine("END"); - - sw.WriteLine("BLOCK \"VarFileInfo\"\r\nBEGIN"); - sw.WriteLine("VALUE \"Translation\", 0x0419, 1251"); - sw.WriteLine("END"); - sw.WriteLine("END"); - } - sw.Close(); - System.Diagnostics.Process prc = new System.Diagnostics.Process(); - prc.StartInfo.FileName = Path.Combine(this.CompilerOptions.SystemDirectory, "rc.exe"); - prc.StartInfo.Arguments = Path.Combine(Path.GetDirectoryName(project.app_icon), Path.GetFileNameWithoutExtension(project.app_icon) + ".rc"); - prc.StartInfo.CreateNoWindow = true; - prc.StartInfo.UseShellExecute = false; - prc.StartInfo.RedirectStandardOutput = true; - prc.StartInfo.RedirectStandardError = true; - prc.Start(); - prc.WaitForExit(); - res_file = Path.Combine(Path.GetDirectoryName(project.app_icon), Path.GetFileNameWithoutExtension(project.app_icon) + ".res"); - if (File.Exists(res_file)) - { - cdo.MainResourceFileName = res_file; - } - File.Delete(rc_file); - } - } - - if (ErrorsList.Count == 0 && compilerOptions.GenerateCode) - { - cdo.ForRunningWithEnvironment = CompilerOptions.RunWithEnvironment; - switch (CompilerOptions.OutputFileType) - { - case CompilerOptions.OutputType.ClassLibrary: cdo.target = NETGenerator.TargetType.Dll; break; - case CompilerOptions.OutputType.ConsoleApplicaton: cdo.target = NETGenerator.TargetType.Exe; break; - case CompilerOptions.OutputType.WindowsApplication: cdo.target = NETGenerator.TargetType.WinExe; break; - - } - if (project != null && project.ProjectType == ProjectType.WindowsApp) - cdo.target = PascalABCCompiler.NETGenerator.TargetType.WinExe; - switch (CompilerOptions.Debug) - { - case true: cdo.dbg_attrs = NETGenerator.DebugAttributes.Debug; break; - case false: cdo.dbg_attrs = NETGenerator.DebugAttributes.Release; break; - } - if (CompilerOptions.ForDebugging) - cdo.dbg_attrs = NETGenerator.DebugAttributes.ForDebugging; - - - //TODO: Разобратся c location для program_node и правильно передавать main_function. Добавить генератор main_function в SyntaxTreeToSemanticTreeConverter. - pn = new PascalABCCompiler.TreeRealization.program_node(null, null); - - for (int i = 0; i < UnitsSortedList.Count; i++) - pn.units.AddElement(UnitsSortedList[i].SemanticTree as TreeRealization.common_unit_node); - - //(ssyy) Добавил в условие c_module - if (FirstCompilationUnit.SyntaxTree is SyntaxTree.program_module || - FirstCompilationUnit.SyntaxTree is SyntaxTree.c_module) - { - if ((cdo.target == NETGenerator.TargetType.Exe) || (cdo.target == NETGenerator.TargetType.WinExe)) - { - if (UnitsSortedList.Count > 0) - { - pn.main_function = ((PascalABCCompiler.TreeRealization.common_unit_node)UnitsSortedList[UnitsSortedList.Count - 1].SemanticTree).main_function; - /***************************Ivan added*******************************/ - if (pn.main_function.function_code.location != null) - { - bool flag = false; - PascalABCCompiler.TreeRealization.common_namespace_node main_ns = pn.main_function.namespace_node; - for (int i = 0; i < main_ns.variables.Count; i++) - { - PascalABCCompiler.TreeRealization.namespace_variable nv = main_ns.variables[i]; - if (nv.inital_value != null && nv.inital_value.location != null && !(nv.inital_value is PascalABCCompiler.TreeRealization.constant_node) - && !(nv.inital_value is PascalABCCompiler.TreeRealization.record_initializer) && !(nv.inital_value is PascalABCCompiler.TreeRealization.array_initializer)) - { - varBeginOffset = main_ns.variables[i].inital_value.location.begin_line_num; - flag = true; - break; - } - } - beginOffset = pn.main_function.function_code.location.begin_line_num; - } - /*******************************************************************/ - Dictionary config_dic = new Dictionary(); - if (CompilerOptions.Locale != null && PascalABCCompiler.StringResourcesLanguage.GetLCIDByTwoLetterISO(CompilerOptions.Locale) != null) - { - config_dic["locale"] = CompilerOptions.Locale; - config_dic["full_locale"] = PascalABCCompiler.StringResourcesLanguage.GetLCIDByTwoLetterISO(CompilerOptions.Locale); - } - pn.create_main_function(StandarModules.ToArray(), config_dic); - - } - } - } - else if (FirstCompilationUnit.SyntaxTree is SyntaxTree.unit_module && cdo.target == NETGenerator.TargetType.Dll) - { - pn.create_main_function_as_in_module(); - } - pn = semanticTreeConvertersController.Convert(pn) as TreeRealization.program_node; - - _semantic_tree = pn; - - if (FirstCompilationUnit.SyntaxTree is SyntaxTree.unit_module && CompilerOptions.OutputFileType != CompilerOptions.OutputType.ClassLibrary) - { - //если мы комилируем PCU - CompilerOptions.OutputFileType = CompilerOptions.OutputType.PascalCompiledUnit; - } - else - { - if( CompilerOptions.OutputFileType!= CompilerOptions.OutputType.SemanticTree) -#if DEBUG - if (InternalDebug.CodeGeneration) -#endif - { - int n = 1; - try - { - n = 2; - var fs = File.Create(CompilerOptions.OutputFileName); - n = 3; - fs.Close(); - n = 4; - ///////File.Delete(CompilerOptions.OutputFileName); - string pdb_file_name=Path.ChangeExtension(CompilerOptions.OutputFileName, ".pdb"); - if (File.Exists(pdb_file_name)) - File.Delete(pdb_file_name); - n = 5; - } - catch (Exception e) - { - throw new UnauthorizedAccessToFile(CompilerOptions.OutputFileName + " -- " + n + " " + e.ToString()); - //throw e; - } - OnChangeCompilerState(this, CompilerState.CodeGeneration, CompilerOptions.OutputFileName); - string[] ResourceFilesArray = null; - if (ResourceFiles != null) - ResourceFilesArray = ResourceFiles.ToArray(); - cds = null; - /*if (compilerDirectives.TryGetValue("platform", out cds) && cds[0].directive.ToLower() == "native") - { - //LLVMCodeGeneratorsController.Compile(pn, CompilerOptions.OutputFileName, CompilerOptions.SourceFileName, ResourceFilesArray); - PABCToCppCodeGeneratorsController.Compile(pn, CompilerOptions.OutputFileName, CompilerOptions.SourceFileName, ResourceFilesArray); - } - else*/ - if (compilerOptions.UseDllForSystemUnits) - cdo.RtlPABCSystemType = NetHelper.NetHelper.FindRtlType("PABCSystem.PABCSystem"); - CodeGeneratorsController.Compile(pn, CompilerOptions.OutputFileName, CompilerOptions.SourceFileName, cdo, CompilerOptions.StandartDirectories, ResourceFilesArray); - if (res_file != null) - File.Delete(res_file); - } - } - } - } - catch (TreeConverter.ParserError err) - { - //конвертор уткнулся в ошибку. ничего не делаем - } - catch (Errors.CompilerInternalError err) - { - if (ErrorsList.Count == 0) - ErrorsList.Add(err); - else - { -#if DEBUG - if (!InternalDebug.SkipInternalErrorsIfSyntaxTreeIsCorrupt) - ErrorsList.Add(err); -#endif - } - } - catch (Errors.Error err) - { - if (ErrorsList.Count == 0) - ErrorsList.Add(err); - else - if (err != ErrorsList[0]) - { - if (err is SemanticError) - { - int pos = ErrorsList.Count; - SourceLocation loc = (err as SemanticError).SourceLocation, loctmp; - if (loc != null) - for (int i = 0; i < ErrorsList.Count; i++) - if (ErrorsList[i] is LocatedError) - if ((loctmp = (ErrorsList[i] as LocatedError).SourceLocation) != null) - if (loctmp > loc) - { - pos = i; - break; - } - - ErrorsList.Insert(pos, err); - } - else - ErrorsList.Add(err); - } - } - catch (Exception err) - { - string fn = "Compiler"; - if (CurrentCompilationUnit != null && this.CurrentCompilationUnit.SyntaxTree != null) fn = Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name); - Errors.CompilerInternalError comp_err = new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", fn), err); - if (ErrorsList.Count == 0) - ErrorsList.Add(comp_err); - else - { -#if DEBUG - if (!InternalDebug.SkipInternalErrorsIfSyntaxTreeIsCorrupt) - ErrorsList.Add(comp_err); -#endif - } - } - - //удаляем лишние ошибки - /*foreach(Error er in errorsList) - { - - }*/ - - //на случай если мы вывалились по исключению но у нас есть откомпилированные модули - try - { - ClosePCUReadersAndWriters(); - } - catch (Exception e) - { - ErrorsList.Add(new Errors.CompilerInternalError("Compiler.ClosePCUReadersAndWriters", e)); - } - bool need_recompiled = false; - if (ErrorsList.Count > 0) - { - if (compilerOptions.UseDllForSystemUnits && !has_only_syntax_errors(ErrorsList) && compilerOptions.IgnoreRtlErrors) - { - compilerOptions.UseDllForSystemUnits = false; - ErrorsList.Clear(); - - need_recompiled = true; - - } - } - OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); - if (ClearAfterCompilation) - ClearAll(); - - - OnChangeCompilerState(this, CompilerState.Ready, null); - if (ErrorsList.Count > 0) - { - return null; - } - else if (need_recompiled) - { - //Compiler c = new Compiler(sourceFilesProvider,OnChangeCompilerState); - //return c.Compile(this.compilerOptions); - return Compile(); - } - else - return CompilerOptions.OutputFileName; - } - - private bool has_only_syntax_errors(List errors) - { - foreach (Error err in errors) - { - if (!(err is SyntaxError)) - return false; - } - return true; - } - - private void SaveDocumentations() - { - DocXmlManager dxm = new DocXmlManager(); - foreach (CompilationUnit cu in UnitsSortedList) - { - if (cu.Documented) - dxm.SaveXml(cu); - } - } - - private void ClosePCUReadersAndWriters() - { - if (PCUReadersAndWritersClosed) - return; - - PCUReadersAndWritersClosed = true; - - bool all_restored = false; - while (!all_restored) - { - foreach (PCUReader p in PCUReader.AllReaders) - { - p.AddInitFinalMethods(); - SystemLibrary.SystemLibInitializer.RestoreStandardFunctions(); - p.ProcessWaitedToRestoreFields(); - } - bool rest = true; - for (int i=0; i usesList) - { - if(usesList==null) - return; - List names = new List(); - foreach (SyntaxTree.unit_or_namespace un in usesList) - { - string name=SyntaxTree.Utils.IdentListToString(un.name.idents,".").ToLower(); - if (un.source_context != null) - { - if (names.Contains(name)) - throw new DuplicateUsesUnit(CurrentCompilationUnit.SyntaxTree.file_name, name, un.source_context); - else - names.Add(name); - } - } - } - - public List GetSyntaxInterfaceUsesList(SyntaxTree.compilation_unit CurrentSyntaxUnit) - { - List result = null; - if(CurrentSyntaxUnit is SyntaxTree.unit_module) - { - SyntaxTree.interface_node intp = (CurrentSyntaxUnit as SyntaxTree.unit_module).interface_part; - if (intp.uses_modules == null) - if (CompilerOptions.StandartModules.Count > 0)//если есть стандартые модули то создать список - { - intp.uses_modules = new SyntaxTree.uses_list(); - intp.uses_modules.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1, 1, 1); - } - else - return null; - result = intp.uses_modules.units; - } - if (CurrentSyntaxUnit is SyntaxTree.program_module) - { - SyntaxTree.program_module pm = (CurrentSyntaxUnit as SyntaxTree.program_module); - if (pm.used_units == null) - if (CompilerOptions.StandartModules.Count > 0)//если есть стандартые модули то создать список - { - pm.used_units = new SyntaxTree.uses_list(); - pm.used_units.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1, 1, 1); - } - else - return null; - result = pm.used_units.units; - } - if (CurrentSyntaxUnit is SyntaxTree.c_module) - { - SyntaxTree.c_module pm = (CurrentSyntaxUnit as SyntaxTree.c_module); - if (pm.used_units == null) - if (CompilerOptions.StandartModules.Count > 0)//если есть стандартые модули то создать список - { - pm.used_units = new SyntaxTree.uses_list(); - pm.used_units.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1, 1, 1); - } - else - return null; - result = pm.used_units.units; - } - checkDuplicateUsesUnit(result); - return result; - } - - private List GetSyntaxImplementationUsesList(SyntaxTree.compilation_unit CurrentSyntaxUnit) - { - List result = null; - if(CurrentSyntaxUnit is SyntaxTree.unit_module) - if ((CurrentSyntaxUnit as SyntaxTree.unit_module).implementation_part!=null) - if ((CurrentSyntaxUnit as SyntaxTree.unit_module).implementation_part.uses_modules != null) - { - result = (CurrentSyntaxUnit as SyntaxTree.unit_module).implementation_part.uses_modules.units; - checkDuplicateUsesUnit(result); - return result; - } - if(CurrentSyntaxUnit is SyntaxTree.program_module) - return null; - return null; - } - - public string FindPCUFileName(string fname, string curr_path) - { - var ext = Path.GetExtension(fname); - - if (string.IsNullOrEmpty(ext)) - fname += CompilerOptions.CompiledUnitExtension; - else if (ext != CompilerOptions.CompiledUnitExtension) - // Чтоб "uses u in 'u.pas';" видело и "u.pcu" тоже - fname = Path.ChangeExtension(fname, CompilerOptions.CompiledUnitExtension); - - if (PCUFileNamesDictionary.ContainsKey(Tuple.Create(fname,curr_path))) - return PCUFileNamesDictionary[Tuple.Create(fname, curr_path)]; - - string res = FindFileInDirs(fname, CompilerOptions.OutputDirectory, curr_path, CompilerOptions.SearchDirectory); - - PCUFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; - return res; - } - - public string FindSourceFileName(string fname, string curr_path) - { - - if (SourceFileNamesDictionary.ContainsKey(Tuple.Create(fname, curr_path))) - return SourceFileNamesDictionary[Tuple.Create(fname, curr_path)]; - - string res = FindSourceFileNameInDirs(fname, curr_path, CompilerOptions.SearchDirectory); - - SourceFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; - return res; - } - - public string FindSourceFileNameInDirs(string fname, params string[] Dirs) - { - var fname_ext = Path.GetExtension(fname); - var need_ext = string.IsNullOrEmpty(fname_ext); - - foreach (SupportedSourceFile sf in SupportedSourceFiles) - foreach (string ext in sf.Extensions) - if (need_ext || fname_ext==ext) - { - var res = FindFileInDirs(need_ext ? fname+ext : fname, Dirs); - //if (!(CompilerOptions.UseDllForSystemUnits && Path.GetDirectoryName(res) == CompilerOptions.SearchDirectory)) - if (res != null) - return res; - } - - return null; - } - - private static string CombinePath(string dir, string path) - { - if (Path.IsPathRooted(path)) return path; - int i = 0; - - for (; i < path.Length && path[i] == '.' && path[i + 1] == '.'; ) - { - dir = Path.GetDirectoryName(dir); - if (string.IsNullOrEmpty(dir)) return null; - i += 2; - if (path[i] == Path.DirectorySeparatorChar || path[i] == Path.AltDirectorySeparatorChar) i += 1; - } - - return Path.Combine(dir, path.Substring(i)); - } - - private string FindFileInDirs(string FileName, params string[] Dirs) - { - foreach (string Dir in Dirs) - { - var res = CombinePath(Dir, FileName); - if (File.Exists(res)) - return res; - } - return null; - } - - public static string GetReferenceFileName(string FileName) - { - // Вначале - кешированные стандартные dll - if (standart_assembly_dict.ContainsKey(FileName)) - return standart_assembly_dict[FileName]; - - if (System.IO.File.Exists(FileName)) - { - return FileName;//.ToLower();//? а надо ли tolover? - } - else - { - return get_assembly_path(FileName,false); - } - } - - private string GetReferenceFileName(string FileName, SyntaxTree.SourceContext sc, string curr_path) - { - if (standart_assembly_dict.ContainsKey(FileName)) - return standart_assembly_dict[FileName]; - - // Наверное, этот код MikhailoMMX лишний - //MikhailoMMX PABCRtl.dll будем искать сначала в GAC, а потом в папке с программой - if (FileName == TreeConverter.compiler_string_consts.pabc_rtl_dll_name) - { - - string name = get_assembly_path(FileName, true); - if ((name != null) && (File.Exists(name))) - return name; - - } - //\MikhailoMMX - - var FullFileName = Path.Combine(curr_path, FileName); - if (System.IO.File.Exists(FullFileName)) // для отладки с *.inc файлами - { - var NewFileName = Path.Combine(compilerOptions.OutputDirectory, Path.GetFileName(FullFileName)); - if (FullFileName != NewFileName) File.Copy(FullFileName, NewFileName, true); - return NewFileName; - } - else - { - string name = get_assembly_path(FileName,false);//? а надо ли tolover? - if (name == null) - throw new AssemblyNotFound(this.CurrentCompilationUnit.SyntaxTree.file_name, FileName, sc); - else - if (File.Exists(name)) - return name; - else - throw new AssemblyNotFound(this.CurrentCompilationUnit.SyntaxTree.file_name, FileName, sc); - } - } - - public string GetUnitFileName(SyntaxTree.unit_or_namespace SyntaxUsesUnit, string curr_path) - { - //ToDo В корневом Compile() создаётся uses_unit_in без name. Выглядит как костыль - if (SyntaxUsesUnit is SyntaxTree.uses_unit_in && (SyntaxUsesUnit as SyntaxTree.uses_unit_in).name == null) return (SyntaxUsesUnit as SyntaxTree.uses_unit_in).in_file.Value; - - string UnitName; - string SourceFileName; - string PCUFileName; - - if (SyntaxUsesUnit is SyntaxTree.uses_unit_in uui) - { - - // Подключение .dll в uses-in. Зачем - не понятно, но было до меня, поэтому просто оставил - switch (Path.GetExtension(uui.in_file.Value).ToLower()) - { - case ".dll": - case ".exe": - return GetReferenceFileName(uui.in_file.Value, uui.in_file.source_context, curr_path); - } - - if (uui.name.idents[0].name.ToLower() != Path.GetFileNameWithoutExtension(uui.in_file.Value).ToLower()) - throw new UsesInWrongName(CurrentCompilationUnit.SyntaxTree.file_name, uui.name.idents[0].name, Path.GetFileNameWithoutExtension(uui.in_file.Value), uui.in_file.source_context); - - UnitName = uui.name.idents[0].name; - - SourceFileName = FindSourceFileName(uui.in_file.Value, curr_path); - PCUFileName = FindPCUFileName(uui.in_file.Value, curr_path); - } - else - { - UnitName = SyntaxUsesUnit.name.idents[0].name; - - SourceFileName = FindSourceFileName(UnitName, curr_path); - PCUFileName = FindPCUFileName(UnitName, curr_path); - - } - - var SourceFileExists = SourceFileName!=null && File.Exists(SourceFileName); - var PCUFileExists = !CompilerOptions.Rebuild && PCUFileName !=null && File.Exists(PCUFileName); - - if (!PCUFileExists && !SourceFileExists) - throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); - - if (PCUFileExists && SourceFileExists) - { - - if (CompilerOptions.Rebuild && !RecompileList.ContainsKey(UnitName)) - PCUFileExists = false; - - else if (File.GetLastWriteTime(PCUFileName) < File.GetLastWriteTime(SourceFileName)) - PCUFileExists = false; - - // На случай если есть своя версия стандартного модуля в папке с программой, но .pcu ещё не создан - else if (Path.GetDirectoryName(SourceFileName) != Path.GetDirectoryName(PCUFileName)) - PCUFileExists = false; - - } - - if (PCUFileExists) - return Path.Combine(curr_path, PCUFileName); - else - return Path.Combine(curr_path, SourceFileName); - - } - - private bool FileInSearchDirectory(string FileName) - { - return Path.GetDirectoryName(FileName).ToLower() == CompilerOptions.SearchDirectory.ToLower(); - } - - public void AddStandartUnitsToUsesSection(SyntaxTree.compilation_unit cu) - { - //if (FileInSearchDirectory(cu.file_name)) return; - - string ModuleName = null; - SyntaxTree.uses_unit_in uses_unit_in = null; - SyntaxTree.unit_or_namespace uses_unit = null; - List UsesList = GetSyntaxInterfaceUsesList(cu); - if (UsesList == null) - return; - string cu_module_name = Path.GetFileNameWithoutExtension(cu.file_name).ToLower(); - foreach (CompilerOptions.StandartModule Module in CompilerOptions.StandartModules) - { - //Я стандартный?? - ModuleName = Path.GetFileNameWithoutExtension(Module.Name); - if (ModuleName.ToLower() == cu_module_name) - return; - } - foreach (CompilerOptions.StandartModule Module in CompilerOptions.StandartModules) - { - if ((Module.AddToLanguages & FirstCompilationUnit.SyntaxTree.Language) != FirstCompilationUnit.SyntaxTree.Language - && (Module.AddToLanguages & CurrentCompilationUnit.SyntaxTree.Language) != CurrentCompilationUnit.SyntaxTree.Language) - continue; - ModuleName = Path.GetFileNameWithoutExtension(Module.Name); - if (Module.AddMethod == CompilerOptions.StandartModuleAddMethod.RightToMain && CurrentCompilationUnit != FirstCompilationUnit) - continue; - foreach (SyntaxTree.unit_or_namespace curunit in UsesList) - { - if (curunit.name.idents.Count == 1 && curunit.name.idents[0].name.ToLower() == ModuleName.ToLower()) - continue; - } - - PascalABCCompiler.SyntaxTree.unit_or_namespace to_add; - if (Path.GetExtension(Module.Name) != "" /*&& Path.GetExtension(ModuleFileName).ToLower() != ".dll"*/) - { - uses_unit_in = new SyntaxTree.uses_unit_in( - _name: new SyntaxTree.ident_list(new SyntaxTree.ident(ModuleName)), - _in_file: new SyntaxTree.string_const(Module.Name)); - //uses_unit_in.source_context = uses_unit_in.in_file.source_context = uses_unit_in.name.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1); - to_add = uses_unit_in; - } - else - { - uses_unit = new SyntaxTree.unit_or_namespace(new SyntaxTree.ident_list(new SyntaxTree.ident(ModuleName))); - //uses_unit.source_context = uses_unit.name.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1); - to_add = uses_unit; - } - switch (Module.AddMethod) - { - case CompilerOptions.StandartModuleAddMethod.RightToMain: - UsesList.Add(to_add); - break; - case CompilerOptions.StandartModuleAddMethod.LeftToAll: - UsesList.Insert(0, to_add); - break; - } - - } - } - - private CompilationUnit CompileReference(PascalABCCompiler.TreeRealization.unit_node_list Units, TreeRealization.compiler_directive cd) - { - TreeRealization.location loc = cd.location; - SyntaxTree.SourceContext sc = null; - if (loc != null) - sc = new SyntaxTree.SourceContext(loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num, 0, 0); - string UnitName = null; - try - { - // "loc == null" для стандартных .dll, как "System.dll" - //ToDo а loc.doc было null в тестранере, но я так и не понял почему. не смог воспроизвести в дебаг режиме - UnitName = GetReferenceFileName(cd.directive, sc, loc?.doc?.file_name == null ? CompilerOptions.OutputDirectory : Path.GetDirectoryName(loc.doc.file_name)); - } - catch (AssemblyNotFound ex) - { - throw; - } - //ToDo плохо, пока дебажил - тут постоянно ловились другие исключения, не связанные с неправильным знаками в путик сборке - catch (Exception ex) - { - throw new InvalidAssemblyPathError(CurrentCompilationUnit.SyntaxTree.file_name, sc); - } - CompilationUnit CurrentUnit = null; - if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); - if ((CurrentUnit = ReadDLL(UnitName)) != null) - { - Units.AddElement(CurrentUnit.SemanticTree); - UnitTable[UnitName] = CurrentUnit; - return CurrentUnit; - } - else - //throw new DLLReadingError(UnitName); - throw new AssemblyReadingError(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, sc); - } - - private bool HasIncludeNamespacesDirective(CompilationUnit Unit) - { - var directives = ConvertDirectives(Unit.SyntaxTree); - foreach (TreeRealization.compiler_directive cd in directives) - { - if (cd.name.ToLower() == TreeConverter.compiler_string_consts.include_namespace_directive) - { - return true; - } - } - return false; - } - - - private Dictionary IncludeNamespaces(CompilationUnit Unit) - { - if (HasIncludeNamespacesDirective(Unit) && Unit.SyntaxTree is SyntaxTree.unit_module && (Unit.SyntaxTree as SyntaxTree.unit_module).unit_name.HeaderKeyword != SyntaxTree.UnitHeaderKeyword.Library) - throw new IncludeNamespaceInUnit(CurrentCompilationUnit.SyntaxTree.file_name, CurrentCompilationUnit.SyntaxTree.source_context); - var directives = ConvertDirectives(Unit.SyntaxTree); - SyntaxTree.unit_module main_library = Unit.SyntaxTree as SyntaxTree.unit_module; - SyntaxTree.program_module main_program = Unit.SyntaxTree as SyntaxTree.program_module; - List files = new List(); - foreach (TreeRealization.compiler_directive cd in directives) - { - if (cd.name.ToLower() == TreeConverter.compiler_string_consts.include_namespace_directive) - { - string directive = cd.directive.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar); - - if (directive == "*.pas" || directive.EndsWith(Path.DirectorySeparatorChar + "*.pas")) - { - string dir = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), directive.Replace(Path.DirectorySeparatorChar + "*.pas", "")); - foreach (string file in Directory.EnumerateFiles(dir, "*.pas")) - { - if (!File.Exists(file)) - throw new FileNotFound(file, cd.location); - files.Add(file); - } - - } - else - { - string file = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), directive); - if (!File.Exists(file)) - throw new FileNotFound(file, cd.location); - files.Add(file); - } - - - - } - } - Dictionary namespaces = new Dictionary(StringComparer.OrdinalIgnoreCase); - List namespace_modules = new List(); - foreach (string file in files) - { - - SyntaxTree.compilation_unit tree = GetNamespaceSyntaxTree(file); - if (!(tree is SyntaxTree.unit_module)) - throw new NamespaceModuleExpected(tree.source_context); - SyntaxTree.unit_module unit = tree as SyntaxTree.unit_module; - if (unit.unit_name.HeaderKeyword != SyntaxTree.UnitHeaderKeyword.Namespace) - throw new NamespaceModuleExpected(unit.unit_name.source_context); - if (unit.implementation_part != null) - throw new NamespaceModuleExpected(unit.implementation_part.source_context); - if (unit.finalization_part != null) - throw new NamespaceModuleExpected(unit.finalization_part.source_context); - if (unit.initialization_part != null && unit.initialization_part.list.Count > 0) - throw new NamespaceModuleExpected(unit.initialization_part.source_context); - SyntaxTree.syntax_namespace_node ns = null; - if (!namespaces.TryGetValue(unit.unit_name.idunit_name.name, out ns)) - { - ns = new SyntaxTree.syntax_namespace_node(unit.unit_name.idunit_name.name); - ns.referenced_units = new TreeRealization.unit_node_list(); - namespaces[unit.unit_name.idunit_name.name] = ns; - } - if (unit.interface_part.interface_definitions != null) - { - foreach (SyntaxTree.declaration decl in unit.interface_part.interface_definitions.defs) - { - ns.defs.Add(decl); - } - if (unit.interface_part.uses_modules != null) - { - checkDuplicateUsesUnit(unit.interface_part.uses_modules.units); - foreach (SyntaxTree.unit_or_namespace name_space in unit.interface_part.uses_modules.units) - { - if (IsPossibleNamespace(name_space, false, Path.GetDirectoryName(file))) - { - ns.referenced_units.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(name_space), get_location_from_treenode(name_space, tree.file_name))); - } - else - { - namespace_modules.Add(name_space); - } - } - } - } - } - foreach (string s in namespaces.Keys) - { - if (main_library != null) - main_library.interface_part.interface_definitions.Insert(0, namespaces[s]); - else - main_program.program_block.defs.Insert(0, namespaces[s]); - } - SyntaxTree.uses_list main_uses = null; - if (main_library != null) - { - if (main_library.interface_part.uses_modules != null) - main_uses = main_library.interface_part.uses_modules; - } - else if (main_program.used_units != null) - main_uses = main_program.used_units; - if (main_uses == null) - main_uses = new SyntaxTree.uses_list(); - Dictionary dict = new Dictionary(); - foreach (SyntaxTree.unit_or_namespace name_space in namespace_modules) - { - string name = SyntaxTree.Utils.IdentListToString(name_space.name.idents, ".").ToLower(); - if (!dict.ContainsKey(name)) - { - main_uses.Add(name_space); - dict.Add(name, name); - } - } - if (main_library != null) - main_library.interface_part.uses_modules = main_uses; - else - main_program.used_units = main_uses; - return namespaces; - } - - private SyntaxTree.compilation_unit GetNamespaceSyntaxTree(string FileName) - { - string SourceText = GetSourceFileText(FileName); - List DefinesList = new List(); - if (!compilerOptions.Debug && !compilerOptions.ForDebugging) - DefinesList.Add("RELEASE"); - else - DefinesList.Add("DEBUG"); - SyntaxTree.compilation_unit SyntaxTree = InternalParseText(FileName, SourceText, errorsList, warnings, DefinesList); - if (errorsList.Count > 0) - throw errorsList[0]; - SyntaxTree = syntaxTreeConvertersController.Convert(SyntaxTree) as SyntaxTree.compilation_unit; - return SyntaxTree; - } - - public TreeRealization.unit_node_list GetReferences(CompilationUnit Unit) - { - //TODO переделать, ConvertDirectives определена дважды и вызывается дважды! - TreeRealization.unit_node_list res = new TreeRealization.unit_node_list(); - List directives; - if (Unit.SemanticTree is TreeRealization.common_unit_node) - directives = (Unit.SemanticTree as TreeRealization.common_unit_node).compiler_directives; - else - directives = ConvertDirectives(Unit.SyntaxTree); - if (CompilerOptions.UseDllForSystemUnits) - { - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PABCRtl.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\mscorlib.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Core.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Numerics.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Windows.Forms.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Drawing.dll", null, null)); - if (Unit.SyntaxTree is SyntaxTree.program_module && (Unit.SyntaxTree as SyntaxTree.program_module).used_units != null) - foreach (SyntaxTree.unit_or_namespace uui in (Unit.SyntaxTree as SyntaxTree.program_module).used_units.units) - { - if (uui.name.ToString() == "Graph3D") - { - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationFramework.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\WindowsBase.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationCore.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.Wpf.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.dll", null, null)); - } - } - } - foreach (TreeRealization.compiler_directive cd in directives) - { - if (cd.name.ToLower() == TreeConverter.compiler_string_consts.compiler_directive_reference) - { - if (string.IsNullOrEmpty(cd.directive)) - throw new TreeConverter.SimpleSemanticError(cd.location, "EXPECTED_ASSEMBLY_NAME"); - else - CompileReference(res, cd); - } - } - if (CompilerOptions.ProjectCompiled) - { - foreach (ReferenceInfo ri in project.references) - { - CompileReference(res,new TreeRealization.compiler_directive("reference",ri.full_assembly_name,null,null)); - } - } - return res; - } - - private bool IsPossibleNamespace(SyntaxTree.unit_or_namespace name_space, bool add_to_standard_modules, string curr_path) - { - if (name_space is SyntaxTree.uses_unit_in) - return false; - if (name_space.name.idents.Count > 1) - return true; - string src = FindSourceFileName(name_space.name.idents[0].name, curr_path); - string pcu = FindPCUFileName(name_space.name.idents[0].name, curr_path); - if (src == null && pcu == null) - return true; - if (CompilerOptions.UseDllForSystemUnits && src != null && string.Compare(Path.GetDirectoryName(src), Path.Combine(CompilerOptions.SystemDirectory, "Lib"), true) == 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "PT4", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "CRT", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "Arrays", true) != 0 - //&& string.Compare(Path.GetFileNameWithoutExtension(src), "FormsABC", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "MPI", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "LibForHaskell", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "Collections", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "Core", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(src), "Oberon00System", true) != 0) - { - string s = Path.GetFileNameWithoutExtension(src).ToLower(); - if (add_to_standard_modules && !StandarModules.Contains(s)) - StandarModules.Add(s); - return true; - } - if (CompilerOptions.UseDllForSystemUnits && pcu != null && string.Compare(Path.GetDirectoryName(pcu), Path.Combine(CompilerOptions.SystemDirectory, "Lib"), true) == 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "PT4", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "CRT", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Arrays", true) != 0 - //&& string.Compare(Path.GetFileNameWithoutExtension(pcu), "FormsABC", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "MPI", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "LibForHaskell", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Collections", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Core", true) != 0 - && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Oberon00System", true) != 0 - ) - { - string s = Path.GetFileNameWithoutExtension(pcu).ToLower(); - if (add_to_standard_modules && !StandarModules.Contains(s)) - StandarModules.Add(s); - return true; - } - return false; - } - - public TreeRealization.using_namespace GetNamespace(SyntaxTree.unit_or_namespace _name_space) - { - return new TreeRealization.using_namespace(SyntaxTree.Utils.IdentListToString(_name_space.name.idents, ".")); - } - - private TreeRealization.using_namespace GetNamespace(TreeRealization.using_namespace_list using_list, string full_namespace_name, SyntaxTree.unit_or_namespace _name_space, bool possible_is_unit, Dictionary pabc_namespaces) - { - if (!NetHelper.NetHelper.NamespaceExists(full_namespace_name) && !(pabc_namespaces != null && pabc_namespaces.ContainsKey(full_namespace_name))) - { - if (possible_is_unit) - if (!full_namespace_name.Contains(".")) - throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, full_namespace_name, _name_space.source_context); - throw new TreeConverter.NamespaceNotFound(full_namespace_name, get_location_from_treenode(_name_space.name, CurrentCompilationUnit.SyntaxTree.file_name)); - } - return new TreeRealization.using_namespace(full_namespace_name); - } - - public void AddNamespaces(TreeRealization.using_namespace_list using_list, List namespaces, bool possible_is_units, Dictionary pabc_namespaces) - { - foreach (SyntaxTree.unit_or_namespace ns in namespaces) - using_list.AddElement(GetNamespace(using_list, SyntaxTree.Utils.IdentListToString(ns.name.idents, "."), ns, possible_is_units, pabc_namespaces)); - } - - public void AddNamespaces(TreeRealization.using_namespace_list using_list, SyntaxTree.using_list ul) - { - if (ul != null) - AddNamespaces(using_list, ul.namespaces, false, null); - } - - public SyntaxTree.using_list GetInterfaceSyntaxUsingList(SyntaxTree.compilation_unit cu) - { - if (cu is SyntaxTree.unit_module) - return (cu as SyntaxTree.unit_module).interface_part.using_namespaces; - if (cu is SyntaxTree.program_module) - return (cu as SyntaxTree.program_module).using_namespaces; - return null; - } - - private SyntaxTree.using_list GetImplementationSyntaxUsingList(SyntaxTree.compilation_unit cu) - { - if (cu is SyntaxTree.unit_module) - if ((cu as SyntaxTree.unit_module).implementation_part!=null) - return (cu as SyntaxTree.unit_module).implementation_part.using_namespaces; - return null; - } - - public string GetSourceFileText(string FileName) - { - return (string)SourceFilesProvider(FileName, SourceFileOperation.GetText); - } - - - public SyntaxTree.compilation_unit ParseText(string FileName, string Text, List ErrorList, List Warnings) - { - Reset(); - OnChangeCompilerState(this, CompilerState.CompilationStarting, FileName); - SyntaxTree.compilation_unit cu = InternalParseText(FileName, Text, ErrorsList, Warnings); - OnChangeCompilerState(this, CompilerState.Ready, FileName); - return cu; - } - - private SyntaxTree.compilation_unit InternalParseText(string FileName, string Text, List ErrorList, List Warnings, List DefinesList = null) - { - OnChangeCompilerState(this, CompilerState.BeginParsingFile, FileName); - SyntaxTree.compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, DefinesList); - OnChangeCompilerState(this, CompilerState.EndParsingFile, FileName); - //Вычисляем сколько строк скомпилировали - if (ErrorList.Count == 0 && cu != null && cu.source_context!=null) - linesCompiled += (uint)(cu.source_context.end_position.line_num - cu.source_context.begin_position.line_num + 1); - return cu; - } - - /*private bool check_for_library(List directives) - { - foreach (compiler_directive cd in directives) - { - if (string.Compare(cd.name,"apptype")==0 && string.Compare(cd.directive,"dll")==0) - return true; - } - return false; - }*/ - - public static bool is_dll(SyntaxTree.compilation_unit cu) - { - foreach (SyntaxTree.compiler_directive cd in cu.compiler_directives) - if (string.Compare(cd.Name.text, "apptype", true) == 0 && string.Compare(cd.Directive.text, "dll", true) == 0) - return true; - return false; - } - - public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) - { - string UnitName = GetUnitFileName(SyntaxUsesUnit, prev_path); - // имя папки, в которой лежит текущий модуль - // используется для подключения модулей, $include и т.п. из модуля, подключённого с uses-in - var curr_path = Path.GetDirectoryName(UnitName); - - CompilationUnit CurrentUnit = UnitTable[UnitName]; - if (CurrentUnit != null && CurrentUnit.SemanticTree is PascalABCCompiler.TreeRealization.dot_net_unit_node - && SyntaxUsesUnit is PascalABCCompiler.SyntaxTree.uses_unit_in ui && ui.in_file != null) // значит, это пространство имен и секция in у него должна отсутствовать - { - ErrorsList.Add(new NamespaceCannotHaveInSection(ui.in_file.source_context)); - } - - if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) - { - string sfn = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); - if (sfn != null && UnitTable[sfn] != null) - CurrentUnit = UnitTable[sfn]; - } - - if (CurrentUnit != null) - if (CurrentUnit.State != UnitState.BeginCompilation || CurrentUnit.SemanticTree != null) //ИЗБАВИТЬСЯ ОТ ВТОРОГО УСЛОВИЯ - { - Units.AddElement(CurrentUnit.SemanticTree); - Units.AddRange(GetReferences(CurrentUnit)); - return CurrentUnit; - } - - if (UnitName.ToLower().LastIndexOf(".dll") >= 0 || UnitName.ToLower().LastIndexOf(".exe") >= 0) - if (File.Exists(UnitName)) - { - if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); - if ((CurrentUnit = ReadDLL(UnitName)) != null) - { - Units.AddElement(CurrentUnit.SemanticTree); - UnitTable[UnitName] = CurrentUnit; - return CurrentUnit; - } - else - //throw new DLLReadingError(UnitName); - throw new AssemblyReadingError(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); - } - if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) - if (File.Exists(UnitName)) - { - if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); - string SourceFileName = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); - try - { - if ((CurrentUnit = ReadPCU(UnitName)) != null) - { - Units.AddElement(CurrentUnit.SemanticTree); - Units.AddRange(GetReferences(CurrentUnit)); - UnitTable[UnitName] = CurrentUnit; - return CurrentUnit; - } - } - catch (InvalidPCUFule) - { - //Перекомпилируем.... - } - catch (Error) - { - throw; - } - catch (Exception e) - { - OnChangeCompilerState(this, CompilerState.PCUReadingError, UnitName); -#if DEBUG - if (!InternalDebug.SkipPCUErrors) - throw new Errors.CompilerInternalError("PCUReader", e); -#endif - } - if (SourceFileName == null) - throw new ReadPCUError(UnitName); - else - UnitName = SourceFileName; - } - string SourceText = null; - Dictionary docs = null; - if (CurrentUnit == null) - { - - CurrentUnit = new CompilationUnit(); - if (FirstCompilationUnit == null) - FirstCompilationUnit = CurrentUnit; - OnChangeCompilerState(this, CompilerState.BeginCompileFile, UnitName); - SourceText = GetSourceFileText(UnitName); - if (SourceText == null) - if (CurrentUnit == FirstCompilationUnit) - throw new SourceFileNotFound(UnitName); - else - throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); - List DefinesList = new List(); - if (!compilerOptions.Debug && !compilerOptions.ForDebugging) - DefinesList.Add("RELEASE"); - else - DefinesList.Add("DEBUG"); - CurrentUnit.SyntaxTree = InternalParseText(UnitName, SourceText, errorsList, warnings, DefinesList); - - if (errorsList.Count == 0) // SSM 2/05/16 - для преобразования синтаксических деревьев извне - { - CurrentUnit.SyntaxTree = syntaxTreeConvertersController.Convert(CurrentUnit.SyntaxTree) as SyntaxTree.compilation_unit; - - } - - if (errorsList.Count == 0 && need_gen_doc(CurrentUnit.SyntaxTree)) - { - if (SourceText != null) - { - docs = AddDocumentationToNodes(CurrentUnit.SyntaxTree, SourceText); - if (docs != null) - CurrentUnit.Documented = true; - } - } - if (CurrentUnit.SyntaxTree is SyntaxTree.unit_module) - { - if ((CurrentUnit.SyntaxTree as SyntaxTree.unit_module).unit_name.HeaderKeyword == SyntaxTree.UnitHeaderKeyword.Namespace) - throw new NamespacesCanBeCompiledOnlyInProjects(CurrentUnit.SyntaxTree.source_context); - compilerOptions.UseDllForSystemUnits = false; - } - - // SSM 21/05/20 Проверка, что мы не записали apptype dll в небиблиотеку - - var ccu = CurrentUnit.SyntaxTree; - foreach (SyntaxTree.compiler_directive cd in ccu.compiler_directives) - if (string.Compare(cd.Name.text, "apptype", true) == 0 && string.Compare(cd.Directive.text, "dll", true) == 0) - { - if (!(ccu is SyntaxTree.unit_module) || - (ccu is SyntaxTree.unit_module um && um.unit_name.HeaderKeyword != SyntaxTree.UnitHeaderKeyword.Library)) - { - ErrorsList.Add(new AppTypeDllIsAllowedOnlyForLibraries(ccu.file_name, cd.source_context)); - break; - } - } - // - - if (is_dll(CurrentUnit.SyntaxTree)) - compilerOptions.OutputFileType = PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary; - CurrentUnit.CaseSensitive = ParsersController.LastParser.CaseSensitive; - CurrentCompilationUnit = CurrentUnit; - - CurrentUnit.SyntaxUnitName = SyntaxUsesUnit; - - //BadNodesInSyntaxTree.Clear(); - if (errorsList.Count > 0) - { - CurrentUnit.syntax_error = errorsList[0] as PascalABCCompiler.Errors.SyntaxError; - foreach (Errors.Error er in errorsList) - if (er is SyntaxError && (er as SyntaxError).bad_node != null) - BadNodesInSyntaxTree[(er as SyntaxError).bad_node] = er; - } - - //if (CurrentUnit.SyntaxTree == null) - if (errorsList.Count > 0) - { - //if (errorsList.Count == 0) - // throw new Errors.SyntaxError("Internal parser error: Parser not create syntax tree", UnitName,null,null); - throw errorsList[0]; - } - - UnitTable[UnitName] = CurrentUnit; - - if (UnitTable.Count > 1)//если это не главный модуль - if (CurrentUnit.SyntaxTree is SyntaxTree.program_module) - throw new UnitModuleExpected(UnitName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); - else if (is_dll(CurrentUnit.SyntaxTree)) - throw new UnitModuleExpectedLibraryFound(UnitName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); - //здесь в начало uses добавляем стандартные модули -#if DEBUG - if (InternalDebug.AddStandartUnits) -#endif - AddStandartUnitsToUsesSection(CurrentUnit.SyntaxTree); - - } - CurrentSyntaxUnit = SyntaxUsesUnit; - CurrentCompilationUnit = CurrentUnit; - - CurrentUnit.PossibleNamespaces.Clear(); - - //TODO переделать, слишком сложно, некоторый код дублируется - - - System.Collections.Generic.List SyntaxUsesList; - SyntaxUsesList = GetSyntaxInterfaceUsesList(CurrentUnit.SyntaxTree); - - if (SyntaxUsesList != null) - { - for (int i = SyntaxUsesList.Count - 1 - CurrentUnit.InterfaceUsedUnits.Count; i >= 0; i--) - { - if (!IsPossibleNamespace(SyntaxUsesList[i], false, curr_path)) - { - compilerOptions.UseDllForSystemUnits = false; - break; - } - } - } - TreeRealization.unit_node_list References = GetReferences(CurrentUnit); - var namespaces = IncludeNamespaces(CurrentUnit); - if (SyntaxUsesList != null) - { - - for (int i = SyntaxUsesList.Count - 1 - CurrentUnit.InterfaceUsedUnits.Count; i >= 0; i--) - { - if (IsPossibleNamespace(SyntaxUsesList[i], true, curr_path) || namespaces.ContainsKey(SyntaxUsesList[i].name.idents[0].name)) - { - CurrentUnit.InterfaceUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); - CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); - } - else - { - string CurrentSyntaxUnitName = GetUnitFileName(SyntaxUsesList[i], curr_path); - CurrentUnit.CurrentUsesUnit = CurrentSyntaxUnitName; - if (UnitTable[CurrentSyntaxUnitName] != null) - if (UnitTable[CurrentSyntaxUnitName].State == UnitState.BeginCompilation) - { - string CurrentSyntaxUnitNameCurrentUsesUnit = UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit; - if (CurrentSyntaxUnitNameCurrentUsesUnit != null) - { - //если сначало взали pcu а потом решили его перекомпилировать, поэтому в таблице его нет - if (UnitTable[CurrentSyntaxUnitNameCurrentUsesUnit] == null) - UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit = FindSourceFileName(Path.GetFileNameWithoutExtension(CurrentSyntaxUnitNameCurrentUsesUnit), Path.GetDirectoryName(CurrentSyntaxUnitNameCurrentUsesUnit)); - //далее финальная поверка на зацикливание - if (UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit != null && UnitTable[UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit].State == UnitState.BeginCompilation) - throw new CycleUnitReference(UnitName, SyntaxUsesList[i]); - } - } - CompileUnit(CurrentUnit.InterfaceUsedUnits, SyntaxUsesList[i], curr_path); - if (CurrentUnit.State == UnitState.Compiled) - { - Units.AddElement(CurrentUnit.SemanticTree); - Units.AddRange(References); - return CurrentUnit; - } - } - - } - } - - CurrentCompilationUnit = CurrentUnit; - - CurrentUnit.InterfaceUsedUnits.AddRange(References); - - AddNamespaces(CurrentUnit.InterfaceUsingNamespaceList, CurrentUnit.PossibleNamespaces, true, namespaces); - AddNamespaces(CurrentUnit.InterfaceUsingNamespaceList, GetInterfaceSyntaxUsingList(CurrentUnit.SyntaxTree)); - - //Console.WriteLine("Compile Interface "+UnitName);//DEBUG -#if DEBUG - if (InternalDebug.SemanticAnalysis) -#endif - { - if (CurrentUnit.State != UnitState.InterfaceCompiled) - { - OnChangeCompilerState(this, CompilerState.CompileInterface, UnitName); - PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; - CurrentUnit.SemanticTree = SyntaxTreeToSemanticTreeConverter.CompileInterface( - CurrentUnit.SyntaxTree, - CurrentUnit.InterfaceUsedUnits, - ErrorsList, Warnings, - CurrentUnit.syntax_error, - BadNodesInSyntaxTree, - CurrentUnit.InterfaceUsingNamespaceList, - docs, - CompilerOptions.Debug, - CompilerOptions.ForDebugging - ); - CheckErrors(); - } - } - TreeRealization.common_unit_node cun = CurrentUnit.SemanticTree as TreeRealization.common_unit_node; - /*if (cun != null) - { - if (!UnitsSortedList.Contains(CurrentUnit))//vnimanie zdes inogda pri silnoj zavisimosti modulej moduli popadajut neskolko raz - UnitsSortedList.Add(CurrentUnit); - }*/ - CurrentUnit.State = UnitState.InterfaceCompiled; - if (Units != null) - { - Units.AddElement(CurrentUnit.SemanticTree); - Units.AddRange(References); - } - SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); - CompilationUnit cu = null; bool interfcompile = true; - CurrentUnit.ImplementationUsedUnits.clear(); - CurrentUnit.PossibleNamespaces.Clear(); - if (SyntaxUsesList != null) - { - for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) - if (!IsPossibleNamespace(SyntaxUsesList[i], true, curr_path)) - { - cu = UnitTable[GetUnitFileName(SyntaxUsesList[i], curr_path)]; - if (cu != null && cu.State == UnitState.BeginCompilation) - { - UnitsToCompile.Add(cu); - interfcompile = false; -#if DEBUG - // Console.WriteLine("[DEBUGINFO]Send compile to end " + Path.GetFileName(GetUnitFileName(SyntaxUsesList[i])));//DEBUG -#endif - } - else - { - CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], curr_path); - } - } - else - { - CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); - CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); - } - } - - CurrentCompilationUnit = CurrentUnit; - - AddNamespaces(CurrentUnit.ImplementationUsingNamespaceList, CurrentUnit.PossibleNamespaces, true, namespaces); - AddNamespaces(CurrentUnit.ImplementationUsingNamespaceList, GetImplementationSyntaxUsingList(CurrentUnit.SyntaxTree)); - - if (!interfcompile) - { - UnitsToCompile.Add(CurrentUnit); - if (cun != null) - { - if (!UnitsSortedList.Contains(CurrentUnit))//vnimanie zdes inogda pri silnoj zavisimosti modulej moduli popadajut neskolko raz - UnitsSortedList.Add(CurrentUnit); - } - //Console.WriteLine("Send compile to end "+UnitName);//DEBUG - return CurrentUnit; - } - - //Console.WriteLine("Compile Implementation "+UnitName);//DEBUG - if (CurrentUnit.SyntaxTree is SyntaxTree.unit_module) - { -#if DEBUG - if (InternalDebug.SemanticAnalysis) -#endif - { - OnChangeCompilerState(this, CompilerState.CompileImplementation, UnitName); - PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; - SyntaxTreeToSemanticTreeConverter.CompileImplementation( - (PascalABCCompiler.TreeRealization.common_unit_node)CurrentUnit.SemanticTree, - CurrentUnit.SyntaxTree, - buildImplementationUsesList(CurrentUnit), - ErrorsList, Warnings, - CurrentUnit.syntax_error, - BadNodesInSyntaxTree, - CurrentUnit.InterfaceUsingNamespaceList, - CurrentUnit.ImplementationUsingNamespaceList, - docs, - CompilerOptions.Debug, - CompilerOptions.ForDebugging - ); - CheckErrors(); - } - } - CurrentUnit.State = UnitState.Compiled; - if (cun != null) - { - if (!UnitsSortedList.Contains(CurrentUnit))//vnimanie zdes inogda pri silnoj zavisimosti modulej moduli popadajut neskolko raz - UnitsSortedList.Add(CurrentUnit); - } - OnChangeCompilerState(this, CompilerState.EndCompileFile, UnitName); - //SavePCU(CurrentUnit, UnitName); - CurrentUnit.UnitName = UnitName; - return CurrentUnit; - /*if(CurrentUnit.State!=UnitState.Compiled) - { - //Console.WriteLine("Compile Interface "+UnitName);//DEBUG - CurrentUnit.SemanticTree=SyntaxTreeToSemanticTreeConverter.CompileInterface(CurrentUnit.SyntaxTree, - CurrentUnit.InterfaceUsedUnits,CurrentUnit.syntax_error); - CurrentUnit.State=UnitState.InterfaceCompiled; - SyntaxUsesList=GetSemanticImplementationUsesList(CurrentUnit.SyntaxTree); - if(SyntaxUsesList!=null) - for(int i=SyntaxUsesList.Count-1;i>=0;i--) - CompileUnit(CurrentUnit.ImplementationUsedUnits,SyntaxUsesList[i]); - //Console.WriteLine("Compile Implementation "+UnitName);//DEBUG - if (CurrentUnit.SyntaxTree is SyntaxTree.unit_module) - { - SyntaxTreeToSemanticTreeConverter.CompileImplementation(CurrentUnit.SemanticTree, - CurrentUnit.SyntaxTree,CurrentUnit.ImplementationUsedUnits,CurrentUnit.syntax_error); - } - CurrentUnit.State=UnitState.Compiled; - Units.Add(CurrentUnit.SemanticTree); - SaveSemanticTreeToFile(CurrentUnit,UnitName); - }*/ - } - - private Dictionary AddDocumentationToNodes(SyntaxTree.compilation_unit cu, string Text) - { - List errors = new List(); - List warnings = new List(); - string doctagsParserExtension = Path.GetExtension(cu.file_name)+"dt"+PascalABCCompiler.Parsers.Controller.HideParserExtensionPostfixChar; - PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(cu.file_name, doctagsParserExtension), Text, errors, warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list; - if (errors.Count > 0) return null; - PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor(); - return docconst.Construct(cu, dt); - } - - private bool need_gen_doc(SyntaxTree.compilation_unit cu) - { - if (project != null && project.generate_xml_doc) - return true; - if (cu == null) - return false; - if (cu.file_name != null && internalDebug.DocumentedUnits.Contains(cu.file_name.ToLower())) - return true; - foreach (SyntaxTree.compiler_directive cd in cu.compiler_directives) - if (string.Compare(cd.Name.text, "gendoc",true)==0 && string.Compare(cd.Directive.text,"true",true)==0) - return true; - return false; - } - - private TreeRealization.unit_node_list buildImplementationUsesList(CompilationUnit cu) - { - TreeRealization.unit_node_list unl = new PascalABCCompiler.TreeRealization.unit_node_list(); - unl.AddRange(cu.ImplementationUsedUnits); - foreach (TreeRealization.unit_node un in cu.InterfaceUsedUnits) - { - if (un is TreeRealization.dot_net_unit_node) - unl.AddElement(un); - } - return unl; - } - - public void SavePCU(CompilationUnit Unit, string TargetFileName) - { -//#if DEBUG - try - { - if (Unit.SyntaxTree != null && Unit.SyntaxTree is SyntaxTree.unit_module) - { - if (((SyntaxTree.unit_module)Unit.SyntaxTree).unit_name.HeaderKeyword == PascalABCCompiler.SyntaxTree.UnitHeaderKeyword.Library) - return; - foreach (SyntaxTree.compiler_directive cd in Unit.SyntaxTree.compiler_directives) - if (cd.Name.text.ToLower() == TreeConverter.compiler_string_consts.compiler_savepcu) - if (!Convert.ToBoolean(cd.Directive.text)) - return; - } - } - catch - { - } -//#endif - PCUWriter writer=null; - try - { -#if DEBUG - if (InternalDebug.PCUGenerate) -#endif - if (compilerOptions.SavePCU) - if ((Unit.SemanticTree as TreeRealization.common_unit_node).namespaces.Count > 1 && - Unit.SyntaxTree!=null && - Unit.State == UnitState.Compiled) - { - writer = new PCUWriter(this, pr_ChangeState); - - if (FileInSearchDirectory(TargetFileName)) - TargetFileName = Path.ChangeExtension(TargetFileName, CompilerOptions.CompiledUnitExtension); - else - TargetFileName = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), Path.GetFileNameWithoutExtension(TargetFileName) + CompilerOptions.CompiledUnitExtension); - - bool dbginfo = true;/*CompilerOptions.Debug*/ -#if DEBUG - dbginfo = InternalDebug.IncludeDebugInfoInPCU; -#endif - writer.SaveSemanticTree(Unit, TargetFileName, dbginfo); - - } - } - catch (Exception err) - { - //ErrorsList.Add(new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err)); - OnChangeCompilerState(this, CompilerState.PCUWritingError, TargetFileName); -#if DEBUG - if (!InternalDebug.SkipPCUErrors) - throw new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err); - writer.RemoveSelf(); -#endif - } - } - - public CompilationUnit ReadPCU(string FileName) - { - PCUReader pr = new PCUReader(this,pr_ChangeState); - return pr.GetCompilationUnit(FileName,CompilerOptions.Debug); - } - - void pr_ChangeState(object Sender, PCUReaderWriterState State, object obj) - { - switch (State) - { - case PCUReaderWriterState.BeginReadTree: - OnChangeCompilerState(this, CompilerState.ReadPCUFile, (Sender as PCUReader).FileName); - break; - case PCUReaderWriterState.EndReadTree: - CompilationUnit cu = obj as CompilationUnit; - cu.State = UnitState.Compiled; - unitTable[(Sender as PCUReader).FileName] = cu; - UnitsSortedList.Add(cu); - GetReferences(cu); - break; - case PCUReaderWriterState.EndSaveTree: - OnChangeCompilerState(this, CompilerState.SavePCUFile, (Sender as PCUWriter).FileName); - break; - - } - } - /* TreeRealization.common_unit_node cun11 = CurrentUnit.SemanticTree as TreeRealization.common_unit_node; - if (cun11 != null) - UnitsSortedList.AddElement(cun11);*/ - - static string standartAssemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(string)).ManifestModule.FullyQualifiedName); - - public static Dictionary standart_assembly_dict = new Dictionary(); - static Compiler() - { - string[] ss = new string[] { "mscorlib.dll","System.dll", "System.Core.dll", "System.Numerics.dll", "System.Windows.Forms.dll", "PABCRtl.dll" }; - foreach (var x in ss) - standart_assembly_dict[x] = get_standart_assembly_path(x); - } - public static string get_standart_assembly_path(string name) - { - name = name.Replace("%GAC%\\", ""); - string ttn = System.IO.Path.GetFileNameWithoutExtension(name); - string tn = Path.Combine(standartAssemblyPath, name); - if (File.Exists(tn)) - return tn; - if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX) - { - string windir = Path.Combine(Environment.GetEnvironmentVariable("windir"), "Microsoft.NET"); - tn = windir + @"\assembly\GAC_MSIL\"; - tn += ttn + "\\"; - System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - tn = windir + @"\assembly\GAC_64\"; - tn += ttn + "\\"; - di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - tn = windir + @"\assembly\GAC_32\"; - tn += ttn + "\\"; - di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - tn = windir + @"\assembly\GAC\"; - tn += ttn + "\\"; - di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - windir = Environment.GetEnvironmentVariable("windir"); - tn = windir + @"\assembly\GAC_MSIL\"; - tn += ttn + "\\"; - di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - tn = windir + @"\assembly\GAC_64\"; - tn += ttn + "\\"; - di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - tn = windir + @"\assembly\GAC_32\"; - tn += ttn + "\\"; - di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - tn = windir + @"\assembly\GAC\"; - tn += ttn + "\\"; - di = new System.IO.DirectoryInfo(tn); - if (!di.Exists) - { - return null; - } - } - } - } - } - } - } - } - System.IO.DirectoryInfo[] diarr = di.GetDirectories(); - tn = Path.Combine((diarr[0]).FullName, name); - } - else - { - string gac_path = "/usr/lib/mono/4.0/gac"; - DirectoryInfo di = new DirectoryInfo(Path.Combine(gac_path, ttn)); - if (di.Exists) - { - System.IO.DirectoryInfo[] diarr = di.GetDirectories(); - tn = Path.Combine((diarr[diarr.Length - 1]).FullName, name); - } - else - return null; - - } - return tn; - - } - public static string get_assembly_path(string name, bool search_for_intellisense) - { - //если явно задан каталог то ищем только там - if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX && !name.StartsWith("%GAC%\\")) - { - if (Path.GetDirectoryName(name) != string.Empty) - if (File.Exists(name)) - return name; - else - return null; - } - if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) - { - string SystemDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); - string SearchDirectory = Path.Combine(SystemDirectory, "Lib"); - if (File.Exists(Path.Combine(Environment.CurrentDirectory, name))) - return Path.Combine(Environment.CurrentDirectory, name); - if (File.Exists(Path.Combine(SearchDirectory, name))) - { - File.Copy(Path.Combine(SearchDirectory, name), Path.Combine(Environment.CurrentDirectory, name), true); - return Path.Combine(Environment.CurrentDirectory, name); - } - - } - if (!search_for_intellisense && !name.StartsWith("%GAC%\\")) - { - string dir = Environment.CurrentDirectory; - - if (File.Exists(Path.Combine(dir, name))) - { - return Path.Combine(dir, name); - } - } - - return get_standart_assembly_path(name); - } - - - - public CompilationUnit ReadDLL(string FileName) - { - if (DLLCashe.ContainsKey(FileName)) - return DLLCashe[FileName]; - OnChangeCompilerState(this, CompilerState.ReadDLL, FileName); - TreeRealization.using_namespace_list using_namespaces = new TreeRealization.using_namespace_list(); - try - { - TreeRealization.dot_net_unit_node un = - new TreeRealization.dot_net_unit_node(new NetHelper.NetScope(using_namespaces, - /*System.Reflection.Assembly.LoadFrom(FileName)*/ - PascalABCCompiler.NetHelper.NetHelper.LoadAssembly(FileName), SyntaxTreeToSemanticTreeConverter.SymbolTable)); - CompilationUnit cu = new CompilationUnit(); - cu.SemanticTree = un; - - //un.dotNetScope=new PascalABCCompiler.NetHelper.NetScope(using_namespaces, - // System.Reflection.Assembly.LoadFrom(FileName),SyntaxTreeToSemanticTreeConverter.SymbolTable); - DLLCashe[FileName] = cu; - - return cu; - } - catch (ReflectionTypeLoadException e) - { - Console.Error.WriteLine(e.Message); - foreach (var eLoaderException in e.LoaderExceptions) - { - Console.Error.WriteLine(eLoaderException.Message); - } - - return null; - } - catch (Exception e) - { - Console.Error.WriteLine(e.Message); - return null; - } - } - - /*public CompilationUnit RecompileUnit(string unit_name) - { - Console.WriteLine("recompile {0}", unit_name); - CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(new SyntaxTree.string_const(program_folder + "\\" + unit_name+".pas")); - CompileUnit(Units, CurrentSyntaxUnit); - CompilationUnit cu = new CompilationUnit(); - if (Units.Count != 0) - cu.SemanticTree = Units[Units.Count - 1]; - else - return null; - return cu; - }*/ - public bool NeedRecompiled(string name, string dir, string[] included, PCUReader pr) - { - string pas_name = FindSourceFileName(name, dir); - string pcu_name = FindPCUFileName(name, dir); - if (UnitTable[pas_name] != null) - return true; - bool need = false; - for (int i = 0; i < included.Length; i++) - { - //if (included[i].Contains("$")) - // continue; - string pas_name2 = FindSourceFileName(included[i], dir); - string pcu_name2 = FindPCUFileName(included[i], dir); - if (UnitTable[pas_name2] != null) - return true; - if (!File.Exists(pcu_name2)) - { - need = true; RecompileList[name] = name; - RecompileList[included[i]] = included[i]; - } - else - if (SourceFileExists(pas_name2) && File.GetLastWriteTime(pcu_name2) <= SourceFileGetLastWriteTime(pas_name2)) - { - need = true; CycleUnits[name] = name; RecompileList[name] = name; - RecompileList[included[i]] = included[i]; - } - } - if (need) return true; - if (!SourceFileExists(pas_name)) return false; - if (!File.Exists(pcu_name)) return true; - if (File.GetLastWriteTime(pcu_name) < SourceFileGetLastWriteTime(pas_name)) return true; - //Console.WriteLine("{0} {1}",name,RecompileList.Count); - for (int i = 0; i < included.Length; i++) - { - string pcu_name2 = FindPCUFileName(included[i], dir); - //TODO: Спросить у Сащи насчет < и <=. - - if ((File.Exists(pcu_name2) && File.GetLastWriteTime(pcu_name) < File.GetLastWriteTime(pcu_name2) && !pr.AlreadyCompiled(pcu_name2))) - { - pr.AddAlreadyCompiledUnit(included[i]); - return true; - } - if (RecompileList.ContainsKey(included[i])) - { - return true; - } - } - return false; - } - - public void ClearAll() - { - _semantic_tree = null; - PCUReader.CloseUnits(); - PCUWriter.Clear(); - RecompileList.Clear(); - CycleUnits.Clear(); - UnitTable.Clear(); - UnitsSortedList.Clear(); - //TreeRealization.PCUReturner.Clear(); - BadNodesInSyntaxTree.Clear(); - PCUReader.AllReaders.Clear(); - project = null; - StandarModules.Clear(); - //SystemLibrary.SystemLibrary.RestoreStandartNames(); - } - - public CompilerType CompilerType - { - get - { - return CompilerType.Standart; - } - } - - public void Free() - { - } - } -} +// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + /*************************************************************************** + * + * Управляющий блок компилятора, алгоритм компиляции модулей + * Зависит от Errors,SyntaxTree,SemanticTree,Parsers,TreeConvertor, + * CodeGenerators + * + ***************************************************************************/ + +//TODO разобраться с ToLower()!!! + +#region algorithm +/*************************************************************************** + * Рекурсивный алгоритм компиляции модулей + * версия 1.4 + * + * CompileUnit(ИмяФайла) + * 1.CompileUnit(new СписокМодулей,ИмяФайла) + * 2.Докомпилировать модули из СписокОтложенойКомпиляции; + * + * CompileUnit(СписокМодулей,ИмяФайла) + * 1.ТекущийМодуль=ТаблицаМодулей[ИмяФайла]; + * Если (ТекущийМодуль!=0) то + * Если (ТекущийМодуль.Состояние==BeginCompilation) + * СписокМодулей.Добавить(ТекущийМодуль); + * Выход; + * иначе перейти к пункту 5 + * + * 2.Если ЭтоФайлDLL(ИмяФайла) то + * Если ((ТекущийМодуль=СчитатьDLL(ИмяФайла))!=0) то + * СписокМодулей.Добавить(ТекущийМодуль); + * ТаблицаМодулей.Добавить(ТекущийМодуль); + * Выход; + * иначе + * Ошибка("Не могу подключить сборку"); + * Выход; + * + * 3.Если ЭтоФайлPCU(ИмяФайла) то + * Если ((ТекущийМодуль=СчитатьPCU(ИмяФайла))!=0) то + * СписокМодулей.Добавить(ТекущийМодуль); + * ТаблицаМодулей.Добавить(ТекущийМодуль); + * Выход; + * иначе + * иначе перейти к пункту 4; + * + * 4.ТекущийМодуль=новыйМодуль(); + * ТекущийМодуль.СинтаксическоеДерево=Парасеры.Парсить(ИмяФайла,ТекущийМодуль.СписокОшибок); + * Если (ТекущийМодуль.СинтаксическоеДерево==0) то + * Если (ТекущийМодуль.СписокОшибок.Количество==0) то + * Ошибка("Модуль не неайден"); + * иначе + * Ошибка(ТекущийМодуль.СписокОшибок[0]); + * ТаблицаМодулей[ИмяФайла]=ТекущийМодуль; + * ТекущийМодуль.Состояние=BeginCompilation; + * + * 5.СинтаксическийСписокМодулей=ТекущийМодуль.СинтаксическоеДерево.Interface.UsesList; + * Для(i=СинтаксическийСписокМодулей.Количество-1-ТекущийМодуль.КомпилированыеВInterface.Количество;i>=0;i--) + * ТекушийМодуль.ТекущийUsesМодуль=СинтаксическийСписокМодулей[i].ИмяФайла; + * ИмяUsesФайла=СинтаксическийСписокМодулей[i].ИмяФайла; + * Если (ТаблицаМодулей[ИмяUsesФайла]!=0) + * Если (ТаблицаМодулей[ИмяUsesФайла].Состояние==BeginCompilation) + * Если (ТаблицаМодулей[ТаблицаМодулей[ИмяUsesФайла].ТекущийUsesМодуль].Состояние=BeginCompilation) + * Ошибка("Циклическая связь модулей"); + * CompileUnit(ТекущийМодуль.КомпилированыеВInterface,ИмяUsesФайла); + * Если (ТекушийМодуль.Состояние==Compiled) то + * СписокМодулей.Добавить(ТекушийМодуль); + * Выход; + * + * 6.ТекущийМодуль.СемантическоеДерево=КонверторДерева.КонвертироватьInterfaceЧасть( + * ТекущийМодуль.СинтаксическоеДерево, + * ТекущийМодуль.КомпилированыеВInterface, + * ТекущийМодуль.СписокОшибок); + * СписокМодулей.Добавить(ТекущийМодуль); + * СинтаксическийСписокМодулей=ТекущийМодуль.СинтаксическоеДерево.Implementation.UsesList; + * Для(i=СинтаксическийСписокМодулей.Количество-1;i>=0;i--) + * Если (ТаблицаМодулей[СинтаксическийСписокМодулей[i].ИмяФайла].Состояние=BeginCompilation) + * СписокОтложенойКомпиляции.Добавить(ТаблицаМодулей[СинтаксическийСписокМодулей[i].ИмяФайла]); + * иначе + * CompileUnit(ТекущийМодуль.КомпилированыеВImplementation,СинтаксическийСписокМодулей[i].ИмяФайла); + * Если(ДобавлялиХотябыОдинВСписокОтложенойКомпиляции) + * СписокОтложенойКомпиляции.Добавить(ТекущийМодуль); + * выход; + * иначе + * КонверторДерева.КонвертироватьImplementationЧасть( + * ТекущийМодуль.СинтаксическоеДерево, + * ТекущийМодуль.СемантическоеДерево, + * ТекущийМодуль.КомпилированыеВImplementation + * ТекущийМодуль.СписокОшибок); + * ТекущийМодуль.Состояние=Compiled; + * СохранитьPCU(ТекущийМодуль); + * + * + * + * [краткая верcия алгоритма компиляции модулей] + * CompileUnit(ИмяФайла) + * 1.CompileUnit(new СписокМодулей,ИмяФайла) + * 2.Докомпилировать модули из СписокОтложенойКомпиляции; + * + * CompileUnit(СписокМодулей,ИмяФайла); + * 1.Если у этого модуля откомпилирован хотябы интерфейс то + * добавить его в СписокМодулей + * выход + * 2.Если это DLL то + * считать + * добавить его в СписокМодулей + * выход + * 3.Если это PCU то + * считать + * добавить его в СписокМодулей + * выход + * 4.создать новый компилируемыйМодуль + * РаспарситьТекст(ИмяФайла) + * Состояние компилируемогоМодуля установить на BeginCompilation + * 5.Для всех модулей из Interface части компилируемогоМодуля справа налево + * Если мы уже начаинали компилировать этот модуль + * Если состояние модуля BeginCompilation + * Если состояние последнего компилируемого им модуля BeginCompilation + * ошибка("Циклическая связь модулей") + * выход + * CompileUnit(Список из Interface части компилируемогоМодуля,модуль.имя) + * Если компилируемыйМодуль.Состояние Compiled то + * добавить его в СписокМодулей + * выход + * 6.Откомпилировать Interface часть компилируемогоМодуля + * Для всех модулей из Implementation части компилируемогоМодуля справа налево + * Если состояние очередного модуля BeginCompilation то + * добавить его в список отложеной компиляции; + * иначе + * CompileUnit(Список из Implementation части компилируемогоМодуля,модуль.имя) + * Если Добавляли Хотябы Один В Список Отложеной Компиляции то + * добавить компилируемыйМодуль в список отложеной компиляции + * выход + * Откомпилировать Implementation часть компилируемогоМодуля + * Состояние компилируемогоМодуля установить на Compiled + * добавить его в СписокМодулей + * Сохранить компилируемыйМодуль в виде PCU файла на диск + * + * + * + ***************************************************************************/ +#endregion + +#define DEBUG +//#undef DEBUG + +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using System.Xml; + +using PascalABCCompiler.Errors; +using PascalABCCompiler.PCU; +using PascalABCCompiler.SemanticTreeConverters; +using ICSharpCode.NRefactory; +using ICSharpCode.NRefactory.Parser.VB; +using System.CodeDom.Compiler; + +//using IronPython.Hosting; +using Microsoft.Scripting.Hosting; +using Microsoft.Scripting; +using System.Reflection; +//using SyntaxTreeChanger; +using PascalABCCompiler.SyntaxTreeConverters; + + +namespace PascalABCCompiler +{ + public class CompilerCompilationError : LocatedError + { + public CompilerCompilationError(string message) + : base(message) + { + } + public CompilerCompilationError(string message, string FileName) + : base(message, FileName) + { + } + public override string ToString() + { + return Message; + } + } + + public class ReadPCUError : CompilerCompilationError + { + public ReadPCUError(string FileName) + : base(string.Format(StringResources.Get("COMPILATIONERROR_READ_PCU{0}_ERROR"),FileName)) + { + } + } + + public class NamespaceCannotHaveInSection : CompilerCompilationError + { + public NamespaceCannotHaveInSection(SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_NAMESPACE_CANNOT_HAVE_IN_SECTION"))) + { + this.source_context = sc; + } + } + + public class ProgramModuleExpected : CompilerCompilationError + { + public ProgramModuleExpected(string FileName, SyntaxTree.SourceContext sc) + : base(StringResources.Get("COMPILATIONERROR_PROGRAM_MODULE_EXPECTED"), FileName) + { + this.source_context = sc; + } + } + + public class UnitModuleExpected : CompilerCompilationError + { + public UnitModuleExpected(string FileName, SyntaxTree.SourceContext sc) + : base(StringResources.Get("COMPILATIONERROR_UNIT_MODULE_EXPECTED"), FileName) + { + this.source_context = sc; + } + } + + public class AppTypeDllIsAllowedOnlyForLibraries : CompilerCompilationError + { + public AppTypeDllIsAllowedOnlyForLibraries(string FileName, SyntaxTree.SourceContext sc) + : base(StringResources.Get("COMPILATIONERROR_APPTYPE_DLL_IS_ALLOWED_ONLY_FOR_LIBRARIES"), FileName) + { + this.source_context = sc; + } + } + + public class UnitModuleExpectedLibraryFound : CompilerCompilationError + { + public UnitModuleExpectedLibraryFound(string FileName, SyntaxTree.SourceContext sc) + : base(StringResources.Get("COMPILATIONERROR_UNIT_MODULE_EXPECTED_LIBRARY_FOUND"), FileName) + { + this.source_context = sc; + } + } + + public class AssemblyNotFound : CompilerCompilationError + { + public string AssemblyFileName; + public AssemblyNotFound(string FileName,string AssemblyFileName, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_ASSEMBLY_{0}_NOT_FOUND"), AssemblyFileName), FileName) + { + this.AssemblyFileName = AssemblyFileName; + this.source_context = sc; + } + + } + + public class AssemblyReadingError : CompilerCompilationError + { + public string AssemblyFileName; + public AssemblyReadingError(string FileName,string AssemblyFileName, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_ASSEMBLY_{0}_READING_ERROR"), AssemblyFileName), FileName) + { + this.AssemblyFileName = AssemblyFileName; + this.source_context = sc; + } + } + + public class InvalidAssemblyPathError : CompilerCompilationError + { + public InvalidAssemblyPathError(string FileName,SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_INVALID_ASSEMBLY_PATH")), FileName) + { + this.source_context = sc; + } + } + + public class ResourceFileNotFound : CompilerCompilationError + { + public ResourceFileNotFound(string ResFileName, TreeRealization.location sl) + : base(string.Format(StringResources.Get("COMPILATIONERROR_RESOURCEFILE_{0}_NOT_FOUND"), ResFileName), sl.doc.file_name) + { + this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num,sl.end_column_num); + } + + public ResourceFileNotFound(string ResFileName) + : base(string.Format(StringResources.Get("COMPILATIONERROR_RESOURCEFILE_{0}_NOT_FOUND"), ResFileName), null) + { + //this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num, sl.end_column_num); + } + } + + public class IncludeNamespaceInUnit: CompilerCompilationError + { + public IncludeNamespaceInUnit(string FileName, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_INCLUDE_NAMESPACE_IN_UNIT")), FileName) + { + this.source_context = sc; + } + } + + public class NamespaceModuleExpected : CompilerCompilationError + { + public NamespaceModuleExpected(SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_NAMESPACE_MODULE_EXPECTED"))) + { + this.source_context = sc; + } + } + + public class MainResourceNotAllowed : CompilerCompilationError + { + public MainResourceNotAllowed(TreeRealization.location sl) + : base(string.Format(StringResources.Get("COMPILATIONERROR_MAINRESOURCE_NOT_ALLOWED")), sl.doc.file_name) + { + this.sourceLocation = new SourceLocation(sl.doc.file_name, sl.begin_line_num, sl.begin_column_num, sl.end_line_num, sl.end_column_num); + } + + } + + public class DuplicateUsesUnit : CompilerCompilationError + { + public string UnitName; + public DuplicateUsesUnit(string FileName, string UnitName, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_DUPLICATE_USES_UNIT{0}"), UnitName), FileName) + { + this.UnitName = UnitName; + this.source_context = sc; + } + } + public class DuplicateDirective : CompilerCompilationError + { + public string DirectiveName; + public DuplicateDirective(string FileName, string DirectiveName, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_DUPLICATE_DIRECTIVE{0}"), DirectiveName), FileName) + { + this.DirectiveName = DirectiveName; + this.source_context = sc; + } + } + + public class NamespacesCanBeCompiledOnlyInProjects: CompilerCompilationError + { + public NamespacesCanBeCompiledOnlyInProjects(SyntaxTree.SourceContext sc) + : base(StringResources.Get("COMPILATIONERROR_NAMESPACE_CAN_BE_COMPILED_ONLY_IN_PROJECTS")) + { + this.source_context = sc; + } + } + + public class UnitNotFound : CompilerCompilationError + { + public string UnitName; + public UnitNotFound(string FileName, string UnitName, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_UNIT_{0}_NOT_FOUND"), UnitName), FileName) + { + this.UnitName = UnitName; + this.source_context = sc; + } + } + + public class UsesInWrongName : CompilerCompilationError + { + public string UnitName1; + public string UnitName2; + public UsesInWrongName(string FileName, string UnitName1, string UnitName2, SyntaxTree.SourceContext sc) + : base(string.Format(StringResources.Get("COMPILATIONERROR_USES_IN_WRONG_NAME"), UnitName1, UnitName2), FileName) + { + this.UnitName1 = UnitName1; + this.UnitName2 = UnitName2; + this.source_context = sc; + } + } + + public class SourceFileNotFound : CompilerCompilationError + { + public SourceFileNotFound(string FileName) + : base(string.Format(StringResources.Get("COMPILATIONERROR_SOURCE_FILE_{0}_NOT_FOUND"),FileName)) + { + } + } + + public class UnauthorizedAccessToFile : CompilerCompilationError + { + public UnauthorizedAccessToFile(string FileName) + : base(string.Format(StringResources.Get("COMPILATIONERROR_NO_ACCESS_TO_FILE{0}"),FileName)) + { + } + } + public class CycleUnitReference : CompilerCompilationError + { + public SyntaxTree.unit_or_namespace SyntaxUsesUnit; + public CycleUnitReference(string FileName, SyntaxTree.unit_or_namespace SyntaxUsesUnit) + : base(string.Format(StringResources.Get("COMPILATIONERROR_CYCLIC_UNIT_REFERENCE_WITH_UNIT_{0}"), SyntaxTree.Utils.IdentListToString(SyntaxUsesUnit.name.idents,".")), FileName) + { + this.SyntaxUsesUnit = SyntaxUsesUnit; + this.source_context = SyntaxUsesUnit.source_context; + } + } + + + public enum UnitState { BeginCompilation, InterfaceCompiled, Compiled } + + public class CompilationUnit + { + internal bool CaseSensitive = false; + public string CurrentUsesUnit; + public PascalABCCompiler.Errors.SyntaxError syntax_error; + public string UnitName; + public List ErrorList=new List(); + public bool Documented; + internal List PossibleNamespaces = new List(); + //internal List AssemblyReferences = new List(); + + //private SemanticTree.compilation_unitArrayList _interfaceUsedUnits=new SemanticTree.compilation_unitArrayList(); + + private PascalABCCompiler.TreeRealization.unit_node_list _interfaceUsedUnits = new PascalABCCompiler.TreeRealization.unit_node_list(); + public PascalABCCompiler.TreeRealization.unit_node_list InterfaceUsedUnits + { + get {return _interfaceUsedUnits;} + } + + private PascalABCCompiler.TreeRealization.unit_node_list _implementationUsedUnits = new PascalABCCompiler.TreeRealization.unit_node_list(); + public PascalABCCompiler.TreeRealization.unit_node_list ImplementationUsedUnits + { + get {return _implementationUsedUnits;} + } + + private SyntaxTree.compilation_unit _syntaxTree=null; + public SyntaxTree.compilation_unit SyntaxTree + { + get {return _syntaxTree;} + set {_syntaxTree=value;} + } + + private PascalABCCompiler.TreeRealization.unit_node _semanticTree = null; + public PascalABCCompiler.TreeRealization.unit_node SemanticTree + { + get {return _semanticTree;} + set {_semanticTree=value;} + } + + private SyntaxTree.unit_or_namespace _syntaxUnitName=null; + public SyntaxTree.unit_or_namespace SyntaxUnitName + { + get {return _syntaxUnitName;} + set {_syntaxUnitName=value;} + } + + private TreeRealization.using_namespace_list _interface_using_namespace_list = new TreeRealization.using_namespace_list(); + public TreeRealization.using_namespace_list InterfaceUsingNamespaceList + { + get { return _interface_using_namespace_list; } + set { _interface_using_namespace_list = value; } + } + + private TreeRealization.using_namespace_list _implementation_using_namespace_list = new TreeRealization.using_namespace_list(); + public TreeRealization.using_namespace_list ImplementationUsingNamespaceList + { + get { return _implementation_using_namespace_list; } + set { _implementation_using_namespace_list = value; } + } + + public UnitState State=UnitState.BeginCompilation; + } + + public class CompilationUnitHashTable:Hashtable + { + public CompilationUnitHashTable() + //DarkStar: fixed error in test_standartuses.pas at rebuild + :base(StringComparer.InvariantCultureIgnoreCase) + { + } + public CompilationUnit this [string key] + { + get + { + if (key != null) + return (base[key] as CompilationUnit); + return null; + } + set + { + base[key]=value; + } + } + } + + /// + /// Опции компиляции + /// + //[Serializable()] + public class CompilerOptions : MarshalByRefObject + { + public enum OutputType {ClassLibrary=0, ConsoleApplicaton=1, WindowsApplication=2, PascalCompiledUnit=3, SemanticTree=4 } + + public bool Debug = false; + public bool ForDebugging = false; + public bool Rebuild = false; + public bool Optimise = false; + public bool SavePCUInThreadPull = false; + public bool RunWithEnvironment = false; + public string CompiledUnitExtension=".pcu"; + public bool ProjectCompiled = false; + public IProjectInfo CurrentProject = null; + public OutputType OutputFileType = OutputType.ConsoleApplicaton; + public bool GenerateCode = true; + public bool SaveDocumentation = true; + public bool SavePCU = true; + public bool IgnoreRtlErrors = true; + public bool Only32Bit = false; + public string Locale = "ru"; + private string sourceFileName = null; + ///имя исходного файла + ///при измененнии меняется OutputFileName,OutputDirectory,SourceFileDirectory + public string SourceFileName + { + get { return sourceFileName; } + set + { + sourceFileName = value; + OutputFileName = value; + sourceFileDirectory = Path.GetDirectoryName(value); + if (sourceFileDirectory == "") sourceFileDirectory = Environment.CurrentDirectory; + outputDirectory = SourceFileDirectory; + useOutputDirectory = false; + } + } + + + private string sourceFileDirectory = null; + public string SourceFileDirectory + { + get { return sourceFileDirectory; } + } + + private string outputFileName=null; + //имя выходного файла без расширения + //ели имя указано без пути то в качестве пути используетя OutputDirectory + public string OutputFileName + { + get + { + string FileName = outputFileName; + switch (OutputFileType) + { + case OutputType.ConsoleApplicaton: + case OutputType.WindowsApplication: FileName = FileName + ".exe"; break; + case OutputType.ClassLibrary: FileName = FileName + ".dll"; break; + case OutputType.PascalCompiledUnit: FileName = FileName + CompiledUnitExtension; break; + } + if (Path.GetDirectoryName(FileName) == "") FileName = Path.Combine(OutputDirectory, FileName); + return FileName; + } + set + { + outputFileName = Path.GetFileNameWithoutExtension(value); + } + } + + // + public string SystemDirectory; + + public string SearchDirectory; + + private bool useDllForSystemUnits = false; + + public bool UseDllForSystemUnits + { + get + { + return useDllForSystemUnits; + } + set + { + useDllForSystemUnits = value; + PascalABCCompiler.NetHelper.NetHelper.UsePABCRtl = value; + } + } + + public string[] ParserSearchPatchs; + + public enum StandartModuleAddMethod {LeftToAll, RightToMain}; + [Serializable()] + public class StandartModule : MarshalByRefObject + { + public string Name = null; + public StandartModuleAddMethod AddMethod = StandartModuleAddMethod.LeftToAll; + public SyntaxTree.LanguageId AddToLanguages = SyntaxTree.LanguageId.PascalABCNET; + public StandartModule(string Name, StandartModuleAddMethod AddMethod) + { + this.Name = Name; + this.AddMethod = AddMethod; + } + public StandartModule(string Name, StandartModuleAddMethod AddMethod, SyntaxTree.LanguageId AddToLanguages) + { + this.Name = Name; + this.AddToLanguages = AddToLanguages; + this.AddMethod = AddMethod; + } + public StandartModule(string Name) + { + this.Name = Name; + } + public StandartModule(string Name, SyntaxTree.LanguageId AddToLanguages) + { + this.AddToLanguages = AddToLanguages; + this.Name = Name; + } + } + /// + /// Module at index 0 is System module + /// + public List StandartModules; + public void RemoveStandartModule(string Name) + { + StandartModule module_to_del=null; + foreach (StandartModule module in StandartModules) + if (module.Name == Name) + { + module_to_del = module; + break; + } + if (module_to_del != null) + StandartModules.Remove(module_to_del); + } + public void RemoveStandartModuleAtIndex(int index) + { + if(index(); + StandartModules.Add(new StandartModule("PABCSystem", SyntaxTree.LanguageId.PascalABCNET | SyntaxTree.LanguageId.C)); + StandartModules.Add(new StandartModule("PABCExtensions", SyntaxTree.LanguageId.PascalABCNET | SyntaxTree.LanguageId.C)); + } + + private void SetDirectories() + { + SystemDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); + SearchDirectory = Path.Combine(SystemDirectory,"Lib"); + StandartDirectories = new Hashtable(StringComparer.InvariantCultureIgnoreCase); + StandartDirectories.Add("%PABCSYSTEM%", SystemDirectory); + ParserSearchPatchs = new string[1]; + ParserSearchPatchs[0] = SearchDirectory; + } + + + public CompilerOptions() + { + SetDirectories(); + SetStandartModules(); + } + + public CompilerOptions(string SourceFileName, OutputType OutputFileType) + { + SetDirectories(); + SetStandartModules(); + this.SourceFileName = SourceFileName; + this.OutputFileType = OutputFileType; + } + + } + + public enum CompilerState + { + Ready, CompilationStarting, Reloading, ParserConnected, + BeginCompileFile, BeginParsingFile, EndParsingFile, CompileInterface, CompileImplementation, EndCompileFile, + ReadDLL, ReadPCUFile, SavePCUFile, CodeGeneration, CompilationFinished, PCUReadingError, PCUWritingError, + SemanticTreeConverterConnected, SemanticTreeConversion, SyntaxTreeConversion, SyntaxTreeConverterConnected + } + + [Serializable()] + public class CompilerInternalDebug + { + public bool CodeGeneration = true; + public bool SemanticAnalysis = true; + public bool PCUGenerate = true; + public bool AddStandartUnits = true; + public bool SkipPCUErrors = true; + public bool IncludeDebugInfoInPCU = true; + public bool AlwaysGenerateXMLDoc=false; + public bool SkipInternalErrorsIfSyntaxTreeIsCorrupt = true; + public bool UseStandarParserForIntellisense = true; + public bool RunOnMono = false; + public List DocumentedUnits=new List(); + +#if DEBUG + public bool DebugVersion + { + get { return true; } + } +#elif !DEBUG + public bool DebugVersion + { + get { return false; } + } +#endif + } + + public class SupportedSourceFile + { + private string[] extensions; + public string[] Extensions + { + get { return extensions; } + } + private string languageName; + public string LanguageName + { + get { return languageName; } + } + public SupportedSourceFile(string[] extensions, string lname) + { + this.extensions = extensions; languageName = lname; + } + public static SupportedSourceFile Make(Parsers.IParser parser) + { + List ext = new List(); + foreach (string ex in parser.FilesExtensions) + if (ex[ex.Length - 1] != Parsers.Controller.HideParserExtensionPostfixChar) + ext.Add(ex); + if (ext.Count > 0) + return new SupportedSourceFile(ext.ToArray(), parser.Name); + return null; + } + public override string ToString() + { + return string.Format("{0} ({1})", LanguageName, FormatTools.ExtensionsToString(Extensions, "*", ";")); + } + } + + public delegate void ChangeCompilerStateEventDelegate(ICompiler sender, CompilerState State, string FileName); + + public class Compiler : MarshalByRefObject, ICompiler + { + //public ISyntaxTreeChanger SyntaxTreeChanger = null; // SSM 17/08/15 - для операций над синтаксическим деревом после его построения + + public static string Version + { + get + { + return RevisionClass.FullVersion; + } + } + public static string ShortVersion + { + get + { + if (RevisionClass.Build == "0") + return RevisionClass.MainVersion; + else return RevisionClass.MainVersion + "." + RevisionClass.Build; + } + } + public static DateTime VersionDateTime + { + get + { + return File.GetLastWriteTime(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); + } + } + public static string Banner + { + get + { + return "PascalABCCompiler.Core v" + Version; + } + } + public override string ToString() + { + return Banner; + } + + private SyntaxTreeConvertersController syntaxTreeConvertersController = null; + public SyntaxTreeConvertersController SyntaxTreeConvertersController + { + get + { + return syntaxTreeConvertersController; + } + } + + private SemanticTreeConvertersController semanticTreeConvertersController = null; + public SemanticTreeConvertersController SemanticTreeConvertersController + { + get + { + return semanticTreeConvertersController; + } + } + + private Hashtable BadNodesInSyntaxTree = new Hashtable(); + + TreeRealization.program_node _semantic_tree = null; + public SemanticTree.IProgramNode SemanticTree + { + get + { + return _semantic_tree; + } + } + + private Dictionary> compilerDirectives = null; + + //public Hashtable CompilerDirectives + //{ + // get { return compilerDirectives; } + //} + + private uint linesCompiled; + public uint LinesCompiled + { + get { return linesCompiled; } + } + + private CompilerInternalDebug internalDebug; + public CompilerInternalDebug InternalDebug + { + get + { + return internalDebug; + } + set + { + internalDebug = value; + } + } + + private CompilerState state = CompilerState.Ready; + public CompilerState State + { + get { return state; } + } + + private void SetSupportedSourceFiles() + { + List supportedSourceFilesList = new List(); + for (int i = 0; i < ParsersController.Parsers.Count; i++) + { + SupportedSourceFile sf = SupportedSourceFile.Make(ParsersController.Parsers[i]); + if (sf != null) + supportedSourceFilesList.Add(sf); + } + supportedSourceFiles = supportedSourceFilesList.ToArray(); + } + + private void SetSupportedProjectFiles() + { + List supportedProjectFilesList = new List(); + /*for (int i = 0; i < ParsersController.Parsers.Count; i++) + { + SupportedSourceFile sf = SupportedSourceFile.Make(ParsersController.Parsers[i]); + if (sf != null) + supportedSourceFilesList.Add(sf); + }*/ + //vremenno + supportedProjectFilesList.Add(new SupportedSourceFile(new string[1]{".pabcproj"},"PascalABC.NET")); + supportedProjectFiles = supportedProjectFilesList.ToArray(); + } + + private SupportedSourceFile[] supportedSourceFiles = null; + public SupportedSourceFile[] SupportedSourceFiles + { + get { return supportedSourceFiles; } + set { supportedSourceFiles = value; } + } + + private SupportedSourceFile[] supportedProjectFiles = null; + public SupportedSourceFile[] SupportedProjectFiles + { + get { return supportedProjectFiles; } + } + + private CompilationUnitHashTable unitTable=new CompilationUnitHashTable(); + public CompilationUnitHashTable UnitTable{ get { return unitTable; } } + public List UnitsSortedList = new List(); + + private List StandarModules = new List(); + + private CompilerOptions compilerOptions = new CompilerOptions(); + public CompilerOptions CompilerOptions + { + get + { + return compilerOptions; + } + set + { + compilerOptions = value; + } + } + + internal Dictionary DLLCashe = new Dictionary(); + + private Parsers.Controller parsersController = null; + public Parsers.Controller ParsersController + { + get + { + return parsersController; + } + set + { + parsersController = value; + } + } + public TreeConverter.SyntaxTreeToSemanticTreeConverter SyntaxTreeToSemanticTreeConverter = null; + public CodeGenerators.Controller CodeGeneratorsController = null; + //public LLVMConverter.Controller LLVMCodeGeneratorsController = null; + //public PascalToCppConverter.Controller PABCToCppCodeGeneratorsController = null; + private SyntaxTree.unit_or_namespace CurrentSyntaxUnit; + private List UnitsToCompile = new List(); + public Hashtable RecompileList = new Hashtable(StringComparer.OrdinalIgnoreCase); + private PascalABCCompiler.TreeRealization.unit_node_list Units; + private Hashtable CycleUnits = new Hashtable(); + private CompilationUnit CurrentCompilationUnit = null; + private CompilationUnit FirstCompilationUnit = null; + private bool PCUReadersAndWritersClosed; + public int beginOffset; + public int varBeginOffset; + private bool _clear_after_compilation = true; + + public bool ClearAfterCompilation + { + get + { + return _clear_after_compilation; + } + set + { + _clear_after_compilation = value; + } + } + + public int BeginOffset + { + get + { + return beginOffset; + } + } + public int VarBeginOffset + { + get + { + return varBeginOffset; + } + } + private List warnings = new List(); + public List Warnings + { + get + { + return warnings; + } + } + + public Dictionary, string> SourceFileNamesDictionary { get; } = new Dictionary, string>(); + + public Dictionary, string> PCUFileNamesDictionary { get; } = new Dictionary, string>(); + + public void AddWarnings(List WarningList) + { + foreach (CompilerWarning cw in WarningList) + warnings.Add(cw); + } + + public event ChangeCompilerStateEventDelegate OnChangeCompilerState; + private void ChangeCompilerStateEvent(ICompiler sender, CompilerState State, string FileName) + { + this.state=State; + } + + private bool SourceFileExists(string FileName) + { + if (FileName == null) return false; + return (bool)SourceFilesProvider(FileName, SourceFileOperation.Exists); + } + private DateTime SourceFileGetLastWriteTime(string FileName) + { + return (DateTime)SourceFilesProvider(FileName, SourceFileOperation.GetLastWriteTime); + } + private SourceFilesProviderDelegate sourceFilesProvider = SourceFilesProviders.DefaultSourceFilesProvider; + public SourceFilesProviderDelegate SourceFilesProvider + { + get + { + return sourceFilesProvider; + } + } + + private List errorsList = new List(); + public List ErrorsList + { + get{return errorsList;} + } + + public Compiler() + { + //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); + + OnChangeCompilerState += ChangeCompilerStateEvent; + Reload(); + } + + public Compiler(ICompiler comp, SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) + { + //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); // SSM 01/05/16 - подключение изменяльщика синтаксического дерева + + this.ParsersController = comp.ParsersController; + this.internalDebug = comp.InternalDebug; + OnChangeCompilerState += ChangeCompilerStateEvent; + if (SourceFilesProvider != null) + this.sourceFilesProvider = SourceFilesProvider; + if (ChangeCompilerState != null) + OnChangeCompilerState += ChangeCompilerState; + this.supportedSourceFiles = comp.SupportedSourceFiles; + this.supportedProjectFiles = comp.SupportedProjectFiles; + } + + public Compiler(SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) + { + //SyntaxTreeChanger = new SyntaxTreeChanger.SyntaxTreeChange(); // SSM 01/05/16 - подключение изменяльщика синтаксического дерева + OnChangeCompilerState += ChangeCompilerStateEvent; + if (SourceFilesProvider != null) + this.sourceFilesProvider = SourceFilesProvider; + if (ChangeCompilerState != null) + OnChangeCompilerState += ChangeCompilerState; + Reload(); + } + + public void Reload() + { + OnChangeCompilerState(this, CompilerState.Reloading, null); + + //А это что? + TreeRealization.type_node tn = SystemLibrary.SystemLibrary.void_type; + + ClearAll(); + errorsList.Clear(); + Warnings.Clear(); + InternalDebug = new CompilerInternalDebug(); + ParsersController = new Parsers.Controller(); + ParsersController.ParserConnected += new PascalABCCompiler.Parsers.Controller.ParserConnectedDeleagte(ParsersController_ParserConnected); + ParsersController.SourceFilesProvider = sourceFilesProvider; + ParsersController.Reload(); + SyntaxTreeToSemanticTreeConverter = new TreeConverter.SyntaxTreeToSemanticTreeConverter(); + CodeGeneratorsController = new CodeGenerators.Controller(); + //PABCToCppCodeGeneratorsController = new PascalToCppConverter.Controller(); + SetSupportedSourceFiles(); + SetSupportedProjectFiles(); + + syntaxTreeConvertersController = new SyntaxTreeConvertersController(this); + syntaxTreeConvertersController.ChangeState += syntaxTreeConvertersController_ChangeState; + syntaxTreeConvertersController.AddConverters(); + + semanticTreeConvertersController = new SemanticTreeConvertersController(this); + semanticTreeConvertersController.ChangeState += semanticTreeConvertersController_ChangeState; + semanticTreeConvertersController.AddConverters(); + + OnChangeCompilerState(this, CompilerState.Ready, null); + } + + void ParsersController_ParserConnected(PascalABCCompiler.Parsers.IParser Parser) + { + if (OnChangeCompilerState != null) + OnChangeCompilerState(this, CompilerState.ParserConnected, Parser.GetType().Assembly.ManifestModule.FullyQualifiedName); + } + + void syntaxTreeConvertersController_ChangeState(SyntaxTreeConvertersController.State State, ISyntaxTreeConverter SyntaxTreeConverter) + { + switch (State) + { + case SyntaxTreeConvertersController.State.Convert: + OnChangeCompilerState(this, CompilerState.SyntaxTreeConversion, SyntaxTreeConverter.Name); + break; + case SyntaxTreeConvertersController.State.ConnectConverter: + OnChangeCompilerState(this, CompilerState.SyntaxTreeConverterConnected, SyntaxTreeConverter.Name); + break; + } + } + + void semanticTreeConvertersController_ChangeState(SemanticTreeConvertersController.State State, ISemanticTreeConverter SemanticTreeConverter) + { + switch (State) + { + case SemanticTreeConvertersController.State.Convert: + OnChangeCompilerState(this, CompilerState.SemanticTreeConversion, SemanticTreeConverter.Name); + break; + case SemanticTreeConvertersController.State.ConnectConverter: + OnChangeCompilerState(this, CompilerState.SemanticTreeConverterConnected, SemanticTreeConverter.Name); + break; + } + } + + private Dictionary> GetCompilerDirectives(List Units) + { + Dictionary> Directives = new Dictionary>(StringComparer.CurrentCultureIgnoreCase); + + for (int i = 0; i < Units.Count; i++) + { + TreeRealization.common_unit_node cun = Units[i].SemanticTree as TreeRealization.common_unit_node; + if (cun != null) + foreach (TreeRealization.compiler_directive cd in cun.compiler_directives) + { + if (!Directives.ContainsKey(cd.name)) + Directives.Add(cd.name, new List()); + else if (string.Compare(cd.name, "mainresource", true) == 0) + throw new DuplicateDirective(cd.location.doc.file_name, "mainresource", cd.location); + Directives[cd.name].Insert(0, cd); + } + } + return Directives; + } + + private Hashtable GetCompilerDirectives(CompilationUnit Unit) + { + Hashtable Directives = new Hashtable(StringComparer.CurrentCultureIgnoreCase); + TreeRealization.common_unit_node cun = Unit.SemanticTree as TreeRealization.common_unit_node; + if (cun != null) + foreach (TreeRealization.compiler_directive cd in cun.compiler_directives) + Directives[cd.name] = cd; + return Directives; + } + + private TreeRealization.location get_location_from_treenode(SyntaxTree.syntax_tree_node tn, string FileName) + { + if (tn.source_context == null) + { + return null; + } + return new TreeRealization.location(tn.source_context.begin_position.line_num, tn.source_context.begin_position.column_num, + tn.source_context.end_position.line_num, tn.source_context.end_position.column_num, new TreeRealization.document(FileName)); + } + + private System.Collections.Generic.List ConvertDirectives(SyntaxTree.compilation_unit cu) + { + System.Collections.Generic.List list = new System.Collections.Generic.List(); + foreach (SyntaxTree.compiler_directive sncd in cu.compiler_directives) + { + list.Add(new TreeRealization.compiler_directive(sncd.Name.text, sncd.Directive!=null?sncd.Directive.text:"", get_location_from_treenode(sncd,cu.file_name), cu.file_name)); + } + return list; + } + + void syncStartCompile() + { + Compile(); + } + + public void StartCompile() + { + System.Threading.Thread th = new System.Threading.Thread(syncStartCompile); + th.SetApartmentState(System.Threading.ApartmentState.STA); + th.Start(); + } + + public string Compile(CompilerOptions CompilerOptions) + { + this.CompilerOptions = CompilerOptions; + return Compile(); + } + + internal void Reset() + { + SourceFileNamesDictionary.Clear(); + PCUFileNamesDictionary.Clear(); + Warnings.Clear(); + errorsList.Clear(); + //if (!File.Exists(CompilerOptions.SourceFileName)) throw new SourceFileNotFound(CompilerOptions.SourceFileName); + CurrentCompilationUnit = null; + FirstCompilationUnit = null; + linesCompiled = 0; + PCUReadersAndWritersClosed = false; + ParsersController.Reset(); + SyntaxTreeToSemanticTreeConverter.Reset(); + CodeGeneratorsController.Reset(); + //PABCToCppCodeGeneratorsController.Reset(); + UnitsToCompile.Clear(); + DLLCashe.Clear(); + project = null; + } + + void CheckErrors() + { + if (ErrorsList.Count > 0) + throw ErrorsList[0]; + } + + private void moveSystemUnitToForwardUnitSortedList() + { + if(CompilerOptions.StandartModules.Count==0) + return; + CompilationUnit system_unit = null; + foreach (CompilationUnit cu in UnitsSortedList) + if (cu.SemanticTree != null && cu.SemanticTree is PascalABCCompiler.TreeRealization.common_unit_node) + if ((cu.SemanticTree as PascalABCCompiler.TreeRealization.common_unit_node).unit_name == CompilerOptions.StandartModules[0].Name) + { + system_unit = cu; + break; + } + if (system_unit != null && system_unit != UnitsSortedList[0]) + { + UnitsSortedList.Remove(system_unit); + UnitsSortedList.Insert(0, system_unit); + } + + } + + private uint get_compiled_lines(string FileName) + { + StreamReader sr = File.OpenText(FileName); + uint line = 0; + while (!sr.EndOfStream) + { + sr.ReadLine(); + line++; + } + sr.Close(); + return line; + } + + class ProgInfo + { + public string entry_module; + public int entry_method_name_pos; + public int entry_method_line; + public int using_pos=-1; + public List modules = new List(); + public List addit_imports = new List(); + public List addit_project_files = new List(); + } + + private void add_import_info(ProgInfo info, List imports) + { + Hashtable ht = new Hashtable(StringComparer.CurrentCultureIgnoreCase); + ht["GraphABC"] = "GraphABC"; + ht["GraphABCHelper"] = "GraphABCHelper"; + ht["ABCObjects"] = "ABCObjects"; + ht["Robot"] = "Robot"; + ht["Drawman"] = "Drawman"; + ht["DrawManField"] = "DrawManField"; + foreach (string s in imports) + { + string low_s = s.ToLower(); + //string mod_file = FindSourceFileInDirectories(s+".mod",Path.Combine(this.CompilerOptions.SystemDirectory,"lib")); + if (ht[s] != null) + { + string name = ht[s] as string; + if (!info.modules.Contains(name)) + { + info.modules.Add(name); + info.addit_imports.Add(name+"."+name); + } + } + /*if (!string.IsNullOrEmpty(mod_file)) + { + switch (low_s) + { + case "graphabc" : + if (!info.modules.Contains("GraphABC") && !info.modules.Contains("ABCObjects") && !info.modules.Contains("ABCButtons") && !info.modules.Contains("ABCHouse") + && !info.modules.Contains("ABCSprites") && !info.modules.Contains("RobotField")) + { + info.modules.Add("GraphABC"); + info.addit_imports.Add("GraphABC.GraphABC"); + } + else if (!info.addit_imports.Contains("GraphABC.GraphABC")) + { + info.addit_imports.Add("GraphABC.GraphABC"); + } + break; + case "abcobjects" : + if (!info.modules.Contains("ABCObjects") && !info.modules.Contains("ABCButtons") && !info.modules.Contains("ABCHouse") + && !info.modules.Contains("ABCSprites") && !info.modules.Contains("RobotField")) + { + info.modules.Add("ABCObjects"); + info.addit_imports.Add("ABCObjects.ABCObjects"); + if (info.modules.Contains("GraphABC")) + { + info.modules.Remove("GraphABC"); + //info.addit_imports.Remove("GraphABC.GraphABC"); + } + } + break; + default: + if (!info.modules.Contains(s)) + { + info.modules.Add(s); + info.addit_imports.Add(s+"."+s); + } + break; + } + }*/ + else + { + string source_file = FindFileInDirs(s+".vb",Path.GetDirectoryName(CompilerOptions.SourceFileName),Path.Combine(this.CompilerOptions.SystemDirectory,"lib"), + Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); + if (!string.IsNullOrEmpty(source_file)) + { + if (!info.addit_project_files.Contains(source_file)) + { + info.addit_project_files.Add(source_file); + } + } + } + } + /*List mods = new List(); + List inds = new List(); + for (int i=0; i usings = new List(); + foreach (ICSharpCode.NRefactory.Ast.INode node in cu.Children) + { + if (node is ICSharpCode.NRefactory.Ast.TypeDeclaration) + { + ICSharpCode.NRefactory.Ast.TypeDeclaration td = node as ICSharpCode.NRefactory.Ast.TypeDeclaration; + if (td.Type == ICSharpCode.NRefactory.Ast.ClassType.Module) + { + foreach (ICSharpCode.NRefactory.Ast.INode node2 in td.Children) + { + if (node2 is ICSharpCode.NRefactory.Ast.MethodDeclaration) + { + ICSharpCode.NRefactory.Ast.MethodDeclaration meth = node2 as ICSharpCode.NRefactory.Ast.MethodDeclaration; + if (string.Compare(meth.Name,"Main",true)==0 && (meth.Parameters == null || meth.Parameters.Count == 0)) + { + //info = new ProgInfo(); + info.entry_module = (meth.Parent as ICSharpCode.NRefactory.Ast.TypeDeclaration).Name; + //info.entry_method_name_line = meth.StartLocation.Line; + //info.entry_method_name_col = meth.StartLocation.Column; + info.entry_method_name_pos = find_pos(source,meth.StartLocation.Line,meth.StartLocation.Column,true); + if (meth.Body.Children.Count > 0) + { + for (int i=0; i 0) + { + for (int i = 0; i < res.Errors.Count; i++) + { + if (!res.Errors[i].IsWarning && errorsList.Count == 0 /*&& res.Errors[i].FileName != redirect_fname*/) + { + if (File.Exists(res.Errors[i].FileName)) + errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); + else + errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, CompilerOptions.SourceFileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); + } + else if (res.Errors[i].IsWarning) + { + warnings.Add(new Errors.CommonWarning(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line, res.Errors[i].Column)); + } + } + } + + //linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); + + OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); + ClearAll(); + OnChangeCompilerState(this, CompilerState.Ready, null); + + if (errorsList.Count > 0) + return null; + else + return res.PathToAssembly; + } + + class PyErrorHandler : ErrorListener + { + Compiler c; + public PyErrorHandler(Compiler cc) {c=cc;} + public override void ErrorReported(ScriptSource source, string message, SourceSpan span, int errorCode, Severity severity) + { + if (severity==Severity.Warning) + c.warnings.Add(new Errors.CommonWarning(message, c.compilerOptions.SourceFileName, span.Start.Line, span.Start.Column)); + else + c.errorsList.Add(new Errors.CommonCompilerError(message, c.compilerOptions.SourceFileName, span.Start.Line, span.Start.Column)); + } + } + + private Assembly IronPythonAssembly; + private MethodInfo PythonCreateEngineMethod; + public string CompilePy() + { + OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); + OnChangeCompilerState(this, CompilerState.BeginCompileFile, CompilerOptions.SourceFileName); + Reset(); + + if (IronPythonAssembly == null) + { + IronPythonAssembly = Assembly.LoadFrom("IronPython.dll"); + PythonCreateEngineMethod = IronPythonAssembly.GetType("IronPython.Hosting.Python").GetMethod("CreateEngine"); + } + string source = GetSourceFileText(CompilerOptions.SourceFileName); + + ScriptEngine pyEngine = (ScriptEngine)PythonCreateEngineMethod.Invoke(null, new object[0]); ; + + ScriptSource src = pyEngine.CreateScriptSourceFromString(source); + CompiledCode compiled = src.Compile(new PyErrorHandler(this)); + if (compiled != null) + compiled.Execute(); + + linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); + + OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); + ClearAll(); + OnChangeCompilerState(this, CompilerState.Ready, null); + + //if (errorsList.Count > 0) + return null; + //else return res.PathToAssembly; + } + + public string CompileCS() + { + OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); + OnChangeCompilerState(this, CompilerState.BeginCompileFile, CompilerOptions.SourceFileName); + Reset(); + var d = new Dictionary(); + d["CompilerVersion"] = "v4.0"; + var cscp = new Microsoft.CSharp.CSharpCodeProvider(d); + + //var cscp = new Microsoft.CSharp.CSharpCodeProvider(); + var comp_opt = new CompilerParameters(); + comp_opt.IncludeDebugInformation = CompilerOptions.Debug; + comp_opt.GenerateExecutable = true; + comp_opt.WarningLevel = 3; + comp_opt.OutputAssembly = CompilerOptions.OutputFileName; + + //comp_opt.ReferencedAssemblies.Add() + + string source = GetSourceFileText(CompilerOptions.SourceFileName); + + using (StringReader sr = new StringReader(source)) + { + do + { + var s = sr.ReadLine(); + + if (s == null) + break; + + if (s.ToLower().StartsWith("//#reference ")) + { + s = s.Remove(0, 13); + s = s.Trim(); + comp_opt.ReferencedAssemblies.Add(s); + } + else break; + + } while (true); + } + + + var res = cscp.CompileAssemblyFromSource(comp_opt, source); + if (res.Errors.Count > 0) + { + for (int i = 0; i < res.Errors.Count; i++) + { + if (!res.Errors[i].IsWarning && errorsList.Count == 0 /*&& res.Errors[i].FileName != redirect_fname*/) + { + if (File.Exists(res.Errors[i].FileName)) + errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); + else + errorsList.Add(new Errors.CommonCompilerError(res.Errors[i].ErrorText, CompilerOptions.SourceFileName, res.Errors[i].Line != 0 ? res.Errors[i].Line : 1, res.Errors[i].Column != 0 ? res.Errors[i].Column : 1)); + } + else if (res.Errors[i].IsWarning) + { + warnings.Add(new Errors.CommonWarning(res.Errors[i].ErrorText, res.Errors[i].FileName, res.Errors[i].Line, res.Errors[i].Column)); + } + } + } + + linesCompiled = get_compiled_lines(CompilerOptions.SourceFileName); + + OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); + ClearAll(); + OnChangeCompilerState(this, CompilerState.Ready, null); + + if (errorsList.Count > 0) + return null; + else + return res.PathToAssembly; + } + + public string CompileVB() + { + OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); + OnChangeCompilerState(this,CompilerState.BeginCompileFile,CompilerOptions.SourceFileName); + Reset(); + Microsoft.VisualBasic.VBCodeProvider vbcp = new Microsoft.VisualBasic.VBCodeProvider(); + List sources = new List(); + sources.Add(CompilerOptions.SourceFileName); + System.CodeDom.Compiler.CompilerParameters comp_opt = new System.CodeDom.Compiler.CompilerParameters(); + comp_opt.OutputAssembly = CompilerOptions.OutputFileName; + comp_opt.WarningLevel = 3; + comp_opt.ReferencedAssemblies.Add("System.Windows.Forms.dll"); + comp_opt.ReferencedAssemblies.Add("System.Drawing.dll"); + comp_opt.ReferencedAssemblies.Add("Microsoft.VisualBasic.dll"); + comp_opt.IncludeDebugInformation = CompilerOptions.Debug; + comp_opt.GenerateExecutable = true; + string fname = Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"_temp$"+Path.GetFileName(CompilerOptions.SourceFileName)); + File.Copy(CompilerOptions.SourceFileName,fname,true); + string source = GetSourceFileText(CompilerOptions.SourceFileName); + + IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.VBNet,new StringReader(source)); + parser.Parse(); + ProgInfo info = get_programm_info(parser.CompilationUnit, source); + parser.Dispose(); + if (info != null) + sources.AddRange(info.addit_project_files); + string redirect_base_fname = FindFileInDirs("__RedirectIOMode.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); + string system_unit_name = FindFileInDirs("VBSystem.vb",Path.Combine(this.CompilerOptions.SystemDirectory,"lib"),Path.Combine(this.CompilerOptions.SystemDirectory,"LibSource")); + string redirect_fname = Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"_RedirectIOMode.vb"); + StreamReader sr = File.OpenText(redirect_base_fname); + string redirect_module = sr.ReadToEnd(); + sr.Close(); + if (info != null) + { + System.Text.StringBuilder tmp_sb = new System.Text.StringBuilder(); + if (info.modules.Count > 0) + { + tmp_sb.AppendLine("GetType(Fictive.Fictive).Assembly.GetType(\"PABCSystem_implementation$.PABCSystem_implementation$\").GetMethod(\"$Initialization\").Invoke(Nothing,Nothing)"); + } + for (int i=0; i 0) + { + comp_opt.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),PascalABCCompiler.TreeConverter.compiler_string_consts.pabc_rtl_dll_name)); + string mod_file_name = FindFileInDirs("PABCRtl.dll",Path.Combine(this.CompilerOptions.SystemDirectory,"Lib")); + File.Copy(mod_file_name,Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),"PABCRtl.dll"),true); + /*foreach (string mod in info.modules) + { + comp_opt.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),mod+".dll")); + string mod_file_name = FindSourceFileInDirectories(mod+".mod",Path.Combine(this.CompilerOptions.SystemDirectory,"lib")); + File.Copy(mod_file_name,Path.Combine(Path.GetDirectoryName(CompilerOptions.SourceFileName),mod+".dll"),true); + }*/ + } + sources.Add(redirect_fname); + sources.Add(system_unit_name); + System.CodeDom.Compiler.CompilerResults res = vbcp.CompileAssemblyFromFile(comp_opt,sources.ToArray()); + if (res.Errors.Count > 0) + { + for (int i=0; i 0) + return null; + else + return res.PathToAssembly; + } + + private ProjectInfo project; + + private void PrepareCompileOptionsForProject() + { + project = new ProjectInfo(); + project.Load(CompilerOptions.SourceFileName); + //LoadProject(CompilerOptions.SourceFileName); + switch (project.ProjectType) + { + case ProjectType.ConsoleApp: CompilerOptions.OutputFileType = CompilerOptions.OutputType.ConsoleApplicaton; break; + case ProjectType.WindowsApp: CompilerOptions.OutputFileType = CompilerOptions.OutputType.WindowsApplication; break; + case ProjectType.Library: CompilerOptions.OutputFileType = CompilerOptions.OutputType.ClassLibrary; break; + } + CompilerOptions.SourceFileName = project.main_file; + CompilerOptions.Debug = project.include_debug_info; + CompilerOptions.OutputFileName = project.output_file_name; + + CompilerOptions.OutputDirectory = project.output_directory; + } + + public string Compile() + { + + try + { + //var timer = System.Diagnostics.Stopwatch.StartNew(); ////// + + if (Path.GetExtension(CompilerOptions.SourceFileName) == ".vb") + { + return CompileVB(); + } + + if (Path.GetExtension(CompilerOptions.SourceFileName) == ".cs") + { + return CompileCS(); + } + + OnChangeCompilerState(this, CompilerState.CompilationStarting, CompilerOptions.SourceFileName); + + Reset(); + //Console.WriteLine(timer.ElapsedMilliseconds / 1000.0); ////// + if (CompilerOptions.ProjectCompiled) + { + PrepareCompileOptionsForProject(); + } + Units = new PascalABCCompiler.TreeRealization.unit_node_list(); + CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(null, new SyntaxTree.string_const(Path.GetFullPath(CompilerOptions.SourceFileName))); + + CompileUnit(Units, CurrentSyntaxUnit, null); + + //Console.WriteLine(timer.ElapsedMilliseconds / 1000.0); ////// + foreach (CompilationUnit CurrentUnit in UnitsToCompile) + if (CurrentUnit.State != UnitState.Compiled) + { + CurrentCompilationUnit = CurrentUnit; + string UnitName = CurrentCompilationUnit.SyntaxTree.file_name; + //if(CurrentUnit.State!=UnitState.InterfaceCompiled) //DEBUG + //Console.WriteLine("ERROR! interface not compiled "+GetUnitFileName(CurrentUnit.SyntaxUnitName));//DEBUG + System.Collections.Generic.List SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); + CurrentUnit.PossibleNamespaces.Clear(); + if (HasIncludeNamespacesDirective(CurrentUnit)) + compilerOptions.UseDllForSystemUnits = false; + if (SyntaxUsesList != null) + { + for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) + if (!IsPossibleNamespace(SyntaxUsesList[i], false, Path.GetDirectoryName(UnitName))) + { + compilerOptions.UseDllForSystemUnits = false; + break; + } + for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) + if (!IsPossibleNamespace(SyntaxUsesList[i], true, Path.GetDirectoryName(UnitName))) + { + CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], Path.GetDirectoryName(UnitName)); + } + else + { + CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); + CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); + } + } + //Console.WriteLine("Compile Implementation "+UnitName);//DEBUG + //TODO: Избавиться от преобразования типа. + + AddNamespaces(CurrentUnit.ImplementationUsingNamespaceList, CurrentUnit.PossibleNamespaces, true, null); + +#if DEBUG + if (InternalDebug.SemanticAnalysis) +#endif + { + OnChangeCompilerState(this, CompilerState.CompileImplementation, UnitName); + PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; + SyntaxTreeToSemanticTreeConverter.CompileImplementation( + (PascalABCCompiler.TreeRealization.common_unit_node)CurrentUnit.SemanticTree, + CurrentUnit.SyntaxTree, + buildImplementationUsesList(CurrentUnit), + ErrorsList,Warnings, + CurrentUnit.syntax_error, BadNodesInSyntaxTree, + CurrentUnit.InterfaceUsingNamespaceList, + CurrentUnit.ImplementationUsingNamespaceList, + null, + CompilerOptions.Debug, + CompilerOptions.ForDebugging + ); + CheckErrors(); + } + CurrentUnit.State = UnitState.Compiled; + OnChangeCompilerState(this, CompilerState.EndCompileFile, UnitName); + //SavePCU(CurrentUnit, UnitName); + CurrentUnit.UnitName = UnitName; + } + + ClosePCUReadersAndWriters(); + if (CompilerOptions.SaveDocumentation) + SaveDocumentations(); + + compilerDirectives = GetCompilerDirectives(UnitsSortedList); + + if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.compiler_directive_apptype)) + { + string directive = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_apptype][0].directive; + if (string.Compare(directive,"console",true)==0) + CompilerOptions.OutputFileType = CompilerOptions.OutputType.ConsoleApplicaton; + else + if (string.Compare(directive,"windows",true)==0) + CompilerOptions.OutputFileType = CompilerOptions.OutputType.WindowsApplication; + else + if (string.Compare(directive,"dll",true)==0) + CompilerOptions.OutputFileType = CompilerOptions.OutputType.ClassLibrary; + else + if (string.Compare(directive,"pcu",true)==0) + CompilerOptions.OutputFileType = CompilerOptions.OutputType.PascalCompiledUnit; + } + + moveSystemUnitToForwardUnitSortedList(); + PascalABCCompiler.TreeRealization.common_unit_node system_unit = null; + if (UnitsSortedList.Count>0) + system_unit = UnitsSortedList[0].SemanticTree as PascalABCCompiler.TreeRealization.common_unit_node; + if (system_unit != null) + system_unit.IsConsoleApplicationVariable = CompilerOptions.OutputFileType == CompilerOptions.OutputType.ConsoleApplicaton; + + TreeRealization.program_node pn = null; + NETGenerator.CompilerOptions cdo = new NETGenerator.CompilerOptions(); + List cds; + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.compiler_directive_platformtarget, out cds)) + { + string plt = cds[0].directive.ToLower(); + if (plt.Equals("x86")) + cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.x86; + else if (plt.Equals("x64")) + cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.x64; + else if (plt.Equals("anycpu")) + cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.AnyCPU; + } + if (this.compilerOptions.Only32Bit) + cdo.platformtarget = NETGenerator.CompilerOptions.PlatformTarget.x86; + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.product_string, out cds)) + { + cdo.Product = cds[0].directive; + } + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.version_string, out cds)) + { + cdo.ProductVersion = cds[0].directive; + } + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.company_string, out cds)) + { + cdo.Company = cds[0].directive; + } + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.trademark_string, out cds)) + { + cdo.TradeMark = cds[0].directive; + } + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.copyright_string, out cds)) + { + cdo.Copyright = cds[0].directive; + } + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.title_string, out cds)) + { + cdo.Title = cds[0].directive; + } + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.description_string, out cds)) + { + cdo.Description = cds[0].directive; + } + if (compilerDirectives.TryGetValue(TreeConverter.compiler_string_consts.main_resource_string, out cds)) + { + if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.product_string) || + compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.version_string) || + compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.company_string) || + compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.trademark_string) || + compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.title_string) || + compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.description_string)) + { + ErrorsList.Add(new MainResourceNotAllowed(cds[0].location)); + } + cdo.MainResourceFileName = cds[0].directive; + if (!File.Exists(cdo.MainResourceFileName)) + { + ErrorsList.Add(new ResourceFileNotFound(cds[0].directive, cds[0].location)); + } + } + + List ResourceFiles = null; + if (compilerDirectives.ContainsKey(TreeConverter.compiler_string_consts.compiler_directive_resource)) + { + ResourceFiles = new List(); + List ResourceDirectives = compilerDirectives[TreeConverter.compiler_string_consts.compiler_directive_resource]; + foreach (TreeRealization.compiler_directive cd in ResourceDirectives) + { + var resource_fname = Path.Combine(Path.GetDirectoryName(cd.source_file), cd.directive); + + if (File.Exists(resource_fname)) + ResourceFiles.Add(resource_fname); + else + ErrorsList.Add(new ResourceFileNotFound(cd.directive, cd.location)); + + } + } + string res_file = null; + if (project != null) + { + if (!(project.major_version == 0 && project.minor_version == 0 && project.build_version == 0 && project.revision_version == 0)) + cdo.ProductVersion = project.major_version + "." + project.minor_version + "." + project.build_version + "." + project.revision_version; + if (!string.IsNullOrEmpty(project.product)) + cdo.Product = project.product; + if (!string.IsNullOrEmpty(project.company)) + cdo.Company = project.company; + if (!string.IsNullOrEmpty(project.trademark)) + cdo.TradeMark = project.trademark; + if (!string.IsNullOrEmpty(project.copyright)) + cdo.Copyright = project.copyright; + if (!string.IsNullOrEmpty(project.title)) + cdo.Title = project.title; + if (!string.IsNullOrEmpty(project.description)) + cdo.Description = project.description; + if (!string.IsNullOrEmpty(project.app_icon) && false) + { + //cdo.MainResourceFileName = project.app_icon; + string rc_file = Path.GetFileNameWithoutExtension(project.app_icon) + ".rc"; + StreamWriter sw = File.CreateText(rc_file); + sw.WriteLine("1 ICON \"" + project.app_icon.Replace("\\", "\\\\") + "\""); + if (cdo.NeedDefineVersionInfo) + { + cdo.NeedDefineVersionInfo = false; + sw.WriteLine("1 VERSIONINFO"); + string ver = project.major_version + "," + project.minor_version + "," + project.build_version + "," + project.revision_version; + sw.WriteLine("FILEVERSION " + ver); + /*sw.WriteLine("FILEFLAGSMASK VS_FFI_FILEFLAGSMASK"); + sw.WriteLine("FILEFLAGS VER_DEBUG"); + sw.WriteLine("FILEOS VOS__WINDOWS32"); + if (project.project_type != ProjectType.Library) + sw.WriteLine("FILETYPE VFT_APP"); + else + sw.WriteLine("FILETYPE VFT_DLL"); + sw.WriteLine("FILESUBTYPE VFT2_UNKNOWN");*/ + sw.WriteLine("BEGIN \r\n BLOCK \"StringFileInfo\"\r\n BEGIN \r\n BLOCK \"041904E3\"\r\nBEGIN"); + sw.WriteLine("VALUE \"ProductName\"," + "\"" + cdo.Product + "\""); + sw.WriteLine("VALUE \"FileVersion\"," + "\"" + ver + "\""); + sw.WriteLine("VALUE \"ProductVersion\"," + "\"" + ver + "\""); + sw.WriteLine("VALUE \"FileDescription\"," + "\"" + cdo.Description + "\""); + sw.WriteLine("VALUE \"OriginalFileName\"," + "\"" + Path.GetFileName(CompilerOptions.OutputFileName) + "\""); + sw.WriteLine("VALUE \"InternalName\"," + "\"" + Path.GetFileNameWithoutExtension(CompilerOptions.OutputFileName) + "\""); + sw.WriteLine("VALUE \"CompanyName\"," + "\"" + cdo.Company + "\""); + sw.WriteLine("VALUE \"LegalTrademarks1\"," + "\"" + cdo.TradeMark + "\""); + sw.WriteLine("VALUE \"LegalCopyright\"," + "\"" + cdo.Copyright + "\""); + sw.WriteLine("END"); + sw.WriteLine("END"); + + sw.WriteLine("BLOCK \"VarFileInfo\"\r\nBEGIN"); + sw.WriteLine("VALUE \"Translation\", 0x0419, 1251"); + sw.WriteLine("END"); + sw.WriteLine("END"); + } + sw.Close(); + System.Diagnostics.Process prc = new System.Diagnostics.Process(); + prc.StartInfo.FileName = Path.Combine(this.CompilerOptions.SystemDirectory, "rc.exe"); + prc.StartInfo.Arguments = Path.Combine(Path.GetDirectoryName(project.app_icon), Path.GetFileNameWithoutExtension(project.app_icon) + ".rc"); + prc.StartInfo.CreateNoWindow = true; + prc.StartInfo.UseShellExecute = false; + prc.StartInfo.RedirectStandardOutput = true; + prc.StartInfo.RedirectStandardError = true; + prc.Start(); + prc.WaitForExit(); + res_file = Path.Combine(Path.GetDirectoryName(project.app_icon), Path.GetFileNameWithoutExtension(project.app_icon) + ".res"); + if (File.Exists(res_file)) + { + cdo.MainResourceFileName = res_file; + } + File.Delete(rc_file); + } + } + + if (ErrorsList.Count == 0 && compilerOptions.GenerateCode) + { + cdo.ForRunningWithEnvironment = CompilerOptions.RunWithEnvironment; + switch (CompilerOptions.OutputFileType) + { + case CompilerOptions.OutputType.ClassLibrary: cdo.target = NETGenerator.TargetType.Dll; break; + case CompilerOptions.OutputType.ConsoleApplicaton: cdo.target = NETGenerator.TargetType.Exe; break; + case CompilerOptions.OutputType.WindowsApplication: cdo.target = NETGenerator.TargetType.WinExe; break; + + } + if (project != null && project.ProjectType == ProjectType.WindowsApp) + cdo.target = PascalABCCompiler.NETGenerator.TargetType.WinExe; + switch (CompilerOptions.Debug) + { + case true: cdo.dbg_attrs = NETGenerator.DebugAttributes.Debug; break; + case false: cdo.dbg_attrs = NETGenerator.DebugAttributes.Release; break; + } + if (CompilerOptions.ForDebugging) + cdo.dbg_attrs = NETGenerator.DebugAttributes.ForDebugging; + + + //TODO: Разобратся c location для program_node и правильно передавать main_function. Добавить генератор main_function в SyntaxTreeToSemanticTreeConverter. + pn = new PascalABCCompiler.TreeRealization.program_node(null, null); + + for (int i = 0; i < UnitsSortedList.Count; i++) + pn.units.AddElement(UnitsSortedList[i].SemanticTree as TreeRealization.common_unit_node); + + //(ssyy) Добавил в условие c_module + if (FirstCompilationUnit.SyntaxTree is SyntaxTree.program_module || + FirstCompilationUnit.SyntaxTree is SyntaxTree.c_module) + { + if ((cdo.target == NETGenerator.TargetType.Exe) || (cdo.target == NETGenerator.TargetType.WinExe)) + { + if (UnitsSortedList.Count > 0) + { + pn.main_function = ((PascalABCCompiler.TreeRealization.common_unit_node)UnitsSortedList[UnitsSortedList.Count - 1].SemanticTree).main_function; + /***************************Ivan added*******************************/ + if (pn.main_function.function_code.location != null) + { + bool flag = false; + PascalABCCompiler.TreeRealization.common_namespace_node main_ns = pn.main_function.namespace_node; + for (int i = 0; i < main_ns.variables.Count; i++) + { + PascalABCCompiler.TreeRealization.namespace_variable nv = main_ns.variables[i]; + if (nv.inital_value != null && nv.inital_value.location != null && !(nv.inital_value is PascalABCCompiler.TreeRealization.constant_node) + && !(nv.inital_value is PascalABCCompiler.TreeRealization.record_initializer) && !(nv.inital_value is PascalABCCompiler.TreeRealization.array_initializer)) + { + varBeginOffset = main_ns.variables[i].inital_value.location.begin_line_num; + flag = true; + break; + } + } + beginOffset = pn.main_function.function_code.location.begin_line_num; + } + /*******************************************************************/ + Dictionary config_dic = new Dictionary(); + if (CompilerOptions.Locale != null && PascalABCCompiler.StringResourcesLanguage.GetLCIDByTwoLetterISO(CompilerOptions.Locale) != null) + { + config_dic["locale"] = CompilerOptions.Locale; + config_dic["full_locale"] = PascalABCCompiler.StringResourcesLanguage.GetLCIDByTwoLetterISO(CompilerOptions.Locale); + } + pn.create_main_function(StandarModules.ToArray(), config_dic); + + } + } + } + else if (FirstCompilationUnit.SyntaxTree is SyntaxTree.unit_module && cdo.target == NETGenerator.TargetType.Dll) + { + pn.create_main_function_as_in_module(); + } + pn = semanticTreeConvertersController.Convert(pn) as TreeRealization.program_node; + + _semantic_tree = pn; + + if (FirstCompilationUnit.SyntaxTree is SyntaxTree.unit_module && CompilerOptions.OutputFileType != CompilerOptions.OutputType.ClassLibrary) + { + //если мы комилируем PCU + CompilerOptions.OutputFileType = CompilerOptions.OutputType.PascalCompiledUnit; + } + else + { + if( CompilerOptions.OutputFileType!= CompilerOptions.OutputType.SemanticTree) +#if DEBUG + if (InternalDebug.CodeGeneration) +#endif + { + int n = 1; + try + { + n = 2; + var fs = File.Create(CompilerOptions.OutputFileName); + n = 3; + fs.Close(); + n = 4; + ///////File.Delete(CompilerOptions.OutputFileName); + string pdb_file_name=Path.ChangeExtension(CompilerOptions.OutputFileName, ".pdb"); + if (File.Exists(pdb_file_name)) + File.Delete(pdb_file_name); + n = 5; + } + catch (Exception e) + { + throw new UnauthorizedAccessToFile(CompilerOptions.OutputFileName + " -- " + n + " " + e.ToString()); + //throw e; + } + OnChangeCompilerState(this, CompilerState.CodeGeneration, CompilerOptions.OutputFileName); + string[] ResourceFilesArray = null; + if (ResourceFiles != null) + ResourceFilesArray = ResourceFiles.ToArray(); + cds = null; + /*if (compilerDirectives.TryGetValue("platform", out cds) && cds[0].directive.ToLower() == "native") + { + //LLVMCodeGeneratorsController.Compile(pn, CompilerOptions.OutputFileName, CompilerOptions.SourceFileName, ResourceFilesArray); + PABCToCppCodeGeneratorsController.Compile(pn, CompilerOptions.OutputFileName, CompilerOptions.SourceFileName, ResourceFilesArray); + } + else*/ + if (compilerOptions.UseDllForSystemUnits) + cdo.RtlPABCSystemType = NetHelper.NetHelper.FindRtlType("PABCSystem.PABCSystem"); + CodeGeneratorsController.Compile(pn, CompilerOptions.OutputFileName, CompilerOptions.SourceFileName, cdo, CompilerOptions.StandartDirectories, ResourceFilesArray); + if (res_file != null) + File.Delete(res_file); + } + } + } + } + catch (TreeConverter.ParserError err) + { + //конвертор уткнулся в ошибку. ничего не делаем + } + catch (Errors.CompilerInternalError err) + { + if (ErrorsList.Count == 0) + ErrorsList.Add(err); + else + { +#if DEBUG + if (!InternalDebug.SkipInternalErrorsIfSyntaxTreeIsCorrupt) + ErrorsList.Add(err); +#endif + } + } + catch (Errors.Error err) + { + if (ErrorsList.Count == 0) + ErrorsList.Add(err); + else + if (err != ErrorsList[0]) + { + if (err is SemanticError) + { + int pos = ErrorsList.Count; + SourceLocation loc = (err as SemanticError).SourceLocation, loctmp; + if (loc != null) + for (int i = 0; i < ErrorsList.Count; i++) + if (ErrorsList[i] is LocatedError) + if ((loctmp = (ErrorsList[i] as LocatedError).SourceLocation) != null) + if (loctmp > loc) + { + pos = i; + break; + } + + ErrorsList.Insert(pos, err); + } + else + ErrorsList.Add(err); + } + } + catch (Exception err) + { + string fn = "Compiler"; + if (CurrentCompilationUnit != null && this.CurrentCompilationUnit.SyntaxTree != null) fn = Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name); + Errors.CompilerInternalError comp_err = new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", fn), err); + if (ErrorsList.Count == 0) + ErrorsList.Add(comp_err); + else + { +#if DEBUG + if (!InternalDebug.SkipInternalErrorsIfSyntaxTreeIsCorrupt) + ErrorsList.Add(comp_err); +#endif + } + } + + //удаляем лишние ошибки + /*foreach(Error er in errorsList) + { + + }*/ + + //на случай если мы вывалились по исключению но у нас есть откомпилированные модули + try + { + ClosePCUReadersAndWriters(); + } + catch (Exception e) + { + ErrorsList.Add(new Errors.CompilerInternalError("Compiler.ClosePCUReadersAndWriters", e)); + } + bool need_recompiled = false; + if (ErrorsList.Count > 0) + { + if (compilerOptions.UseDllForSystemUnits && !has_only_syntax_errors(ErrorsList) && compilerOptions.IgnoreRtlErrors) + { + compilerOptions.UseDllForSystemUnits = false; + ErrorsList.Clear(); + + need_recompiled = true; + + } + } + OnChangeCompilerState(this, CompilerState.CompilationFinished, CompilerOptions.SourceFileName); + if (ClearAfterCompilation) + ClearAll(); + + + OnChangeCompilerState(this, CompilerState.Ready, null); + if (ErrorsList.Count > 0) + { + return null; + } + else if (need_recompiled) + { + //Compiler c = new Compiler(sourceFilesProvider,OnChangeCompilerState); + //return c.Compile(this.compilerOptions); + return Compile(); + } + else + return CompilerOptions.OutputFileName; + } + + private bool has_only_syntax_errors(List errors) + { + foreach (Error err in errors) + { + if (!(err is SyntaxError)) + return false; + } + return true; + } + + private void SaveDocumentations() + { + DocXmlManager dxm = new DocXmlManager(); + foreach (CompilationUnit cu in UnitsSortedList) + { + if (cu.Documented) + dxm.SaveXml(cu); + } + } + + private void ClosePCUReadersAndWriters() + { + if (PCUReadersAndWritersClosed) + return; + + PCUReadersAndWritersClosed = true; + + bool all_restored = false; + while (!all_restored) + { + foreach (PCUReader p in PCUReader.AllReaders) + { + p.AddInitFinalMethods(); + SystemLibrary.SystemLibInitializer.RestoreStandardFunctions(); + p.ProcessWaitedToRestoreFields(); + } + bool rest = true; + for (int i=0; i usesList) + { + if(usesList==null) + return; + List names = new List(); + foreach (SyntaxTree.unit_or_namespace un in usesList) + { + string name=SyntaxTree.Utils.IdentListToString(un.name.idents,".").ToLower(); + if (un.source_context != null) + { + if (names.Contains(name)) + throw new DuplicateUsesUnit(CurrentCompilationUnit.SyntaxTree.file_name, name, un.source_context); + else + names.Add(name); + } + } + } + + public List GetSyntaxInterfaceUsesList(SyntaxTree.compilation_unit CurrentSyntaxUnit) + { + List result = null; + if(CurrentSyntaxUnit is SyntaxTree.unit_module) + { + SyntaxTree.interface_node intp = (CurrentSyntaxUnit as SyntaxTree.unit_module).interface_part; + if (intp.uses_modules == null) + if (CompilerOptions.StandartModules.Count > 0)//если есть стандартые модули то создать список + { + intp.uses_modules = new SyntaxTree.uses_list(); + intp.uses_modules.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1, 1, 1); + } + else + return null; + result = intp.uses_modules.units; + } + if (CurrentSyntaxUnit is SyntaxTree.program_module) + { + SyntaxTree.program_module pm = (CurrentSyntaxUnit as SyntaxTree.program_module); + if (pm.used_units == null) + if (CompilerOptions.StandartModules.Count > 0)//если есть стандартые модули то создать список + { + pm.used_units = new SyntaxTree.uses_list(); + pm.used_units.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1, 1, 1); + } + else + return null; + result = pm.used_units.units; + } + if (CurrentSyntaxUnit is SyntaxTree.c_module) + { + SyntaxTree.c_module pm = (CurrentSyntaxUnit as SyntaxTree.c_module); + if (pm.used_units == null) + if (CompilerOptions.StandartModules.Count > 0)//если есть стандартые модули то создать список + { + pm.used_units = new SyntaxTree.uses_list(); + pm.used_units.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1, 1, 1); + } + else + return null; + result = pm.used_units.units; + } + checkDuplicateUsesUnit(result); + return result; + } + + private List GetSyntaxImplementationUsesList(SyntaxTree.compilation_unit CurrentSyntaxUnit) + { + List result = null; + if(CurrentSyntaxUnit is SyntaxTree.unit_module) + if ((CurrentSyntaxUnit as SyntaxTree.unit_module).implementation_part!=null) + if ((CurrentSyntaxUnit as SyntaxTree.unit_module).implementation_part.uses_modules != null) + { + result = (CurrentSyntaxUnit as SyntaxTree.unit_module).implementation_part.uses_modules.units; + checkDuplicateUsesUnit(result); + return result; + } + if(CurrentSyntaxUnit is SyntaxTree.program_module) + return null; + return null; + } + + public string FindPCUFileName(string fname, string curr_path) + { + var ext = Path.GetExtension(fname); + + if (string.IsNullOrEmpty(ext)) + fname += CompilerOptions.CompiledUnitExtension; + else if (ext != CompilerOptions.CompiledUnitExtension) + // Чтоб "uses u in 'u.pas';" видело и "u.pcu" тоже + fname = Path.ChangeExtension(fname, CompilerOptions.CompiledUnitExtension); + + if (PCUFileNamesDictionary.ContainsKey(Tuple.Create(fname,curr_path))) + return PCUFileNamesDictionary[Tuple.Create(fname, curr_path)]; + + string res = FindFileInDirs(fname, CompilerOptions.OutputDirectory, curr_path, CompilerOptions.SearchDirectory); + + PCUFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; + return res; + } + + public string FindSourceFileName(string fname, string curr_path) + { + + if (SourceFileNamesDictionary.ContainsKey(Tuple.Create(fname, curr_path))) + return SourceFileNamesDictionary[Tuple.Create(fname, curr_path)]; + + string res = FindSourceFileNameInDirs(fname, curr_path, CompilerOptions.SearchDirectory); + + SourceFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; + return res; + } + + public string FindSourceFileNameInDirs(string fname, params string[] Dirs) + { + var fname_ext = Path.GetExtension(fname); + var need_ext = string.IsNullOrEmpty(fname_ext); + + foreach (SupportedSourceFile sf in SupportedSourceFiles) + foreach (string ext in sf.Extensions) + if (need_ext || fname_ext==ext) + { + var res = FindFileInDirs(need_ext ? fname+ext : fname, Dirs); + //if (!(CompilerOptions.UseDllForSystemUnits && Path.GetDirectoryName(res) == CompilerOptions.SearchDirectory)) + if (res != null) + return res; + } + + return null; + } + + private static string CombinePath(string dir, string path) + { + if (Path.IsPathRooted(path)) return path; + int i = 0; + + for (; i < path.Length && path[i] == '.' && path[i + 1] == '.'; ) + { + dir = Path.GetDirectoryName(dir); + if (string.IsNullOrEmpty(dir)) return null; + i += 2; + if (path[i] == Path.DirectorySeparatorChar || path[i] == Path.AltDirectorySeparatorChar) i += 1; + } + + return Path.Combine(dir, path.Substring(i)); + } + + private string FindFileInDirs(string FileName, params string[] Dirs) + { + foreach (string Dir in Dirs) + { + var res = CombinePath(Dir, FileName); + if (File.Exists(res)) + return res; + } + return null; + } + + public static string GetReferenceFileName(string FileName) + { + // Вначале - кешированные стандартные dll + if (standart_assembly_dict.ContainsKey(FileName)) + return standart_assembly_dict[FileName]; + + if (System.IO.File.Exists(FileName)) + { + return FileName;//.ToLower();//? а надо ли tolover? + } + else + { + return get_assembly_path(FileName,false); + } + } + + private string GetReferenceFileName(string FileName, SyntaxTree.SourceContext sc, string curr_path) + { + if (standart_assembly_dict.ContainsKey(FileName)) + return standart_assembly_dict[FileName]; + + // Наверное, этот код MikhailoMMX лишний + //MikhailoMMX PABCRtl.dll будем искать сначала в GAC, а потом в папке с программой + if (FileName == TreeConverter.compiler_string_consts.pabc_rtl_dll_name) + { + + string name = get_assembly_path(FileName, true); + if ((name != null) && (File.Exists(name))) + return name; + + } + //\MikhailoMMX + + var FullFileName = Path.Combine(curr_path, FileName); + if (System.IO.File.Exists(FullFileName)) // для отладки с *.inc файлами + { + var NewFileName = Path.Combine(compilerOptions.OutputDirectory, Path.GetFileName(FullFileName)); + if (FullFileName != NewFileName) File.Copy(FullFileName, NewFileName, true); + return NewFileName; + } + else + { + string name = get_assembly_path(FileName,false);//? а надо ли tolover? + if (name == null) + throw new AssemblyNotFound(this.CurrentCompilationUnit.SyntaxTree.file_name, FileName, sc); + else + if (File.Exists(name)) + return name; + else + throw new AssemblyNotFound(this.CurrentCompilationUnit.SyntaxTree.file_name, FileName, sc); + } + } + + public string GetUnitFileName(SyntaxTree.unit_or_namespace SyntaxUsesUnit, string curr_path) + { + //ToDo В корневом Compile() создаётся uses_unit_in без name. Выглядит как костыль + if (SyntaxUsesUnit is SyntaxTree.uses_unit_in && (SyntaxUsesUnit as SyntaxTree.uses_unit_in).name == null) return (SyntaxUsesUnit as SyntaxTree.uses_unit_in).in_file.Value; + + string UnitName; + string SourceFileName; + string PCUFileName; + + if (SyntaxUsesUnit is SyntaxTree.uses_unit_in uui) + { + + // Подключение .dll в uses-in. Зачем - не понятно, но было до меня, поэтому просто оставил + switch (Path.GetExtension(uui.in_file.Value).ToLower()) + { + case ".dll": + case ".exe": + return GetReferenceFileName(uui.in_file.Value, uui.in_file.source_context, curr_path); + } + + if (uui.name.idents[0].name.ToLower() != Path.GetFileNameWithoutExtension(uui.in_file.Value).ToLower()) + throw new UsesInWrongName(CurrentCompilationUnit.SyntaxTree.file_name, uui.name.idents[0].name, Path.GetFileNameWithoutExtension(uui.in_file.Value), uui.in_file.source_context); + + UnitName = uui.name.idents[0].name; + + SourceFileName = FindSourceFileName(uui.in_file.Value, curr_path); + PCUFileName = FindPCUFileName(uui.in_file.Value, curr_path); + } + else + { + UnitName = SyntaxUsesUnit.name.idents[0].name; + + SourceFileName = FindSourceFileName(UnitName, curr_path); + PCUFileName = FindPCUFileName(UnitName, curr_path); + + } + + var SourceFileExists = SourceFileName!=null && File.Exists(SourceFileName); + var PCUFileExists = !CompilerOptions.Rebuild && PCUFileName !=null && File.Exists(PCUFileName); + + if (!PCUFileExists && !SourceFileExists) + throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); + + if (PCUFileExists && SourceFileExists) + { + + if (CompilerOptions.Rebuild && !RecompileList.ContainsKey(UnitName)) + PCUFileExists = false; + + else if (File.GetLastWriteTime(PCUFileName) < File.GetLastWriteTime(SourceFileName)) + PCUFileExists = false; + + // На случай если есть своя версия стандартного модуля в папке с программой, но .pcu ещё не создан + else if (Path.GetDirectoryName(SourceFileName) != Path.GetDirectoryName(PCUFileName)) + PCUFileExists = false; + + } + + if (PCUFileExists) + return Path.Combine(curr_path, PCUFileName); + else + return Path.Combine(curr_path, SourceFileName); + + } + + private bool FileInSearchDirectory(string FileName) + { + return Path.GetDirectoryName(FileName).ToLower() == CompilerOptions.SearchDirectory.ToLower(); + } + + public void AddStandartUnitsToUsesSection(SyntaxTree.compilation_unit cu) + { + //if (FileInSearchDirectory(cu.file_name)) return; + + string ModuleName = null; + SyntaxTree.uses_unit_in uses_unit_in = null; + SyntaxTree.unit_or_namespace uses_unit = null; + List UsesList = GetSyntaxInterfaceUsesList(cu); + if (UsesList == null) + return; + string cu_module_name = Path.GetFileNameWithoutExtension(cu.file_name).ToLower(); + foreach (CompilerOptions.StandartModule Module in CompilerOptions.StandartModules) + { + //Я стандартный?? + ModuleName = Path.GetFileNameWithoutExtension(Module.Name); + if (ModuleName.ToLower() == cu_module_name) + return; + } + foreach (CompilerOptions.StandartModule Module in CompilerOptions.StandartModules) + { + if ((Module.AddToLanguages & FirstCompilationUnit.SyntaxTree.Language) != FirstCompilationUnit.SyntaxTree.Language + && (Module.AddToLanguages & CurrentCompilationUnit.SyntaxTree.Language) != CurrentCompilationUnit.SyntaxTree.Language) + continue; + ModuleName = Path.GetFileNameWithoutExtension(Module.Name); + if (Module.AddMethod == CompilerOptions.StandartModuleAddMethod.RightToMain && CurrentCompilationUnit != FirstCompilationUnit) + continue; + foreach (SyntaxTree.unit_or_namespace curunit in UsesList) + { + if (curunit.name.idents.Count == 1 && curunit.name.idents[0].name.ToLower() == ModuleName.ToLower()) + continue; + } + + PascalABCCompiler.SyntaxTree.unit_or_namespace to_add; + if (Path.GetExtension(Module.Name) != "" /*&& Path.GetExtension(ModuleFileName).ToLower() != ".dll"*/) + { + uses_unit_in = new SyntaxTree.uses_unit_in( + _name: new SyntaxTree.ident_list(new SyntaxTree.ident(ModuleName)), + _in_file: new SyntaxTree.string_const(Module.Name)); + //uses_unit_in.source_context = uses_unit_in.in_file.source_context = uses_unit_in.name.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1); + to_add = uses_unit_in; + } + else + { + uses_unit = new SyntaxTree.unit_or_namespace(new SyntaxTree.ident_list(new SyntaxTree.ident(ModuleName))); + //uses_unit.source_context = uses_unit.name.source_context = new SyntaxTree.SourceContext(1, 1, 1, 1); + to_add = uses_unit; + } + switch (Module.AddMethod) + { + case CompilerOptions.StandartModuleAddMethod.RightToMain: + UsesList.Add(to_add); + break; + case CompilerOptions.StandartModuleAddMethod.LeftToAll: + UsesList.Insert(0, to_add); + break; + } + + } + } + + private CompilationUnit CompileReference(PascalABCCompiler.TreeRealization.unit_node_list Units, TreeRealization.compiler_directive cd) + { + TreeRealization.location loc = cd.location; + SyntaxTree.SourceContext sc = null; + if (loc != null) + sc = new SyntaxTree.SourceContext(loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num, 0, 0); + string UnitName = null; + try + { + // "loc == null" для стандартных .dll, как "System.dll" + //ToDo а loc.doc было null в тестранере, но я так и не понял почему. не смог воспроизвести в дебаг режиме + UnitName = GetReferenceFileName(cd.directive, sc, loc?.doc?.file_name == null ? CompilerOptions.OutputDirectory : Path.GetDirectoryName(loc.doc.file_name)); + } + catch (AssemblyNotFound ex) + { + throw; + } + //ToDo плохо, пока дебажил - тут постоянно ловились другие исключения, не связанные с неправильным знаками в путик сборке + catch (Exception ex) + { + throw new InvalidAssemblyPathError(CurrentCompilationUnit.SyntaxTree.file_name, sc); + } + CompilationUnit CurrentUnit = null; + if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); + if ((CurrentUnit = ReadDLL(UnitName)) != null) + { + Units.AddElement(CurrentUnit.SemanticTree); + UnitTable[UnitName] = CurrentUnit; + return CurrentUnit; + } + else + //throw new DLLReadingError(UnitName); + throw new AssemblyReadingError(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, sc); + } + + private bool HasIncludeNamespacesDirective(CompilationUnit Unit) + { + var directives = ConvertDirectives(Unit.SyntaxTree); + foreach (TreeRealization.compiler_directive cd in directives) + { + if (cd.name.ToLower() == TreeConverter.compiler_string_consts.include_namespace_directive) + { + return true; + } + } + return false; + } + + + private Dictionary IncludeNamespaces(CompilationUnit Unit) + { + if (HasIncludeNamespacesDirective(Unit) && Unit.SyntaxTree is SyntaxTree.unit_module && (Unit.SyntaxTree as SyntaxTree.unit_module).unit_name.HeaderKeyword != SyntaxTree.UnitHeaderKeyword.Library) + throw new IncludeNamespaceInUnit(CurrentCompilationUnit.SyntaxTree.file_name, CurrentCompilationUnit.SyntaxTree.source_context); + var directives = ConvertDirectives(Unit.SyntaxTree); + SyntaxTree.unit_module main_library = Unit.SyntaxTree as SyntaxTree.unit_module; + SyntaxTree.program_module main_program = Unit.SyntaxTree as SyntaxTree.program_module; + List files = new List(); + foreach (TreeRealization.compiler_directive cd in directives) + { + if (cd.name.ToLower() == TreeConverter.compiler_string_consts.include_namespace_directive) + { + string directive = cd.directive.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar); + + if (directive == "*.pas" || directive.EndsWith(Path.DirectorySeparatorChar + "*.pas")) + { + string dir = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), directive.Replace(Path.DirectorySeparatorChar + "*.pas", "")); + foreach (string file in Directory.EnumerateFiles(dir, "*.pas")) + { + if (!File.Exists(file)) + throw new FileNotFound(file, cd.location); + files.Add(file); + } + + } + else + { + string file = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), directive); + if (!File.Exists(file)) + throw new FileNotFound(file, cd.location); + files.Add(file); + } + + + + } + } + Dictionary namespaces = new Dictionary(StringComparer.OrdinalIgnoreCase); + List namespace_modules = new List(); + foreach (string file in files) + { + + SyntaxTree.compilation_unit tree = GetNamespaceSyntaxTree(file); + if (!(tree is SyntaxTree.unit_module)) + throw new NamespaceModuleExpected(tree.source_context); + SyntaxTree.unit_module unit = tree as SyntaxTree.unit_module; + if (unit.unit_name.HeaderKeyword != SyntaxTree.UnitHeaderKeyword.Namespace) + throw new NamespaceModuleExpected(unit.unit_name.source_context); + if (unit.implementation_part != null) + throw new NamespaceModuleExpected(unit.implementation_part.source_context); + if (unit.finalization_part != null) + throw new NamespaceModuleExpected(unit.finalization_part.source_context); + if (unit.initialization_part != null && unit.initialization_part.list.Count > 0) + throw new NamespaceModuleExpected(unit.initialization_part.source_context); + SyntaxTree.syntax_namespace_node ns = null; + if (!namespaces.TryGetValue(unit.unit_name.idunit_name.name, out ns)) + { + ns = new SyntaxTree.syntax_namespace_node(unit.unit_name.idunit_name.name); + ns.referenced_units = new TreeRealization.unit_node_list(); + namespaces[unit.unit_name.idunit_name.name] = ns; + } + if (unit.interface_part.interface_definitions != null) + { + foreach (SyntaxTree.declaration decl in unit.interface_part.interface_definitions.defs) + { + ns.defs.Add(decl); + } + if (unit.interface_part.uses_modules != null) + { + checkDuplicateUsesUnit(unit.interface_part.uses_modules.units); + foreach (SyntaxTree.unit_or_namespace name_space in unit.interface_part.uses_modules.units) + { + if (IsPossibleNamespace(name_space, false, Path.GetDirectoryName(file))) + { + ns.referenced_units.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(name_space), get_location_from_treenode(name_space, tree.file_name))); + } + else + { + namespace_modules.Add(name_space); + } + } + } + } + } + foreach (string s in namespaces.Keys) + { + if (main_library != null) + main_library.interface_part.interface_definitions.Insert(0, namespaces[s]); + else + main_program.program_block.defs.Insert(0, namespaces[s]); + } + SyntaxTree.uses_list main_uses = null; + if (main_library != null) + { + if (main_library.interface_part.uses_modules != null) + main_uses = main_library.interface_part.uses_modules; + } + else if (main_program.used_units != null) + main_uses = main_program.used_units; + if (main_uses == null) + main_uses = new SyntaxTree.uses_list(); + Dictionary dict = new Dictionary(); + foreach (SyntaxTree.unit_or_namespace name_space in namespace_modules) + { + string name = SyntaxTree.Utils.IdentListToString(name_space.name.idents, ".").ToLower(); + if (!dict.ContainsKey(name)) + { + main_uses.Add(name_space); + dict.Add(name, name); + } + } + if (main_library != null) + main_library.interface_part.uses_modules = main_uses; + else + main_program.used_units = main_uses; + return namespaces; + } + + private SyntaxTree.compilation_unit GetNamespaceSyntaxTree(string FileName) + { + string SourceText = GetSourceFileText(FileName); + List DefinesList = new List(); + if (!compilerOptions.Debug && !compilerOptions.ForDebugging) + DefinesList.Add("RELEASE"); + else + DefinesList.Add("DEBUG"); + SyntaxTree.compilation_unit SyntaxTree = InternalParseText(FileName, SourceText, errorsList, warnings, DefinesList); + if (errorsList.Count > 0) + throw errorsList[0]; + SyntaxTree = syntaxTreeConvertersController.Convert(SyntaxTree) as SyntaxTree.compilation_unit; + return SyntaxTree; + } + + public TreeRealization.unit_node_list GetReferences(CompilationUnit Unit) + { + //TODO переделать, ConvertDirectives определена дважды и вызывается дважды! + TreeRealization.unit_node_list res = new TreeRealization.unit_node_list(); + List directives; + if (Unit.SemanticTree is TreeRealization.common_unit_node) + directives = (Unit.SemanticTree as TreeRealization.common_unit_node).compiler_directives; + else + directives = ConvertDirectives(Unit.SyntaxTree); + if (CompilerOptions.UseDllForSystemUnits) + { + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PABCRtl.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\mscorlib.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Core.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Numerics.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Windows.Forms.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Drawing.dll", null, null)); + if (Unit.SyntaxTree is SyntaxTree.program_module && (Unit.SyntaxTree as SyntaxTree.program_module).used_units != null) + foreach (SyntaxTree.unit_or_namespace uui in (Unit.SyntaxTree as SyntaxTree.program_module).used_units.units) + { + if (uui.name.ToString() == "Graph3D") + { + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationFramework.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\WindowsBase.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationCore.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.Wpf.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.dll", null, null)); + } + } + } + foreach (TreeRealization.compiler_directive cd in directives) + { + if (cd.name.ToLower() == TreeConverter.compiler_string_consts.compiler_directive_reference) + { + if (string.IsNullOrEmpty(cd.directive)) + throw new TreeConverter.SimpleSemanticError(cd.location, "EXPECTED_ASSEMBLY_NAME"); + else + CompileReference(res, cd); + } + } + if (CompilerOptions.ProjectCompiled) + { + foreach (ReferenceInfo ri in project.references) + { + CompileReference(res,new TreeRealization.compiler_directive("reference",ri.full_assembly_name,null,null)); + } + } + return res; + } + + private bool IsPossibleNamespace(SyntaxTree.unit_or_namespace name_space, bool add_to_standard_modules, string curr_path) + { + if (name_space is SyntaxTree.uses_unit_in) + return false; + if (name_space.name.idents.Count > 1) + return true; + string src = FindSourceFileName(name_space.name.idents[0].name, curr_path); + string pcu = FindPCUFileName(name_space.name.idents[0].name, curr_path); + if (src == null && pcu == null) + return true; + if (CompilerOptions.UseDllForSystemUnits && src != null && string.Compare(Path.GetDirectoryName(src), Path.Combine(CompilerOptions.SystemDirectory, "Lib"), true) == 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "PT4", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "CRT", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "Arrays", true) != 0 + //&& string.Compare(Path.GetFileNameWithoutExtension(src), "FormsABC", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "MPI", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "LibForHaskell", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "Collections", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "Core", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(src), "Oberon00System", true) != 0) + { + string s = Path.GetFileNameWithoutExtension(src).ToLower(); + if (add_to_standard_modules && !StandarModules.Contains(s)) + StandarModules.Add(s); + return true; + } + if (CompilerOptions.UseDllForSystemUnits && pcu != null && string.Compare(Path.GetDirectoryName(pcu), Path.Combine(CompilerOptions.SystemDirectory, "Lib"), true) == 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "PT4", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "CRT", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Arrays", true) != 0 + //&& string.Compare(Path.GetFileNameWithoutExtension(pcu), "FormsABC", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "MPI", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "LibForHaskell", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Collections", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Core", true) != 0 + && string.Compare(Path.GetFileNameWithoutExtension(pcu), "Oberon00System", true) != 0 + ) + { + string s = Path.GetFileNameWithoutExtension(pcu).ToLower(); + if (add_to_standard_modules && !StandarModules.Contains(s)) + StandarModules.Add(s); + return true; + } + return false; + } + + public TreeRealization.using_namespace GetNamespace(SyntaxTree.unit_or_namespace _name_space) + { + return new TreeRealization.using_namespace(SyntaxTree.Utils.IdentListToString(_name_space.name.idents, ".")); + } + + private TreeRealization.using_namespace GetNamespace(TreeRealization.using_namespace_list using_list, string full_namespace_name, SyntaxTree.unit_or_namespace _name_space, bool possible_is_unit, Dictionary pabc_namespaces) + { + if (!NetHelper.NetHelper.NamespaceExists(full_namespace_name) && !(pabc_namespaces != null && pabc_namespaces.ContainsKey(full_namespace_name))) + { + if (possible_is_unit) + if (!full_namespace_name.Contains(".")) + throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, full_namespace_name, _name_space.source_context); + throw new TreeConverter.NamespaceNotFound(full_namespace_name, get_location_from_treenode(_name_space.name, CurrentCompilationUnit.SyntaxTree.file_name)); + } + return new TreeRealization.using_namespace(full_namespace_name); + } + + public void AddNamespaces(TreeRealization.using_namespace_list using_list, List namespaces, bool possible_is_units, Dictionary pabc_namespaces) + { + foreach (SyntaxTree.unit_or_namespace ns in namespaces) + using_list.AddElement(GetNamespace(using_list, SyntaxTree.Utils.IdentListToString(ns.name.idents, "."), ns, possible_is_units, pabc_namespaces)); + } + + public void AddNamespaces(TreeRealization.using_namespace_list using_list, SyntaxTree.using_list ul) + { + if (ul != null) + AddNamespaces(using_list, ul.namespaces, false, null); + } + + public SyntaxTree.using_list GetInterfaceSyntaxUsingList(SyntaxTree.compilation_unit cu) + { + if (cu is SyntaxTree.unit_module) + return (cu as SyntaxTree.unit_module).interface_part.using_namespaces; + if (cu is SyntaxTree.program_module) + return (cu as SyntaxTree.program_module).using_namespaces; + return null; + } + + private SyntaxTree.using_list GetImplementationSyntaxUsingList(SyntaxTree.compilation_unit cu) + { + if (cu is SyntaxTree.unit_module) + if ((cu as SyntaxTree.unit_module).implementation_part!=null) + return (cu as SyntaxTree.unit_module).implementation_part.using_namespaces; + return null; + } + + public string GetSourceFileText(string FileName) + { + return (string)SourceFilesProvider(FileName, SourceFileOperation.GetText); + } + + + public SyntaxTree.compilation_unit ParseText(string FileName, string Text, List ErrorList, List Warnings) + { + Reset(); + OnChangeCompilerState(this, CompilerState.CompilationStarting, FileName); + SyntaxTree.compilation_unit cu = InternalParseText(FileName, Text, ErrorsList, Warnings); + OnChangeCompilerState(this, CompilerState.Ready, FileName); + return cu; + } + + private SyntaxTree.compilation_unit InternalParseText(string FileName, string Text, List ErrorList, List Warnings, List DefinesList = null) + { + OnChangeCompilerState(this, CompilerState.BeginParsingFile, FileName); + SyntaxTree.compilation_unit cu = ParsersController.GetCompilationUnit(FileName, Text, ErrorsList, Warnings, DefinesList); + OnChangeCompilerState(this, CompilerState.EndParsingFile, FileName); + //Вычисляем сколько строк скомпилировали + if (ErrorList.Count == 0 && cu != null && cu.source_context!=null) + linesCompiled += (uint)(cu.source_context.end_position.line_num - cu.source_context.begin_position.line_num + 1); + return cu; + } + + /*private bool check_for_library(List directives) + { + foreach (compiler_directive cd in directives) + { + if (string.Compare(cd.name,"apptype")==0 && string.Compare(cd.directive,"dll")==0) + return true; + } + return false; + }*/ + + public static bool is_dll(SyntaxTree.compilation_unit cu) + { + foreach (SyntaxTree.compiler_directive cd in cu.compiler_directives) + if (string.Compare(cd.Name.text, "apptype", true) == 0 && string.Compare(cd.Directive.text, "dll", true) == 0) + return true; + return false; + } + + public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) + { + string UnitName = GetUnitFileName(SyntaxUsesUnit, prev_path); + // имя папки, в которой лежит текущий модуль + // используется для подключения модулей, $include и т.п. из модуля, подключённого с uses-in + var curr_path = Path.GetDirectoryName(UnitName); + + CompilationUnit CurrentUnit = UnitTable[UnitName]; + if (CurrentUnit != null && CurrentUnit.SemanticTree is PascalABCCompiler.TreeRealization.dot_net_unit_node + && SyntaxUsesUnit is PascalABCCompiler.SyntaxTree.uses_unit_in ui && ui.in_file != null) // значит, это пространство имен и секция in у него должна отсутствовать + { + ErrorsList.Add(new NamespaceCannotHaveInSection(ui.in_file.source_context)); + } + + if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) + { + string sfn = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); + if (sfn != null && UnitTable[sfn] != null) + CurrentUnit = UnitTable[sfn]; + } + + if (CurrentUnit != null) + if (CurrentUnit.State != UnitState.BeginCompilation || CurrentUnit.SemanticTree != null) //ИЗБАВИТЬСЯ ОТ ВТОРОГО УСЛОВИЯ + { + Units.AddElement(CurrentUnit.SemanticTree); + Units.AddRange(GetReferences(CurrentUnit)); + return CurrentUnit; + } + + if (UnitName.ToLower().LastIndexOf(".dll") >= 0 || UnitName.ToLower().LastIndexOf(".exe") >= 0) + if (File.Exists(UnitName)) + { + if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); + if ((CurrentUnit = ReadDLL(UnitName)) != null) + { + Units.AddElement(CurrentUnit.SemanticTree); + UnitTable[UnitName] = CurrentUnit; + return CurrentUnit; + } + else + //throw new DLLReadingError(UnitName); + throw new AssemblyReadingError(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); + } + if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) + if (File.Exists(UnitName)) + { + if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); + string SourceFileName = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); + try + { + if ((CurrentUnit = ReadPCU(UnitName)) != null) + { + Units.AddElement(CurrentUnit.SemanticTree); + Units.AddRange(GetReferences(CurrentUnit)); + UnitTable[UnitName] = CurrentUnit; + return CurrentUnit; + } + } + catch (InvalidPCUFule) + { + //Перекомпилируем.... + } + catch (Error) + { + throw; + } + catch (Exception e) + { + OnChangeCompilerState(this, CompilerState.PCUReadingError, UnitName); +#if DEBUG + if (!InternalDebug.SkipPCUErrors) + throw new Errors.CompilerInternalError("PCUReader", e); +#endif + } + if (SourceFileName == null) + throw new ReadPCUError(UnitName); + else + UnitName = SourceFileName; + } + string SourceText = null; + Dictionary docs = null; + if (CurrentUnit == null) + { + + CurrentUnit = new CompilationUnit(); + if (FirstCompilationUnit == null) + FirstCompilationUnit = CurrentUnit; + OnChangeCompilerState(this, CompilerState.BeginCompileFile, UnitName); + SourceText = GetSourceFileText(UnitName); + if (SourceText == null) + if (CurrentUnit == FirstCompilationUnit) + throw new SourceFileNotFound(UnitName); + else + throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); + List DefinesList = new List(); + if (!compilerOptions.Debug && !compilerOptions.ForDebugging) + DefinesList.Add("RELEASE"); + else + DefinesList.Add("DEBUG"); + CurrentUnit.SyntaxTree = InternalParseText(UnitName, SourceText, errorsList, warnings, DefinesList); + + if (errorsList.Count == 0) // SSM 2/05/16 - для преобразования синтаксических деревьев извне + { + CurrentUnit.SyntaxTree = syntaxTreeConvertersController.Convert(CurrentUnit.SyntaxTree) as SyntaxTree.compilation_unit; + + } + + if (errorsList.Count == 0 && need_gen_doc(CurrentUnit.SyntaxTree)) + { + if (SourceText != null) + { + docs = AddDocumentationToNodes(CurrentUnit.SyntaxTree, SourceText); + if (docs != null) + CurrentUnit.Documented = true; + } + } + if (CurrentUnit.SyntaxTree is SyntaxTree.unit_module) + { + if ((CurrentUnit.SyntaxTree as SyntaxTree.unit_module).unit_name.HeaderKeyword == SyntaxTree.UnitHeaderKeyword.Namespace) + throw new NamespacesCanBeCompiledOnlyInProjects(CurrentUnit.SyntaxTree.source_context); + compilerOptions.UseDllForSystemUnits = false; + } + + // SSM 21/05/20 Проверка, что мы не записали apptype dll в небиблиотеку + + var ccu = CurrentUnit.SyntaxTree; + foreach (SyntaxTree.compiler_directive cd in ccu.compiler_directives) + if (string.Compare(cd.Name.text, "apptype", true) == 0 && string.Compare(cd.Directive.text, "dll", true) == 0) + { + if (!(ccu is SyntaxTree.unit_module) || + (ccu is SyntaxTree.unit_module um && um.unit_name.HeaderKeyword != SyntaxTree.UnitHeaderKeyword.Library)) + { + ErrorsList.Add(new AppTypeDllIsAllowedOnlyForLibraries(ccu.file_name, cd.source_context)); + break; + } + } + // + + if (is_dll(CurrentUnit.SyntaxTree)) + compilerOptions.OutputFileType = PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary; + CurrentUnit.CaseSensitive = ParsersController.LastParser.CaseSensitive; + CurrentCompilationUnit = CurrentUnit; + + CurrentUnit.SyntaxUnitName = SyntaxUsesUnit; + + //BadNodesInSyntaxTree.Clear(); + if (errorsList.Count > 0) + { + CurrentUnit.syntax_error = errorsList[0] as PascalABCCompiler.Errors.SyntaxError; + foreach (Errors.Error er in errorsList) + if (er is SyntaxError && (er as SyntaxError).bad_node != null) + BadNodesInSyntaxTree[(er as SyntaxError).bad_node] = er; + } + + //if (CurrentUnit.SyntaxTree == null) + if (errorsList.Count > 0) + { + //if (errorsList.Count == 0) + // throw new Errors.SyntaxError("Internal parser error: Parser not create syntax tree", UnitName,null,null); + throw errorsList[0]; + } + + UnitTable[UnitName] = CurrentUnit; + + if (UnitTable.Count > 1)//если это не главный модуль + if (CurrentUnit.SyntaxTree is SyntaxTree.program_module) + throw new UnitModuleExpected(UnitName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); + else if (is_dll(CurrentUnit.SyntaxTree)) + throw new UnitModuleExpectedLibraryFound(UnitName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); + //здесь в начало uses добавляем стандартные модули +#if DEBUG + if (InternalDebug.AddStandartUnits) +#endif + AddStandartUnitsToUsesSection(CurrentUnit.SyntaxTree); + + } + CurrentSyntaxUnit = SyntaxUsesUnit; + CurrentCompilationUnit = CurrentUnit; + + CurrentUnit.PossibleNamespaces.Clear(); + + //TODO переделать, слишком сложно, некоторый код дублируется + + + System.Collections.Generic.List SyntaxUsesList; + SyntaxUsesList = GetSyntaxInterfaceUsesList(CurrentUnit.SyntaxTree); + + if (SyntaxUsesList != null) + { + for (int i = SyntaxUsesList.Count - 1 - CurrentUnit.InterfaceUsedUnits.Count; i >= 0; i--) + { + if (!IsPossibleNamespace(SyntaxUsesList[i], false, curr_path)) + { + compilerOptions.UseDllForSystemUnits = false; + break; + } + } + } + TreeRealization.unit_node_list References = GetReferences(CurrentUnit); + var namespaces = IncludeNamespaces(CurrentUnit); + if (SyntaxUsesList != null) + { + + for (int i = SyntaxUsesList.Count - 1 - CurrentUnit.InterfaceUsedUnits.Count; i >= 0; i--) + { + if (IsPossibleNamespace(SyntaxUsesList[i], true, curr_path) || namespaces.ContainsKey(SyntaxUsesList[i].name.idents[0].name)) + { + CurrentUnit.InterfaceUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); + CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); + } + else + { + string CurrentSyntaxUnitName = GetUnitFileName(SyntaxUsesList[i], curr_path); + CurrentUnit.CurrentUsesUnit = CurrentSyntaxUnitName; + if (UnitTable[CurrentSyntaxUnitName] != null) + if (UnitTable[CurrentSyntaxUnitName].State == UnitState.BeginCompilation) + { + string CurrentSyntaxUnitNameCurrentUsesUnit = UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit; + if (CurrentSyntaxUnitNameCurrentUsesUnit != null) + { + //если сначало взали pcu а потом решили его перекомпилировать, поэтому в таблице его нет + if (UnitTable[CurrentSyntaxUnitNameCurrentUsesUnit] == null) + UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit = FindSourceFileName(Path.GetFileNameWithoutExtension(CurrentSyntaxUnitNameCurrentUsesUnit), Path.GetDirectoryName(CurrentSyntaxUnitNameCurrentUsesUnit)); + //далее финальная поверка на зацикливание + if (UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit != null && UnitTable[UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit].State == UnitState.BeginCompilation) + throw new CycleUnitReference(UnitName, SyntaxUsesList[i]); + } + } + CompileUnit(CurrentUnit.InterfaceUsedUnits, SyntaxUsesList[i], curr_path); + if (CurrentUnit.State == UnitState.Compiled) + { + Units.AddElement(CurrentUnit.SemanticTree); + Units.AddRange(References); + return CurrentUnit; + } + } + + } + } + + CurrentCompilationUnit = CurrentUnit; + + CurrentUnit.InterfaceUsedUnits.AddRange(References); + + AddNamespaces(CurrentUnit.InterfaceUsingNamespaceList, CurrentUnit.PossibleNamespaces, true, namespaces); + AddNamespaces(CurrentUnit.InterfaceUsingNamespaceList, GetInterfaceSyntaxUsingList(CurrentUnit.SyntaxTree)); + + //Console.WriteLine("Compile Interface "+UnitName);//DEBUG +#if DEBUG + if (InternalDebug.SemanticAnalysis) +#endif + { + if (CurrentUnit.State != UnitState.InterfaceCompiled) + { + OnChangeCompilerState(this, CompilerState.CompileInterface, UnitName); + PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; + CurrentUnit.SemanticTree = SyntaxTreeToSemanticTreeConverter.CompileInterface( + CurrentUnit.SyntaxTree, + CurrentUnit.InterfaceUsedUnits, + ErrorsList, Warnings, + CurrentUnit.syntax_error, + BadNodesInSyntaxTree, + CurrentUnit.InterfaceUsingNamespaceList, + docs, + CompilerOptions.Debug, + CompilerOptions.ForDebugging + ); + CheckErrors(); + } + } + TreeRealization.common_unit_node cun = CurrentUnit.SemanticTree as TreeRealization.common_unit_node; + /*if (cun != null) + { + if (!UnitsSortedList.Contains(CurrentUnit))//vnimanie zdes inogda pri silnoj zavisimosti modulej moduli popadajut neskolko raz + UnitsSortedList.Add(CurrentUnit); + }*/ + CurrentUnit.State = UnitState.InterfaceCompiled; + if (Units != null) + { + Units.AddElement(CurrentUnit.SemanticTree); + Units.AddRange(References); + } + SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); + CompilationUnit cu = null; bool interfcompile = true; + CurrentUnit.ImplementationUsedUnits.clear(); + CurrentUnit.PossibleNamespaces.Clear(); + if (SyntaxUsesList != null) + { + for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) + if (!IsPossibleNamespace(SyntaxUsesList[i], true, curr_path)) + { + cu = UnitTable[GetUnitFileName(SyntaxUsesList[i], curr_path)]; + if (cu != null && cu.State == UnitState.BeginCompilation) + { + UnitsToCompile.Add(cu); + interfcompile = false; +#if DEBUG + // Console.WriteLine("[DEBUGINFO]Send compile to end " + Path.GetFileName(GetUnitFileName(SyntaxUsesList[i])));//DEBUG +#endif + } + else + { + CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], curr_path); + } + } + else + { + CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); + CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); + } + } + + CurrentCompilationUnit = CurrentUnit; + + AddNamespaces(CurrentUnit.ImplementationUsingNamespaceList, CurrentUnit.PossibleNamespaces, true, namespaces); + AddNamespaces(CurrentUnit.ImplementationUsingNamespaceList, GetImplementationSyntaxUsingList(CurrentUnit.SyntaxTree)); + + if (!interfcompile) + { + UnitsToCompile.Add(CurrentUnit); + if (cun != null) + { + if (!UnitsSortedList.Contains(CurrentUnit))//vnimanie zdes inogda pri silnoj zavisimosti modulej moduli popadajut neskolko raz + UnitsSortedList.Add(CurrentUnit); + } + //Console.WriteLine("Send compile to end "+UnitName);//DEBUG + return CurrentUnit; + } + + //Console.WriteLine("Compile Implementation "+UnitName);//DEBUG + if (CurrentUnit.SyntaxTree is SyntaxTree.unit_module) + { +#if DEBUG + if (InternalDebug.SemanticAnalysis) +#endif + { + OnChangeCompilerState(this, CompilerState.CompileImplementation, UnitName); + PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; + SyntaxTreeToSemanticTreeConverter.CompileImplementation( + (PascalABCCompiler.TreeRealization.common_unit_node)CurrentUnit.SemanticTree, + CurrentUnit.SyntaxTree, + buildImplementationUsesList(CurrentUnit), + ErrorsList, Warnings, + CurrentUnit.syntax_error, + BadNodesInSyntaxTree, + CurrentUnit.InterfaceUsingNamespaceList, + CurrentUnit.ImplementationUsingNamespaceList, + docs, + CompilerOptions.Debug, + CompilerOptions.ForDebugging + ); + CheckErrors(); + } + } + CurrentUnit.State = UnitState.Compiled; + if (cun != null) + { + if (!UnitsSortedList.Contains(CurrentUnit))//vnimanie zdes inogda pri silnoj zavisimosti modulej moduli popadajut neskolko raz + UnitsSortedList.Add(CurrentUnit); + } + OnChangeCompilerState(this, CompilerState.EndCompileFile, UnitName); + //SavePCU(CurrentUnit, UnitName); + CurrentUnit.UnitName = UnitName; + return CurrentUnit; + /*if(CurrentUnit.State!=UnitState.Compiled) + { + //Console.WriteLine("Compile Interface "+UnitName);//DEBUG + CurrentUnit.SemanticTree=SyntaxTreeToSemanticTreeConverter.CompileInterface(CurrentUnit.SyntaxTree, + CurrentUnit.InterfaceUsedUnits,CurrentUnit.syntax_error); + CurrentUnit.State=UnitState.InterfaceCompiled; + SyntaxUsesList=GetSemanticImplementationUsesList(CurrentUnit.SyntaxTree); + if(SyntaxUsesList!=null) + for(int i=SyntaxUsesList.Count-1;i>=0;i--) + CompileUnit(CurrentUnit.ImplementationUsedUnits,SyntaxUsesList[i]); + //Console.WriteLine("Compile Implementation "+UnitName);//DEBUG + if (CurrentUnit.SyntaxTree is SyntaxTree.unit_module) + { + SyntaxTreeToSemanticTreeConverter.CompileImplementation(CurrentUnit.SemanticTree, + CurrentUnit.SyntaxTree,CurrentUnit.ImplementationUsedUnits,CurrentUnit.syntax_error); + } + CurrentUnit.State=UnitState.Compiled; + Units.Add(CurrentUnit.SemanticTree); + SaveSemanticTreeToFile(CurrentUnit,UnitName); + }*/ + } + + private Dictionary AddDocumentationToNodes(SyntaxTree.compilation_unit cu, string Text) + { + List errors = new List(); + List warnings = new List(); + string doctagsParserExtension = Path.GetExtension(cu.file_name)+"dt"+PascalABCCompiler.Parsers.Controller.HideParserExtensionPostfixChar; + PascalABCCompiler.SyntaxTree.documentation_comment_list dt = ParsersController.Compile(System.IO.Path.ChangeExtension(cu.file_name, doctagsParserExtension), Text, errors, warnings, PascalABCCompiler.Parsers.ParseMode.Normal) as PascalABCCompiler.SyntaxTree.documentation_comment_list; + if (errors.Count > 0) return null; + PascalABCCompiler.DocumentationConstructor docconst = new PascalABCCompiler.DocumentationConstructor(); + return docconst.Construct(cu, dt); + } + + private bool need_gen_doc(SyntaxTree.compilation_unit cu) + { + if (project != null && project.generate_xml_doc) + return true; + if (cu == null) + return false; + if (cu.file_name != null && internalDebug.DocumentedUnits.Contains(cu.file_name.ToLower())) + return true; + foreach (SyntaxTree.compiler_directive cd in cu.compiler_directives) + if (string.Compare(cd.Name.text, "gendoc",true)==0 && string.Compare(cd.Directive.text,"true",true)==0) + return true; + return false; + } + + private TreeRealization.unit_node_list buildImplementationUsesList(CompilationUnit cu) + { + TreeRealization.unit_node_list unl = new PascalABCCompiler.TreeRealization.unit_node_list(); + unl.AddRange(cu.ImplementationUsedUnits); + foreach (TreeRealization.unit_node un in cu.InterfaceUsedUnits) + { + if (un is TreeRealization.dot_net_unit_node) + unl.AddElement(un); + } + return unl; + } + + public void SavePCU(CompilationUnit Unit, string TargetFileName) + { +//#if DEBUG + try + { + if (Unit.SyntaxTree != null && Unit.SyntaxTree is SyntaxTree.unit_module) + { + if (((SyntaxTree.unit_module)Unit.SyntaxTree).unit_name.HeaderKeyword == PascalABCCompiler.SyntaxTree.UnitHeaderKeyword.Library) + return; + foreach (SyntaxTree.compiler_directive cd in Unit.SyntaxTree.compiler_directives) + if (cd.Name.text.ToLower() == TreeConverter.compiler_string_consts.compiler_savepcu) + if (!Convert.ToBoolean(cd.Directive.text)) + return; + } + } + catch + { + } +//#endif + PCUWriter writer=null; + try + { +#if DEBUG + if (InternalDebug.PCUGenerate) +#endif + if (compilerOptions.SavePCU) + if ((Unit.SemanticTree as TreeRealization.common_unit_node).namespaces.Count > 1 && + Unit.SyntaxTree!=null && + Unit.State == UnitState.Compiled) + { + writer = new PCUWriter(this, pr_ChangeState); + + if (FileInSearchDirectory(TargetFileName)) + TargetFileName = Path.ChangeExtension(TargetFileName, CompilerOptions.CompiledUnitExtension); + else + TargetFileName = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), Path.GetFileNameWithoutExtension(TargetFileName) + CompilerOptions.CompiledUnitExtension); + + bool dbginfo = true;/*CompilerOptions.Debug*/ +#if DEBUG + dbginfo = InternalDebug.IncludeDebugInfoInPCU; +#endif + writer.SaveSemanticTree(Unit, TargetFileName, dbginfo); + + } + } + catch (Exception err) + { + //ErrorsList.Add(new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err)); + OnChangeCompilerState(this, CompilerState.PCUWritingError, TargetFileName); +#if DEBUG + if (!InternalDebug.SkipPCUErrors) + throw new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err); + writer.RemoveSelf(); +#endif + } + } + + public CompilationUnit ReadPCU(string FileName) + { + PCUReader pr = new PCUReader(this,pr_ChangeState); + return pr.GetCompilationUnit(FileName,CompilerOptions.Debug); + } + + void pr_ChangeState(object Sender, PCUReaderWriterState State, object obj) + { + switch (State) + { + case PCUReaderWriterState.BeginReadTree: + OnChangeCompilerState(this, CompilerState.ReadPCUFile, (Sender as PCUReader).FileName); + break; + case PCUReaderWriterState.EndReadTree: + CompilationUnit cu = obj as CompilationUnit; + cu.State = UnitState.Compiled; + unitTable[(Sender as PCUReader).FileName] = cu; + UnitsSortedList.Add(cu); + GetReferences(cu); + break; + case PCUReaderWriterState.EndSaveTree: + OnChangeCompilerState(this, CompilerState.SavePCUFile, (Sender as PCUWriter).FileName); + break; + + } + } + /* TreeRealization.common_unit_node cun11 = CurrentUnit.SemanticTree as TreeRealization.common_unit_node; + if (cun11 != null) + UnitsSortedList.AddElement(cun11);*/ + + static string standartAssemblyPath = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(string)).ManifestModule.FullyQualifiedName); + + public static Dictionary standart_assembly_dict = new Dictionary(); + static Compiler() + { + string[] ss = new string[] { "mscorlib.dll","System.dll", "System.Core.dll", "System.Numerics.dll", "System.Windows.Forms.dll", "PABCRtl.dll" }; + foreach (var x in ss) + standart_assembly_dict[x] = get_standart_assembly_path(x); + } + public static string get_standart_assembly_path(string name) + { + name = name.Replace("%GAC%\\", ""); + string ttn = System.IO.Path.GetFileNameWithoutExtension(name); + string tn = Path.Combine(standartAssemblyPath, name); + if (File.Exists(tn)) + return tn; + if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX) + { + string windir = Path.Combine(Environment.GetEnvironmentVariable("windir"), "Microsoft.NET"); + tn = windir + @"\assembly\GAC_MSIL\"; + tn += ttn + "\\"; + System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_64\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_32\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + windir = Environment.GetEnvironmentVariable("windir"); + tn = windir + @"\assembly\GAC_MSIL\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_64\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC_32\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + tn = windir + @"\assembly\GAC\"; + tn += ttn + "\\"; + di = new System.IO.DirectoryInfo(tn); + if (!di.Exists) + { + return null; + } + } + } + } + } + } + } + } + System.IO.DirectoryInfo[] diarr = di.GetDirectories(); + tn = Path.Combine((diarr[0]).FullName, name); + } + else + { + string gac_path = "/usr/lib/mono/4.0/gac"; + DirectoryInfo di = new DirectoryInfo(Path.Combine(gac_path, ttn)); + if (di.Exists) + { + System.IO.DirectoryInfo[] diarr = di.GetDirectories(); + tn = Path.Combine((diarr[diarr.Length - 1]).FullName, name); + } + else + return null; + + } + return tn; + + } + public static string get_assembly_path(string name, bool search_for_intellisense) + { + //если явно задан каталог то ищем только там + if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX && !name.StartsWith("%GAC%\\")) + { + if (Path.GetDirectoryName(name) != string.Empty) + if (File.Exists(name)) + return name; + else + return null; + } + if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) + { + string SystemDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName); + string SearchDirectory = Path.Combine(SystemDirectory, "Lib"); + if (File.Exists(Path.Combine(Environment.CurrentDirectory, name))) + return Path.Combine(Environment.CurrentDirectory, name); + if (File.Exists(Path.Combine(SearchDirectory, name))) + { + File.Copy(Path.Combine(SearchDirectory, name), Path.Combine(Environment.CurrentDirectory, name), true); + return Path.Combine(Environment.CurrentDirectory, name); + } + + } + if (!search_for_intellisense && !name.StartsWith("%GAC%\\")) + { + string dir = Environment.CurrentDirectory; + + if (File.Exists(Path.Combine(dir, name))) + { + return Path.Combine(dir, name); + } + } + + return get_standart_assembly_path(name); + } + + + + public CompilationUnit ReadDLL(string FileName) + { + if (DLLCashe.ContainsKey(FileName)) + return DLLCashe[FileName]; + OnChangeCompilerState(this, CompilerState.ReadDLL, FileName); + TreeRealization.using_namespace_list using_namespaces = new TreeRealization.using_namespace_list(); + try + { + TreeRealization.dot_net_unit_node un = + new TreeRealization.dot_net_unit_node(new NetHelper.NetScope(using_namespaces, + /*System.Reflection.Assembly.LoadFrom(FileName)*/ + PascalABCCompiler.NetHelper.NetHelper.LoadAssembly(FileName), SyntaxTreeToSemanticTreeConverter.SymbolTable)); + CompilationUnit cu = new CompilationUnit(); + cu.SemanticTree = un; + + //un.dotNetScope=new PascalABCCompiler.NetHelper.NetScope(using_namespaces, + // System.Reflection.Assembly.LoadFrom(FileName),SyntaxTreeToSemanticTreeConverter.SymbolTable); + DLLCashe[FileName] = cu; + + return cu; + } + catch (ReflectionTypeLoadException e) + { + Console.Error.WriteLine(e.Message); + foreach (var eLoaderException in e.LoaderExceptions) + { + Console.Error.WriteLine(eLoaderException.Message); + } + + return null; + } + catch (Exception e) + { + Console.Error.WriteLine(e.Message); + return null; + } + } + + /*public CompilationUnit RecompileUnit(string unit_name) + { + Console.WriteLine("recompile {0}", unit_name); + CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(new SyntaxTree.string_const(program_folder + "\\" + unit_name+".pas")); + CompileUnit(Units, CurrentSyntaxUnit); + CompilationUnit cu = new CompilationUnit(); + if (Units.Count != 0) + cu.SemanticTree = Units[Units.Count - 1]; + else + return null; + return cu; + }*/ + public bool NeedRecompiled(string name, string dir, string[] included, PCUReader pr) + { + string pas_name = FindSourceFileName(name, dir); + string pcu_name = FindPCUFileName(name, dir); + if (UnitTable[pas_name] != null) + return true; + bool need = false; + for (int i = 0; i < included.Length; i++) + { + //if (included[i].Contains("$")) + // continue; + string pas_name2 = FindSourceFileName(included[i], dir); + string pcu_name2 = FindPCUFileName(included[i], dir); + if (UnitTable[pas_name2] != null) + return true; + if (!File.Exists(pcu_name2)) + { + need = true; RecompileList[name] = name; + RecompileList[included[i]] = included[i]; + } + else + if (SourceFileExists(pas_name2) && File.GetLastWriteTime(pcu_name2) <= SourceFileGetLastWriteTime(pas_name2)) + { + need = true; CycleUnits[name] = name; RecompileList[name] = name; + RecompileList[included[i]] = included[i]; + } + } + if (need) return true; + if (!SourceFileExists(pas_name)) return false; + if (!File.Exists(pcu_name)) return true; + if (File.GetLastWriteTime(pcu_name) < SourceFileGetLastWriteTime(pas_name)) return true; + //Console.WriteLine("{0} {1}",name,RecompileList.Count); + for (int i = 0; i < included.Length; i++) + { + string pcu_name2 = FindPCUFileName(included[i], dir); + //TODO: Спросить у Сащи насчет < и <=. + + if ((File.Exists(pcu_name2) && File.GetLastWriteTime(pcu_name) < File.GetLastWriteTime(pcu_name2) && !pr.AlreadyCompiled(pcu_name2))) + { + pr.AddAlreadyCompiledUnit(included[i]); + return true; + } + if (RecompileList.ContainsKey(included[i])) + { + return true; + } + } + return false; + } + + public void ClearAll() + { + _semantic_tree = null; + PCUReader.CloseUnits(); + PCUWriter.Clear(); + RecompileList.Clear(); + CycleUnits.Clear(); + UnitTable.Clear(); + UnitsSortedList.Clear(); + //TreeRealization.PCUReturner.Clear(); + BadNodesInSyntaxTree.Clear(); + PCUReader.AllReaders.Clear(); + project = null; + StandarModules.Clear(); + //SystemLibrary.SystemLibrary.RestoreStandartNames(); + } + + public CompilerType CompilerType + { + get + { + return CompilerType.Standart; + } + } + + public void Free() + { + } + } +} From 4838c51b2e103c181782c83e2986e829f5e6568a Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 13 Jul 2020 06:23:13 +0300 Subject: [PATCH 22/43] proper uses-in in .pcu --- Compiler/Compiler.cs | 28 ++--- Compiler/PCU/PCUReader.cs | 80 ++++++++------ Compiler/PCU/PCUWriter.cs | 110 +++++++------------ SyntaxTree/tree/Tree.cs | 8 +- TreeConverter/TreeRealization/Collections.cs | 12 +- TreeConverter/TreeRealization/units.cs | 18 +-- 6 files changed, 117 insertions(+), 139 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 760581e22..fc0a170f1 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -163,7 +163,7 @@ using Microsoft.Scripting; using System.Reflection; //using SyntaxTreeChanger; using PascalABCCompiler.SyntaxTreeConverters; - +using System.Text; namespace PascalABCCompiler { @@ -407,19 +407,11 @@ namespace PascalABCCompiler //private SemanticTree.compilation_unitArrayList _interfaceUsedUnits=new SemanticTree.compilation_unitArrayList(); - private PascalABCCompiler.TreeRealization.unit_node_list _interfaceUsedUnits = new PascalABCCompiler.TreeRealization.unit_node_list(); - public PascalABCCompiler.TreeRealization.unit_node_list InterfaceUsedUnits - { - get {return _interfaceUsedUnits;} - } + public PascalABCCompiler.TreeRealization.unit_node_list InterfaceUsedUnits { get; } = new PascalABCCompiler.TreeRealization.unit_node_list(); - private PascalABCCompiler.TreeRealization.unit_node_list _implementationUsedUnits = new PascalABCCompiler.TreeRealization.unit_node_list(); - public PascalABCCompiler.TreeRealization.unit_node_list ImplementationUsedUnits - { - get {return _implementationUsedUnits;} - } + public PascalABCCompiler.TreeRealization.unit_node_list ImplementationUsedUnits { get; } = new PascalABCCompiler.TreeRealization.unit_node_list(); - private SyntaxTree.compilation_unit _syntaxTree=null; + private SyntaxTree.compilation_unit _syntaxTree=null; public SyntaxTree.compilation_unit SyntaxTree { get {return _syntaxTree;} @@ -2497,7 +2489,7 @@ namespace PascalABCCompiler return null; } - private static string CombinePath(string dir, string path) + public static string CombinePath(string dir, string path) { if (Path.IsPathRooted(path)) return path; int i = 0; @@ -3100,7 +3092,7 @@ namespace PascalABCCompiler if (CurrentUnit != null) if (CurrentUnit.State != UnitState.BeginCompilation || CurrentUnit.SemanticTree != null) //ИЗБАВИТЬСЯ ОТ ВТОРОГО УСЛОВИЯ { - Units.AddElement(CurrentUnit.SemanticTree); + Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); Units.AddRange(GetReferences(CurrentUnit)); return CurrentUnit; } @@ -3111,7 +3103,7 @@ namespace PascalABCCompiler if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); if ((CurrentUnit = ReadDLL(UnitName)) != null) { - Units.AddElement(CurrentUnit.SemanticTree); + Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); UnitTable[UnitName] = CurrentUnit; return CurrentUnit; } @@ -3128,7 +3120,7 @@ namespace PascalABCCompiler { if ((CurrentUnit = ReadPCU(UnitName)) != null) { - Units.AddElement(CurrentUnit.SemanticTree); + Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); Units.AddRange(GetReferences(CurrentUnit)); UnitTable[UnitName] = CurrentUnit; return CurrentUnit; @@ -3307,7 +3299,7 @@ namespace PascalABCCompiler CompileUnit(CurrentUnit.InterfaceUsedUnits, SyntaxUsesList[i], curr_path); if (CurrentUnit.State == UnitState.Compiled) { - Units.AddElement(CurrentUnit.SemanticTree); + Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); Units.AddRange(References); return CurrentUnit; } @@ -3355,7 +3347,7 @@ namespace PascalABCCompiler CurrentUnit.State = UnitState.InterfaceCompiled; if (Units != null) { - Units.AddElement(CurrentUnit.SemanticTree); + Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); Units.AddRange(References); } SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 41009a1af..265ce6462 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -223,29 +223,42 @@ namespace PascalABCCompiler.PCU ReadPCUHeader(); } + public string GetFullUnitName(string UnitName) + { + UnitName = Compiler.CombinePath(dir, UnitName); + if (Path.GetExtension(UnitName) != comp.CompilerOptions.CompiledUnitExtension) + UnitName = Path.ChangeExtension(UnitName, comp.CompilerOptions.CompiledUnitExtension); + return UnitName; + } + //десериализация модуля //читается только шапка PCU и заполняются имена сущностей модуля в таблицу символов public CompilationUnit GetCompilationUnit(string FileName, bool readDebugInfo) { try { + // Compiler.CombinePath всегда должно быть применено к имени файла, перед тем как кидать его сюда + if (!Path.IsPathRooted(FileName)) throw new InvalidOperationException(); + + FileName = GetFullUnitName(FileName); + dir = Path.GetDirectoryName(FileName); + this.FileName = FileName; this.readDebugInfo = readDebugInfo; unit_name = System.IO.Path.GetFileNameWithoutExtension(FileName); - PCUReader pr = (PCUReader)units[unit_name]; + PCUReader pr = (PCUReader)units[FileName]; if (pr != null) return pr.unit; if (!File.Exists(FileName)) return null; - dir = System.IO.Path.GetDirectoryName(FileName); //fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); ms = new MemoryStream(File.ReadAllBytes(FileName)); br = new BinaryReader(ms); ReadPCUHeader(); - units[unit_name] = this; + units[FileName] = this; if (NeedRecompiled()) { CloseUnit(); need = true; - return null; // return comp.RecompileUnit(unit_name); + return null; // return comp.RecompileUnit(FileName); } unit = new CompilationUnit(); cun = new common_unit_node(); @@ -256,7 +269,7 @@ namespace PascalABCCompiler.PCU //TODO сохранить в PCU cun.scope.CaseSensitive = false; - if (string.Compare(unit_name,PascalABCCompiler.TreeConverter.compiler_string_consts.system_unit_file_name, true)==0) + if (string.Compare(unit_name, compiler_string_consts.system_unit_file_name, true)==0) PascalABCCompiler.TreeConverter.syntax_tree_visitor.init_system_module(cun); //ssyy //Создаём область видимости для implementation - части @@ -333,14 +346,15 @@ namespace PascalABCCompiler.PCU string source_file_name = comp.FindSourceFileName(pcu_file.incl_modules[i], dir); if (source_file_name != null && comp.UnitTable[source_file_name] != null) return true; - PCUReader pr = (PCUReader)units[pcu_file.incl_modules[i]]; + var incl_unit_name = GetFullUnitName(pcu_file.incl_modules[i]); + PCUReader pr = (PCUReader)units[incl_unit_name]; if (pr == null) pr = new PCUReader(this); pr.AddAlreadyCompiledUnit(FileName); - if (used_units[pcu_file.incl_modules[i]] == null) + if (used_units[incl_unit_name] == null) { - used_units[pcu_file.incl_modules[i]] = used_units; - if (already_compiled[pcu_file.incl_modules[i]] == null) + used_units[incl_unit_name] = used_units; + if (already_compiled[incl_unit_name] == null) pr.GetCompilationUnit(comp.FindPCUFileName(pcu_file.incl_modules[i], dir), this.readDebugInfo); } if (need == false) need = pr.need; @@ -411,7 +425,7 @@ namespace PascalABCCompiler.PCU private void AddNamespaces() { cun.unit_name=br.ReadString(); - + common_namespace_node cnn = new common_namespace_node(null, cun, cun.unit_name, cun.scope, ReadDebugInfo()); cun.namespaces.AddElement(cnn); @@ -975,12 +989,13 @@ namespace PascalABCCompiler.PCU private type_node ReadCommonExtType() { int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; - PCUReader pr = (PCUReader)units[s];//вдруг этот модуль уже читается + string s = GetFullUnitName(pcu_file.incl_modules[pos]); + + PCUReader pr = (PCUReader)units[s];//вдруг этот модуль уже читается if (pr == null)//это по моему чёс, так как все модули уже добавлены { pr = new PCUReader(this);//если нет, то создаем ридер - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); type_node tn = pr.GetTypeReference(br.ReadInt32()); units[s] = pr;//добавляем в таблицу ридеров return tn; @@ -996,12 +1011,13 @@ namespace PascalABCCompiler.PCU private template_class ReadTemplateExtClass() { int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); + PCUReader pr = (PCUReader)units[s];//вдруг этот модуль уже читается if (pr == null)//это по моему чёс, так как все модули уже добавлены { pr = new PCUReader(this);//если нет, то создаем ридер - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); template_class tc = pr.GetTemplateClass(br.ReadInt32()); units[s] = pr;//добавляем в таблицу ридеров return tc; @@ -1085,12 +1101,12 @@ namespace PascalABCCompiler.PCU { br.ReadByte(); int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); int offset = br.ReadInt32(); common_namespace_function_node cffn = pr.GetNamespaceFunction(offset); return cffn; @@ -1106,12 +1122,12 @@ namespace PascalABCCompiler.PCU { br.ReadByte(); int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); namespace_variable nv = pr.GetNamespaceVariable(br.ReadInt32()); return nv; } @@ -1126,12 +1142,12 @@ namespace PascalABCCompiler.PCU { br.ReadByte(); int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); namespace_constant_definition nv = pr.GetConstantDefinition(br.ReadInt32()); return nv; } @@ -1150,13 +1166,13 @@ namespace PascalABCCompiler.PCU br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; br.BaseStream.Seek(tmp, SeekOrigin.Begin); if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); common_namespace_event ev = pr.GetNamespaceEventNode(br.ReadInt32()); return ev; } @@ -1175,13 +1191,13 @@ namespace PascalABCCompiler.PCU br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; br.BaseStream.Seek(tmp, SeekOrigin.Begin); if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); common_event ev = pr.GetEventNode(br.ReadInt32()); return ev; } @@ -1200,13 +1216,13 @@ namespace PascalABCCompiler.PCU br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; br.BaseStream.Seek(tmp, SeekOrigin.Begin); if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); class_field field = pr.GetClassField(br.ReadInt32()); return field; } @@ -1225,13 +1241,13 @@ namespace PascalABCCompiler.PCU br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; br.BaseStream.Seek(tmp, SeekOrigin.Begin); if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); common_method_node meth = pr.GetClassMethod(br.ReadInt32()); return meth; } @@ -1250,13 +1266,13 @@ namespace PascalABCCompiler.PCU br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed int pos = br.ReadInt32(); - string s = pcu_file.incl_modules[pos]; + string s = GetFullUnitName(pcu_file.incl_modules[pos]); PCUReader pr = (PCUReader)units[s]; br.BaseStream.Seek(tmp, SeekOrigin.Begin); if (pr == null) { pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(dir + s + comp.CompilerOptions.CompiledUnitExtension, this.readDebugInfo); + CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); common_property_node prop = pr.GetPropertyNode(br.ReadInt32()); return prop; } @@ -2525,7 +2541,7 @@ namespace PascalABCCompiler.PCU //Добавляем подключенные модули for (int i = 0; i < uses_count; i++) { - PCUReader pcu_r = units[pcu_file.incl_modules[i]] as PCUReader; + PCUReader pcu_r = units[GetFullUnitName(pcu_file.incl_modules[i])] as PCUReader; if (pcu_r != null) { top_scopes.Add(pcu_r.cun.scope); diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index db55758fe..4853145d8 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -8,7 +8,8 @@ using TreeConverter; using PascalABCCompiler.TreeConverter; using PascalABCCompiler.TreeRealization; using System.Collections.Generic; - +using System.Linq; + namespace PascalABCCompiler.PCU { public class PCUConsts @@ -212,7 +213,7 @@ namespace PascalABCCompiler.PCU private List ref_assemblies = new List();//список подключаемых сборок, заполняется в процессе private Dictionary assm_refs = new Dictionary();//таблица для привязывания сборки private Dictionary func_codes = new Dictionary();//таблица, хранящая смещения тел методов в PCU - private Dictionary used_units = new Dictionary(); + private Dictionary used_units = new Dictionary(); private Dictionary ext_members = new Dictionary();//таблица, привязывающая импорт. сущность с записью в списке имп. сущ-тей private common_namespace_node cur_cnn;//текущее пространство имен private bool is_interface = true;//переводим ли интерфейсную часть @@ -1008,79 +1009,50 @@ namespace PascalABCCompiler.PCU //заполнение списка подключаемых модулей private void GetUsedUnits() { - int num = 0; - common_unit_node unt = null; AddIndirectInteraceUsedUnits(); - AddIndirectImplementationUsedUnits(); - for (int j = 0; j < unit.InterfaceUsedUnits.Count; j++) - { - unt = unit.InterfaceUsedUnits[j] as common_unit_node; - if (unt == null) continue; - if (unt.namespaces.Count != 0) - num += 1;//unt.namespaces.Count; + AddIndirectImplementationUsedUnits(); + + var c1 = unit.InterfaceUsedUnits.unit_uses_paths.Count; + var c2 = unit.ImplementationUsedUnits.unit_uses_paths.Count; + pcu_file.interface_uses_count = c1; + + pcu_file.incl_modules = new string[c1 + c2]; + var i = 0; + + foreach (var used_unit in unit.InterfaceUsedUnits.OfType()) + { + // каждый модуль, зачем то, подключён сам к себе + // конечно, записи в unit_uses_paths для такого подключения - нет + if (unit.SemanticTree == used_unit) continue; + + // раньше вместо пути модуля - брало имя его первого пространства имён + // и сразу стояла эта проверка. Если будет тут вылетать - наверное надо заменить throw на continue + if (used_unit.namespaces.Count == 0) throw new InvalidOperationException(); + + this.used_units.Add(used_unit, this.used_units.Count); + pcu_file.incl_modules[i] = unit.InterfaceUsedUnits.unit_uses_paths[used_unit]; + + i++; } - for (int j = 0; j < unit.ImplementationUsedUnits.Count; j++) - { - unt = unit.ImplementationUsedUnits[j] as common_unit_node; - if (unt == null) continue; - if (unt.namespaces.Count != 0) - num += 1;//unt.namespaces.Count; + foreach (var used_unit in unit.ImplementationUsedUnits.OfType()) + { + // раньше вместо пути модуля - брало имя его первого пространства имён + // и сразу стояла эта проверка. Если будет тут вылетать - наверное надо заменить throw на continue + if (used_unit.namespaces.Count == 0) throw new InvalidOperationException(); + + this.used_units.Add(used_unit, this.used_units.Count); + pcu_file.incl_modules[i] = unit.ImplementationUsedUnits.unit_uses_paths[used_unit]; + + i++; } - - pcu_file.incl_modules = new string[num]; - int i = 0; num = 0; - for (i=0; i 1) - { - pcu_file.incl_modules[num] = unt.namespaces[1].namespace_name; - used_units[unt.namespaces[1]] = num; - num++; - }*/ - } - } - - //(ssyy) Запомнили, какие модули относятся к секции interface - pcu_file.interface_uses_count = num; - - for (int j=0; j 1) - { - pcu_file.incl_modules[num] = unt.namespaces[1].namespace_name; - used_units[unt.namespaces[1]] = num; - num++; - }*/ - } - } - - - pcu_file.used_namespaces = cun.used_namespaces.ToArray(); + + pcu_file.used_namespaces = cun.used_namespaces.ToArray(); } //получения индекса модуля в списке подключ. модулей private int GetUnitToken(common_namespace_node ns) { - int tok = 0; - if (!used_units.TryGetValue(ns,out tok)) - { - return used_units[(ns.cont_unit as common_unit_node).namespaces[0]]; - } - return tok; + return used_units[ns.cont_unit as common_unit_node]; } private int GetTokenForNetEntity(FieldInfo val) @@ -1696,7 +1668,7 @@ namespace PascalABCCompiler.PCU is_def = 1; return off;//возвращаем его смещение } - if (!used_units.ContainsKey(nv.namespace_node)) + if (!used_units.ContainsKey(nv.namespace_node.cont_unit as common_unit_node)) { is_def = 1; return -1; @@ -1726,7 +1698,7 @@ namespace PascalABCCompiler.PCU is_def = 1; return off;//возвращаем его смещение } - if (!used_units.ContainsKey(nv.comprehensive_namespace)) + if (!used_units.ContainsKey(nv.comprehensive_namespace.cont_unit as common_unit_node)) { is_def = 1; return -1; diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs index 1c77cfb11..442a0fa70 100644 --- a/SyntaxTree/tree/Tree.cs +++ b/SyntaxTree/tree/Tree.cs @@ -11288,6 +11288,7 @@ namespace PascalABCCompiler.SyntaxTree } } + public virtual string UsesPath() => name.idents[0].name; /// Создает копию узла public override syntax_tree_node Clone() @@ -11456,9 +11457,10 @@ namespace PascalABCCompiler.SyntaxTree if (_in_file != null) _in_file.Parent = this; } - } - - + } + + public override string UsesPath() => in_file.Value; + /// Создает копию узла public override syntax_tree_node Clone() { diff --git a/TreeConverter/TreeRealization/Collections.cs b/TreeConverter/TreeRealization/Collections.cs index f59ffb63f..4bb8258e9 100644 --- a/TreeConverter/TreeRealization/Collections.cs +++ b/TreeConverter/TreeRealization/Collections.cs @@ -1,7 +1,7 @@ // Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; - +using System.Collections.Generic; using PascalABCCompiler.Collections; namespace PascalABCCompiler.TreeRealization @@ -104,7 +104,15 @@ namespace PascalABCCompiler.TreeRealization /// [Serializable] public class unit_node_list : extended_collection - { + { + public Dictionary unit_uses_paths = new Dictionary(); + + public void AddElement(unit_node unit, string unit_uses_path) + { + base.AddElement(unit); + unit_uses_paths.Add(unit, unit_uses_path); + } + } /// diff --git a/TreeConverter/TreeRealization/units.cs b/TreeConverter/TreeRealization/units.cs index 4b6fca387..b4db08a77 100644 --- a/TreeConverter/TreeRealization/units.cs +++ b/TreeConverter/TreeRealization/units.cs @@ -89,7 +89,7 @@ namespace PascalABCCompiler.TreeRealization } [Serializable] - public class common_unit_node : unit_node + public sealed class common_unit_node : unit_node { private readonly common_namespace_node_list _namespaces = new common_namespace_node_list(); @@ -100,7 +100,7 @@ namespace PascalABCCompiler.TreeRealization private common_namespace_function_node _main_function; private common_namespace_function_node _finalization_method; - private string _unit_name; + public string unit_name { get; set; } internal common_parameter MainArgsParameter = null; internal expression_node MainArgsAssignExpr = null; @@ -154,7 +154,7 @@ namespace PascalABCCompiler.TreeRealization public common_unit_node(string name) { - _unit_name = name; + this.unit_name = name; } public void add_unit_name_to_namespace() @@ -162,18 +162,6 @@ namespace PascalABCCompiler.TreeRealization this.scope.AddSymbol(unit_name, new TreeConverter.SymbolInfo(this)); } - public string unit_name - { - get - { - return _unit_name; - } - set - { - _unit_name = value; - } - } - public common_namespace_function_node main_function { get From ef8b8f17cc12f73e516058641a7a111342246a26 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 13 Jul 2020 08:18:57 +0300 Subject: [PATCH 23/43] cleanup --- Compiler/PCU/PCUReader.cs | 11 +++++++++-- Compiler/PCU/PCUWriter.cs | 19 ++++++++----------- TreeConverter/TreeRealization/Collections.cs | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 265ce6462..d9ca09a03 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -225,10 +225,17 @@ namespace PascalABCCompiler.PCU public string GetFullUnitName(string UnitName) { - UnitName = Compiler.CombinePath(dir, UnitName); if (Path.GetExtension(UnitName) != comp.CompilerOptions.CompiledUnitExtension) UnitName = Path.ChangeExtension(UnitName, comp.CompilerOptions.CompiledUnitExtension); - return UnitName; + + var FullUnitName = Compiler.CombinePath(dir, UnitName); + if (!File.Exists(FullUnitName)) + { + FullUnitName = Compiler.CombinePath(comp.CompilerOptions.SearchDirectory, UnitName); + if (!File.Exists(FullUnitName)) throw new FileNotFound(UnitName, null); + } + + return FullUnitName; } //десериализация модуля diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index 4853145d8..4ca07711a 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -1016,9 +1016,7 @@ namespace PascalABCCompiler.PCU var c2 = unit.ImplementationUsedUnits.unit_uses_paths.Count; pcu_file.interface_uses_count = c1; - pcu_file.incl_modules = new string[c1 + c2]; - var i = 0; - + var incl_modules = new List(c1 + c2); foreach (var used_unit in unit.InterfaceUsedUnits.OfType()) { // каждый модуль, зачем то, подключён сам к себе @@ -1029,22 +1027,21 @@ namespace PascalABCCompiler.PCU // и сразу стояла эта проверка. Если будет тут вылетать - наверное надо заменить throw на continue if (used_unit.namespaces.Count == 0) throw new InvalidOperationException(); - this.used_units.Add(used_unit, this.used_units.Count); - pcu_file.incl_modules[i] = unit.InterfaceUsedUnits.unit_uses_paths[used_unit]; + this.used_units.Add(used_unit, used_units.Count); + incl_modules.Add(unit.InterfaceUsedUnits.unit_uses_paths[used_unit]); - i++; } foreach (var used_unit in unit.ImplementationUsedUnits.OfType()) { - // раньше вместо пути модуля - брало имя его первого пространства имён - // и сразу стояла эта проверка. Если будет тут вылетать - наверное надо заменить throw на continue + if (unit.SemanticTree == used_unit) continue; + if (used_units.ContainsKey(used_unit)) continue; //AddIndirectImplementationUsedUnits может добавить модуль из uses из interface if (used_unit.namespaces.Count == 0) throw new InvalidOperationException(); - this.used_units.Add(used_unit, this.used_units.Count); - pcu_file.incl_modules[i] = unit.ImplementationUsedUnits.unit_uses_paths[used_unit]; + this.used_units.Add(used_unit, used_units.Count); + incl_modules.Add(unit.ImplementationUsedUnits.unit_uses_paths[used_unit]); - i++; } + pcu_file.incl_modules = incl_modules.ToArray(); pcu_file.used_namespaces = cun.used_namespaces.ToArray(); } diff --git a/TreeConverter/TreeRealization/Collections.cs b/TreeConverter/TreeRealization/Collections.cs index 4bb8258e9..ffd2d5c42 100644 --- a/TreeConverter/TreeRealization/Collections.cs +++ b/TreeConverter/TreeRealization/Collections.cs @@ -109,6 +109,7 @@ namespace PascalABCCompiler.TreeRealization public void AddElement(unit_node unit, string unit_uses_path) { + if (unit_uses_paths.ContainsKey(unit)) return; base.AddElement(unit); unit_uses_paths.Add(unit, unit_uses_path); } From 37de196fcfc1fdb62a4e515153d23558b8a0bed2 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 13 Jul 2020 09:01:47 +0300 Subject: [PATCH 24/43] cleanup --- Compiler/PCU/PCUReader.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index d9ca09a03..1ea0ed01f 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -228,12 +228,8 @@ namespace PascalABCCompiler.PCU if (Path.GetExtension(UnitName) != comp.CompilerOptions.CompiledUnitExtension) UnitName = Path.ChangeExtension(UnitName, comp.CompilerOptions.CompiledUnitExtension); - var FullUnitName = Compiler.CombinePath(dir, UnitName); - if (!File.Exists(FullUnitName)) - { - FullUnitName = Compiler.CombinePath(comp.CompilerOptions.SearchDirectory, UnitName); - if (!File.Exists(FullUnitName)) throw new FileNotFound(UnitName, null); - } + var FullUnitName = comp.FindPCUFileName(UnitName, dir); + if (FullUnitName == null) throw new FileNotFound(UnitName, null); return FullUnitName; } From 21c56c8e06bd63c8b7704114355d44d343ddedbf Mon Sep 17 00:00:00 2001 From: SunSerega Date: Tue, 14 Jul 2020 00:22:04 +0300 Subject: [PATCH 25/43] RecompileUnit cleanup --- Compiler/Compiler.cs | 44 ++++++++++++++++++++++----------------- Compiler/PCU/PCUReader.cs | 6 ++---- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index fc0a170f1..dd820d874 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2446,14 +2446,11 @@ namespace PascalABCCompiler if (string.IsNullOrEmpty(ext)) fname += CompilerOptions.CompiledUnitExtension; - else if (ext != CompilerOptions.CompiledUnitExtension) - // Чтоб "uses u in 'u.pas';" видело и "u.pcu" тоже - fname = Path.ChangeExtension(fname, CompilerOptions.CompiledUnitExtension); if (PCUFileNamesDictionary.ContainsKey(Tuple.Create(fname,curr_path))) return PCUFileNamesDictionary[Tuple.Create(fname, curr_path)]; - string res = FindFileInDirs(fname, CompilerOptions.OutputDirectory, curr_path, CompilerOptions.SearchDirectory); + string res = FindFileInDirs(fname, curr_path, CompilerOptions.SearchDirectory) ?? FindFileInDirs(Path.GetFileName(fname), CompilerOptions.OutputDirectory); PCUFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; return res; @@ -3115,7 +3112,6 @@ namespace PascalABCCompiler if (File.Exists(UnitName)) { if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); - string SourceFileName = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); try { if ((CurrentUnit = ReadPCU(UnitName)) != null) @@ -3142,6 +3138,7 @@ namespace PascalABCCompiler throw new Errors.CompilerInternalError("PCUReader", e); #endif } + string SourceFileName = FindSourceFileName(Path.ChangeExtension(UnitName, null), null); if (SourceFileName == null) throw new ReadPCUError(UnitName); else @@ -3755,12 +3752,15 @@ namespace PascalABCCompiler return null; return cu; }*/ - public bool NeedRecompiled(string name, string dir, string[] included, PCUReader pr) + public bool NeedRecompiled(string pcu_name, string[] included, PCUReader pr) { - string pas_name = FindSourceFileName(name, dir); - string pcu_name = FindPCUFileName(name, dir); + if (!Path.IsPathRooted(pcu_name)) throw new InvalidOperationException(); + string pas_name = FindSourceFileName(Path.ChangeExtension(pcu_name, null), null); + var dir = Path.GetDirectoryName(pcu_name); + if (UnitTable[pas_name] != null) return true; + bool need = false; for (int i = 0; i < included.Length; i++) { @@ -3772,19 +3772,25 @@ namespace PascalABCCompiler return true; if (!File.Exists(pcu_name2)) { - need = true; RecompileList[name] = name; - RecompileList[included[i]] = included[i]; + need = true; + RecompileList[pcu_name] = pcu_name; + RecompileList[pcu_name2] = pcu_name2; + } + else if (SourceFileExists(pas_name2) && File.GetLastWriteTime(pcu_name2) < SourceFileGetLastWriteTime(pas_name2)) + { + need = true; + CycleUnits[pcu_name] = pcu_name; + RecompileList[pcu_name] = pcu_name; + RecompileList[pcu_name2] = pcu_name2; } - else - if (SourceFileExists(pas_name2) && File.GetLastWriteTime(pcu_name2) <= SourceFileGetLastWriteTime(pas_name2)) - { - need = true; CycleUnits[name] = name; RecompileList[name] = name; - RecompileList[included[i]] = included[i]; - } } if (need) return true; + if (!SourceFileExists(pas_name)) return false; - if (!File.Exists(pcu_name)) return true; + + // NeedRecompiled вызывается уже после успешного прочтения заголовка модуля (иначе откуда included) + //if (!File.Exists(pcu_name)) return true; + if (File.GetLastWriteTime(pcu_name) < SourceFileGetLastWriteTime(pas_name)) return true; //Console.WriteLine("{0} {1}",name,RecompileList.Count); for (int i = 0; i < included.Length; i++) @@ -3794,10 +3800,10 @@ namespace PascalABCCompiler if ((File.Exists(pcu_name2) && File.GetLastWriteTime(pcu_name) < File.GetLastWriteTime(pcu_name2) && !pr.AlreadyCompiled(pcu_name2))) { - pr.AddAlreadyCompiledUnit(included[i]); + pr.AddAlreadyCompiledUnit(pcu_name2); return true; } - if (RecompileList.ContainsKey(included[i])) + if (RecompileList.ContainsKey(pcu_name2)) { return true; } diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 1ea0ed01f..4b01061d0 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -225,8 +225,6 @@ namespace PascalABCCompiler.PCU public string GetFullUnitName(string UnitName) { - if (Path.GetExtension(UnitName) != comp.CompilerOptions.CompiledUnitExtension) - UnitName = Path.ChangeExtension(UnitName, comp.CompilerOptions.CompiledUnitExtension); var FullUnitName = comp.FindPCUFileName(UnitName, dir); if (FullUnitName == null) throw new FileNotFound(UnitName, null); @@ -334,10 +332,10 @@ namespace PascalABCCompiler.PCU need = true; return need; }*/ - if (comp.NeedRecompiled(unit_name, Path.GetDirectoryName(FileName), pcu_file.incl_modules,this)) + if (comp.NeedRecompiled(FileName, pcu_file.incl_modules, this)) { //comp.RecompileList.Add(unit_name,unit_name); - comp.RecompileList[unit_name] = unit_name; + comp.RecompileList[FileName] = FileName; need = true; return need; } From 1f5d1134410de671d1378f8abd38baf40cc2f267 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Tue, 14 Jul 2020 07:31:18 +0300 Subject: [PATCH 26/43] FindPCUFileName cleanup --- Compiler/Compiler.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index dd820d874..f10e9d692 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2442,15 +2442,17 @@ namespace PascalABCCompiler public string FindPCUFileName(string fname, string curr_path) { - var ext = Path.GetExtension(fname); - if (string.IsNullOrEmpty(ext)) + if (string.IsNullOrEmpty(Path.GetExtension(fname))) fname += CompilerOptions.CompiledUnitExtension; if (PCUFileNamesDictionary.ContainsKey(Tuple.Create(fname,curr_path))) return PCUFileNamesDictionary[Tuple.Create(fname, curr_path)]; - string res = FindFileInDirs(fname, curr_path, CompilerOptions.SearchDirectory) ?? FindFileInDirs(Path.GetFileName(fname), CompilerOptions.OutputDirectory); + string res = + FindFileInDirs(fname, curr_path) ?? + FindFileInDirs(Path.GetFileName(fname), CompilerOptions.OutputDirectory) ?? + FindFileInDirs(fname, CompilerOptions.SearchDirectory); PCUFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; return res; @@ -2603,8 +2605,8 @@ namespace PascalABCCompiler } - var SourceFileExists = SourceFileName!=null && File.Exists(SourceFileName); - var PCUFileExists = !CompilerOptions.Rebuild && PCUFileName !=null && File.Exists(PCUFileName); + var SourceFileExists = SourceFileName != null; + var PCUFileExists = !CompilerOptions.Rebuild && PCUFileName != null; if (!PCUFileExists && !SourceFileExists) throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); @@ -2612,7 +2614,7 @@ namespace PascalABCCompiler if (PCUFileExists && SourceFileExists) { - if (CompilerOptions.Rebuild && !RecompileList.ContainsKey(UnitName)) + if (CompilerOptions.Rebuild && !RecompileList.ContainsKey(PCUFileName)) PCUFileExists = false; else if (File.GetLastWriteTime(PCUFileName) < File.GetLastWriteTime(SourceFileName)) From 855bf972b7e8afdfffbe8e8167d09083015f09e4 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Fri, 17 Jul 2020 01:58:34 +0300 Subject: [PATCH 27/43] folder priority when searching module files --- CodeCompletion/DomSyntaxTreeVisitor.cs | 4 +- Compiler/Compiler.cs | 162 +++++++++++++++---------- Compiler/PCU/PCUReader.cs | 21 ++-- SyntaxTree/tree/Tree.cs | 2 + 4 files changed, 110 insertions(+), 79 deletions(-) diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 7e84999a1..ff539090e 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -2414,7 +2414,7 @@ namespace CodeCompletion public string FindPCUFileName(string UnitName) { - return CodeCompletionController.comp.FindPCUFileName(UnitName,System.IO.Path.GetDirectoryName(doc.file_name)); + return CodeCompletionController.comp.FindPCUFileName(UnitName,System.IO.Path.GetDirectoryName(doc.file_name), out _); } private void add_system_unit() @@ -5120,7 +5120,7 @@ namespace CodeCompletion } else { - string unit_name = CodeCompletionController.comp.FindSourceFileName(str, System.IO.Path.GetDirectoryName(_c_module.file_name)); + string unit_name = CodeCompletionController.comp.FindSourceFileName(str, System.IO.Path.GetDirectoryName(_c_module.file_name), out _); if (unit_name == null) { unit_name = Path.Combine(System.IO.Path.GetDirectoryName(_c_module.file_name), str) + System.IO.Path.GetExtension(_c_module.file_name); diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index f10e9d692..ae39713e2 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -963,9 +963,11 @@ namespace PascalABCCompiler } } - public Dictionary, string> SourceFileNamesDictionary { get; } = new Dictionary, string>(); + public Dictionary, Tuple> SourceFileNamesDictionary { get; } = new Dictionary, Tuple>(); - public Dictionary, string> PCUFileNamesDictionary { get; } = new Dictionary, string>(); + public Dictionary, Tuple> PCUFileNamesDictionary { get; } = new Dictionary, Tuple>(); + + public Dictionary, string> GetUnitFileNameCache { get; } = new Dictionary, string>(); public void AddWarnings(List WarningList) { @@ -2440,34 +2442,50 @@ namespace PascalABCCompiler return null; } - public string FindPCUFileName(string fname, string curr_path) + public string FindPCUFileName(string fname, string curr_path, out int folder_priority) { - if (string.IsNullOrEmpty(Path.GetExtension(fname))) fname += CompilerOptions.CompiledUnitExtension; + var cache_key = Tuple.Create(fname.ToLower(), curr_path.ToLower()); - if (PCUFileNamesDictionary.ContainsKey(Tuple.Create(fname,curr_path))) - return PCUFileNamesDictionary[Tuple.Create(fname, curr_path)]; + if (!PCUFileNamesDictionary.TryGetValue(cache_key, out var res)) + { - string res = - FindFileInDirs(fname, curr_path) ?? - FindFileInDirs(Path.GetFileName(fname), CompilerOptions.OutputDirectory) ?? - FindFileInDirs(fname, CompilerOptions.SearchDirectory); + if (FindFileInDirs(fname, curr_path) is string res_s1) + res = Tuple.Create(res_s1, 1); + else if (FindFileInDirs(Path.GetFileName(fname), CompilerOptions.OutputDirectory) is string res_s2) + res = Tuple.Create(res_s2, 2); + else if (FindFileInDirs(fname, CompilerOptions.SearchDirectory) is string res_s3) + res = Tuple.Create(res_s3, 3); + else + res = null; - PCUFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; - return res; + PCUFileNamesDictionary[cache_key] = res; + } + + folder_priority = res == null ? 0 : res.Item2; + return res?.Item1; } - public string FindSourceFileName(string fname, string curr_path) + public string FindSourceFileName(string fname, string curr_path, out int folder_priority) { + var cache_key = Tuple.Create(fname.ToLower(), curr_path.ToLower()); - if (SourceFileNamesDictionary.ContainsKey(Tuple.Create(fname, curr_path))) - return SourceFileNamesDictionary[Tuple.Create(fname, curr_path)]; + if (!SourceFileNamesDictionary.TryGetValue(cache_key, out var res)) + { - string res = FindSourceFileNameInDirs(fname, curr_path, CompilerOptions.SearchDirectory); + if (FindSourceFileNameInDirs(fname, curr_path) is string res_s1) + res = Tuple.Create(res_s1, 1); + else if (FindSourceFileNameInDirs(fname, CompilerOptions.SearchDirectory) is string res_s3) + res = Tuple.Create(res_s3, 3); + else + res = null; - SourceFileNamesDictionary[Tuple.Create(fname, curr_path)] = res; - return res; + SourceFileNamesDictionary[cache_key] = res; + } + + folder_priority = res == null ? 0 : res.Item2; + return res?.Item1; } public string FindSourceFileNameInDirs(string fname, params string[] Dirs) @@ -2572,10 +2590,7 @@ namespace PascalABCCompiler { //ToDo В корневом Compile() создаётся uses_unit_in без name. Выглядит как костыль if (SyntaxUsesUnit is SyntaxTree.uses_unit_in && (SyntaxUsesUnit as SyntaxTree.uses_unit_in).name == null) return (SyntaxUsesUnit as SyntaxTree.uses_unit_in).in_file.Value; - - string UnitName; - string SourceFileName; - string PCUFileName; + var UnitName = SyntaxUsesUnit.name.idents[0].name; if (SyntaxUsesUnit is SyntaxTree.uses_unit_in uui) { @@ -2588,51 +2603,74 @@ namespace PascalABCCompiler return GetReferenceFileName(uui.in_file.Value, uui.in_file.source_context, curr_path); } - if (uui.name.idents[0].name.ToLower() != Path.GetFileNameWithoutExtension(uui.in_file.Value).ToLower()) - throw new UsesInWrongName(CurrentCompilationUnit.SyntaxTree.file_name, uui.name.idents[0].name, Path.GetFileNameWithoutExtension(uui.in_file.Value), uui.in_file.source_context); - - UnitName = uui.name.idents[0].name; - - SourceFileName = FindSourceFileName(uui.in_file.Value, curr_path); - PCUFileName = FindPCUFileName(uui.in_file.Value, curr_path); - } - else - { - UnitName = SyntaxUsesUnit.name.idents[0].name; - - SourceFileName = FindSourceFileName(UnitName, curr_path); - PCUFileName = FindPCUFileName(UnitName, curr_path); + if (UnitName.ToLower() != Path.GetFileNameWithoutExtension(uui.in_file.Value).ToLower()) + throw new UsesInWrongName(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, Path.GetFileNameWithoutExtension(uui.in_file.Value), uui.in_file.source_context); } + return GetUnitFileName(UnitName, SyntaxUsesUnit.UsesPath(), curr_path, SyntaxUsesUnit.source_context); + } + + public string GetUnitFileName(string UnitName, string path, string curr_path, SyntaxTree.SourceContext source_context) + { + var cache_key = Tuple.Create(path.ToLower(), curr_path.ToLower()); + string res; + if (GetUnitFileNameCache.TryGetValue(cache_key, out res)) + return res; + + // число приоритета меньше = более важная папка + // может выглядеть задом-наперёд, но так должно быть проще в будущем добавлять папки... + var SourceFileName = FindSourceFileName(path, curr_path, out var SourceFilePriority); + var PCUFileName = FindPCUFileName(path, curr_path, out var PCUFilePriority); + var SourceFileExists = SourceFileName != null; + //ToDo то есть Rebuild режим игнорирует .pcu, даже если нет .pas файла? + // а ещё ниже стоит ещё 1 проверка Rebuild... var PCUFileExists = !CompilerOptions.Rebuild && PCUFileName != null; if (!PCUFileExists && !SourceFileExists) - throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); + if (UnitName == null) + // вызов с "UnitName == null" должен быть только там, где уже известно что хотя бы какой то файл есть + // если где то ещё будет исопльзоваться UnitName или source_context - надо будет добавить такую же проверку + throw new InvalidOperationException(nameof(UnitName)); + else + throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, source_context); if (PCUFileExists && SourceFileExists) { + //ToDo из за проверки Rebuild выше - тут всегда будет false + // но я не понимаю какая из этих 2 проверок правильная if (CompilerOptions.Rebuild && !RecompileList.ContainsKey(PCUFileName)) PCUFileExists = false; - else if (File.GetLastWriteTime(PCUFileName) < File.GetLastWriteTime(SourceFileName)) - PCUFileExists = false; - - // На случай если есть своя версия стандартного модуля в папке с программой, но .pcu ещё не создан + else if (SourceFilePriority != PCUFilePriority) + { + if (SourceFilePriority < PCUFilePriority) + PCUFileExists = false; + else + SourceFileExists = false; + } else if (Path.GetDirectoryName(SourceFileName) != Path.GetDirectoryName(PCUFileName)) + throw new InvalidOperationException("priority"); // не должно происходить, раз приоритет одинаковый + + else if (File.GetLastWriteTime(PCUFileName) < File.GetLastWriteTime(SourceFileName)) PCUFileExists = false; } if (PCUFileExists) - return Path.Combine(curr_path, PCUFileName); + res = Path.Combine(curr_path, PCUFileName); + else if (SourceFileExists) + res = Path.Combine(curr_path, SourceFileName); else - return Path.Combine(curr_path, SourceFileName); + throw new InvalidOperationException(nameof(SourceFileExists)); // тело "if (PCUFileExists && SourceFileExists)" не должно присваивать false обоим переменным + + Console.WriteLine(Tuple.Create(cache_key, res)); + GetUnitFileNameCache[cache_key] = res; + return res; + } - } - private bool FileInSearchDirectory(string FileName) { return Path.GetDirectoryName(FileName).ToLower() == CompilerOptions.SearchDirectory.ToLower(); @@ -2937,8 +2975,8 @@ namespace PascalABCCompiler return false; if (name_space.name.idents.Count > 1) return true; - string src = FindSourceFileName(name_space.name.idents[0].name, curr_path); - string pcu = FindPCUFileName(name_space.name.idents[0].name, curr_path); + string src = FindSourceFileName(name_space.name.idents[0].name, curr_path, out _); + string pcu = FindPCUFileName(name_space.name.idents[0].name, curr_path, out _); if (src == null && pcu == null) return true; if (CompilerOptions.UseDllForSystemUnits && src != null && string.Compare(Path.GetDirectoryName(src), Path.Combine(CompilerOptions.SystemDirectory, "Lib"), true) == 0 @@ -3083,7 +3121,7 @@ namespace PascalABCCompiler if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) { - string sfn = FindSourceFileName(Path.GetFileNameWithoutExtension(UnitName), Path.GetDirectoryName(UnitName)); + string sfn = FindSourceFileName(Path.ChangeExtension(UnitName, null), null, out _); if (sfn != null && UnitTable[sfn] != null) CurrentUnit = UnitTable[sfn]; } @@ -3140,7 +3178,7 @@ namespace PascalABCCompiler throw new Errors.CompilerInternalError("PCUReader", e); #endif } - string SourceFileName = FindSourceFileName(Path.ChangeExtension(UnitName, null), null); + string SourceFileName = FindSourceFileName(Path.ChangeExtension(UnitName, null), null, out _); if (SourceFileName == null) throw new ReadPCUError(UnitName); else @@ -3289,7 +3327,7 @@ namespace PascalABCCompiler { //если сначало взали pcu а потом решили его перекомпилировать, поэтому в таблице его нет if (UnitTable[CurrentSyntaxUnitNameCurrentUsesUnit] == null) - UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit = FindSourceFileName(Path.GetFileNameWithoutExtension(CurrentSyntaxUnitNameCurrentUsesUnit), Path.GetDirectoryName(CurrentSyntaxUnitNameCurrentUsesUnit)); + UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit = FindSourceFileName(Path.ChangeExtension(CurrentSyntaxUnitNameCurrentUsesUnit, null), null, out _); //далее финальная поверка на зацикливание if (UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit != null && UnitTable[UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit].State == UnitState.BeginCompilation) throw new CycleUnitReference(UnitName, SyntaxUsesList[i]); @@ -3757,7 +3795,7 @@ namespace PascalABCCompiler public bool NeedRecompiled(string pcu_name, string[] included, PCUReader pr) { if (!Path.IsPathRooted(pcu_name)) throw new InvalidOperationException(); - string pas_name = FindSourceFileName(Path.ChangeExtension(pcu_name, null), null); + string pas_name = FindSourceFileName(Path.ChangeExtension(pcu_name, null), null, out _); var dir = Path.GetDirectoryName(pcu_name); if (UnitTable[pas_name] != null) @@ -3767,23 +3805,15 @@ namespace PascalABCCompiler for (int i = 0; i < included.Length; i++) { //if (included[i].Contains("$")) - // continue; - string pas_name2 = FindSourceFileName(included[i], dir); - string pcu_name2 = FindPCUFileName(included[i], dir); - if (UnitTable[pas_name2] != null) - return true; - if (!File.Exists(pcu_name2)) + // continue; + var used_unit_fname = GetUnitFileName(null, included[i], dir, null); + var used_unit_is_pcu = Path.GetExtension(used_unit_fname) == CompilerOptions.CompiledUnitExtension; + + if (!used_unit_is_pcu) { + if (UnitTable[used_unit_fname] != null) return true; need = true; RecompileList[pcu_name] = pcu_name; - RecompileList[pcu_name2] = pcu_name2; - } - else if (SourceFileExists(pas_name2) && File.GetLastWriteTime(pcu_name2) < SourceFileGetLastWriteTime(pas_name2)) - { - need = true; - CycleUnits[pcu_name] = pcu_name; - RecompileList[pcu_name] = pcu_name; - RecompileList[pcu_name2] = pcu_name2; } } if (need) return true; @@ -3797,7 +3827,7 @@ namespace PascalABCCompiler //Console.WriteLine("{0} {1}",name,RecompileList.Count); for (int i = 0; i < included.Length; i++) { - string pcu_name2 = FindPCUFileName(included[i], dir); + string pcu_name2 = FindPCUFileName(included[i], dir, out _); //TODO: Спросить у Сащи насчет < и <=. if ((File.Exists(pcu_name2) && File.GetLastWriteTime(pcu_name) < File.GetLastWriteTime(pcu_name2) && !pr.AlreadyCompiled(pcu_name2))) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 4b01061d0..d4ed558a4 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -226,7 +226,7 @@ namespace PascalABCCompiler.PCU public string GetFullUnitName(string UnitName) { - var FullUnitName = comp.FindPCUFileName(UnitName, dir); + var FullUnitName = comp.FindPCUFileName(UnitName, dir, out _); if (FullUnitName == null) throw new FileNotFound(UnitName, null); return FullUnitName; @@ -343,20 +343,19 @@ namespace PascalABCCompiler.PCU for (int i = 0; i < pcu_file.incl_modules.Length; i++) { //if (pcu_file.incl_modules[i].Contains("$")) - // continue; - string source_file_name = comp.FindSourceFileName(pcu_file.incl_modules[i], dir); - if (source_file_name != null && comp.UnitTable[source_file_name] != null) - return true; - var incl_unit_name = GetFullUnitName(pcu_file.incl_modules[i]); - PCUReader pr = (PCUReader)units[incl_unit_name]; + // continue; + var used_unit_fname = comp.GetUnitFileName(Path.GetFileNameWithoutExtension(pcu_file.incl_modules[i]), pcu_file.incl_modules[i], dir, new SyntaxTree.SourceContext(0,0,0,0, FileName)); + if (Path.GetExtension(used_unit_fname) != comp.CompilerOptions.CompiledUnitExtension) return true; + + PCUReader pr = (PCUReader)units[used_unit_fname]; if (pr == null) pr = new PCUReader(this); pr.AddAlreadyCompiledUnit(FileName); - if (used_units[incl_unit_name] == null) + if (used_units[used_unit_fname] == null) { - used_units[incl_unit_name] = used_units; - if (already_compiled[incl_unit_name] == null) - pr.GetCompilationUnit(comp.FindPCUFileName(pcu_file.incl_modules[i], dir), this.readDebugInfo); + used_units[used_unit_fname] = used_units; + if (already_compiled[used_unit_fname] == null) + pr.GetCompilationUnit(used_unit_fname, this.readDebugInfo); } if (need == false) need = pr.need; } diff --git a/SyntaxTree/tree/Tree.cs b/SyntaxTree/tree/Tree.cs index 442a0fa70..e1fad5ffe 100644 --- a/SyntaxTree/tree/Tree.cs +++ b/SyntaxTree/tree/Tree.cs @@ -11288,6 +11288,8 @@ namespace PascalABCCompiler.SyntaxTree } } + // имя модуля в случае обычного uses + // или путь к модулю в случае uses-in public virtual string UsesPath() => name.idents[0].name; /// Создает копию узла From 2cf359c6c0c7905682b640431396f4b89e881baa Mon Sep 17 00:00:00 2001 From: SunSerega Date: Fri, 17 Jul 2020 04:13:17 +0300 Subject: [PATCH 28/43] cleanup --- Compiler/Compiler.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index ae39713e2..0b5c82d37 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1175,7 +1175,8 @@ namespace PascalABCCompiler { SourceFileNamesDictionary.Clear(); PCUFileNamesDictionary.Clear(); - Warnings.Clear(); + GetUnitFileNameCache.Clear(); + Warnings.Clear(); errorsList.Clear(); //if (!File.Exists(CompilerOptions.SourceFileName)) throw new SourceFileNotFound(CompilerOptions.SourceFileName); CurrentCompilationUnit = null; @@ -2446,7 +2447,7 @@ namespace PascalABCCompiler { if (string.IsNullOrEmpty(Path.GetExtension(fname))) fname += CompilerOptions.CompiledUnitExtension; - var cache_key = Tuple.Create(fname.ToLower(), curr_path.ToLower()); + var cache_key = Tuple.Create(fname.ToLower(), curr_path?.ToLower()); if (!PCUFileNamesDictionary.TryGetValue(cache_key, out var res)) { @@ -2469,7 +2470,7 @@ namespace PascalABCCompiler public string FindSourceFileName(string fname, string curr_path, out int folder_priority) { - var cache_key = Tuple.Create(fname.ToLower(), curr_path.ToLower()); + var cache_key = Tuple.Create(fname.ToLower(), curr_path?.ToLower()); if (!SourceFileNamesDictionary.TryGetValue(cache_key, out var res)) { @@ -2613,7 +2614,7 @@ namespace PascalABCCompiler public string GetUnitFileName(string UnitName, string path, string curr_path, SyntaxTree.SourceContext source_context) { - var cache_key = Tuple.Create(path.ToLower(), curr_path.ToLower()); + var cache_key = Tuple.Create(path.ToLower(), curr_path?.ToLower()); string res; if (GetUnitFileNameCache.TryGetValue(cache_key, out res)) return res; @@ -2666,7 +2667,6 @@ namespace PascalABCCompiler else throw new InvalidOperationException(nameof(SourceFileExists)); // тело "if (PCUFileExists && SourceFileExists)" не должно присваивать false обоим переменным - Console.WriteLine(Tuple.Create(cache_key, res)); GetUnitFileNameCache[cache_key] = res; return res; } From cae6b94d4e3dd3ad66270ac126ea1fa545befe4a Mon Sep 17 00:00:00 2001 From: SunSerega Date: Fri, 17 Jul 2020 06:22:30 +0300 Subject: [PATCH 29/43] cleanup --- Compiler/Compiler.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 0b5c82d37..2f5233630 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2355,7 +2355,7 @@ namespace PascalABCCompiler { foreach (CompilationUnit cu in UnitsSortedList) { - SavePCU(cu, cu.UnitName); + SavePCU(cu); } foreach (PCUWriter pw in PCUWriter.AllWriters) { @@ -3528,7 +3528,7 @@ namespace PascalABCCompiler return unl; } - public void SavePCU(CompilationUnit Unit, string TargetFileName) + public void SavePCU(CompilationUnit Unit) { //#if DEBUG try @@ -3560,23 +3560,19 @@ namespace PascalABCCompiler { writer = new PCUWriter(this, pr_ChangeState); - if (FileInSearchDirectory(TargetFileName)) - TargetFileName = Path.ChangeExtension(TargetFileName, CompilerOptions.CompiledUnitExtension); - else - TargetFileName = Path.Combine(Path.GetDirectoryName(Unit.SyntaxTree.file_name), Path.GetFileNameWithoutExtension(TargetFileName) + CompilerOptions.CompiledUnitExtension); - bool dbginfo = true;/*CompilerOptions.Debug*/ #if DEBUG dbginfo = InternalDebug.IncludeDebugInfoInPCU; #endif - writer.SaveSemanticTree(Unit, TargetFileName, dbginfo); + + writer.SaveSemanticTree(Unit, Path.ChangeExtension(Unit.UnitName, CompilerOptions.CompiledUnitExtension), dbginfo); } } catch (Exception err) { //ErrorsList.Add(new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err)); - OnChangeCompilerState(this, CompilerState.PCUWritingError, TargetFileName); + OnChangeCompilerState(this, CompilerState.PCUWritingError, Unit.UnitName); #if DEBUG if (!InternalDebug.SkipPCUErrors) throw new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err); From dd65ff671542dee754f721dbe940997139783263 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 20 Jul 2020 11:20:59 +0300 Subject: [PATCH 30/43] cleanup --- Compiler/Compiler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 2f5233630..4248cdb27 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -3802,7 +3802,7 @@ namespace PascalABCCompiler { //if (included[i].Contains("$")) // continue; - var used_unit_fname = GetUnitFileName(null, included[i], dir, null); + var used_unit_fname = GetUnitFileName(Path.GetFileNameWithoutExtension(included[i]), included[i], dir, null); var used_unit_is_pcu = Path.GetExtension(used_unit_fname) == CompilerOptions.CompiledUnitExtension; if (!used_unit_is_pcu) From d144d091f504aedd8a35b7a30533c6e65a425594 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Sun, 27 Sep 2020 20:16:36 +0300 Subject: [PATCH 31/43] cleanup --- Compiler/PCU/PCUWriter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index da41ea924..f2e805fcb 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -1029,6 +1029,9 @@ namespace PascalABCCompiler.PCU // конечно, записи в unit_uses_paths для такого подключения - нет if (unit.SemanticTree == used_unit) continue; + // AddIndirectInteraceUsedUnits может добавлять один и тот же модуль несколько раз + if (used_units.ContainsKey(used_unit)) continue; + // раньше вместо пути модуля - брало имя его первого пространства имён // и сразу стояла эта проверка. Если будет тут вылетать - наверное надо заменить throw на continue if (used_unit.namespaces.Count == 0) throw new InvalidOperationException(); @@ -1040,7 +1043,7 @@ namespace PascalABCCompiler.PCU foreach (var used_unit in unit.ImplementationUsedUnits.OfType()) { if (unit.SemanticTree == used_unit) continue; - if (used_units.ContainsKey(used_unit)) continue; //AddIndirectImplementationUsedUnits может добавить модуль из uses из interface + if (used_units.ContainsKey(used_unit)) continue; if (used_unit.namespaces.Count == 0) throw new InvalidOperationException(); this.used_units.Add(used_unit, used_units.Count); From 0c219874fddab85cd9055d1496a2114399e13860 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Sun, 11 Oct 2020 21:20:44 +0300 Subject: [PATCH 32/43] Uses-in path calculation for saving indirectly used units in .pcu --- Compiler/Compiler.cs | 86 +++++++++++++++----- Compiler/PCU/PCUWriter.cs | 9 +- TreeConverter/TreeRealization/Collections.cs | 22 +++-- 3 files changed, 89 insertions(+), 28 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index f1ab3c20f..d7a7ac603 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -164,6 +164,8 @@ using System.Reflection; //using SyntaxTreeChanger; using PascalABCCompiler.SyntaxTreeConverters; using System.Text; +using PascalABCCompiler.TreeRealization; +using System.Linq; namespace PascalABCCompiler { @@ -405,10 +407,12 @@ namespace PascalABCCompiler internal List PossibleNamespaces = new List(); //internal List AssemblyReferences = new List(); - //private SemanticTree.compilation_unitArrayList _interfaceUsedUnits=new SemanticTree.compilation_unitArrayList(); + //private SemanticTree.compilation_unitArrayList _interfaceUsedUnits=new SemanticTree.compilation_unitArrayList(); + public Dictionary DirectInterfaceCompilationUnits { get; } = new Dictionary(); public PascalABCCompiler.TreeRealization.unit_node_list InterfaceUsedUnits { get; } = new PascalABCCompiler.TreeRealization.unit_node_list(); + public Dictionary DirectImplementationCompilationUnits { get; } = new Dictionary(); public PascalABCCompiler.TreeRealization.unit_node_list ImplementationUsedUnits { get; } = new PascalABCCompiler.TreeRealization.unit_node_list(); private SyntaxTree.compilation_unit _syntaxTree=null; @@ -867,7 +871,7 @@ namespace PascalABCCompiler supportedProjectFilesList.Add(new SupportedSourceFile(new string[1]{".pabcproj"},"PascalABC.NET")); supportedProjectFiles = supportedProjectFilesList.ToArray(); } - + private SupportedSourceFile[] supportedSourceFiles = null; public SupportedSourceFile[] SupportedSourceFiles { @@ -921,7 +925,6 @@ namespace PascalABCCompiler public SyntaxTree.unit_or_namespace CurrentSyntaxUnit; private List UnitsToCompile = new List(); public Hashtable RecompileList = new Hashtable(StringComparer.OrdinalIgnoreCase); - private PascalABCCompiler.TreeRealization.unit_node_list Units; private Hashtable CycleUnits = new Hashtable(); public CompilationUnit CurrentCompilationUnit = null; private CompilationUnit FirstCompilationUnit = null; @@ -1815,10 +1818,12 @@ namespace PascalABCCompiler { PrepareCompileOptionsForProject(); } - Units = new PascalABCCompiler.TreeRealization.unit_node_list(); CurrentSyntaxUnit = new SyntaxTree.uses_unit_in(null, new SyntaxTree.string_const(Path.GetFullPath(CompilerOptions.SourceFileName))); - CompileUnit(Units, CurrentSyntaxUnit, null); + CompileUnit( + new PascalABCCompiler.TreeRealization.unit_node_list(), + new Dictionary(), + CurrentSyntaxUnit, null); //Console.WriteLine(timer.ElapsedMilliseconds / 1000.0); ////// foreach (CompilationUnit CurrentUnit in UnitsToCompile) @@ -1843,11 +1848,11 @@ namespace PascalABCCompiler for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) if (!IsPossibleNamespace(SyntaxUsesList[i], true, Path.GetDirectoryName(UnitName))) { - CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], Path.GetDirectoryName(UnitName)); + CompileUnit(CurrentUnit.ImplementationUsedUnits, CurrentUnit.DirectImplementationCompilationUnits, SyntaxUsesList[i], Path.GetDirectoryName(UnitName)); } else { - CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); + CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i])), null); CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); } } @@ -2528,6 +2533,42 @@ namespace PascalABCCompiler return Path.Combine(dir, path.Substring(i)); } + public static string GetUnitPath(CompilationUnit u1, CompilationUnit u2) + { + if (u1 == null) throw new ArgumentException(nameof(u1)); + if (u2 == null) throw new ArgumentException(nameof(u2)); + + if (u1.DirectInterfaceCompilationUnits .Values.Contains(u2)) return u1.InterfaceUsedUnits .unit_uses_paths[u2.SemanticTree]; + if (u1.DirectImplementationCompilationUnits .Values.Contains(u2)) return u1.ImplementationUsedUnits .unit_uses_paths[u2.SemanticTree]; + + var last = new Dictionary(); + var done = new HashSet(); + + foreach (var u in u1.DirectInterfaceCompilationUnits.Values.Concat(u1.DirectImplementationCompilationUnits.Values)) + { + last.Add(u, u1.InterfaceUsedUnits.unit_uses_paths[u.SemanticTree]); + done.Add(u); + } + + while (last.Count != 0) + { + var next = new Dictionary(); + + foreach (var u in last.Keys) + foreach (var used_u in u.DirectInterfaceCompilationUnits.Values.Concat(u.DirectImplementationCompilationUnits.Values)) + { + if (!done.Add(used_u)) continue; + var path = CombinePath(Path.GetDirectoryName(last[u]), u.InterfaceUsedUnits.unit_uses_paths[used_u.SemanticTree]); + if (used_u == u2) return path; + next.Add(used_u, path); + } + + last = next; + } + + throw new InvalidOperationException($"Could not find path to \"{u2.UnitName}\" relative to \"{u1.UnitName}\""); + } + private string FindFileInDirs(string FileName, params string[] Dirs) { foreach (string Dir in Dirs) @@ -2767,7 +2808,7 @@ namespace PascalABCCompiler if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); if ((CurrentUnit = ReadDLL(UnitName)) != null) { - Units.AddElement(CurrentUnit.SemanticTree); + Units.AddElement(CurrentUnit.SemanticTree, null); UnitTable[UnitName] = CurrentUnit; return CurrentUnit; } @@ -2864,7 +2905,7 @@ namespace PascalABCCompiler { if (IsPossibleNamespace(name_space, false, Path.GetDirectoryName(file))) { - ns.referenced_units.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(name_space), get_location_from_treenode(name_space, tree.file_name))); + ns.referenced_units.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(name_space), get_location_from_treenode(name_space, tree.file_name)), null); } else { @@ -3121,7 +3162,7 @@ namespace PascalABCCompiler return false; } - public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) + public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, Dictionary DirectCompilationUnits, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) { string UnitName = GetUnitFileName(SyntaxUsesUnit, prev_path); // имя папки, в которой лежит текущий модуль @@ -3145,7 +3186,8 @@ namespace PascalABCCompiler if (CurrentUnit != null) if (CurrentUnit.State != UnitState.BeginCompilation || CurrentUnit.SemanticTree != null) //ИЗБАВИТЬСЯ ОТ ВТОРОГО УСЛОВИЯ { - Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); + if (Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath())) + DirectCompilationUnits.Add(CurrentUnit.SemanticTree, CurrentUnit); Units.AddRange(GetReferences(CurrentUnit)); return CurrentUnit; } @@ -3156,7 +3198,8 @@ namespace PascalABCCompiler if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); if ((CurrentUnit = ReadDLL(UnitName)) != null) { - Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); + if (Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath())) + DirectCompilationUnits.Add(CurrentUnit.SemanticTree, CurrentUnit); UnitTable[UnitName] = CurrentUnit; return CurrentUnit; } @@ -3172,7 +3215,8 @@ namespace PascalABCCompiler { if ((CurrentUnit = ReadPCU(UnitName)) != null) { - Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); + if (Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath())) + DirectCompilationUnits.Add(CurrentUnit.SemanticTree, CurrentUnit); Units.AddRange(GetReferences(CurrentUnit)); UnitTable[UnitName] = CurrentUnit; return CurrentUnit; @@ -3329,7 +3373,7 @@ namespace PascalABCCompiler { if (IsPossibleNamespace(SyntaxUsesList[i], true, curr_path) || namespaces.ContainsKey(SyntaxUsesList[i].name.idents[0].name)) { - CurrentUnit.InterfaceUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); + CurrentUnit.InterfaceUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i])), null); CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); } else @@ -3350,10 +3394,11 @@ namespace PascalABCCompiler throw new CycleUnitReference(UnitName, SyntaxUsesList[i]); } } - CompileUnit(CurrentUnit.InterfaceUsedUnits, SyntaxUsesList[i], curr_path); + CompileUnit(CurrentUnit.InterfaceUsedUnits, CurrentUnit.DirectInterfaceCompilationUnits, SyntaxUsesList[i], curr_path); if (CurrentUnit.State == UnitState.Compiled) { - Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); + if (Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath())) + DirectCompilationUnits.Add(CurrentUnit.SemanticTree, CurrentUnit); Units.AddRange(References); return CurrentUnit; } @@ -3401,7 +3446,8 @@ namespace PascalABCCompiler CurrentUnit.State = UnitState.InterfaceCompiled; if (Units != null) { - Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath()); + if (Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath())) + DirectCompilationUnits.Add(CurrentUnit.SemanticTree, CurrentUnit); Units.AddRange(References); } SyntaxUsesList = GetSyntaxImplementationUsesList(CurrentUnit.SyntaxTree); @@ -3424,12 +3470,12 @@ namespace PascalABCCompiler } else { - CompileUnit(CurrentUnit.ImplementationUsedUnits, SyntaxUsesList[i], curr_path); + CompileUnit(CurrentUnit.ImplementationUsedUnits, CurrentUnit.DirectImplementationCompilationUnits, SyntaxUsesList[i], curr_path); } } else { - CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i]))); + CurrentUnit.ImplementationUsedUnits.AddElement(new TreeRealization.namespace_unit_node(GetNamespace(SyntaxUsesList[i])), null); CurrentUnit.PossibleNamespaces.Add(SyntaxUsesList[i]); } } @@ -3540,7 +3586,7 @@ namespace PascalABCCompiler foreach (TreeRealization.unit_node un in cu.InterfaceUsedUnits) { if (un is TreeRealization.dot_net_unit_node) - unl.AddElement(un); + unl.AddElement(un, null); } return unl; } diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index f2e805fcb..ca0cab515 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -876,12 +876,15 @@ namespace PascalABCCompiler.PCU if (tn is common_type_node) { common_namespace_node comp_cnn = (tn as common_type_node).comprehensive_namespace; - if (comp_cnn != null && !ns_dict.ContainsKey(comp_cnn)) + if (comp_cnn != null && !ns_dict.ContainsKey(comp_cnn) && unit.SemanticTree != comp_cnn.cont_unit) { + var path = Compiler.GetUnitPath(unit, compiler.UnitsSortedList.Find(u => u.SemanticTree == comp_cnn.cont_unit)); + if (interf) - unit.InterfaceUsedUnits.AddElement(comp_cnn.cont_unit); + unit.InterfaceUsedUnits.AddElement(comp_cnn.cont_unit, path); else - unit.ImplementationUsedUnits.AddElement(comp_cnn.cont_unit); + unit.ImplementationUsedUnits.AddElement(comp_cnn.cont_unit, path); + ns_dict[comp_cnn] = true; } if (tn.base_type is common_type_node) diff --git a/TreeConverter/TreeRealization/Collections.cs b/TreeConverter/TreeRealization/Collections.cs index ffd2d5c42..b815c3d8c 100644 --- a/TreeConverter/TreeRealization/Collections.cs +++ b/TreeConverter/TreeRealization/Collections.cs @@ -2,8 +2,8 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Collections.Generic; -using PascalABCCompiler.Collections; - +using PascalABCCompiler.Collections; + namespace PascalABCCompiler.TreeRealization { /// @@ -107,11 +107,23 @@ namespace PascalABCCompiler.TreeRealization { public Dictionary unit_uses_paths = new Dictionary(); - public void AddElement(unit_node unit, string unit_uses_path) + public new void AddElement(unit_node unit) { - if (unit_uses_paths.ContainsKey(unit)) return; + throw new InvalidOperationException("Use second overload of \"unit_node_list.AddElement\""); + } + + /// + /// Adds element to the "uses" list + /// + /// Element to add. Can be unit, namespace, .dll reference, etc. + /// Path to unit. Can be relative string, null for non-pascal_unit's + /// Returns true if new pascal unit (not .dll, namespace, etc.) was added + public bool AddElement(unit_node unit, string unit_uses_path) + { + if (unit_uses_paths.ContainsKey(unit)) return false; base.AddElement(unit); - unit_uses_paths.Add(unit, unit_uses_path); + if (unit_uses_path != null) unit_uses_paths.Add(unit, unit_uses_path); + return true; } } From b638cc172c413f1547a61f73fa54c36c9a20173b Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 19 Oct 2020 14:42:03 +0300 Subject: [PATCH 33/43] loading InterfaceUsedUnits from .pcu --- Compiler/Compiler.cs | 2 +- Compiler/PCU/PCUReader.cs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index d7a7ac603..ab951cd88 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2522,7 +2522,7 @@ namespace PascalABCCompiler if (Path.IsPathRooted(path)) return path; int i = 0; - for (; i < path.Length && path[i] == '.' && path[i + 1] == '.'; ) + for (; dir!="" && i < path.Length && path[i] == '.' && path[i + 1] == '.'; ) { dir = Path.GetDirectoryName(dir); if (string.IsNullOrEmpty(dir)) return null; diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 63ec0cfdc..48a5cf4f2 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -189,6 +189,7 @@ namespace PascalABCCompiler.PCU return already_compiled[name] != null; } + /* public static bool ContainsUnit(string FileName, out PCUReader pr) { string unit_name = System.IO.Path.GetFileNameWithoutExtension(FileName); @@ -196,6 +197,7 @@ namespace PascalABCCompiler.PCU if (pr != null) return true; return false; } + */ public static void CloseUnits() { @@ -258,16 +260,17 @@ namespace PascalABCCompiler.PCU br = new BinaryReader(ms); ReadPCUHeader(); units[FileName] = this; + unit = new CompilationUnit(); + unit.UnitName = unit_name; + cun = new common_unit_node(); + cun.compiler_directives = pcu_file.compiler_directives; + unit.SemanticTree = cun; if (NeedRecompiled()) { CloseUnit(); need = true; return null; // return comp.RecompileUnit(FileName); } - unit = new CompilationUnit(); - cun = new common_unit_node(); - cun.compiler_directives = pcu_file.compiler_directives; - unit.SemanticTree = cun; ChangeState(this, PCUReaderWriterState.BeginReadTree, unit); cun.scope = new WrappedUnitInterfaceScope(this); @@ -357,8 +360,12 @@ namespace PascalABCCompiler.PCU if (used_units[used_unit_fname] == null) { used_units[used_unit_fname] = used_units; - if (already_compiled[used_unit_fname] == null) - pr.GetCompilationUnit(used_unit_fname, this.readDebugInfo); + if (already_compiled[used_unit_fname] == null) + { + var sub_u = pr.GetCompilationUnit(used_unit_fname, this.readDebugInfo); + this.unit.DirectInterfaceCompilationUnits.Add(sub_u.SemanticTree, sub_u); + this.unit.InterfaceUsedUnits.AddElement(sub_u.SemanticTree, pcu_file.incl_modules[i]); + } } if (need == false) need = pr.need; } From 5dbaa1c0aeca9ab75cb60ee8ff53eaea29689eea Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 19 Oct 2020 15:09:46 +0300 Subject: [PATCH 34/43] cleanup --- Compiler/Compiler.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index ab951cd88..610cb94e3 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2555,7 +2555,8 @@ namespace PascalABCCompiler var next = new Dictionary(); foreach (var u in last.Keys) - foreach (var used_u in u.DirectInterfaceCompilationUnits.Values.Concat(u.DirectImplementationCompilationUnits.Values)) + { + foreach (var used_u in u.DirectInterfaceCompilationUnits.Values) { if (!done.Add(used_u)) continue; var path = CombinePath(Path.GetDirectoryName(last[u]), u.InterfaceUsedUnits.unit_uses_paths[used_u.SemanticTree]); @@ -2563,6 +2564,15 @@ namespace PascalABCCompiler next.Add(used_u, path); } + foreach (var used_u in u.DirectImplementationCompilationUnits.Values) + { + if (!done.Add(used_u)) continue; + var path = CombinePath(Path.GetDirectoryName(last[u]), u.ImplementationUsedUnits.unit_uses_paths[used_u.SemanticTree]); + if (used_u == u2) return path; + next.Add(used_u, path); + } + } + last = next; } From 926884b0cc35f4824d0e7ee4c8508d503087e8d3 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Mon, 19 Oct 2020 15:48:11 +0300 Subject: [PATCH 35/43] all tests pass again --- Compiler/PCU/PCUReader.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 48a5cf4f2..8abcc9cc2 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -268,6 +268,7 @@ namespace PascalABCCompiler.PCU if (NeedRecompiled()) { CloseUnit(); + this.unit = null; need = true; return null; // return comp.RecompileUnit(FileName); } @@ -363,6 +364,7 @@ namespace PascalABCCompiler.PCU if (already_compiled[used_unit_fname] == null) { var sub_u = pr.GetCompilationUnit(used_unit_fname, this.readDebugInfo); + if (sub_u == null) return true; this.unit.DirectInterfaceCompilationUnits.Add(sub_u.SemanticTree, sub_u); this.unit.InterfaceUsedUnits.AddElement(sub_u.SemanticTree, pcu_file.incl_modules[i]); } From 0619c6341d91d0de8fa15d28407f31345451e9cc Mon Sep 17 00:00:00 2001 From: SunSerega Date: Thu, 19 Nov 2020 13:12:53 +0200 Subject: [PATCH 36/43] saving full file name for directives --- Compiler/PCU/PCUReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index ba2d51efb..a1238dca0 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -608,7 +608,7 @@ namespace PascalABCCompiler.PCU pcu_file.compiler_directives = new List(); for (int i = 0; i < num_directives; i++) { - pcu_file.compiler_directives.Add(new compiler_directive(br.ReadString(),br.ReadString(),ReadDebugInfo(), pcu_file.SourceFileName)); + pcu_file.compiler_directives.Add(new compiler_directive(br.ReadString(),br.ReadString(),ReadDebugInfo(), this.FileName)); } ReadAllAssemblies(); int num_imp_entity = br.ReadInt32(); From e65b1181e1126ef24813371d76400c064f847669 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Sun, 22 Nov 2020 19:46:31 +0200 Subject: [PATCH 37/43] PCUReader cleanup: removed code duplicates --- Compiler/PCU/PCUReader.cs | 210 ++++++++------------------------------ Compiler/PCU/PCUWriter.cs | 12 ++- 2 files changed, 51 insertions(+), 171 deletions(-) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index a1238dca0..2f02a0066 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -235,11 +235,24 @@ namespace PascalABCCompiler.PCU if (FullUnitName == null) throw new FileNotFound(UnitName, null); return FullUnitName; - } - - //десериализация модуля - //читается только шапка PCU и заполняются имена сущностей модуля в таблицу символов - public CompilationUnit GetCompilationUnit(string FileName, bool readDebugInfo) + } + + private PCUReader GetPCUReaderForUnitId(int id) + { + if (id == -1) return this; + string s = GetFullUnitName(pcu_file.incl_modules[id]); + var pr = (PCUReader)units[s]; + if (pr == null) + { + pr = new PCUReader(this); + pr.GetCompilationUnit(s, this.readDebugInfo); + } + return pr; + } + + //десериализация модуля + //читается только шапка PCU и заполняются имена сущностей модуля в таблицу символов + public CompilationUnit GetCompilationUnit(string FileName, bool readDebugInfo) { try { @@ -1010,47 +1023,17 @@ namespace PascalABCCompiler.PCU } //получение импорт. типа - private type_node ReadCommonExtType() - { - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - - PCUReader pr = (PCUReader)units[s];//вдруг этот модуль уже читается - if (pr == null)//это по моему чёс, так как все модули уже добавлены - { - pr = new PCUReader(this);//если нет, то создаем ридер - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - type_node tn = pr.GetTypeReference(br.ReadInt32()); - units[s] = pr;//добавляем в таблицу ридеров - return tn; - } - else - { - type_node tn = pr.GetTypeReference(br.ReadInt32()); - return tn; - } + private type_node ReadCommonExtType() + { + var pr = GetPCUReaderForUnitId(br.ReadInt32()); + return pr.GetTypeReference(br.ReadInt32()); } //(ssyy) Получение шаблонного класса private template_class ReadTemplateExtClass() { - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - - PCUReader pr = (PCUReader)units[s];//вдруг этот модуль уже читается - if (pr == null)//это по моему чёс, так как все модули уже добавлены - { - pr = new PCUReader(this);//если нет, то создаем ридер - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - template_class tc = pr.GetTemplateClass(br.ReadInt32()); - units[s] = pr;//добавляем в таблицу ридеров - return tc; - } - else - { - template_class tc = pr.GetTemplateClass(br.ReadInt32()); - return tc; - } + var pr = GetPCUReaderForUnitId(br.ReadInt32()); + return pr.GetTemplateClass(br.ReadInt32()); } //получение откомпил. типа @@ -1118,68 +1101,28 @@ namespace PascalABCCompiler.PCU ext_members[offset] = ctn; br.BaseStream.Seek(tmp,SeekOrigin.Begin); return ctn; - } - - //получение импортируемой функции - private common_namespace_function_node ReadCommonExtNamespaceFunc() + } + + //получение импортируемой функции + private common_namespace_function_node ReadCommonExtNamespaceFunc() { br.ReadByte(); - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - int offset = br.ReadInt32(); - common_namespace_function_node cffn = pr.GetNamespaceFunction(offset); - return cffn; - } - else - { - common_namespace_function_node cffn = pr.GetNamespaceFunction(br.ReadInt32()); - return cffn; - } + var pr = GetPCUReaderForUnitId(br.ReadInt32()); + return pr.GetNamespaceFunction(br.ReadInt32()); } private namespace_variable ReadExtNamespaceVariable() { br.ReadByte(); - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - namespace_variable nv = pr.GetNamespaceVariable(br.ReadInt32()); - return nv; - } - else - { - namespace_variable nv = pr.GetNamespaceVariable(br.ReadInt32()); - return nv; - } + var pr = GetPCUReaderForUnitId(br.ReadInt32()); + return pr.GetNamespaceVariable(br.ReadInt32()); } private namespace_constant_definition ReadExtNamespaceConstant() { br.ReadByte(); - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - namespace_constant_definition nv = pr.GetConstantDefinition(br.ReadInt32()); - return nv; - } - else - { - namespace_constant_definition nv = pr.GetConstantDefinition(br.ReadInt32()); - return nv; - } + var pr = GetPCUReaderForUnitId(br.ReadInt32()); + return pr.GetConstantDefinition(br.ReadInt32()); } private common_namespace_event ReadCommonNamespaceExtEvent() @@ -1189,22 +1132,9 @@ namespace PascalABCCompiler.PCU int tmp = (int)br.BaseStream.Position; br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; + var pr = GetPCUReaderForUnitId(br.ReadInt32()); br.BaseStream.Seek(tmp, SeekOrigin.Begin); - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - common_namespace_event ev = pr.GetNamespaceEventNode(br.ReadInt32()); - return ev; - } - else - { - common_namespace_event ev = pr.GetNamespaceEventNode(br.ReadInt32()); - return ev; - } + return pr.GetNamespaceEventNode(br.ReadInt32()); } private common_event ReadCommonExtEvent() @@ -1214,22 +1144,9 @@ namespace PascalABCCompiler.PCU int tmp = (int)br.BaseStream.Position; br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; + var pr = GetPCUReaderForUnitId(br.ReadInt32()); br.BaseStream.Seek(tmp, SeekOrigin.Begin); - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - common_event ev = pr.GetEventNode(br.ReadInt32()); - return ev; - } - else - { - common_event ev = pr.GetEventNode(br.ReadInt32()); - return ev; - } + return pr.GetEventNode(br.ReadInt32()); } private class_field ReadCommonExtField() @@ -1239,22 +1156,9 @@ namespace PascalABCCompiler.PCU int tmp = (int)br.BaseStream.Position; br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; + var pr = GetPCUReaderForUnitId(br.ReadInt32()); br.BaseStream.Seek(tmp, SeekOrigin.Begin); - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - class_field field = pr.GetClassField(br.ReadInt32()); - return field; - } - else - { - class_field field = pr.GetClassField(br.ReadInt32()); - return field; - } + return pr.GetClassField(br.ReadInt32()); } private common_method_node ReadCommonExtMethod() @@ -1264,22 +1168,9 @@ namespace PascalABCCompiler.PCU int tmp = (int)br.BaseStream.Position; br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; + var pr = GetPCUReaderForUnitId(br.ReadInt32()); br.BaseStream.Seek(tmp, SeekOrigin.Begin); - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - common_method_node meth = pr.GetClassMethod(br.ReadInt32()); - return meth; - } - else - { - common_method_node meth = pr.GetClassMethod(br.ReadInt32()); - return meth; - } + return pr.GetClassMethod(br.ReadInt32()); } private common_property_node ReadCommonExtProperty() @@ -1289,22 +1180,9 @@ namespace PascalABCCompiler.PCU int tmp = (int)br.BaseStream.Position; br.BaseStream.Seek(ext_pos + offset, SeekOrigin.Begin); br.ReadByte();//DS Changed - int pos = br.ReadInt32(); - string s = GetFullUnitName(pcu_file.incl_modules[pos]); - PCUReader pr = (PCUReader)units[s]; + var pr = GetPCUReaderForUnitId(br.ReadInt32()); br.BaseStream.Seek(tmp, SeekOrigin.Begin); - if (pr == null) - { - pr = new PCUReader(this); - CompilationUnit cu = pr.GetCompilationUnit(s, this.readDebugInfo); - common_property_node prop = pr.GetPropertyNode(br.ReadInt32()); - return prop; - } - else - { - common_property_node prop = pr.GetPropertyNode(br.ReadInt32()); - return prop; - } + return pr.GetPropertyNode(br.ReadInt32()); } //получение типа, описанного в этом модуле (может вызываться извне) diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index c46c04308..8732d76a0 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -1027,9 +1027,9 @@ namespace PascalABCCompiler.PCU var incl_modules = new List(c1 + c2); foreach (var used_unit in unit.InterfaceUsedUnits.OfType()) - { - // каждый модуль, зачем то, подключён сам к себе - // конечно, записи в unit_uses_paths для такого подключения - нет + { + // Каждый модуль, зачем то, подключён сам к себе + // Конечно, записи в unit_uses_paths для такого подключения - нет if (unit.SemanticTree == used_unit) continue; // AddIndirectInteraceUsedUnits может добавлять один и тот же модуль несколько раз @@ -1053,8 +1053,10 @@ namespace PascalABCCompiler.PCU incl_modules.Add(unit.ImplementationUsedUnits.unit_uses_paths[used_unit]); } - pcu_file.incl_modules = incl_modules.ToArray(); - + + used_units.Add(unit.SemanticTree as common_unit_node, -1); + + pcu_file.incl_modules = incl_modules.ToArray(); pcu_file.used_namespaces = cun.used_namespaces.ToArray(); } From 09d2791ce44ddf2a18011e8d6e3c52498d0c9b67 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Sun, 22 Nov 2020 21:10:26 +0200 Subject: [PATCH 38/43] cleanup --- Compiler/Compiler.cs | 10 ++++------ Compiler/PCU/PCUReader.cs | 10 ---------- ...uses_in3_cycle_uses.pas => uses_in4_cycle_uses.pas} | 2 +- TreeConverter/TreeRealization/CompilerDirective.cs | 2 +- 4 files changed, 6 insertions(+), 18 deletions(-) rename TestSuite/usesunits/{uses_in3_cycle_uses.pas => uses_in4_cycle_uses.pas} (63%) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index d010c9168..a0386f129 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -1991,7 +1991,7 @@ namespace PascalABCCompiler else ErrorsList.Add(new ResourceFileNotFound(cd.directive, cd.location)); - } + } } string res_file = null; if (project != null) @@ -2624,7 +2624,7 @@ namespace PascalABCCompiler //\MikhailoMMX var FullFileName = Path.Combine(curr_path, FileName); - if (System.IO.File.Exists(FullFileName)) // для отладки с *.inc файлами + if (System.IO.File.Exists(FullFileName)) { var NewFileName = Path.Combine(compilerOptions.OutputDirectory, Path.GetFileName(FullFileName)); if (FullFileName != NewFileName) File.Copy(FullFileName, NewFileName, true); @@ -2801,15 +2801,13 @@ namespace PascalABCCompiler string UnitName = null; try { - // "loc == null" для стандартных .dll, как "System.dll" - //ToDo а loc.doc было null в тестранере, но я так и не понял почему. не смог воспроизвести в дебаг режиме - UnitName = GetReferenceFileName(cd.directive, sc, loc?.doc?.file_name == null ? CompilerOptions.OutputDirectory : Path.GetDirectoryName(loc.doc.file_name)); + UnitName = GetReferenceFileName(cd.directive, sc, Path.GetDirectoryName(cd.source_file)); } catch (AssemblyNotFound ex) { throw; } - //ToDo плохо, пока дебажил - тут постоянно ловились другие исключения, не связанные с неправильным знаками в путик сборке + //ToDo плохо, пока дебажил - тут постоянно ловились другие исключения, не связанные с неправильным знаками в пути к сборке catch (Exception ex) { throw new InvalidAssemblyPathError(CurrentCompilationUnit.SyntaxTree.file_name, sc); diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 2f02a0066..84a8a641b 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -189,16 +189,6 @@ namespace PascalABCCompiler.PCU return already_compiled[name] != null; } - /* - public static bool ContainsUnit(string FileName, out PCUReader pr) - { - string unit_name = System.IO.Path.GetFileNameWithoutExtension(FileName); - pr = (PCUReader)units[unit_name]; - if (pr != null) return true; - return false; - } - */ - public static void CloseUnits() { AllReadOrWritedDefinitionNodesOffsets.Clear(); diff --git a/TestSuite/usesunits/uses_in3_cycle_uses.pas b/TestSuite/usesunits/uses_in4_cycle_uses.pas similarity index 63% rename from TestSuite/usesunits/uses_in3_cycle_uses.pas rename to TestSuite/usesunits/uses_in4_cycle_uses.pas index 8d82d2305..68685ae2d 100644 --- a/TestSuite/usesunits/uses_in3_cycle_uses.pas +++ b/TestSuite/usesunits/uses_in4_cycle_uses.pas @@ -1,4 +1,4 @@ -unit uses_in3_cycle_uses; +unit uses_in4_cycle_uses; {$savepcu false} interface diff --git a/TreeConverter/TreeRealization/CompilerDirective.cs b/TreeConverter/TreeRealization/CompilerDirective.cs index 9e9916400..d8c2c1bf1 100644 --- a/TreeConverter/TreeRealization/CompilerDirective.cs +++ b/TreeConverter/TreeRealization/CompilerDirective.cs @@ -11,7 +11,7 @@ namespace PascalABCCompiler.TreeRealization public string name; public string directive; public location location; - public string source_file; // файл из которого загрузили директиву. в отличии от location - может указывать на .pcu + public string source_file; // Файл из которого загрузили директиву. В отличии от location - может указывать на .pcu public compiler_directive(string name, string directive, location loc, string source_file) { From dd9f0da99e4cdc003b48468d42c4bc6b968b8e2e Mon Sep 17 00:00:00 2001 From: SunSerega Date: Sun, 22 Nov 2020 21:13:42 +0200 Subject: [PATCH 39/43] cleanup --- TestSuite/usesunits/UsesInUnits4/u2.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestSuite/usesunits/UsesInUnits4/u2.pas b/TestSuite/usesunits/UsesInUnits4/u2.pas index 8f48fbbd0..c206b9ccd 100644 --- a/TestSuite/usesunits/UsesInUnits4/u2.pas +++ b/TestSuite/usesunits/UsesInUnits4/u2.pas @@ -7,6 +7,6 @@ interface implementation -uses uses_in3_cycle_uses in '..\uses_in3_cycle_uses'; +uses uses_in4_cycle_uses in '..\uses_in4_cycle_uses'; end. \ No newline at end of file From 3f03f9b6a6c1f3278dbef6c19553ef9a4c890ab2 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Sun, 22 Nov 2020 22:55:28 +0200 Subject: [PATCH 40/43] cleanup done --- Compiler/Compiler.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index a0386f129..a55d324b8 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2984,23 +2984,23 @@ namespace PascalABCCompiler directives = ConvertDirectives(Unit.SyntaxTree); if (CompilerOptions.UseDllForSystemUnits) { - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PABCRtl.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\mscorlib.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Core.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Numerics.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Windows.Forms.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Drawing.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PABCRtl.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\mscorlib.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Core.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Numerics.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Windows.Forms.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\System.Drawing.dll", null, ".")); if (Unit.SyntaxTree is SyntaxTree.program_module && (Unit.SyntaxTree as SyntaxTree.program_module).used_units != null) foreach (SyntaxTree.unit_or_namespace uui in (Unit.SyntaxTree as SyntaxTree.program_module).used_units.units) { if (uui.name.ToString() == "Graph3D") { - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationFramework.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\WindowsBase.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationCore.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.Wpf.dll", null, null)); - directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.dll", null, null)); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationFramework.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\WindowsBase.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\PresentationCore.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.Wpf.dll", null, ".")); + directives.Add(new TreeRealization.compiler_directive("reference", "%GAC%\\HelixToolkit.dll", null, ".")); } } } @@ -3018,7 +3018,7 @@ namespace PascalABCCompiler { foreach (ReferenceInfo ri in project.references) { - CompileReference(res,new TreeRealization.compiler_directive("reference",ri.full_assembly_name,null,null)); + CompileReference(res, new TreeRealization.compiler_directive("reference", ri.full_assembly_name, null, project.MainFile)); } } return res; From 83fde8ce9ff3b6b553f218d470252a2597594938 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Fri, 11 Dec 2020 11:17:25 +0200 Subject: [PATCH 41/43] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?.dll=20=D0=BF=D0=BE=20uses-in?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Compiler/Compiler.cs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index a55d324b8..ede840d17 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2652,14 +2652,6 @@ namespace PascalABCCompiler if (SyntaxUsesUnit is SyntaxTree.uses_unit_in uui) { - // Подключение .dll в uses-in. Зачем - не понятно, но было до меня, поэтому просто оставил - switch (Path.GetExtension(uui.in_file.Value).ToLower()) - { - case ".dll": - case ".exe": - return GetReferenceFileName(uui.in_file.Value, uui.in_file.source_context, curr_path); - } - if (UnitName.ToLower() != Path.GetFileNameWithoutExtension(uui.in_file.Value).ToLower()) throw new UsesInWrongName(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, Path.GetFileNameWithoutExtension(uui.in_file.Value), uui.in_file.source_context); @@ -3173,8 +3165,8 @@ namespace PascalABCCompiler public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, Dictionary DirectCompilationUnits, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) { string UnitName = GetUnitFileName(SyntaxUsesUnit, prev_path); - // имя папки, в которой лежит текущий модуль - // используется для подключения модулей, $include и т.п. из модуля, подключённого с uses-in + // Имя папки, в которой лежит текущий модуль + // Используется для подключения модулей, $include и т.п. из модуля, подключённого с uses-in var curr_path = Path.GetDirectoryName(UnitName); CompilationUnit CurrentUnit = UnitTable[UnitName]; @@ -3200,21 +3192,6 @@ namespace PascalABCCompiler return CurrentUnit; } - if (UnitName.ToLower().LastIndexOf(".dll") >= 0 || UnitName.ToLower().LastIndexOf(".exe") >= 0) - if (File.Exists(UnitName)) - { - if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); - if ((CurrentUnit = ReadDLL(UnitName)) != null) - { - if (Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath())) - DirectCompilationUnits.Add(CurrentUnit.SemanticTree, CurrentUnit); - UnitTable[UnitName] = CurrentUnit; - return CurrentUnit; - } - else - //throw new DLLReadingError(UnitName); - throw new AssemblyReadingError(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); - } if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) if (File.Exists(UnitName)) { From 56a4dea364cf96c740c35ac52eb6d14846775954 Mon Sep 17 00:00:00 2001 From: SunSerega Date: Tue, 5 Jan 2021 23:47:18 +0200 Subject: [PATCH 42/43] Separated UnitName into unit id (for UnitTable) and unit file name fix #pascalabcnet/pascalabcnet#2387 --- Compiler/Compiler.cs | 98 +++++++++++++++++++-------------------- Compiler/DocXml.cs | 8 ++-- Compiler/PCU/PCUReader.cs | 2 +- 3 files changed, 52 insertions(+), 56 deletions(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 6b8acfe55..42fa320f5 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -399,9 +399,9 @@ namespace PascalABCCompiler public class CompilationUnit { internal bool CaseSensitive = false; - public string CurrentUsesUnit; + public string CurrentUsesUnitId; public PascalABCCompiler.Errors.SyntaxError syntax_error; - public string UnitName; + public string UnitFileName; public List ErrorList=new List(); public bool Documented; internal List PossibleNamespaces = new List(); @@ -1884,7 +1884,7 @@ namespace PascalABCCompiler CurrentUnit.State = UnitState.Compiled; OnChangeCompilerState(this, CompilerState.EndCompileFile, UnitName); //SavePCU(CurrentUnit, UnitName); - CurrentUnit.UnitName = UnitName; + CurrentUnit.UnitFileName = UnitName; } ClosePCUReadersAndWriters(); @@ -2582,7 +2582,7 @@ namespace PascalABCCompiler last = next; } - throw new InvalidOperationException($"Could not find path to \"{u2.UnitName}\" relative to \"{u1.UnitName}\""); + throw new InvalidOperationException($"Could not find path to \"{u2.UnitFileName}\" relative to \"{u1.UnitFileName}\""); } private string FindFileInDirs(string FileName, params string[] Dirs) @@ -3177,25 +3177,19 @@ namespace PascalABCCompiler public CompilationUnit CompileUnit(PascalABCCompiler.TreeRealization.unit_node_list Units, Dictionary DirectCompilationUnits, SyntaxTree.unit_or_namespace SyntaxUsesUnit, string prev_path) { - string UnitName = GetUnitFileName(SyntaxUsesUnit, prev_path); + string UnitFileName = GetUnitFileName(SyntaxUsesUnit, prev_path); + string UnitId = Path.ChangeExtension(UnitFileName, null); // Имя папки, в которой лежит текущий модуль // Используется для подключения модулей, $include и т.п. из модуля, подключённого с uses-in - var curr_path = Path.GetDirectoryName(UnitName); + var curr_path = Path.GetDirectoryName(UnitFileName); - CompilationUnit CurrentUnit = UnitTable[UnitName]; + CompilationUnit CurrentUnit = UnitTable[UnitId]; if (CurrentUnit != null && CurrentUnit.SemanticTree is PascalABCCompiler.TreeRealization.dot_net_unit_node && SyntaxUsesUnit is PascalABCCompiler.SyntaxTree.uses_unit_in ui && ui.in_file != null) // значит, это пространство имен и секция in у него должна отсутствовать { ErrorsList.Add(new NamespaceCannotHaveInSection(ui.in_file.source_context)); } - if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) - { - string sfn = FindSourceFileName(Path.ChangeExtension(UnitName, null), null, out _); - if (sfn != null && UnitTable[sfn] != null) - CurrentUnit = UnitTable[sfn]; - } - if (CurrentUnit != null) if (CurrentUnit.State != UnitState.BeginCompilation || CurrentUnit.SemanticTree != null) //ИЗБАВИТЬСЯ ОТ ВТОРОГО УСЛОВИЯ { @@ -3205,18 +3199,18 @@ namespace PascalABCCompiler return CurrentUnit; } - if (Path.GetExtension(UnitName).ToLower() == CompilerOptions.CompiledUnitExtension) - if (File.Exists(UnitName)) + if (CurrentUnit==null && Path.GetExtension(UnitFileName).ToLower() == CompilerOptions.CompiledUnitExtension) + if (File.Exists(UnitFileName)) { - if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitName, null); + if (UnitTable.Count == 0) throw new ProgramModuleExpected(UnitFileName, null); try { - if ((CurrentUnit = ReadPCU(UnitName)) != null) + if ((CurrentUnit = ReadPCU(UnitFileName)) != null) { if (Units.AddElement(CurrentUnit.SemanticTree, SyntaxUsesUnit.UsesPath())) DirectCompilationUnits.Add(CurrentUnit.SemanticTree, CurrentUnit); Units.AddRange(GetReferences(CurrentUnit)); - UnitTable[UnitName] = CurrentUnit; + UnitTable[UnitId] = CurrentUnit; return CurrentUnit; } } @@ -3230,17 +3224,17 @@ namespace PascalABCCompiler } catch (Exception e) { - OnChangeCompilerState(this, CompilerState.PCUReadingError, UnitName); + OnChangeCompilerState(this, CompilerState.PCUReadingError, UnitFileName); #if DEBUG if (!InternalDebug.SkipPCUErrors) throw new Errors.CompilerInternalError("PCUReader", e); #endif } - string SourceFileName = FindSourceFileName(Path.ChangeExtension(UnitName, null), null, out _); + string SourceFileName = FindSourceFileName(Path.ChangeExtension(UnitFileName, null), null, out _); if (SourceFileName == null) - throw new ReadPCUError(UnitName); + throw new ReadPCUError(UnitFileName); else - UnitName = SourceFileName; + UnitFileName = SourceFileName; } string SourceText = null; Dictionary docs = null; @@ -3250,20 +3244,20 @@ namespace PascalABCCompiler CurrentUnit = new CompilationUnit(); if (FirstCompilationUnit == null) FirstCompilationUnit = CurrentUnit; - OnChangeCompilerState(this, CompilerState.BeginCompileFile, UnitName); - SourceText = GetSourceFileText(UnitName); + OnChangeCompilerState(this, CompilerState.BeginCompileFile, UnitFileName); + SourceText = GetSourceFileText(UnitFileName); if (SourceText == null) if (CurrentUnit == FirstCompilationUnit) - throw new SourceFileNotFound(UnitName); + throw new SourceFileNotFound(UnitFileName); else - throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitName, SyntaxUsesUnit.source_context); + throw new UnitNotFound(CurrentCompilationUnit.SyntaxTree.file_name, UnitFileName, SyntaxUsesUnit.source_context); List DefinesList = new List(); DefinesList.Add("PASCALABC"); if (!compilerOptions.Debug && !compilerOptions.ForDebugging) DefinesList.Add("RELEASE"); else DefinesList.Add("DEBUG"); - CurrentUnit.SyntaxTree = InternalParseText(UnitName, SourceText, errorsList, warnings, DefinesList); + CurrentUnit.SyntaxTree = InternalParseText(UnitFileName, SourceText, errorsList, warnings, DefinesList); if (errorsList.Count == 0) // SSM 2/05/16 - для преобразования синтаксических деревьев извне { @@ -3326,13 +3320,13 @@ namespace PascalABCCompiler throw errorsList[0]; } - UnitTable[UnitName] = CurrentUnit; + UnitTable[UnitId] = CurrentUnit; if (UnitTable.Count > 1)//если это не главный модуль if (CurrentUnit.SyntaxTree is SyntaxTree.program_module) - throw new UnitModuleExpected(UnitName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); + throw new UnitModuleExpected(UnitFileName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); else if (is_dll(CurrentUnit.SyntaxTree)) - throw new UnitModuleExpectedLibraryFound(UnitName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); + throw new UnitModuleExpectedLibraryFound(UnitFileName, CurrentUnit.SyntaxTree.source_context.LeftSourceContext); //здесь в начало uses добавляем стандартные модули #if DEBUG if (InternalDebug.AddStandartUnits) @@ -3376,20 +3370,22 @@ namespace PascalABCCompiler } else { - string CurrentSyntaxUnitName = GetUnitFileName(SyntaxUsesList[i], curr_path); - CurrentUnit.CurrentUsesUnit = CurrentSyntaxUnitName; - if (UnitTable[CurrentSyntaxUnitName] != null) - if (UnitTable[CurrentSyntaxUnitName].State == UnitState.BeginCompilation) + var CurrentSyntaxUnitFileName = GetUnitFileName(SyntaxUsesList[i], curr_path); + var CurrentSyntaxUnitId = Path.ChangeExtension(CurrentSyntaxUnitFileName, null); + CurrentUnit.CurrentUsesUnitId = CurrentSyntaxUnitId; + + if (UnitTable[CurrentSyntaxUnitId] != null) + if (UnitTable[CurrentSyntaxUnitId].State == UnitState.BeginCompilation) { - string CurrentSyntaxUnitNameCurrentUsesUnit = UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit; - if (CurrentSyntaxUnitNameCurrentUsesUnit != null) + string CurrentSyntaxUnit_CurrentUsesUnitId = UnitTable[CurrentSyntaxUnitId].CurrentUsesUnitId; + if (CurrentSyntaxUnit_CurrentUsesUnitId != null) { - //если сначало взали pcu а потом решили его перекомпилировать, поэтому в таблице его нет - if (UnitTable[CurrentSyntaxUnitNameCurrentUsesUnit] == null) - UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit = FindSourceFileName(Path.ChangeExtension(CurrentSyntaxUnitNameCurrentUsesUnit, null), null, out _); + //если сначало взяли pcu а потом решили его перекомпилировать, поэтому в таблице его нет + if (UnitTable[CurrentSyntaxUnit_CurrentUsesUnitId] == null) + UnitTable[CurrentSyntaxUnitId].CurrentUsesUnitId = CurrentSyntaxUnit_CurrentUsesUnitId; //далее финальная поверка на зацикливание - if (UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit != null && UnitTable[UnitTable[CurrentSyntaxUnitName].CurrentUsesUnit].State == UnitState.BeginCompilation) - throw new CycleUnitReference(UnitName, SyntaxUsesList[i]); + if (UnitTable[CurrentSyntaxUnitId].CurrentUsesUnitId != null && UnitTable[UnitTable[CurrentSyntaxUnitId].CurrentUsesUnitId].State == UnitState.BeginCompilation) + throw new CycleUnitReference(UnitFileName, SyntaxUsesList[i]); } } CompileUnit(CurrentUnit.InterfaceUsedUnits, CurrentUnit.DirectInterfaceCompilationUnits, SyntaxUsesList[i], curr_path); @@ -3419,7 +3415,7 @@ namespace PascalABCCompiler { if (CurrentUnit.State != UnitState.InterfaceCompiled) { - OnChangeCompilerState(this, CompilerState.CompileInterface, UnitName); + OnChangeCompilerState(this, CompilerState.CompileInterface, UnitFileName); PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; CurrentUnit.SemanticTree = SyntaxTreeToSemanticTreeConverter.CompileInterface( CurrentUnit.SyntaxTree, @@ -3457,7 +3453,7 @@ namespace PascalABCCompiler for (int i = SyntaxUsesList.Count - 1; i >= 0; i--) if (!IsPossibleNamespace(SyntaxUsesList[i], true, curr_path)) { - cu = UnitTable[GetUnitFileName(SyntaxUsesList[i], curr_path)]; + cu = UnitTable[Path.ChangeExtension(GetUnitFileName(SyntaxUsesList[i], curr_path), null)]; if (cu != null && cu.State == UnitState.BeginCompilation) { UnitsToCompile.Add(cu); @@ -3502,7 +3498,7 @@ namespace PascalABCCompiler if (InternalDebug.SemanticAnalysis) #endif { - OnChangeCompilerState(this, CompilerState.CompileImplementation, UnitName); + OnChangeCompilerState(this, CompilerState.CompileImplementation, UnitFileName); PascalABCCompiler.TreeConverter.SemanticRules.SymbolTableCaseSensitive = CurrentUnit.CaseSensitive; SyntaxTreeToSemanticTreeConverter.CompileImplementation( (PascalABCCompiler.TreeRealization.common_unit_node)CurrentUnit.SemanticTree, @@ -3526,9 +3522,9 @@ namespace PascalABCCompiler if (!UnitsSortedList.Contains(CurrentUnit))//vnimanie zdes inogda pri silnoj zavisimosti modulej moduli popadajut neskolko raz UnitsSortedList.Add(CurrentUnit); } - OnChangeCompilerState(this, CompilerState.EndCompileFile, UnitName); + OnChangeCompilerState(this, CompilerState.EndCompileFile, UnitFileName); //SavePCU(CurrentUnit, UnitName); - CurrentUnit.UnitName = UnitName; + CurrentUnit.UnitFileName = UnitFileName; return CurrentUnit; /*if(CurrentUnit.State!=UnitState.Compiled) { @@ -3626,14 +3622,14 @@ namespace PascalABCCompiler dbginfo = InternalDebug.IncludeDebugInfoInPCU; #endif - writer.SaveSemanticTree(Unit, Path.ChangeExtension(Unit.UnitName, CompilerOptions.CompiledUnitExtension), dbginfo); + writer.SaveSemanticTree(Unit, Path.ChangeExtension(Unit.UnitFileName, CompilerOptions.CompiledUnitExtension), dbginfo); } } catch (Exception err) { //ErrorsList.Add(new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err)); - OnChangeCompilerState(this, CompilerState.PCUWritingError, Unit.UnitName); + OnChangeCompilerState(this, CompilerState.PCUWritingError, Unit.UnitFileName); #if DEBUG if (!InternalDebug.SkipPCUErrors) throw new Errors.CompilerInternalError(string.Format("Compiler.Compile[{0}]", Path.GetFileName(this.CurrentCompilationUnit.SyntaxTree.file_name)), err); @@ -3855,7 +3851,7 @@ namespace PascalABCCompiler string pas_name = FindSourceFileName(Path.ChangeExtension(pcu_name, null), null, out _); var dir = Path.GetDirectoryName(pcu_name); - if (UnitTable[pas_name] != null) + if (UnitTable[Path.ChangeExtension(pas_name, null)] != null) return true; bool need = false; @@ -3868,7 +3864,7 @@ namespace PascalABCCompiler if (!used_unit_is_pcu) { - if (UnitTable[used_unit_fname] != null) return true; + if (UnitTable[Path.ChangeExtension(used_unit_fname, null)] != null) return true; need = true; RecompileList[pcu_name] = pcu_name; } diff --git a/Compiler/DocXml.cs b/Compiler/DocXml.cs index 8e0d8c02d..aa6375082 100644 --- a/Compiler/DocXml.cs +++ b/Compiler/DocXml.cs @@ -28,15 +28,15 @@ namespace PascalABCCompiler XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; settings.Indent = true; - xtw = XmlTextWriter.Create(Path.ChangeExtension(cu.UnitName, ".xml"), settings); - unit_name = Path.GetFileNameWithoutExtension(cu.UnitName); + xtw = XmlTextWriter.Create(Path.ChangeExtension(cu.UnitFileName, ".xml"), settings); + unit_name = Path.GetFileNameWithoutExtension(cu.UnitFileName); xtw.WriteStartDocument(); xtw.WriteStartElement("doc"); if (is_assembly) { xtw.WriteStartElement("assembly"); xtw.WriteStartElement("name"); - xtw.WriteString(Path.GetFileNameWithoutExtension(cu.UnitName)); + xtw.WriteString(Path.GetFileNameWithoutExtension(cu.UnitFileName)); xtw.WriteEndElement(); xtw.WriteEndElement(); } @@ -45,7 +45,7 @@ namespace PascalABCCompiler xtw.WriteStartElement("unit"); xtw.WriteStartAttribute("name"); //xtw.WriteString((cu.SemanticTree as common_unit_node).unit_name); - xtw.WriteString(Path.GetFileNameWithoutExtension(cu.UnitName)); + xtw.WriteString(Path.GetFileNameWithoutExtension(cu.UnitFileName)); xtw.WriteEndAttribute(); xtw.WriteString(cu.SemanticTree.documentation); xtw.WriteEndElement(); diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index 88c439a05..4aa1ab2bb 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -264,7 +264,7 @@ namespace PascalABCCompiler.PCU ReadPCUHeader(); units[FileName] = this; unit = new CompilationUnit(); - unit.UnitName = unit_name; + unit.UnitFileName = FileName; cun = new common_unit_node(); cun.compiler_directives = pcu_file.compiler_directives; unit.SemanticTree = cun; From 7535be45c000b1db6c9d55e7b650422bd085e1fb Mon Sep 17 00:00:00 2001 From: SunSerega Date: Fri, 8 Jan 2021 23:37:21 +0200 Subject: [PATCH 43/43] fixed minor .dll coping bug --- Compiler/Compiler.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 42fa320f5..9dfc071b8 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -2632,7 +2632,6 @@ namespace PascalABCCompiler var FullFileName = Path.Combine(curr_path, FileName); if (System.IO.File.Exists(FullFileName)) { - if (!CompilerOptions.useOutputDirectory) return FullFileName; var NewFileName = Path.Combine(compilerOptions.OutputDirectory, Path.GetFileName(FullFileName)); if (FullFileName != NewFileName) File.Copy(FullFileName, NewFileName, true); return NewFileName;