From 4760aa02d737afee491811ccb3d38a62a4b9b10f Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Sat, 17 Jan 2026 23:26:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B5=D0=B7=D0=B4=D0=B5=20=D0=B2=20locat?= =?UTF-8?q?ion=20=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20document=20-=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20=D0=B5=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BD=D0=B5=D0=BF=D0=BE=D1=81=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D0=B5=D0=BD=D0=BD=D0=BE=20file=5Fname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CodeCompletion/DomConverter.cs | 10 ++-- CodeCompletion/DomSyntaxTreeVisitor.cs | 20 +++---- CodeCompletion/SymTable.cs | 24 ++++----- Compiler/Compiler.cs | 10 ++-- Compiler/PCU/PCUReader.cs | 14 ++--- Compiler/PCU/PCUWriter.cs | 2 +- Compiler/RemoteCompiler.cs | 6 +-- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- Errors/BaseErrors.cs | 2 +- NETGenerator/NETGenerator.cs | 54 +++++++++---------- Optimizer/Warnings.cs | 2 +- Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- SemanticTree/SemanticTree.cs | 2 +- TreeConverter/OpenMP/OpenMP.cs | 12 ++--- .../TreeConversion/CompilationErrors.cs | 6 +-- .../TreeConversion/CompilationWarnings.cs | 2 +- .../SyntaxTreeVisitorNodes/ForLoop.cs | 2 +- .../convertion_data_and_alghoritms.cs | 4 +- .../TreeConversion/syntax_tree_visitor.cs | 26 ++++----- .../TreeConversion/type_constructor.cs | 8 +-- TreeConverter/TreeRealization/document.cs | 35 +----------- TreeConverter/TreeRealization/location.cs | 18 +++---- TreeConverter/TreeRealization/templates.cs | 10 ++-- VisualPlugins/LanguageConverter/Visitor.cs | 4 +- 26 files changed, 124 insertions(+), 157 deletions(-) diff --git a/CodeCompletion/DomConverter.cs b/CodeCompletion/DomConverter.cs index a35848766..9c0ee31d6 100644 --- a/CodeCompletion/DomConverter.cs +++ b/CodeCompletion/DomConverter.cs @@ -242,7 +242,7 @@ namespace CodeCompletion SymScope ss = visitor.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope; if (ss == null) return null; List meths = new List(); - pos.file_name = this.visitor.doc.file_name; + pos.file_name = this.visitor.doc_name; SetCurrentUsedAssemblies(); if (ss is TypeScope && (ss as TypeScope).kind == SymbolKind.Class) { @@ -306,7 +306,7 @@ namespace CodeCompletion SymScope ss = visitor.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope; if (ss == null) return null; List meths = new List(); - pos.file_name = this.visitor.doc.file_name; + pos.file_name = this.visitor.doc_name; SetCurrentUsedAssemblies(); if (ss is TypeScope && ((ss as TypeScope).kind == SymbolKind.Class || (ss as TypeScope).kind == SymbolKind.Struct)) { @@ -730,7 +730,7 @@ namespace CodeCompletion { pos.line = ss.loc.begin_line_num; pos.column = ss.loc.begin_column_num; - pos.file_name = ss.loc.doc.file_name; + pos.file_name = ss.loc.file_name; poses.Add(pos); } } @@ -741,7 +741,7 @@ namespace CodeCompletion { pos.line = ss.loc.begin_line_num; pos.column = ss.loc.begin_column_num; - pos.file_name = ss.loc.doc.file_name; + pos.file_name = ss.loc.file_name; poses.Add(pos); } } @@ -949,7 +949,7 @@ namespace CodeCompletion ProcRealization pr = (ss as ProcScope).procRealization; pos.line = pr.loc.begin_line_num; pos.column = pr.loc.begin_column_num; - pos.file_name = pr.loc.doc.file_name; + pos.file_name = pr.loc.file_name; poses.Add(pos); if (on_proc) break; //ss = (ss as ProcScope).nextProc; diff --git a/CodeCompletion/DomSyntaxTreeVisitor.cs b/CodeCompletion/DomSyntaxTreeVisitor.cs index 82f59cc00..25278e3e4 100644 --- a/CodeCompletion/DomSyntaxTreeVisitor.cs +++ b/CodeCompletion/DomSyntaxTreeVisitor.cs @@ -886,7 +886,7 @@ namespace CodeCompletion } } - public document doc; + public string doc_name; public location get_location(SourceContext sc) { @@ -895,7 +895,7 @@ namespace CodeCompletion return null; } return new location(sc.begin_position.line_num, sc.begin_position.column_num, - sc.end_position.line_num, sc.end_position.column_num, doc); + sc.end_position.line_num, sc.end_position.column_num, doc_name); } @@ -906,7 +906,7 @@ namespace CodeCompletion return null; } return new 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,doc); + tn.source_context.end_position.line_num,tn.source_context.end_position.column_num,doc_name); } public override void visit(declaration _declaration) @@ -2273,7 +2273,7 @@ namespace CodeCompletion key = "static " + key; if (key != null && returned_scope.body_loc != null) { - returned_scope.head_loc = new location(returned_scope.body_loc.begin_line_num, returned_scope.body_loc.begin_column_num, returned_scope.body_loc.begin_line_num, returned_scope.body_loc.begin_column_num + key.Length, doc); + returned_scope.head_loc = new location(returned_scope.body_loc.begin_line_num, returned_scope.body_loc.begin_column_num, returned_scope.body_loc.begin_line_num, returned_scope.body_loc.begin_column_num + key.Length, doc_name); } if ((cl_def.attribute & class_attribute.Partial) == class_attribute.Partial) { @@ -2308,7 +2308,7 @@ namespace CodeCompletion if (_type_declaration.type_def is enum_type_definition && ts.loc.begin_line_num != ts.loc.end_line_num) { location loc = get_location(_type_declaration.type_def); - ts.head_loc = new location(loc.begin_line_num, loc.begin_column_num, loc.begin_line_num, loc.begin_column_num, doc); + ts.head_loc = new location(loc.begin_line_num, loc.begin_column_num, loc.begin_line_num, loc.begin_column_num, doc_name); ts.body_loc = loc; } cur_scope.AddName(_type_declaration.type_name.name, ts); @@ -2629,7 +2629,7 @@ namespace CodeCompletion } ns_cache = new Hashtable(StringComparer.CurrentCultureIgnoreCase); - doc = new document(_unit_module.file_name); + doc_name = _unit_module.file_name; cur_scope.head_loc = get_location(_unit_module.unit_name); cur_scope.file_name = _unit_module.file_name; @@ -3236,7 +3236,7 @@ namespace CodeCompletion } } - doc = new document(_program_module.file_name); + doc_name = _program_module.file_name; cur_scope.loc = get_location(_program_module); cur_scope.file_name = _program_module.file_name; entry_scope = cur_scope; @@ -3353,8 +3353,8 @@ namespace CodeCompletion cur_scope.body_loc = new location(left_line_num, left_column_num, right_line_num, right_column_num, - doc); - cur_scope.loc = new location(cur_scope.loc.begin_line_num, cur_scope.loc.begin_column_num, right_line_num, right_column_num, doc); + doc_name); + cur_scope.loc = new location(cur_scope.loc.begin_line_num, cur_scope.loc.begin_column_num, right_line_num, right_column_num, doc_name); _program_module.program_block.program_code.visit(this); } } @@ -5236,7 +5236,7 @@ namespace CodeCompletion if (_exception_handler.statements.source_context != null) stmt_scope.loc = new location(stmt_scope.loc.begin_line_num, stmt_scope.loc.begin_column_num, _exception_handler.statements.source_context.end_position.line_num, - _exception_handler.statements.source_context.end_position.column_num, stmt_scope.loc.doc); + _exception_handler.statements.source_context.end_position.column_num, stmt_scope.loc.file_name); returned_scope = null; if (_exception_handler.variable == null) return; if (_exception_handler.type_name != null) diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index d5586f952..bd41af464 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -597,7 +597,7 @@ namespace CodeCompletion Position pos = new Position(); if (loc != null) { - pos.file_name = loc.doc.file_name; + pos.file_name = loc.file_name; pos.line = loc.begin_line_num; pos.column = loc.begin_column_num; pos.end_line = loc.end_line_num; @@ -611,7 +611,7 @@ namespace CodeCompletion Position pos = new Position(); if (head_loc != null) { - pos.file_name = head_loc.doc.file_name; + pos.file_name = head_loc.file_name; pos.line = head_loc.begin_line_num; pos.column = head_loc.begin_column_num; pos.end_line = head_loc.end_line_num; @@ -625,7 +625,7 @@ namespace CodeCompletion Position pos = new Position(); if (body_loc != null) { - pos.file_name = body_loc.doc.file_name; + pos.file_name = body_loc.file_name; pos.line = body_loc.begin_line_num; pos.column = body_loc.begin_column_num; pos.end_line = body_loc.end_line_num; @@ -780,7 +780,7 @@ namespace CodeCompletion if (res == null && ts != null && ts.predef_loc != null && IsInScope(ts.predef_loc, line, column)) res = this; foreach (SymScope ss in members) - if (this != ss && this.topScope != ss && ss.loc != null && (loc == null || loc != null && loc.doc != null && ss.loc.doc.file_name == loc.doc.file_name)) + if (this != ss && this.topScope != ss && ss.loc != null && (loc == null || loc != null && loc.file_name != null && ss.loc.file_name == loc.file_name)) { if (IsInScope(ss.loc, line, column)) { @@ -879,7 +879,7 @@ namespace CodeCompletion { if (ss.loc != null && loc != null) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, true) == 0) + if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0) { if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) { @@ -910,7 +910,7 @@ namespace CodeCompletion // continue; if (ss.loc != null && loc != null) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, true) == 0) + if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0) { if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) { @@ -1005,7 +1005,7 @@ namespace CodeCompletion } if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, true) == 0 && this != ss) + if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0 && this != ss) { if (IsClassMember(ss) || IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num) || ts != null && ts.predef_loc != null && IsAfterDefinition(ts.predef_loc.begin_line_num, ts.predef_loc.begin_column_num)) @@ -1024,7 +1024,7 @@ namespace CodeCompletion if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0) if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0 && this != ss) + if (string.Compare(ss.loc.file_name, loc.file_name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0 && this != ss) { if (IsClassMember(ss) || IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) { @@ -1054,7 +1054,7 @@ namespace CodeCompletion foreach (SymScope ss in tmp_names) if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, true) == 0 && this != ss) + if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0 && this != ss) { if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) { @@ -1071,7 +1071,7 @@ namespace CodeCompletion if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0) if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, true) == 0 && this != ss && ss.topScope != this) + if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0 && this != ss && ss.topScope != this) { if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) { @@ -2677,7 +2677,7 @@ namespace CodeCompletion { if (ss.loc != null && loc != null) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, true) == 0) + if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0) { if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) { @@ -2704,7 +2704,7 @@ namespace CodeCompletion { if (ss.loc != null && loc != null) { - if (string.Compare(ss.loc.doc.file_name, loc.doc.file_name, true) == 0) + if (string.Compare(ss.loc.file_name, loc.file_name, true) == 0) { if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num)) { diff --git a/Compiler/Compiler.cs b/Compiler/Compiler.cs index 6f4238a74..04cbf7545 100644 --- a/Compiler/Compiler.cs +++ b/Compiler/Compiler.cs @@ -822,7 +822,7 @@ namespace PascalABCCompiler directives.Add(cd.name, new List()); // TODO: сделать проверку на дубликаты централизованной (в другом месте) EVA else if (cd.name.Equals("mainresource", StringComparison.CurrentCultureIgnoreCase)) - throw new DuplicateDirective(cd.location.doc.file_name, "mainresource", cd.location); + throw new DuplicateDirective(cd.location.file_name, "mainresource", cd.location); directives[cd.name].Insert(0, cd); } } @@ -865,7 +865,7 @@ namespace PascalABCCompiler 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)); + tn.source_context.end_position.line_num, tn.source_context.end_position.column_num, FileName); } public void StartCompile() @@ -1234,14 +1234,14 @@ namespace PascalABCCompiler compilerDirectives.ContainsKey(StringConstants.compiler_directive_description_string) || compilerDirectives.ContainsKey(StringConstants.compiler_directive_copyright_string)) { - ErrorsList.Add(new MainResourceNotAllowed(compilerDirectivesList[0].location.doc.file_name, compilerDirectivesList[0].location)); + ErrorsList.Add(new MainResourceNotAllowed(compilerDirectivesList[0].location.file_name, compilerDirectivesList[0].location)); } TryThrowInvalidPath(compilerDirectivesList[0].directive, compilerDirectivesList[0].location); // Тут не обязательно нормализовывать путь // И если он слишком длинный - File.Exists вернёт false netCompilerOptions.MainResourceFileName = Path.Combine(Path.GetDirectoryName(compilerDirectivesList[0].source_file), compilerDirectivesList[0].directive); if (!File.Exists(netCompilerOptions.MainResourceFileName)) - ErrorsList.Add(new ResourceFileNotFound(compilerDirectivesList[0].location.doc.file_name, compilerDirectivesList[0].directive, compilerDirectivesList[0].location)); + ErrorsList.Add(new ResourceFileNotFound(compilerDirectivesList[0].location.file_name, compilerDirectivesList[0].directive, compilerDirectivesList[0].location)); } } @@ -1726,7 +1726,7 @@ namespace PascalABCCompiler if (File.Exists(resourceFileName)) ResourceFiles.Add(resourceFileName); else - ErrorsList.Add(new ResourceFileNotFound(cd.location.doc.file_name, cd.directive, cd.location)); + ErrorsList.Add(new ResourceFileNotFound(cd.location.file_name, cd.directive, cd.location)); } } diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index d9738485e..ca1bd8b2f 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -37,7 +37,7 @@ namespace PascalABCCompiler.PCU private PCUFile pcu_file = new PCUFile(); private CompilationUnit unit; private common_unit_node cun; - private document cur_doc; + private string cur_doc_name; private string unit_name; private string dir; private int start_pos;//смещение относительно начала PCU-файла, по которому находятся описание всех сущностей модуля @@ -301,7 +301,7 @@ namespace PascalABCCompiler.PCU if (!File.Exists(SourceFileName)) SourceFileName = Path.Combine(Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(FileName)),"LibSource"), pcu_file.SourceFileName); } - cur_doc = new document(SourceFileName); + cur_doc_name = SourceFileName; AddNamespaces(); AddInterfaceNames(); @@ -583,9 +583,9 @@ namespace PascalABCCompiler.PCU else pcu_file.SourceFileName = Path.GetFileNameWithoutExtension(FileName); if (Path.GetDirectoryName(pcu_file.SourceFileName) == "") - cur_doc = new document(Path.Combine(Path.GetDirectoryName(FileName), pcu_file.SourceFileName)); + cur_doc_name = Path.Combine(Path.GetDirectoryName(FileName), pcu_file.SourceFileName); else - cur_doc = new document(pcu_file.SourceFileName); + cur_doc_name = pcu_file.SourceFileName; pcu_file.languageName = br.ReadString(); @@ -1060,7 +1060,7 @@ namespace PascalABCCompiler.PCU { if (readDebugInfo) { - location loc = new location(br.ReadInt32(), br.ReadInt32(), br.ReadInt32(), br.ReadInt32(), cur_doc); + location loc = new location(br.ReadInt32(), br.ReadInt32(), br.ReadInt32(), br.ReadInt32(), cur_doc_name); if (loc.begin_column_num == -1) return null; else @@ -2389,10 +2389,10 @@ namespace PascalABCCompiler.PCU unl2.AddElement(new using_namespace(br.ReadString())); } } - document doc = null; + string doc = null; if (br.ReadByte() == 1) { - doc = new document(Path.Combine(Path.GetDirectoryName(cur_doc.file_name),br.ReadString())); + doc = Path.Combine(Path.GetDirectoryName(cur_doc_name),br.ReadString()); } SyntaxTree.SyntaxTreeStreamReader str = new SyntaxTree.SyntaxTreeStreamReader(); diff --git a/Compiler/PCU/PCUWriter.cs b/Compiler/PCU/PCUWriter.cs index d2ebd8970..bf3ad9802 100644 --- a/Compiler/PCU/PCUWriter.cs +++ b/Compiler/PCU/PCUWriter.cs @@ -2851,7 +2851,7 @@ namespace PascalABCCompiler.PCU else { bw.Write((byte)1); - bw.Write(Path.GetFileName(tclass.cur_document.file_name)); + bw.Write(Path.GetFileName(tclass.cur_document)); } SyntaxTree.SyntaxTreeStreamWriter stw = new SyntaxTree.SyntaxTreeStreamWriter(); stw.bw = bw; diff --git a/Compiler/RemoteCompiler.cs b/Compiler/RemoteCompiler.cs index 693891b08..d94ced6f8 100644 --- a/Compiler/RemoteCompiler.cs +++ b/Compiler/RemoteCompiler.cs @@ -59,7 +59,7 @@ namespace PascalABCCompiler get { if(loc!=null) - return new SourceLocation(loc.doc.file_name, loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num); + return new SourceLocation(loc.file_name, loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num); else return null; } @@ -157,9 +157,9 @@ namespace PascalABCCompiler loc = new location( Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), - new document(args[5])); + args[5]); if (args.Length == 2) - loc = new location(0,0,0,0,new document(args[1])); + loc = new location(0,0,0,0,args[1]); switch(command) { case ConsoleCompilerConstants.Error: diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index a736f7d37..27a164ef1 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "11"; public const string Build = "0"; - public const string Revision = "3736"; + public const string Revision = "3738"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index ab3a46378..02b35a3b9 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=0 -%REVISION%=3736 +%REVISION%=3738 %MINOR%=11 %MAJOR%=3 diff --git a/Errors/BaseErrors.cs b/Errors/BaseErrors.cs index 3fb0a381f..cfa20f865 100644 --- a/Errors/BaseErrors.cs +++ b/Errors/BaseErrors.cs @@ -275,7 +275,7 @@ namespace PascalABCCompiler.Errors return sourceLocation; if (Location != null) { - return new SourceLocation(Location.document.file_name, + return new SourceLocation(Location.file_name, Location.begin_line_num, Location.begin_column_num, Location.end_line_num, Location.end_column_num); } return null; diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index e584aae95..01d8b8c30 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -193,15 +193,15 @@ namespace PascalABCCompiler.NETGenerator if (Location != null) { ISymbolDocumentWriter temp_doc = null; - if (sym_docs.ContainsKey(Location.document.file_name)) + if (sym_docs.ContainsKey(Location.file_name)) { - temp_doc = sym_docs[Location.document.file_name]; + temp_doc = sym_docs[Location.file_name]; } else if (save_debug_info) // иногда вызывается MarkSequencePoint при save_debug_info = false { - temp_doc = mb.DefineDocument(Location.document.file_name, SymDocumentType.Text, SymLanguageType.Pascal, SymLanguageVendor.Microsoft); - sym_docs.Add(Location.document.file_name, temp_doc); + temp_doc = mb.DefineDocument(Location.file_name, SymDocumentType.Text, SymLanguageType.Pascal, SymLanguageVendor.Microsoft); + sym_docs.Add(Location.file_name, temp_doc); } if (temp_doc != doc) { @@ -671,7 +671,7 @@ namespace PascalABCCompiler.NETGenerator } catch (Exception ex) { - throw new TreeConverter.SaveAssemblyError(ex.Message, new TreeRealization.location(0, 0, 0, 0, new TreeRealization.document(SourceFileName))); + throw new TreeConverter.SaveAssemblyError(ex.Message, new TreeRealization.location(0, 0, 0, 0, SourceFileName)); } } @@ -817,7 +817,7 @@ namespace PascalABCCompiler.NETGenerator string cnns_document_file_name = null; if (cnns[iii].Location != null) { - cnns_document_file_name = cnns[iii].Location.document.file_name; + cnns_document_file_name = cnns[iii].Location.file_name; doc = mb.DefineDocument(cnns_document_file_name, SymDocumentType.Text, SymLanguageType.Pascal, SymLanguageVendor.Microsoft); } else @@ -825,7 +825,7 @@ namespace PascalABCCompiler.NETGenerator if (cnns_document_file_name != null && !sym_docs.ContainsKey(cnns_document_file_name)) sym_docs.Add(cnns_document_file_name, doc);//сохраняем его в таблице документов } - first_doc = sym_docs[cnns[0].Location == null ? SourceFileName : cnns[0].Location.document.file_name]; + first_doc = sym_docs[cnns[0].Location == null ? SourceFileName : cnns[0].Location.file_name]; if (p.main_function != null) { @@ -842,7 +842,7 @@ namespace PascalABCCompiler.NETGenerator //Переводим заголовки типов for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; bool is_main_namespace = cnns[iii].namespace_name == "" && comp_opt.target != TargetType.Dll || comp_opt.target == TargetType.Dll && cnns[iii].namespace_name == ""; ICommonNamespaceNode cnn = cnns[iii]; // SSM 07.02.20 @@ -946,7 +946,7 @@ namespace PascalABCCompiler.NETGenerator } for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; cur_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]]; MethodBuilder mb = cur_unit_type.DefineMethod("$static_init$", MethodAttributes.Public | MethodAttributes.Static); @@ -962,7 +962,7 @@ namespace PascalABCCompiler.NETGenerator for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; cur_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]]; ConvertFunctionHeaders(cnns[iii].functions, false); @@ -976,7 +976,7 @@ namespace PascalABCCompiler.NETGenerator for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; cur_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]]; ConvertFunctionHeaders(cnns[iii].functions, true); @@ -1010,7 +1010,7 @@ namespace PascalABCCompiler.NETGenerator //Переводим заголовки всего остального (процедур, переменных) for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; bool is_main_namespace = iii == cnns.Length - 1 && comp_opt.target != TargetType.Dll; ICommonNamespaceNode cnn = cnns[iii]; string tmp_unit_name = cur_unit; @@ -1061,7 +1061,7 @@ namespace PascalABCCompiler.NETGenerator for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; cur_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]]; //генерим инциализацию для полей @@ -1086,7 +1086,7 @@ namespace PascalABCCompiler.NETGenerator //переводим реализации for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; bool is_main_namespace = iii == 0 && comp_opt.target != TargetType.Dll; ICommonNamespaceNode cnn = cnns[iii]; string tmp_unit_name = cur_unit; @@ -1111,7 +1111,7 @@ namespace PascalABCCompiler.NETGenerator } for (int iii = 0; iii < cnns.Length; iii++) { - if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name]; + if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.file_name]; cur_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]]; //вставляем ret в int_meth @@ -1277,18 +1277,18 @@ namespace PascalABCCompiler.NETGenerator } catch (System.Runtime.InteropServices.COMException e) { - throw new TreeConverter.SaveAssemblyError(e.Message, new TreeRealization.location(0, 0, 0, 0, new TreeRealization.document(SourceFileName))); + throw new TreeConverter.SaveAssemblyError(e.Message, new TreeRealization.location(0, 0, 0, 0, SourceFileName)); } catch (System.IO.IOException e) { if (tries < num_try_save) { if (has_unmanaged_resources) - throw new TreeConverter.SaveAssemblyError(e.Message, new TreeRealization.location(0, 0, 0, 0, new TreeRealization.document(SourceFileName))); + throw new TreeConverter.SaveAssemblyError(e.Message, new TreeRealization.location(0, 0, 0, 0, SourceFileName)); tries++; } else - throw new TreeConverter.SaveAssemblyError(e.Message, new TreeRealization.location(0, 0, 0, 0, new TreeRealization.document(SourceFileName))); + throw new TreeConverter.SaveAssemblyError(e.Message, new TreeRealization.location(0, 0, 0, 0, SourceFileName)); } } while (not_done); @@ -1470,7 +1470,7 @@ namespace PascalABCCompiler.NETGenerator { SemanticTree.ICommonTypeNode ctn = helper.GetTypeNodeByTypeBuilder(types[i]); if (ctn != null) - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); } } @@ -1542,7 +1542,7 @@ namespace PascalABCCompiler.NETGenerator } catch (TypeLoadException ex2) { - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); } } } @@ -1555,7 +1555,7 @@ namespace PascalABCCompiler.NETGenerator continue; } } - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); } else throw ex; @@ -1583,7 +1583,7 @@ namespace PascalABCCompiler.NETGenerator { SemanticTree.ICommonTypeNode ctn = helper.GetTypeNodeByTypeBuilder(failed_types[i]); if (ctn != null) - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); else throw ex; } @@ -1760,7 +1760,7 @@ namespace PascalABCCompiler.NETGenerator catch (ArgumentException ex) { if (ex.Message.IndexOf("fullname") != -1) - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), t.Location.document.file_name, t.Location.begin_line_num, t.Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), t.Location.file_name, t.Location.begin_line_num, t.Location.begin_column_num); throw ex; } @@ -2149,7 +2149,7 @@ namespace PascalABCCompiler.NETGenerator } catch (ArgumentException ex) { - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), attrs[i].Location.document.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), attrs[i].Location.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); } } } @@ -2184,7 +2184,7 @@ namespace PascalABCCompiler.NETGenerator } catch (ArgumentException ex) { - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), attrs[i].Location.document.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), attrs[i].Location.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); } } } @@ -2205,7 +2205,7 @@ namespace PascalABCCompiler.NETGenerator } catch (ArgumentException ex) { - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), attrs[i].Location.document.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace("System.ArgumentException: ", ""), attrs[i].Location.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); } } } @@ -2233,7 +2233,7 @@ namespace PascalABCCompiler.NETGenerator } catch(ArgumentException ex) { - throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace(", переданный для DefineUnmanagedMarshal,",""), attrs[i].Location.document.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); + throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message.Replace(", переданный для DefineUnmanagedMarshal,",""), attrs[i].Location.file_name, attrs[i].Location.begin_line_num, attrs[i].Location.begin_column_num); } else { diff --git a/Optimizer/Warnings.cs b/Optimizer/Warnings.cs index bf494cf06..74a86f9e9 100644 --- a/Optimizer/Warnings.cs +++ b/Optimizer/Warnings.cs @@ -46,7 +46,7 @@ namespace PascalABCCompiler { try { - return new SourceLocation(loc.doc.file_name, loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num); + return new SourceLocation(loc.file_name, loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num); } catch (Exception e) { diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index b4b84f4c5..b0e4eb276 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.11.0.3736 +3.11.0.3738 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index d679a77a0..8da900c5d 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.11.0.3736' +!define VERSION '3.11.0.3738' diff --git a/SemanticTree/SemanticTree.cs b/SemanticTree/SemanticTree.cs index 769d3e436..e98440f72 100644 --- a/SemanticTree/SemanticTree.cs +++ b/SemanticTree/SemanticTree.cs @@ -109,7 +109,7 @@ namespace PascalABCCompiler.SemanticTree } //Документ, в котором определен данный элемент дерева. - IDocument document + string file_name { get; } diff --git a/TreeConverter/OpenMP/OpenMP.cs b/TreeConverter/OpenMP/OpenMP.cs index 0001f9570..fc9b51358 100644 --- a/TreeConverter/OpenMP/OpenMP.cs +++ b/TreeConverter/OpenMP/OpenMP.cs @@ -2173,23 +2173,23 @@ namespace PascalABCCompiler.TreeConverter { if (LoopVariables.Contains(rdVarName)) { - visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_REDUCTION_WITH_LOOPVAR_{0}"), rdVarName), visitor.CurrentDocument.file_name, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); + visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_REDUCTION_WITH_LOOPVAR_{0}"), rdVarName), visitor.CurrentDocument, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); continue; } SymbolInfo si = visitor.context.find_first(rdVarName); if (si == null) { - visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_UNKNOWN_VARNAME_{0}"), rdVarName), visitor.CurrentDocument.file_name, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); + visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_UNKNOWN_VARNAME_{0}"), rdVarName), visitor.CurrentDocument, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); continue; } if (!(si.sym_info is SemanticTree.IVAriableDefinitionNode)) { - visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_NAME_IS_NOT_VAR_{0}"), rdVarName), visitor.CurrentDocument.file_name, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); + visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_NAME_IS_NOT_VAR_{0}"), rdVarName), visitor.CurrentDocument, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); continue; } if (!IsValidVarForReduction(si.sym_info as SemanticTree.IVAriableDefinitionNode)) { - visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_IS_NOT_POSSIBLE_REDUCTION_WITH_THIS_VAR_{0}"), rdVarName), visitor.CurrentDocument.file_name, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); + visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_IS_NOT_POSSIBLE_REDUCTION_WITH_THIS_VAR_{0}"), rdVarName), visitor.CurrentDocument, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); continue; } Result.ReductionVariables.Add(si.sym_info as SemanticTree.IVAriableDefinitionNode); @@ -2209,12 +2209,12 @@ namespace PascalABCCompiler.TreeConverter SymbolInfo si = visitor.context.find_first(privateVar); if (si == null) { - visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_UNKNOWN_VARNAME_{0}"), privateVar), visitor.CurrentDocument.file_name, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); + visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_UNKNOWN_VARNAME_{0}"), privateVar), visitor.CurrentDocument, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); continue; } if (!(si.sym_info is SemanticTree.IVAriableDefinitionNode)) { - visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_NAME_IS_NOT_VAR_{0}"), privateVar), visitor.CurrentDocument.file_name, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); + visitor.AddWarning(new PascalABCCompiler.Errors.CommonWarning(String.Format(PascalABCCompiler.StringResources.Get("OMPERROR_NAME_IS_NOT_VAR_{0}"), privateVar), visitor.CurrentDocument, dir.source_context.begin_position.line_num, dir.source_context.begin_position.column_num)); continue; } Result.PrivateVariables.Add(si.sym_info as SemanticTree.IVAriableDefinitionNode); diff --git a/TreeConverter/TreeConversion/CompilationErrors.cs b/TreeConverter/TreeConversion/CompilationErrors.cs index 975f2e4ea..13da573dc 100644 --- a/TreeConverter/TreeConversion/CompilationErrors.cs +++ b/TreeConverter/TreeConversion/CompilationErrors.cs @@ -73,7 +73,7 @@ namespace PascalABCCompiler.TreeConverter public string loc_to_string(ILocation loc) { if (loc == null) return "Undefined location(!)"; - string res = "File: " + loc.document.file_name; + string res = "File: " + loc.file_name; res += " line: " + loc.begin_line_num.ToString(); res += " column: " + loc.begin_column_num.ToString(); return res; @@ -2649,12 +2649,12 @@ namespace PascalABCCompiler.TreeConverter string message = "NOT_SUPPORTED_BY_THIS_VERSION_OF_COMPILER"; public NotSupportedError(location loc) - :base(loc.document.file_name) + :base(loc.document) { _loc = loc; } public NotSupportedError(location loc, string msg) - : base(loc.document.file_name) + : base(loc.document) { _loc = loc; message = msg; diff --git a/TreeConverter/TreeConversion/CompilationWarnings.cs b/TreeConverter/TreeConversion/CompilationWarnings.cs index c8d187fe0..bd4445cd8 100644 --- a/TreeConverter/TreeConversion/CompilationWarnings.cs +++ b/TreeConverter/TreeConversion/CompilationWarnings.cs @@ -35,7 +35,7 @@ namespace PascalABCCompiler.TreeConverter get { if (loc != null) - return new SourceLocation(loc.doc.file_name, loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num); + return new SourceLocation(loc.file_name, loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num); else return null; } diff --git a/TreeConverter/TreeConversion/SyntaxTreeVisitorNodes/ForLoop.cs b/TreeConverter/TreeConversion/SyntaxTreeVisitorNodes/ForLoop.cs index ab5816b05..4b81c6cb9 100644 --- a/TreeConverter/TreeConversion/SyntaxTreeVisitorNodes/ForLoop.cs +++ b/TreeConverter/TreeConversion/SyntaxTreeVisitorNodes/ForLoop.cs @@ -32,7 +32,7 @@ namespace PascalABCCompiler.TreeConverter //в конце за счет флага вернем состояние обратно и сгенерируем и параллельную ветку тоже } else - WarningsList.Add(new OMP_BuildigError(new Exception("Переменная параллельного цикла должна быть определена в заголовке цикла"), new location(_for_node.source_context.begin_position.line_num, _for_node.source_context.begin_position.column_num, _for_node.source_context.end_position.line_num, _for_node.source_context.end_position.column_num, new document(_for_node.source_context.FileName)))); + WarningsList.Add(new OMP_BuildigError(new Exception("Переменная параллельного цикла должна быть определена в заголовке цикла"), new location(_for_node.source_context.begin_position.line_num, _for_node.source_context.begin_position.column_num, _for_node.source_context.end_position.line_num, _for_node.source_context.end_position.column_num, _for_node.source_context.FileName))); } else //уже генерируем одну из веток //если это параллельная ветка - последовательную генерировать не будем diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 63584a678..fece2bba2 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -158,7 +158,7 @@ namespace PascalABCCompiler.TreeConverter { return null; } - document doc = _stv.CurrentDocument; + string doc = _stv.CurrentDocument; location loc=null; //DarkStar changed //В PCU не сохраняются location некоторых конструкций, например @@ -177,7 +177,7 @@ namespace PascalABCCompiler.TreeConverter { return null; } - document d = new document(l.document.file_name); + string d = l.file_name; if (d == null) d = syntax_tree_visitor.CurrentDocument; diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index ff7c8c5a6..145ee01ae 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -70,7 +70,7 @@ namespace PascalABCCompiler.TreeConverter public returner ret; - internal document current_document; + internal string current_document; public compilation_context context; private bool var_def_statement_converting; @@ -151,7 +151,7 @@ namespace PascalABCCompiler.TreeConverter using_list.Clear(); - current_document = new document(initializationData.syntaxUnit.file_name); + current_document = initializationData.syntaxUnit.file_name; ErrorsList = initializationData.errorsList; WarningsList = initializationData.warningsList; @@ -712,7 +712,7 @@ namespace PascalABCCompiler.TreeConverter } - public PascalABCCompiler.TreeRealization.document CurrentDocument + public string CurrentDocument { get { @@ -741,11 +741,11 @@ namespace PascalABCCompiler.TreeConverter { return null; } - document d = current_document; - if (tns.FileName != null && (d == null || d.file_name != tns.FileName)) - d = new document(tns.FileName); + string file_name = current_document; + if (tns.FileName != null && (file_name == null || file_name != tns.FileName)) + file_name = tns.FileName; return new location(tns.begin_position.line_num, tns.begin_position.column_num, - tns.end_position.line_num, tns.end_position.column_num, d); + tns.end_position.line_num, tns.end_position.column_num, file_name); } public location get_right_location(SyntaxTree.syntax_tree_node tn) { @@ -763,11 +763,11 @@ namespace PascalABCCompiler.TreeConverter { return null; } - document d = current_document; + string file_name = current_document; if (tn.source_context.FileName != null) - d = new document(tn.source_context.FileName); + file_name = tn.source_context.FileName; return new 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, d); + tn.source_context.end_position.line_num, tn.source_context.end_position.column_num, file_name); } public common_unit_node CompiledUnit @@ -3628,7 +3628,7 @@ namespace PascalABCCompiler.TreeConverter { constant_definition_node ncd = si.FirstOrDefault().sym_info as constant_definition_node; if (_enum_type_definition.source_context != null && ncd.type.location != null && ncd.type.location.begin_line_num == _enum_type_definition.source_context.begin_position.line_num - && ncd.type.location.begin_column_num == _enum_type_definition.source_context.begin_position.column_num && ncd.type.location.doc.file_name == _enum_type_definition.source_context.FileName) + && ncd.type.location.begin_column_num == _enum_type_definition.source_context.begin_position.column_num && ncd.type.location.file_name == _enum_type_definition.source_context.FileName) { return_value(ncd.type); return; @@ -11506,7 +11506,7 @@ namespace PascalABCCompiler.TreeConverter SymbolTable.Scope[] used_units = build_referenced_units(ReferencedUnits,true); - _compiled_unit.scope = convertion_data_and_alghoritms.symbol_table.CreateUnitInterfaceScope(used_units, namespace_name == ""? System.IO.Path.GetFileName(CurrentDocument.file_name) : namespace_name); + _compiled_unit.scope = convertion_data_and_alghoritms.symbol_table.CreateUnitInterfaceScope(used_units, namespace_name == ""? System.IO.Path.GetFileName(CurrentDocument) : namespace_name); common_namespace_node cnsn = context.create_namespace(namespace_name, _compiled_unit, _compiled_unit.scope, loc); cnsn.is_main = true; @@ -19689,7 +19689,7 @@ namespace PascalABCCompiler.TreeConverter bool current_record_created = _record_created; _record_created = false; SemanticTree.field_access_level current_fal = context.get_field_access_level(); - document current_doc = current_document; + string current_doc = current_document; current_document = tc.cur_document; bool current_body_exists = body_exists; body_exists = false; diff --git a/TreeConverter/TreeConversion/type_constructor.cs b/TreeConverter/TreeConversion/type_constructor.cs index eddecfe63..38d93bcf1 100644 --- a/TreeConverter/TreeConversion/type_constructor.cs +++ b/TreeConverter/TreeConversion/type_constructor.cs @@ -461,7 +461,7 @@ namespace PascalABCCompiler.TreeConverter ctn.const_defs.AddElement(cdn2); common_method_node get_func = new common_method_node(StringConstants.get_val_pascal_array_name, - element_type, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private, + element_type, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.file_name), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private, convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope, "get " + name)); common_parameter get_param = new common_parameter(StringConstants.unary_param_name, oti_indexer.lower_value.type, SemanticTree.parameter_type.value, get_func, concrete_parameter_type.cpt_none, @@ -481,12 +481,12 @@ namespace PascalABCCompiler.TreeConverter expression_node index_expr = new simple_array_indexing(cfr1, sub_expr, element_type, loc); - statement_node sn = new return_node(index_expr, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc)); + statement_node sn = new return_node(index_expr, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.file_name)); get_func.function_code = sn; common_method_node set_func = new common_method_node(StringConstants.set_val_pascal_array_name, - null, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private, + null, /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.file_name), ctn, SemanticTree.polymorphic_state.ps_common, SemanticTree.field_access_level.fal_private, convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope, "set " + name)); common_parameter set_ind = new common_parameter(StringConstants.left_param_name, oti_indexer.lower_value.type, SemanticTree.parameter_type.value, set_func, concrete_parameter_type.cpt_none, @@ -522,7 +522,7 @@ namespace PascalABCCompiler.TreeConverter function_node assign = (function_node)si.sym_info; statement_node assign_call = convertion_data_and_alghoritms.create_simple_function_call(assign, - /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.doc), index_expr2, val_ref); + /*loc*/new location(0xFFFFFF, 0, 0xFFFFFF, 0, loc.file_name), index_expr2, val_ref); set_func.function_code = assign_call; diff --git a/TreeConverter/TreeRealization/document.cs b/TreeConverter/TreeRealization/document.cs index 930db6999..e14f7b86b 100644 --- a/TreeConverter/TreeRealization/document.cs +++ b/TreeConverter/TreeRealization/document.cs @@ -5,42 +5,9 @@ using System; namespace PascalABCCompiler.TreeRealization { /// - /// Класс, описывающий файл кода. + /// Класс, описывающий файл кода. Убрал. Теперь это просто имя файла string /// Используется для указания позиции частей кода. /// - [Serializable] - public class document : SemanticTree.IDocument - { - /// - /// Имя файла. - /// - private readonly string _file_name; - /// - /// Конструктор документа. - /// - /// Путь к документу. - public document(string file_name) - { - _file_name=file_name; - } - - /// - /// Путь к документу. - /// - public string file_name - { - get - { - return _file_name; - } - } - - public override string ToString() - { - return (_file_name); - } - - } } \ No newline at end of file diff --git a/TreeConverter/TreeRealization/location.cs b/TreeConverter/TreeRealization/location.cs index aac50cff3..a86d60d3c 100644 --- a/TreeConverter/TreeRealization/location.cs +++ b/TreeConverter/TreeRealization/location.cs @@ -33,7 +33,7 @@ namespace PascalABCCompiler.TreeRealization /// /// Документ, в котором расположен этот фрагмент кода. /// - private document _doc; + private string _file_name; /// /// Конструктор класса. @@ -43,13 +43,13 @@ namespace PascalABCCompiler.TreeRealization /// Номер строки конца фрагмента кода (нумерация начинается с 1). /// Номер колонки конца фрагмента кода (нумерация начинается с 1) /// Документ, в котором расположен этот фрагмент кода. - public location(int begin_line_num, int begin_column_num,int end_line_num,int end_column_num,document doc) + public location(int begin_line_num, int begin_column_num,int end_line_num,int end_column_num,string file_name) { _begin_line_num=begin_line_num; _begin_column_num=begin_column_num; _end_line_num=end_line_num; _end_column_num=end_column_num; - _doc=doc; + _file_name=file_name; } /// @@ -115,26 +115,26 @@ namespace PascalABCCompiler.TreeRealization /// /// Документ, в котором расположен этот фрагмент кода. /// - public document doc + public string file_name { get { - return _doc; + return _file_name; } set { - _doc = value; + _file_name = value; } } /// /// Документ, в котором расположен этот фрагмент кода. /// - public SemanticTree.IDocument document + public string document { get { - return _doc; + return _file_name; } } @@ -142,7 +142,7 @@ namespace PascalABCCompiler.TreeRealization { if (loc == null) return null; - return new SyntaxTree.SourceContext(loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num, loc.document != null ? loc.document.file_name : null); + return new SyntaxTree.SourceContext(loc.begin_line_num, loc.begin_column_num, loc.end_line_num, loc.end_column_num, loc.document != null ? loc.file_name : null); } public override string ToString() diff --git a/TreeConverter/TreeRealization/templates.cs b/TreeConverter/TreeRealization/templates.cs index dac6be9c2..0c2130ead 100644 --- a/TreeConverter/TreeRealization/templates.cs +++ b/TreeConverter/TreeRealization/templates.cs @@ -150,7 +150,7 @@ namespace PascalABCCompiler.TreeRealization private SyntaxTree.type_declaration _type_decl; //Синтаксическое дерево шаблона private string _name; //Имя шаблона private common_namespace_node _cnn; //Пространство, где описан шаблон - private document _doc; //Документ, т.е. файл, где описан шаблон + private string _file_name; //Документ, т.е. файл, где описан шаблон private using_namespace_list _unl; //Список подключенных к _cnn пространств private using_namespace_list _unl2 = null; //То же для пространства внешних методов private bool _ForwardDeclarationOnly = false; //true, если пока есть только предописание @@ -219,11 +219,11 @@ namespace PascalABCCompiler.TreeRealization } } - public document cur_document + public string cur_document { get { - return _doc; + return _file_name; } } @@ -279,12 +279,12 @@ namespace PascalABCCompiler.TreeRealization } } - public template_class(SyntaxTree.type_declaration type_decl, string name,common_namespace_node cnn,/*common_type_node ctn,location loc,*/document doc,using_namespace_list unl) + public template_class(SyntaxTree.type_declaration type_decl, string name,common_namespace_node cnn,/*common_type_node ctn,location loc,*/string file_name,using_namespace_list unl) { _cnn = cnn; _type_decl = type_decl; _name = name; - _doc = doc; + _file_name = file_name; //(ssyy) using - список, по-видимому, можно только копировать, т.к. Николай его периодически чистит. _unl = new using_namespace_list(); diff --git a/VisualPlugins/LanguageConverter/Visitor.cs b/VisualPlugins/LanguageConverter/Visitor.cs index e0e757770..affdce577 100644 --- a/VisualPlugins/LanguageConverter/Visitor.cs +++ b/VisualPlugins/LanguageConverter/Visitor.cs @@ -946,7 +946,7 @@ namespace VisualPascalABCPlugins // перед входом в блок ув. отступ //SemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyIncrement(); mainNamespace = value.main_function.comprehensive_namespace; - string outdir = System.IO.Path.GetDirectoryName(mainNamespace.Location.document.file_name); + string outdir = System.IO.Path.GetDirectoryName(mainNamespace.Location.file_name); foreach (ICommonNamespaceNode nodeNamespace in value.namespaces) { nodeNamespace.visit(this); @@ -957,7 +957,7 @@ namespace VisualPascalABCPlugins bodyBlock.Append(System.Environment.NewLine); string name = nodeNamespace.namespace_name.Replace('$', 'S'); if (name == "") - name = System.IO.Path.GetFileNameWithoutExtension(mainNamespace.Location.document.file_name); + name = System.IO.Path.GetFileNameWithoutExtension(mainNamespace.Location.file_name); SaveTextInFile(outdir + "\\" +name+".cs", currNamespace, false); nmspaceFiles.Add(outdir + "\\" + name + ".cs"); }