diff --git a/documentation/Compiler/Compilation algorithm/Compilation algorithm.md b/documentation/Compiler/Compilation algorithm/Compilation algorithm.md new file mode 100644 index 000000000..38960f475 --- /dev/null +++ b/documentation/Compiler/Compilation algorithm/Compilation algorithm.md @@ -0,0 +1,163 @@ + +Owner: Alexander Zemlyak +Tags: Infrastructure + +### Алгоритм на псевдокоде + +- Полная версия + + ``` + 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(ТекущийМодуль); + ``` + +- Краткая версия (меньше технических подробностей) + + ``` + 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 файла на диск + ``` + + +### Словесное описание алгоритма + +Модули компилируются в порядке, соответствующем порядку **обхода в глубину** графа зависимостей. Обход в глубину реализуется рекурсивными вызовами функции CompileUnit. + +Сначала рекурсивно обходятся все зависимости интерфейсных частей модулей, причем в порядке **обратном** порядку в списке uses. Ясно, что может существовать **циклическая зависимость интерфейсных частей** модулей. Она запрещается (во время компиляции выдается соотв. ошибка). Цикл обнаруживается, если мы встречаем модуль с не откомпилированным интерфейсом, в котором мы уже были. + + + +**Пример допустимого цикла** +![[допустимая циклическая зависимость.png]] +--- + +Если все зависимости интерфейса скомпилированы, то в том же порядке начинают рекурсивно обходиться зависимости части реализации (implementation). **Отложенная компиляция** происходит сразу после окончания первого обхода всех модулей, когда абсолютно все интерфейсные части модулей уже скомпилированы. Это условие гарантирует отсутствие новых циклических интерфейсных зависимостей. Модули добавляются в список отложенной компиляции в случае, если в некотором модуле в списке uses части реализации есть ранее встреченный модуль с еще не откомпилированным интерфейсом (в список добавляются оба этих модуля). + + + +```csharp +if (currentUnit.State != UnitState.BeginCompilation || currentUnit.SemanticTree != null) +{ + AddCurrentUnitAndItsReferencesToUsesLists(unitsFromUsesSection, directUnitsFromUsesSection, + currentUnitNode, currentUnit, GetReferences(currentUnit)); + return currentUnit; +} +``` \ No newline at end of file diff --git a/documentation/Compiler/Compilation algorithm/допустимая циклическая зависимость.png b/documentation/Compiler/Compilation algorithm/допустимая циклическая зависимость.png new file mode 100644 index 000000000..771d1f2c3 Binary files /dev/null and b/documentation/Compiler/Compilation algorithm/допустимая циклическая зависимость.png differ diff --git a/documentation/Compiler/Compiler_api.md b/documentation/Compiler/Compiler_api.md new file mode 100644 index 000000000..f8f6100c4 --- /dev/null +++ b/documentation/Compiler/Compiler_api.md @@ -0,0 +1,2412 @@ +# Class Compiler + +Namespace: [PascalABCCompiler](PascalABCCompiler.md) +Assembly: Compiler.dll + +```csharp +public class Compiler : MarshalByRefObject, ICompiler +``` + +#### Inheritance + +[object](https://learn.microsoft.com/dotnet/api/system.object) ← +[MarshalByRefObject](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject) ← +[Compiler](PascalABCCompiler.Compiler.md) + +#### Implements + +[ICompiler](PascalABCCompiler.ICompiler.md) + +#### Inherited Members + +[MarshalByRefObject.MemberwiseClone\(bool\)](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject.memberwiseclone), +[MarshalByRefObject.GetLifetimeService\(\)](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject.getlifetimeservice), +[MarshalByRefObject.InitializeLifetimeService\(\)](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject.initializelifetimeservice), +[MarshalByRefObject.CreateObjRef\(Type\)](https://learn.microsoft.com/dotnet/api/system.marshalbyrefobject.createobjref), +[object.ToString\(\)](https://learn.microsoft.com/dotnet/api/system.object.tostring), +[object.Equals\(object\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\)), +[object.Equals\(object, object\)](https://learn.microsoft.com/dotnet/api/system.object.equals\#system\-object\-equals\(system\-object\-system\-object\)), +[object.ReferenceEquals\(object, object\)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), +[object.GetHashCode\(\)](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), +[object.GetType\(\)](https://learn.microsoft.com/dotnet/api/system.object.gettype), +[object.MemberwiseClone\(\)](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) + +## Constructors + +### Compiler\(\) + +```csharp +private static Compiler() +``` + +### Compiler\(\) + +```csharp +public Compiler() +``` + +### Compiler\(ICompiler, SourceFilesProviderDelegate, ChangeCompilerStateEventDelegate\) + +```csharp +public Compiler(ICompiler comp, SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) +``` + +#### Parameters + +`comp` [ICompiler](PascalABCCompiler.ICompiler.md) + +`SourceFilesProvider` SourceFilesProviderDelegate + +`ChangeCompilerState` [ChangeCompilerStateEventDelegate](PascalABCCompiler.ChangeCompilerStateEventDelegate.md) + +### Compiler\(SourceFilesProviderDelegate, ChangeCompilerStateEventDelegate\) + +```csharp +public Compiler(SourceFilesProviderDelegate SourceFilesProvider, ChangeCompilerStateEventDelegate ChangeCompilerState) +``` + +#### Parameters + +`SourceFilesProvider` SourceFilesProviderDelegate + +`ChangeCompilerState` [ChangeCompilerStateEventDelegate](PascalABCCompiler.ChangeCompilerStateEventDelegate.md) + +## Fields + +### BadNodesInSyntaxTree + +```csharp +private Hashtable BadNodesInSyntaxTree +``` + +#### Field Value + + [Hashtable](https://learn.microsoft.com/dotnet/api/system.collections.hashtable) + +### CodeGeneratorsController + +```csharp +public Controller CodeGeneratorsController +``` + +#### Field Value + + Controller + +### CompiledVariables + +```csharp +public List CompiledVariables +``` + +#### Field Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### DLLCache + +```csharp +private Dictionary DLLCache +``` + +#### Field Value + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [CompilationUnit](PascalABCCompiler.CompilationUnit.md)\> + +### PCUReadersAndWritersClosed + +```csharp +private bool PCUReadersAndWritersClosed +``` + +#### Field Value + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### RecompileList + +```csharp +public Hashtable RecompileList +``` + +#### Field Value + + [Hashtable](https://learn.microsoft.com/dotnet/api/system.collections.hashtable) + +### StandardModules + +```csharp +private List StandardModules +``` + +#### Field Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\> + +### SyntaxTreeToSemanticTreeConverter + +```csharp +public SyntaxTreeToSemanticTreeConverter SyntaxTreeToSemanticTreeConverter +``` + +#### Field Value + + [SyntaxTreeToSemanticTreeConverter](PascalABCCompiler.TreeConverter.SyntaxTreeToSemanticTreeConverter.md) + +### UnitsToCompileDelayedList + +список отложенной компиляции реализации (она будет откомпилирована в Compile, а не в СompileUnit) + +```csharp +private List UnitsToCompileDelayedList +``` + +#### Field Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[CompilationUnit](PascalABCCompiler.CompilationUnit.md)\> + +### UnitsTopologicallySortedList + +```csharp +public List UnitsTopologicallySortedList +``` + +#### Field Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[CompilationUnit](PascalABCCompiler.CompilationUnit.md)\> + +### \_clear\_after\_compilation + +```csharp +private bool _clear_after_compilation +``` + +#### Field Value + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### assemblyResolveScope + +```csharp +private AssemblyResolveScope assemblyResolveScope +``` + +#### Field Value + + AssemblyResolveScope + +### beginOffset + +Начало основной программы + +```csharp +public int beginOffset +``` + +#### Field Value + + [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### currentCompilationUnit + +```csharp +private CompilationUnit currentCompilationUnit +``` + +#### Field Value + + [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### errorsList + +```csharp +private List errorsList +``` + +#### Field Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### firstCompilationUnit + +```csharp +private CompilationUnit firstCompilationUnit +``` + +#### Field Value + + [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### internalDebug + +```csharp +private CompilerInternalDebug internalDebug +``` + +#### Field Value + + [CompilerInternalDebug](PascalABCCompiler.CompilerInternalDebug.md) + +### linesCompiled + +```csharp +private uint linesCompiled +``` + +#### Field Value + + [uint](https://learn.microsoft.com/dotnet/api/system.uint32) + +### pABCCodeHealth + +```csharp +private int pABCCodeHealth +``` + +#### Field Value + + [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### pcuCompilationUnits + +```csharp +private static Dictionary pcuCompilationUnits +``` + +#### Field Value + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [CompilationUnit](PascalABCCompiler.CompilationUnit.md)\> + +### project + +```csharp +private ProjectInfo project +``` + +#### Field Value + + [ProjectInfo](PascalABCCompiler.ProjectInfo.md) + +### semanticTree + +```csharp +private program_node semanticTree +``` + +#### Field Value + + program\_node + +### semanticTreeConvertersController + +```csharp +private SemanticTreeConvertersController semanticTreeConvertersController +``` + +#### Field Value + + [SemanticTreeConvertersController](PascalABCCompiler.SemanticTreeConverters.SemanticTreeConvertersController.md) + +### sourceFilesProvider + +```csharp +private SourceFilesProviderDelegate sourceFilesProvider +``` + +#### Field Value + + SourceFilesProviderDelegate + +### standartAssemblyPath + +```csharp +private static string standartAssemblyPath +``` + +#### Field Value + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### standart\_assembly\_dict + +```csharp +public static Dictionary standart_assembly_dict +``` + +#### Field Value + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\> + +### state + +```csharp +private CompilerState state +``` + +#### Field Value + + [CompilerState](PascalABCCompiler.CompilerState.md) + +### supportedProjectFiles + +```csharp +private SupportedSourceFile[] supportedProjectFiles +``` + +#### Field Value + + [SupportedSourceFile](PascalABCCompiler.SupportedSourceFile.md)\[\] + +### supportedSourceFiles + +```csharp +private SupportedSourceFile[] supportedSourceFiles +``` + +#### Field Value + + [SupportedSourceFile](PascalABCCompiler.SupportedSourceFile.md)\[\] + +### unitTable + +```csharp +private CompilationUnitHashTable unitTable +``` + +#### Field Value + + [CompilationUnitHashTable](PascalABCCompiler.CompilationUnitHashTable.md) + +### varBeginOffset + +Положение первых переменных в пространстве имен основной программы + +```csharp +public int varBeginOffset +``` + +#### Field Value + + [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### warnings + +```csharp +private List warnings +``` + +#### Field Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +## Properties + +### Banner + +```csharp +public static string Banner { get; } +``` + +#### Property Value + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### BeginOffset + +```csharp +public int BeginOffset { get; } +``` + +#### Property Value + + [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### ClearAfterCompilation + +```csharp +public bool ClearAfterCompilation { get; set; } +``` + +#### Property Value + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### CompilerOptions + +```csharp +public CompilerOptions CompilerOptions { get; set; } +``` + +#### Property Value + + [CompilerOptions](PascalABCCompiler.CompilerOptions.md) + +### CompilerType + +```csharp +public CompilerType CompilerType { get; } +``` + +#### Property Value + + [CompilerType](PascalABCCompiler.CompilerType.md) + +### ErrorsList + +```csharp +public List ErrorsList { get; } +``` + +#### Property Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### GetUnitFileNameCache + +```csharp +public Dictionary, string> GetUnitFileNameCache { get; } +``` + +#### Property Value + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[Tuple](https://learn.microsoft.com/dotnet/api/system.tuple\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>, [string](https://learn.microsoft.com/dotnet/api/system.string)\> + +### InternalDebug + +```csharp +public CompilerInternalDebug InternalDebug { get; set; } +``` + +#### Property Value + + [CompilerInternalDebug](PascalABCCompiler.CompilerInternalDebug.md) + +### LanguageProvider + +```csharp +private LanguageProvider LanguageProvider { get; } +``` + +#### Property Value + + LanguageProvider + +### LinesCompiled + +```csharp +public uint LinesCompiled { get; } +``` + +#### Property Value + + [uint](https://learn.microsoft.com/dotnet/api/system.uint32) + +### PABCCodeHealth + +Здоровье кода на всякий случай выносим в интерфейс компилятора +Реально оно будет использоваться только при запуске из под оболочки (Remote Compiler) + +```csharp +public int PABCCodeHealth { get; } +``` + +#### Property Value + + [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### PCUFileNamesDictionary + +```csharp +public Dictionary, Tuple> PCUFileNamesDictionary { get; } +``` + +#### Property Value + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[Tuple](https://learn.microsoft.com/dotnet/api/system.tuple\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>, [Tuple](https://learn.microsoft.com/dotnet/api/system.tuple\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [int](https://learn.microsoft.com/dotnet/api/system.int32)\>\> + +### SemanticTree + +```csharp +public IProgramNode SemanticTree { get; } +``` + +#### Property Value + + IProgramNode + +### SemanticTreeConvertersController + +```csharp +public SemanticTreeConvertersController SemanticTreeConvertersController { get; } +``` + +#### Property Value + + [SemanticTreeConvertersController](PascalABCCompiler.SemanticTreeConverters.SemanticTreeConvertersController.md) + +### ShortVersion + +```csharp +public static string ShortVersion { get; } +``` + +#### Property Value + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### SourceFileNamesDictionary + +```csharp +public Dictionary, Tuple> SourceFileNamesDictionary { get; } +``` + +#### Property Value + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[Tuple](https://learn.microsoft.com/dotnet/api/system.tuple\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [string](https://learn.microsoft.com/dotnet/api/system.string)\>, [Tuple](https://learn.microsoft.com/dotnet/api/system.tuple\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [int](https://learn.microsoft.com/dotnet/api/system.int32)\>\> + +### SourceFilesProvider + +```csharp +public SourceFilesProviderDelegate SourceFilesProvider { get; } +``` + +#### Property Value + + SourceFilesProviderDelegate + +### State + +```csharp +public CompilerState State { get; } +``` + +#### Property Value + + [CompilerState](PascalABCCompiler.CompilerState.md) + +### SupportedProjectFiles + +```csharp +public SupportedSourceFile[] SupportedProjectFiles { get; } +``` + +#### Property Value + + [SupportedSourceFile](PascalABCCompiler.SupportedSourceFile.md)\[\] + +### SupportedSourceFiles + +```csharp +public SupportedSourceFile[] SupportedSourceFiles { get; set; } +``` + +#### Property Value + + [SupportedSourceFile](PascalABCCompiler.SupportedSourceFile.md)\[\] + +### UnitTable + +```csharp +public CompilationUnitHashTable UnitTable { get; } +``` + +#### Property Value + + [CompilationUnitHashTable](PascalABCCompiler.CompilationUnitHashTable.md) + +### VarBeginOffset + +```csharp +public int VarBeginOffset { get; } +``` + +#### Property Value + + [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### Version + +```csharp +public static string Version { get; } +``` + +#### Property Value + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### VersionDateTime + +```csharp +public static DateTime VersionDateTime { get; } +``` + +#### Property Value + + [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) + +### Warnings + +```csharp +public List Warnings { get; } +``` + +#### Property Value + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +## Methods + +### AddCodeGenerationErrorToErrorList\(Exception\) + +```csharp +private void AddCodeGenerationErrorToErrorList(Exception err) +``` + +#### Parameters + +`err` [Exception](https://learn.microsoft.com/dotnet/api/system.exception) + +### AddCurrentUnitAndItsReferencesToUsesLists\(unit\_node\_list, Dictionary, unit\_or\_namespace, CompilationUnit, unit\_node\_list\) + +```csharp +private void AddCurrentUnitAndItsReferencesToUsesLists(unit_node_list unitsFromUsesSection, Dictionary directUnitsFromUsesSection, unit_or_namespace currentUnitNode, CompilationUnit currentUnit, unit_node_list references) +``` + +#### Parameters + +`unitsFromUsesSection` unit\_node\_list + +`directUnitsFromUsesSection` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +`currentUnitNode` unit\_or\_namespace + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`references` unit\_node\_list + +### AddDeclarationsAndReferencedUnitsToNamespaces\(List, string, unit\_module, syntax\_namespace\_node\) + +```csharp +private void AddDeclarationsAndReferencedUnitsToNamespaces(List namespace_modules, string file, unit_module unitModule, syntax_namespace_node namespaceNode) +``` + +#### Parameters + +`namespace_modules` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`file` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`unitModule` unit\_module + +`namespaceNode` syntax\_namespace\_node + +### AddDocumentationToNodes\(CompilationUnit, string\) + +```csharp +private Dictionary AddDocumentationToNodes(CompilationUnit currentUnit, string text) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`text` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +### AddErrorToErrorListConsideringPosition\(Error\) + +```csharp +private void AddErrorToErrorListConsideringPosition(Error err) +``` + +#### Parameters + +`err` Error + +### AddInternalErrorToErrorList\(CompilerInternalError\) + +```csharp +private void AddInternalErrorToErrorList(CompilerInternalError internalError) +``` + +#### Parameters + +`internalError` CompilerInternalError + +### AddNamespacesToMainDefinitions\(unit\_module, program\_module, Dictionary\) + +```csharp +private void AddNamespacesToMainDefinitions(unit_module mainLibrary, program_module main_program, Dictionary namespaces) +``` + +#### Parameters + +`mainLibrary` unit\_module + +`main_program` program\_module + +`namespaces` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), syntax\_namespace\_node\> + +### AddNamespacesToMainUsesList\(unit\_module, program\_module, List\) + +```csharp +private void AddNamespacesToMainUsesList(unit_module mainLibrary, program_module main_program, List namespaceModules) +``` + +#### Parameters + +`mainLibrary` unit\_module + +`main_program` program\_module + +`namespaceModules` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### AddNamespacesToUsingList\(using\_namespace\_list, List, bool, Dictionary\) + +```csharp +public void AddNamespacesToUsingList(using_namespace_list usingList, List possibleNamespaces, bool mightContainUnits, Dictionary namespaces) +``` + +#### Parameters + +`usingList` using\_namespace\_list + +`possibleNamespaces` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`mightContainUnits` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +`namespaces` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), syntax\_namespace\_node\> + +### AddNamespacesToUsingList\(using\_namespace\_list, using\_list\) + +```csharp +public void AddNamespacesToUsingList(using_namespace_list using_list, using_list ul) +``` + +#### Parameters + +`using_list` using\_namespace\_list + +`ul` using\_list + +### AddReferencesToNetSystemLibraries\(CompilationUnit, List\) + +Добавляет ссылки на стандартные системные dll .NET - версия с директивами уровня семантики + +```csharp +private void AddReferencesToNetSystemLibraries(CompilationUnit compilationUnit, List directives) +``` + +#### Parameters + +`compilationUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`directives` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### AddReferencesToNetSystemLibraries\(CompilationUnit, List\) + +Добавляет ссылки на стандартные системные dll .NET - версия с директивами уровня синтаксиса + +```csharp +private void AddReferencesToNetSystemLibraries(CompilationUnit compilationUnit, List directives) +``` + +#### Parameters + +`compilationUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`directives` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### AddStandardUnitsToInterfaceUsesSection\(CompilationUnit\) + +```csharp +public void AddStandardUnitsToInterfaceUsesSection(CompilationUnit currentUnit) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### AddWarnings\(List\) + +```csharp +public void AddWarnings(List WarningList) +``` + +#### Parameters + +`WarningList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### AsyncClosePCUWriters\(\) + +```csharp +private void AsyncClosePCUWriters() +``` + +### CalculateLinesCompiled\(List, compilation\_unit\) + +```csharp +private void CalculateLinesCompiled(List errorList, compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`errorList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`unitSyntaxTree` compilation\_unit + +### CalculatePascalProgramHealth\(compilation\_unit\) + +```csharp +private void CalculatePascalProgramHealth(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +### ChangeCompilerStateEvent\(ICompiler, CompilerState, string\) + +```csharp +private void ChangeCompilerStateEvent(ICompiler sender, CompilerState State, string FileName) +``` + +#### Parameters + +`sender` [ICompiler](PascalABCCompiler.ICompiler.md) + +`State` [CompilerState](PascalABCCompiler.CompilerState.md) + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +### CheckErrorsAndThrowTheFirstOne\(\) + +```csharp +private void CheckErrorsAndThrowTheFirstOne() +``` + +### CheckForDuplicatesInUsesSection\(List\) + +Бросает ошибку если находит дупликаты в секции uses + +```csharp +private void CheckForDuplicatesInUsesSection(List usesList) +``` + +#### Parameters + +`usesList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### CheckForRTLErrorsAndClearAllErrorsIfFound\(\) + +```csharp +private bool CheckForRTLErrorsAndClearAllErrorsIfFound() +``` + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### CheckPathValid\(string\) + +```csharp +public static bool CheckPathValid(string path) +``` + +#### Parameters + +`path` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### ClearAll\(bool\) + +```csharp +public void ClearAll(bool close_pcu = true) +``` + +#### Parameters + +`close_pcu` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### ClosePCUReadersAndWriters\(\) + +```csharp +private void ClosePCUReadersAndWriters() +``` + +### ClosePCUWriters\(\) + +```csharp +private void ClosePCUWriters() +``` + +### CombinePathsRelatively\(string, string\) + +```csharp +public static string CombinePathsRelatively(string path1, string path2) +``` + +#### Parameters + +`path1` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`path2` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### Compile\(CompilerOptions\) + +```csharp +public string Compile(CompilerOptions CompilerOptions) +``` + +#### Parameters + +`CompilerOptions` [CompilerOptions](PascalABCCompiler.CompilerOptions.md) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### Compile\(\) + +```csharp +public string Compile() +``` + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### CompileCS\(\) + +```csharp +public string CompileCS() +``` + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### CompileCurrentUnitImplementation\(string, CompilationUnit, Dictionary\) + +```csharp +private void CompileCurrentUnitImplementation(string UnitFileName, CompilationUnit currentUnit, Dictionary docs) +``` + +#### Parameters + +`UnitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`docs` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +### CompileCurrentUnitInterface\(string, CompilationUnit, Dictionary\) + +```csharp +private void CompileCurrentUnitInterface(string UnitFileName, CompilationUnit currentUnit, Dictionary docs) +``` + +#### Parameters + +`UnitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`docs` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +### CompileImplementationDependencies\(string, CompilationUnit, List, Dictionary, common\_unit\_node, out bool\) + +Компилирует модули из секции uses текущего модуля реализации рекурсивно + +```csharp +private void CompileImplementationDependencies(string currentPath, CompilationUnit currentUnit, List implementationUsesList, Dictionary namespaces, common_unit_node commonUnitNode, out bool shouldReturnCurrentUnit) +``` + +#### Parameters + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`implementationUsesList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`namespaces` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), syntax\_namespace\_node\> + +`commonUnitNode` common\_unit\_node + +`shouldReturnCurrentUnit` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### CompileInterfaceDependencies\(unit\_node\_list, Dictionary, unit\_or\_namespace, string, string, CompilationUnit, List, unit\_node\_list, Dictionary, out bool\) + +Компилирует модули из секции uses интерфейса текущего модуля рекурсивно + +```csharp +private void CompileInterfaceDependencies(unit_node_list unitsFromUsesSection, Dictionary directUnitsFromUsesSection, unit_or_namespace currentUnitNode, string unitFileName, string currentPath, CompilationUnit currentUnit, List interfaceUsesList, unit_node_list references, Dictionary namespaces, out bool shouldReturnCurrentUnit) +``` + +#### Parameters + +`unitsFromUsesSection` unit\_node\_list + +`directUnitsFromUsesSection` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +`currentUnitNode` unit\_or\_namespace + +`unitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`interfaceUsesList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`references` unit\_node\_list + +`namespaces` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), syntax\_namespace\_node\> + +`shouldReturnCurrentUnit` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +#### Exceptions + + [CycleUnitReference](PascalABCCompiler.Errors.CycleUnitReference.md) + +### CompileReference\(unit\_node\_list, compiler\_directive\) + +```csharp +private CompilationUnit CompileReference(unit_node_list dlls, compiler_directive reference) +``` + +#### Parameters + +`dlls` unit\_node\_list + +`reference` compiler\_directive + +#### Returns + + [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### CompileUnit\(unit\_node\_list, Dictionary, unit\_or\_namespace, string\) + +Компилирует основную программу и все используемые ей юниты рекурсивно + +```csharp +public CompilationUnit CompileUnit(unit_node_list unitsFromUsesSection, Dictionary directUnitsFromUsesSection, unit_or_namespace currentUnitNode, string previousPath) +``` + +#### Parameters + +`unitsFromUsesSection` unit\_node\_list + +Вспомогательная переменная для заполнения CompilationUnit.interfaceUsedUnits и + CompilationUnit.implementationUsedUnits (здесь могут содержаться юниты и dll) + +`directUnitsFromUsesSection` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +Вспомогательная переменная для заполнения CompilationUnit.interfaceUsedDirectUnits и + CompilationUnit.implementationUsedDirectUnits + +`currentUnitNode` unit\_or\_namespace + +Синтаксический узел текущего модуля (или пространства имен) + +`previousPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +Директория родительского модуля + +#### Returns + + [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +Скомпилированный юнит + +### CompileUnitsFromDelayedList\(\) + +```csharp +private void CompileUnitsFromDelayedList() +``` + +### ConstructMainSemanticTree\(CompilerOptions\) + +```csharp +private program_node ConstructMainSemanticTree(CompilerOptions compilerOptions) +``` + +#### Parameters + +`compilerOptions` CompilerOptions + +#### Returns + + program\_node + +### ConstructSyntaxTree\(string, CompilationUnit, string\) + +```csharp +private compilation_unit ConstructSyntaxTree(string unitFileName, CompilationUnit currentUnit, string sourceText) +``` + +#### Parameters + +`unitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`sourceText` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + compilation\_unit + +### ConstructSyntaxTreeAndRunSugarConversions\(string, CompilationUnit, out Dictionary\) + +Строит синтаксическое дерево, бросает первую из найденных ошибок (если они есть) и запускает сахарные преобразования + +```csharp +private void ConstructSyntaxTreeAndRunSugarConversions(string unitFileName, CompilationUnit currentUnit, out Dictionary docs) +``` + +#### Parameters + +`unitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`docs` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +### ConvertSyntaxTree\(compilation\_unit, List\) + +```csharp +private compilation_unit ConvertSyntaxTree(compilation_unit syntaxTree, List converters) +``` + +#### Parameters + +`syntaxTree` compilation\_unit + +`converters` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +#### Returns + + compilation\_unit + +### CreateDependencyListsForCurrentUnit\(CompilationUnit, string, out List, out unit\_node\_list, out Dictionary\) + +```csharp +private void CreateDependencyListsForCurrentUnit(CompilationUnit currentUnit, string currentDirectory, out List interfaceUsesList, out unit_node_list references, out Dictionary namespaces) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`currentDirectory` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`interfaceUsesList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`references` unit\_node\_list + +`namespaces` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), syntax\_namespace\_node\> + +### CurrentUnitIsNotMainProgram\(\) + +Возвращает true, если текущий компилируемый модуль не является основной программой (program_module) + +```csharp +private bool CurrentUnitIsNotMainProgram() +``` + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### DebugOutputFileCreationUsingPDB\(\) + +```csharp +private void DebugOutputFileCreationUsingPDB() +``` + +### DisablePABCRtlIfUsingDotnet5\(List\) + +```csharp +private void DisablePABCRtlIfUsingDotnet5(List directives) +``` + +#### Parameters + +`directives` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### FillNetCompilerOptionsFromCompilerDirectives\(CompilerOptions, Dictionary\>\) + +```csharp +private void FillNetCompilerOptionsFromCompilerDirectives(CompilerOptions netCompilerOptions, Dictionary> compilerDirectives) +``` + +#### Parameters + +`netCompilerOptions` CompilerOptions + +`compilerDirectives` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)\> + +### FillNetCompilerOptionsFromProject\(CompilerOptions\) + +```csharp +private void FillNetCompilerOptionsFromProject(CompilerOptions netCompilerOptions) +``` + +#### Parameters + +`netCompilerOptions` CompilerOptions + +### FindFileWithExtensionInDirs\(string, out int, params string\[\]\) + +```csharp +private string FindFileWithExtensionInDirs(string fileName, out int foundDirIndex, params string[] dirs) +``` + +#### Parameters + +`fileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`foundDirIndex` [int](https://learn.microsoft.com/dotnet/api/system.int32) + +`dirs` [string](https://learn.microsoft.com/dotnet/api/system.string)\[\] + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### FindPCUFileName\(string, string, out int\) + +```csharp +public string FindPCUFileName(string fileName, string currentPath, out int folderPriority) +``` + +#### Parameters + +`fileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`folderPriority` [int](https://learn.microsoft.com/dotnet/api/system.int32) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### FindPositionForSemanticErrorInTheErrorList\(Error\) + +```csharp +private int FindPositionForSemanticErrorInTheErrorList(Error err) +``` + +#### Parameters + +`err` Error + +#### Returns + + [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### FindSourceFileName\(string, string, out int\) + +```csharp +public string FindSourceFileName(string fileName, string currentPath, out int folderPriority) +``` + +#### Parameters + +`fileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`folderPriority` [int](https://learn.microsoft.com/dotnet/api/system.int32) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### FindSourceFileNameInDirs\(string, out int, params string\[\]\) + +```csharp +public string FindSourceFileNameInDirs(string fileName, out int foundDirIndex, params string[] Dirs) +``` + +#### Parameters + +`fileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`foundDirIndex` [int](https://learn.microsoft.com/dotnet/api/system.int32) + +`Dirs` [string](https://learn.microsoft.com/dotnet/api/system.string)\[\] + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### Free\(\) + +```csharp +public void Free() +``` + +### GenUnitDocumentation\(CompilationUnit, string\) + +```csharp +private Dictionary GenUnitDocumentation(CompilationUnit currentUnit, string SourceText) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`SourceText` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +### GenerateILCode\(program\_node, CompilerOptions, List\) + +```csharp +private void GenerateILCode(program_node programNode, CompilerOptions compilerOptions, List resourceFiles) +``` + +#### Parameters + +`programNode` program\_node + +`compilerOptions` CompilerOptions + +`resourceFiles` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\> + +### GetCompilerDirectives\(List\) + +Формирует словарь директив компилятора, собирая их из всех переданных модулей + +```csharp +private Dictionary> GetCompilerDirectives(List Units) +``` + +#### Parameters + +`Units` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[CompilationUnit](PascalABCCompiler.CompilationUnit.md)\> + +#### Returns + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)\> + +#### Exceptions + + [DuplicateDirective](PascalABCCompiler.Errors.DuplicateDirective.md) + +### GetDirectivesAsSemanticNodes\(List, string\) + +преобразует в директивы семантического уровня | в syntax_tree_visitor такая же функция EVA + +```csharp +private List GetDirectivesAsSemanticNodes(List compilerDirectives, string unitFileName) +``` + +#### Parameters + +`compilerDirectives` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`unitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### GetImplementationSyntaxUsingList\(compilation\_unit\) + +получение списка using - legacy code !!! + +```csharp +private using_list GetImplementationSyntaxUsingList(compilation_unit cu) +``` + +#### Parameters + +`cu` compilation\_unit + +#### Returns + + using\_list + +### GetImplementationUsesSection\(compilation\_unit\) + +```csharp +private List GetImplementationUsesSection(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +#### Returns + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### GetIncludedFilesFromDirectives\(CompilationUnit, List\) + +```csharp +private static List GetIncludedFilesFromDirectives(CompilationUnit compilationUnit, List directives) +``` + +#### Parameters + +`compilationUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`directives` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +#### Returns + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\> + +### GetInterfaceUsesSection\(compilation\_unit\) + +Возвращает список зависимостей из интерфейсной части модуля (или основной программы) + +```csharp +public List GetInterfaceUsesSection(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +#### Returns + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +### GetInterfaceUsingList\(compilation\_unit\) + +получение списка using - legacy code !!! + +```csharp +public using_list GetInterfaceUsingList(compilation_unit cu) +``` + +#### Parameters + +`cu` compilation\_unit + +#### Returns + + using\_list + +### GetLocationFromTreenode\(syntax\_tree\_node, string\) + +```csharp +private location GetLocationFromTreenode(syntax_tree_node tn, string FileName) +``` + +#### Parameters + +`tn` syntax\_tree\_node + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + location + +### GetNamespace\(unit\_or\_namespace\) + +```csharp +public using_namespace GetNamespace(unit_or_namespace _name_space) +``` + +#### Parameters + +`_name_space` unit\_or\_namespace + +#### Returns + + using\_namespace + +### GetNamespace\(using\_namespace\_list, string, unit\_or\_namespace, bool, Dictionary\) + +Формирует узел семантического дерева, соответствующий пространству имен (.NET или пользовательскому) + +```csharp +private using_namespace GetNamespace(using_namespace_list usingList, string fullNamespaceName, unit_or_namespace name_space, bool mightBeUnit, Dictionary namespaces) +``` + +#### Parameters + +`usingList` using\_namespace\_list + +`fullNamespaceName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`name_space` unit\_or\_namespace + +`mightBeUnit` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +`namespaces` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), syntax\_namespace\_node\> + +#### Returns + + using\_namespace + +#### Exceptions + + [UnitNotFound](PascalABCCompiler.Errors.UnitNotFound.md) + + NamespaceNotFound + +### GetNamespaceSyntaxTree\(string\) + +```csharp +private compilation_unit GetNamespaceSyntaxTree(string fileName) +``` + +#### Parameters + +`fileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + compilation\_unit + +### GetReferenceFileName\(string, string\) + +```csharp +public static string GetReferenceFileName(string FileName, string curr_path = null) +``` + +#### Parameters + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`curr_path` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### GetReferenceFileName\(string, SourceContext, string, bool\) + +```csharp +private string GetReferenceFileName(string FileName, SourceContext sc, string curr_path, bool overwrite) +``` + +#### Parameters + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`sc` SourceContext + +`curr_path` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`overwrite` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### GetReferences\(CompilationUnit\) + +```csharp +public unit_node_list GetReferences(CompilationUnit compilationUnit) +``` + +#### Parameters + +`compilationUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +#### Returns + + unit\_node\_list + +### GetResourceFilesFromCompilerDirectives\(Dictionary\>\) + +```csharp +private List GetResourceFilesFromCompilerDirectives(Dictionary> compilerDirectives) +``` + +#### Parameters + +`compilerDirectives` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)\> + +#### Returns + + [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\> + +### GetSourceCode\(string, CompilationUnit\) + +```csharp +private string GetSourceCode(string UnitFileName, CompilationUnit currentUnit) +``` + +#### Parameters + +`UnitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### GetSourceContext\(compiler\_directive\) + +```csharp +private SourceContext GetSourceContext(compiler_directive directive) +``` + +#### Parameters + +`directive` compiler\_directive + +#### Returns + + SourceContext + +### GetSourceFileText\(string\) + +```csharp +public string GetSourceFileText(string FileName) +``` + +#### Parameters + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### GetUnitFileName\(unit\_or\_namespace, string\) + +```csharp +public string GetUnitFileName(unit_or_namespace unitNode, string currentPath) +``` + +#### Parameters + +`unitNode` unit\_or\_namespace + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### GetUnitFileName\(string, string, string, SourceContext\) + +```csharp +public string GetUnitFileName(string unitName, string usesPath, string currentPath, SourceContext sourceContext) +``` + +#### Parameters + +`unitName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`usesPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`sourceContext` SourceContext + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### GetUnitPath\(CompilationUnit, CompilationUnit\) + +```csharp +public static string GetUnitPath(CompilationUnit u1, CompilationUnit u2) +``` + +#### Parameters + +`u1` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`u2` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### HasIncludeNamespaceDirective\(CompilationUnit\) + +```csharp +private bool HasIncludeNamespaceDirective(CompilationUnit unit) +``` + +#### Parameters + +`unit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### HasOnlySyntaxErrors\(List\) + +```csharp +private bool HasOnlySyntaxErrors(List errors) +``` + +#### Parameters + +`errors` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### InitializeCompilerOptionsRelatedToStandardUnits\(compilation\_unit\) + +Устанавливает значения опций DisableStandardUnits и UseDllForSystemUnits + +```csharp +private void InitializeCompilerOptionsRelatedToStandardUnits(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +### InitializeNewUnit\(string, string, ref CompilationUnit, out Dictionary\) + +Получение исходного кода модуля, заполнение документации, +генерация синтаксического дерева, +обработка синтаксических ошибок + +```csharp +private void InitializeNewUnit(string unitFileName, string UnitId, ref CompilationUnit currentUnit, out Dictionary docs) +``` + +#### Parameters + +`unitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`UnitId` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`docs` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +### InitializeProjectInfoAndFillCompilerOptionsFromIt\(\) + +```csharp +private void InitializeProjectInfoAndFillCompilerOptionsFromIt() +``` + +### InternalParseText\(ILanguage, string, string, List, List, List, bool\) + +```csharp +private compilation_unit InternalParseText(ILanguage language, string fileName, string text, List errorList, List warnings, List definesList = null, bool calculateHealth = true) +``` + +#### Parameters + +`language` ILanguage + +`fileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`text` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`errorList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`warnings` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`definesList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\> + +`calculateHealth` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +#### Returns + + compilation\_unit + +### IsDll\(compilation\_unit\) + +Проверяет, является ли модуль dll по соответствующей директиве + +```csharp +public static bool IsDll(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### IsDll\(compilation\_unit, out compiler\_directive\) + +Проверяет, является ли модуль dll по соответствующей директиве и возвращает эту директиву выходным параметром + +```csharp +public static bool IsDll(compilation_unit unitSyntaxTree, out compiler_directive dllDirective) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +`dllDirective` compiler\_directive + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### IsDocumentationNeeded\(compilation\_unit\) + +```csharp +private bool IsDocumentationNeeded(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### IsPossibleNetNamespaceOrStandardPasFile\(unit\_or\_namespace, bool, string\) + +```csharp +private bool IsPossibleNetNamespaceOrStandardPasFile(unit_or_namespace name_space, bool addToStandardModules, string currentPath) +``` + +#### Parameters + +`name_space` unit\_or\_namespace + +`addToStandardModules` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### MatchSyntaxErrorsToBadNodes\(CompilationUnit\) + +```csharp +private void MatchSyntaxErrorsToBadNodes(CompilationUnit currentUnit) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### NeedRecompiled\(string, string\[\], PCUReader\) + +```csharp +public bool NeedRecompiled(string pcu_name, string[] included, PCUReader pr) +``` + +#### Parameters + +`pcu_name` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`included` [string](https://learn.microsoft.com/dotnet/api/system.string)\[\] + +`pr` [PCUReader](PascalABCCompiler.PCU.PCUReader.md) + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### ParseText\(string, string, List, List\) + +```csharp +public compilation_unit ParseText(string fileName, string text, List errorList, List warnings) +``` + +#### Parameters + +`fileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`text` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`errorList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`warnings` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +#### Returns + + compilation\_unit + +### PrebuildMainSemanticTreeActions\(out CompilerOptions, out List\) + +Сохраняет документацию для модулей; +Выясняет тип выходного файла, целевой фреймворк, платформу; +Заполняет опции .NET компиляции согласно директивам и/или информации из проекта; +Находит ресурсные файлы из директив + +```csharp +private void PrebuildMainSemanticTreeActions(out CompilerOptions netCompilerOptions, out List resourceFiles) +``` + +#### Parameters + +`netCompilerOptions` CompilerOptions + +`resourceFiles` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)<[string](https://learn.microsoft.com/dotnet/api/system.string)\> + +### PreloadReference\(compiler\_directive\) + +```csharp +private Assembly PreloadReference(compiler_directive reference) +``` + +#### Parameters + +`reference` compiler\_directive + +#### Returns + + [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly) + +### PrepareFinalMainFunctionForExe\(program\_node\) + +```csharp +public void PrepareFinalMainFunctionForExe(program_node mainSemanticTree) +``` + +#### Parameters + +`mainSemanticTree` program\_node + +### PrepareUserNamespacesUsedInTheCurrentUnit\(CompilationUnit\) + +```csharp +private Dictionary PrepareUserNamespacesUsedInTheCurrentUnit(CompilationUnit compilationUnit) +``` + +#### Parameters + +`compilationUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +#### Returns + + [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), syntax\_namespace\_node\> + +### ReadDLL\(string, SourceContext\) + +```csharp +public CompilationUnit ReadDLL(string FileName, SourceContext sc = null) +``` + +#### Parameters + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`sc` SourceContext + +#### Returns + + [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### ReadPCU\(string\) + +```csharp +public CompilationUnit ReadPCU(string FileName) +``` + +#### Parameters + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### Reload\(\) + +```csharp +public void Reload() +``` + +### Reset\(\) + +```csharp +private void Reset() +``` + +### RunSemanticChecks\(string, CompilationUnit\) + +Семантические проверки по директивам и по типу файла + +```csharp +private void RunSemanticChecks(string unitFileName, CompilationUnit currentUnit) +``` + +#### Parameters + +`unitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### SaveDocumentationsForUnits\(\) + +```csharp +private void SaveDocumentationsForUnits() +``` + +### SavePCU\(CompilationUnit\) + +```csharp +public void SavePCU(CompilationUnit Unit) +``` + +#### Parameters + +`Unit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### SaveUnitCheckInParsers\(\) + +Передаем парсерам возможность проверить, компилируется ли в данный момент модуль +(нужно, если нет ключевого слова unit или подобного в языке) + +```csharp +private void SaveUnitCheckInParsers() +``` + +### SemanticCheckCurrentUnitMustBeUnitModule\(string, CompilationUnit, bool\) + +```csharp +private void SemanticCheckCurrentUnitMustBeUnitModule(string UnitFileName, CompilationUnit currentUnit, bool isDll) +``` + +#### Parameters + +`UnitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`isDll` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### SemanticCheckDLLDirectiveOnlyForLibraries\(compilation\_unit, bool, compiler\_directive\) + +Проверка, что директива dll только в Library - требует передачи директивы dll + +```csharp +private void SemanticCheckDLLDirectiveOnlyForLibraries(compilation_unit unitSyntaxTree, bool isDll, compiler_directive dllDirective) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +`isDll` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +`dllDirective` compiler\_directive + +### SemanticCheckDisableStandardUnitsDirectiveInUnit\(compilation\_unit\) + +Ошибка указания директивы DisableStandardUnits в подключенном модулей + +```csharp +private void SemanticCheckDisableStandardUnitsDirectiveInUnit(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +### SemanticCheckIsUserNamespace\(compilation\_unit\) + +```csharp +private void SemanticCheckIsUserNamespace(compilation_unit unitSyntaxTree) +``` + +#### Parameters + +`unitSyntaxTree` compilation\_unit + +### SemanticCheckNamespacesOnlyInProjects\(CompilationUnit\) + +```csharp +private void SemanticCheckNamespacesOnlyInProjects(CompilationUnit currentUnit) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### SemanticCheckNoIncludeNamespaceDirectivesInUnit\(CompilationUnit\) + +```csharp +private void SemanticCheckNoIncludeNamespaceDirectivesInUnit(CompilationUnit currentUnit) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### SemanticCheckNoLoopDependenciesOfInterfaces\(CompilationUnit, string, unit\_or\_namespace, string\) + +```csharp +private void SemanticCheckNoLoopDependenciesOfInterfaces(CompilationUnit currentUnit, string unitFileName, unit_or_namespace usedUnitNode, string currentPath) +``` + +#### Parameters + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +`unitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`usedUnitNode` unit\_or\_namespace + +`currentPath` [string](https://learn.microsoft.com/dotnet/api/system.string) + +### SemanticCheckUsesInIsNotNamespace\(unit\_or\_namespace, CompilationUnit\) + +```csharp +private void SemanticCheckUsesInIsNotNamespace(unit_or_namespace currentUnitNode, CompilationUnit currentUnit) +``` + +#### Parameters + +`currentUnitNode` unit\_or\_namespace + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +### SetOutputFileTypeOption\(Dictionary\>\) + +```csharp +private void SetOutputFileTypeOption(Dictionary> compilerDirectives) +``` + +#### Parameters + +`compilerDirectives` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)\> + +### SetOutputPlatformOption\(CompilerOptions, Dictionary\>\) + +```csharp +private void SetOutputPlatformOption(CompilerOptions netCompilerOptions, Dictionary> compilerDirectives) +``` + +#### Parameters + +`netCompilerOptions` CompilerOptions + +`compilerDirectives` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2)<[string](https://learn.microsoft.com/dotnet/api/system.string), [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1)\> + +### SetSupportedProjectFiles\(\) + +```csharp +private void SetSupportedProjectFiles() +``` + +### SetSupportedSourceFiles\(\) + +```csharp +private void SetSupportedSourceFiles() +``` + +### SetTargetTypeOption\(CompilerOptions\) + +```csharp +private void SetTargetTypeOption(CompilerOptions netCompilerOptions) +``` + +#### Parameters + +`netCompilerOptions` CompilerOptions + +### SetUseDLLForSystemUnits\(string, List, int\) + +Если в программе в секции uses есть не про-во имен и не стандартный модуль, то использование PABCRtl.dll отменяется + +```csharp +private void SetUseDLLForSystemUnits(string currentDirectory, List usesList, int lastUnitIndex) +``` + +#### Parameters + +`currentDirectory` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`usesList` [List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list\-1) + +`lastUnitIndex` [int](https://learn.microsoft.com/dotnet/api/system.int32) + +### SourceFileExists\(string\) + +```csharp +private bool SourceFileExists(string FileName) +``` + +#### Parameters + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### SourceFileGetLastWriteTime\(string\) + +```csharp +private DateTime SourceFileGetLastWriteTime(string FileName) +``` + +#### Parameters + +`FileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) + +### StartCompile\(\) + +```csharp +public void StartCompile() +``` + +### ToString\(\) + +```csharp +public override string ToString() +``` + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### TryThrowInvalidPath\(string, SourceContext\) + +```csharp +public static void TryThrowInvalidPath(string path, SourceContext loc) +``` + +#### Parameters + +`path` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`loc` SourceContext + +### UnitHasPCU\(unit\_node\_list, Dictionary, unit\_or\_namespace, ref string, ref CompilationUnit\) + +```csharp +private bool UnitHasPCU(unit_node_list unitsFromUsesSection, Dictionary directUnitsFromUsesSection, unit_or_namespace currentUnitNode, ref string UnitFileName, ref CompilationUnit currentUnit) +``` + +#### Parameters + +`unitsFromUsesSection` unit\_node\_list + +`directUnitsFromUsesSection` [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary\-2) + +`currentUnitNode` unit\_or\_namespace + +`UnitFileName` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`currentUnit` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +#### Returns + + [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +### WaitCallback\_ClosePCUWriters\(object\) + +```csharp +private void WaitCallback_ClosePCUWriters(object state) +``` + +#### Parameters + +`state` [object](https://learn.microsoft.com/dotnet/api/system.object) + +### buildImplementationUsesList\(CompilationUnit\) + +```csharp +private unit_node_list buildImplementationUsesList(CompilationUnit cu) +``` + +#### Parameters + +`cu` [CompilationUnit](PascalABCCompiler.CompilationUnit.md) + +#### Returns + + unit\_node\_list + +### get\_assembly\_path\(string, bool\) + +```csharp +public static string get_assembly_path(string name, bool search_for_intellisense) +``` + +#### Parameters + +`name` [string](https://learn.microsoft.com/dotnet/api/system.string) + +`search_for_intellisense` [bool](https://learn.microsoft.com/dotnet/api/system.boolean) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### get\_standart\_assembly\_path\(string\) + +```csharp +public static string get_standart_assembly_path(string name) +``` + +#### Parameters + +`name` [string](https://learn.microsoft.com/dotnet/api/system.string) + +#### Returns + + [string](https://learn.microsoft.com/dotnet/api/system.string) + +### pr\_ChangeState\(object, PCUReaderWriterState, object\) + +```csharp +private void pr_ChangeState(object Sender, PCUReaderWriterState State, object obj) +``` + +#### Parameters + +`Sender` [object](https://learn.microsoft.com/dotnet/api/system.object) + +`State` [PCUReaderWriterState](PascalABCCompiler.PCU.PCUReaderWriterState.md) + +`obj` [object](https://learn.microsoft.com/dotnet/api/system.object) + +### semanticTreeConvertersController\_ChangeState\(State, ISemanticTreeConverter\) + +```csharp +private void semanticTreeConvertersController_ChangeState(SemanticTreeConvertersController.State State, ISemanticTreeConverter SemanticTreeConverter) +``` + +#### Parameters + +`State` [SemanticTreeConvertersController](PascalABCCompiler.SemanticTreeConverters.SemanticTreeConvertersController.md).[State](PascalABCCompiler.SemanticTreeConverters.SemanticTreeConvertersController.State.md) + +`SemanticTreeConverter` [ISemanticTreeConverter](PascalABCCompiler.SemanticTreeConverters.ISemanticTreeConverter.md) + +### OnChangeCompilerState + +```csharp +public event ChangeCompilerStateEventDelegate OnChangeCompilerState +``` + +#### Event Type + + [ChangeCompilerStateEventDelegate](PascalABCCompiler.ChangeCompilerStateEventDelegate.md) + diff --git a/documentation/Compiler/PABCRtl/PABCRtl dll.md b/documentation/Compiler/PABCRtl/PABCRtl dll.md new file mode 100644 index 000000000..f9e935858 --- /dev/null +++ b/documentation/Compiler/PABCRtl/PABCRtl dll.md @@ -0,0 +1,22 @@ + +Owner: Alexander Zemlyak +Tags: Codebase + +Dll-библиотека для ускорения времени выполнения “простых” программ без пользовательских uses (допускается использование пр-в имен и стандартных модулей Паскаля из самой RTL). Для использования требуется включить флажок *“Ускорять запуск из под оболочки”.* + +--- + +На картинке можно видеть стандартные модули из библиотеки: + +![Untitled](Untitled.png) + +--- + +> [!NOTE] Особые стандартные модули. 1-я группа +>  Некоторые стандартные модули не входят в PABCRtl.dll, поскольку она 64-битная, а они используют нативные 32-битные библиотеки. Таковыми являются модули из следующего списка: PT4, CRT, Arrays, MPI, Collections, Core. При использовании их в программе PABCRtl.dll не загружается. *2-я группа* Если стандартные модули не входят в RTL и одновременно не входят в список исключения RTL, о котором говорилось выше, то RTL загружается. Но при этом возникает ошибка компиляции и компиляция запускается заново без использования RTL. + + +> [!NOTE] Как сделано так, что при явном использовании стандартных модулей из RTL их pcu-файлы не используются? +> Стандартные модули в этом случае воспринимаются как пространства имен и даже добавляются в соответствующие списки, такие как `possibleNamespaces` (см. [[Uses lists]]). Метод `CompileUnit` для них вообще не вызывается. Конечно, хотелось бы выделить логику обработки стандартных модулей из rtl в отдельный блок кода. + + diff --git a/documentation/Compiler/PABCRtl/Untitled.png b/documentation/Compiler/PABCRtl/Untitled.png new file mode 100644 index 000000000..f9ec58e4a Binary files /dev/null and b/documentation/Compiler/PABCRtl/Untitled.png differ diff --git a/documentation/Compiler/Uses lists/Uses lists.md b/documentation/Compiler/Uses lists/Uses lists.md new file mode 100644 index 000000000..dd18d02e5 --- /dev/null +++ b/documentation/Compiler/Uses lists/Uses lists.md @@ -0,0 +1,39 @@ + +Owner: Alexander Zemlyak + +- **Получение списков зависимостей из синтаксического дерева юнита** +1. *interfaceUsesList* может содержать юниты, пространства имен .NET и явные пространства имен (узлы SyntaxTree.unit_or_namepace) +2. *references* содержит библиотеки dll (узлы TreeRealization.unit_node) +3. *namespaces* содержит явные пользовательские пространства имен, подключенные с помощью директивы {$includenamespace} (узлы SyntaxTree.syntax_namespace_node) + +```csharp +CreateDependencyListsForCurrentUnit(currentUnit, currentDirectory, out var interfaceUsesList, out var references, out var namespaces); +``` + +- **Списки зависимостей, содержащиеся в CompilationUnit** +1. *possibleNamespaces* может содержать пространства имен .NET, стандартные паскалевские юниты из папки Lib, а также явные пространства имен, если они есть в секции uses +2. *InterfaceUsedUnits* содержит все, что есть в *possibleNamespaces +* пользовательские юниты и dll, т.е., грубо говоря, все виды программных единиц, являющиеся зависимостями CompilationUnit +3. *InterfaceUsedDirectUnits* содержит только пользовательские юниты +4. *ImplementationUsedUnits* и *ImplementationUsedDirectUnits* устроены аналогично предыдущим двум + +```csharp +public class CompilationUnit +{ +... +internal List possibleNamespaces = new List(); + +public Dictionary InterfaceUsedDirectUnits { get; } = new Dictionary(); + +public unit_node_list InterfaceUsedUnits { get; } = new unit_node_list(); + +public Dictionary ImplementationUsedDirectUnits { get; } = new Dictionary(); + +public unit_node_list ImplementationUsedUnits { get; } = new unit_node_list(); +... +} +``` + + \ No newline at end of file diff --git a/documentation/Intellisense/Функции Intellisense.md b/documentation/Intellisense/Функции Intellisense.md new file mode 100644 index 000000000..e81a9f53f --- /dev/null +++ b/documentation/Intellisense/Функции Intellisense.md @@ -0,0 +1,41 @@ +#### Подсказка при наведении мыши +На верхнем уровне реализуется в классе `TooltipServiceManager`. Основная логика реализована в методе `GetPopupHintText`. Вначале вызывается `FindExpressionFromAnyPosition` для получения нужного `expression` в виде строки. +Затем вызывается нужный парсер для получения дерева выражения (используется часть грамматики, связанная с нетерминалом parts). Если не получается распарсить, то делается попытка с решением неоднозначности, связанной с шаблонными параметрами (&<). +После этого еще попытка с удалением разыменования, пока непонятно зачем это. +Еще удаление разыменования было найдено в методе `GetDefinitionPosition` из `CodeCompletionActions`. +Затем еще попытка с тем же выражением без скобочек. При этом, если без скобочек распарсить не удается, то вне зависимости от успешности парсинга полного `expression` возвращается `null`. +В конце проверяется был ли успешен обход дерева программы визитором (`DomSyntaxTreeVisitor`). Если это так, то в словаре откомпилированных модулей будет данный модуль и соответствующий ему `DomConverter`. +Тогда мы сможем вызвать метод `GetDescription` из этого класса, который выдаст нам описание выражения. + +#### Подсказка параметров функции +На нажатие клавиш (скобки, квадратной скобки или запятой) реагирует `TextAreaKeyEventHandler` из класса `CodeCompletionKeyHandler`. Там создается экземпляр `DefaultInsightDataProvider`, который загружается в стек провайдеров. Информация для подсказки формируется в методе `SetupDataProvider` инсайт-провайдера. После выяснения кода на текущей подстроке вызывается `FindExpressionForMethod` из `LanguageInformation`. +Далее делается попытка парсинга стандартным парсером языка и наконец из `DomConverter` вызывается `GetNameOfMethod`, либо `GetIndex` в зависимости от нажатой клавиши. + +#### Подсказка по нажатию клавиш (по точке или пробелу) +`CodeCompletionKeyHandler` реагирует на нажатие вызовом метода `ShowCompletionWindow`. В нем есть обращение к `GenerateCompletionDataWithKeyword` из класса `CodeCompletionProvider`. В этом методе выделяется нужная подстрока и есть обращение к методу `GetCompletionData`. +**Логика этого метода следующая:** +1) если был нажат `ctrl + space` (`shift + space` входит в это понятие тоже) +Вызывается `FindPattern` из `LanguageInformation` для получения "токена" до каретки. Если в процессе встретится точка, то вызывается `FindExpression`. Ниже если pattern пустой, то в итоговый список `ICompletionData` добавляются ключевые слова языка. +2) если был нажат пробел после `new` +Вызывается SkipNew для пропуска `new` и поиска expression перед ним. +3) иначе, если не было введено `uses` +вызывается `FindExpression` (c текущей позиции) + +Далее, если [**не** `ctrl + space` или была найдена цепочка имен в выражении] и выражение не пусто, то делается попытка вызова функции `GetTypeAsExpression` стандартного парсера. Если это ничего не дало далее попытка вызова `GetExpression`. Если снова ничего не удалось и мы не в случае пробела после `new`, то возврат. + +Далее, если Intellisense успешно не обошла текущий модуль, то для случая `uses` мы будем рассматривать SymInfo стандартных модулей (взятых из DomConverter). Если же у нас не `uses`случай и не случай ctrl + space, мы возвращаем пустой массив. + +Иначе, если у нас есть `DomConverter`: + - Если пробел после `new`, то вызываем `GetTypes` + - Иначе, если `uses`, то работаем со списком стандартных модулей + пр-в имен в случае семантического Intellisense. + - Иначе, если не `ctrl + space` (случай, когда мы поставили точку), то вызываем `GetName` для получения всех возможных имен после точки + - Иначе, если `ctrl + space`, то либо ищем имена после точки - `GetName` (если точка была раньше), либо ищем имя по его началу - `GetNameByPattern` + + +> [!NOTE] Замечание +>Также на нажатие реагирует Execute из CodeCompletionAllNamesAction. key подменяется на доллар если это было нажатие `ctrl + space` сразу после точки. + +В конце по полученным SymInfo строится результирующий список CompletionData (без повторений). + +#### Переход к определению символа +В `CodeCompletionActoins` есть специальный класс GotoAction, в котором вызывается метод `GoToDefinition`. В этом методе используется метод GetDefinitionPosition, который в свою очередь (тоже косвенно) использует `FindExpressionFromAnyPosition` из `LanguageInformation` и `GetDefinition` из `CodeCompletionProvider`. Последний вышеупомянутый метод является оберткой на `GetDefinition` из DomConverter. \ No newline at end of file