Везде в location убрал document - заменил его на непосредственно file_name

This commit is contained in:
Mikhalkovich Stanislav 2026-01-17 23:26:40 +03:00
parent fed0786795
commit 4760aa02d7
26 changed files with 124 additions and 157 deletions

View file

@ -242,7 +242,7 @@ namespace CodeCompletion
SymScope ss = visitor.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope; SymScope ss = visitor.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope;
if (ss == null) return null; if (ss == null) return null;
List<ProcScope> meths = new List<ProcScope>(); List<ProcScope> meths = new List<ProcScope>();
pos.file_name = this.visitor.doc.file_name; pos.file_name = this.visitor.doc_name;
SetCurrentUsedAssemblies(); SetCurrentUsedAssemblies();
if (ss is TypeScope && (ss as TypeScope).kind == SymbolKind.Class) 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; SymScope ss = visitor.FindScopeByLocation(line + 1, col + 1);//stv.cur_scope;
if (ss == null) return null; if (ss == null) return null;
List<ProcScope> meths = new List<ProcScope>(); List<ProcScope> meths = new List<ProcScope>();
pos.file_name = this.visitor.doc.file_name; pos.file_name = this.visitor.doc_name;
SetCurrentUsedAssemblies(); SetCurrentUsedAssemblies();
if (ss is TypeScope && ((ss as TypeScope).kind == SymbolKind.Class || (ss as TypeScope).kind == SymbolKind.Struct)) 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.line = ss.loc.begin_line_num;
pos.column = ss.loc.begin_column_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); poses.Add(pos);
} }
} }
@ -741,7 +741,7 @@ namespace CodeCompletion
{ {
pos.line = ss.loc.begin_line_num; pos.line = ss.loc.begin_line_num;
pos.column = ss.loc.begin_column_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); poses.Add(pos);
} }
} }
@ -949,7 +949,7 @@ namespace CodeCompletion
ProcRealization pr = (ss as ProcScope).procRealization; ProcRealization pr = (ss as ProcScope).procRealization;
pos.line = pr.loc.begin_line_num; pos.line = pr.loc.begin_line_num;
pos.column = pr.loc.begin_column_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); poses.Add(pos);
if (on_proc) break; if (on_proc) break;
//ss = (ss as ProcScope).nextProc; //ss = (ss as ProcScope).nextProc;

View file

@ -886,7 +886,7 @@ namespace CodeCompletion
} }
} }
public document doc; public string doc_name;
public location get_location(SourceContext sc) public location get_location(SourceContext sc)
{ {
@ -895,7 +895,7 @@ namespace CodeCompletion
return null; return null;
} }
return new location(sc.begin_position.line_num, sc.begin_position.column_num, 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 null;
} }
return new location(tn.source_context.begin_position.line_num,tn.source_context.begin_position.column_num, 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) public override void visit(declaration _declaration)
@ -2273,7 +2273,7 @@ namespace CodeCompletion
key = "static " + key; key = "static " + key;
if (key != null && returned_scope.body_loc != null) 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) 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) 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); 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; ts.body_loc = loc;
} }
cur_scope.AddName(_type_declaration.type_name.name, ts); cur_scope.AddName(_type_declaration.type_name.name, ts);
@ -2629,7 +2629,7 @@ namespace CodeCompletion
} }
ns_cache = new Hashtable(StringComparer.CurrentCultureIgnoreCase); 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.head_loc = get_location(_unit_module.unit_name);
cur_scope.file_name = _unit_module.file_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.loc = get_location(_program_module);
cur_scope.file_name = _program_module.file_name; cur_scope.file_name = _program_module.file_name;
entry_scope = cur_scope; entry_scope = cur_scope;
@ -3353,8 +3353,8 @@ namespace CodeCompletion
cur_scope.body_loc = new location(left_line_num, cur_scope.body_loc = new location(left_line_num,
left_column_num, left_column_num,
right_line_num, right_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); 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); _program_module.program_block.program_code.visit(this);
} }
} }
@ -5236,7 +5236,7 @@ namespace CodeCompletion
if (_exception_handler.statements.source_context != null) if (_exception_handler.statements.source_context != null)
stmt_scope.loc = new location(stmt_scope.loc.begin_line_num, stmt_scope.loc.begin_column_num, 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.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; returned_scope = null;
if (_exception_handler.variable == null) return; if (_exception_handler.variable == null) return;
if (_exception_handler.type_name != null) if (_exception_handler.type_name != null)

View file

@ -597,7 +597,7 @@ namespace CodeCompletion
Position pos = new Position(); Position pos = new Position();
if (loc != null) if (loc != null)
{ {
pos.file_name = loc.doc.file_name; pos.file_name = loc.file_name;
pos.line = loc.begin_line_num; pos.line = loc.begin_line_num;
pos.column = loc.begin_column_num; pos.column = loc.begin_column_num;
pos.end_line = loc.end_line_num; pos.end_line = loc.end_line_num;
@ -611,7 +611,7 @@ namespace CodeCompletion
Position pos = new Position(); Position pos = new Position();
if (head_loc != null) 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.line = head_loc.begin_line_num;
pos.column = head_loc.begin_column_num; pos.column = head_loc.begin_column_num;
pos.end_line = head_loc.end_line_num; pos.end_line = head_loc.end_line_num;
@ -625,7 +625,7 @@ namespace CodeCompletion
Position pos = new Position(); Position pos = new Position();
if (body_loc != null) 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.line = body_loc.begin_line_num;
pos.column = body_loc.begin_column_num; pos.column = body_loc.begin_column_num;
pos.end_line = body_loc.end_line_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)) if (res == null && ts != null && ts.predef_loc != null && IsInScope(ts.predef_loc, line, column))
res = this; res = this;
foreach (SymScope ss in members) 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)) if (IsInScope(ss.loc, line, column))
{ {
@ -879,7 +879,7 @@ namespace CodeCompletion
{ {
if (ss.loc != null && loc != null) 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)) if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num))
{ {
@ -910,7 +910,7 @@ namespace CodeCompletion
// continue; // continue;
if (ss.loc != null && loc != null) 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)) 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 (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) || 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)) 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 (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 (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)) 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) foreach (SymScope ss in tmp_names)
if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) 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)) 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 (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 (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)) 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 (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)) 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 (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)) if (IsAfterDefinition(ss.loc.begin_line_num, ss.loc.begin_column_num))
{ {

View file

@ -822,7 +822,7 @@ namespace PascalABCCompiler
directives.Add(cd.name, new List<compiler_directive>()); directives.Add(cd.name, new List<compiler_directive>());
// TODO: сделать проверку на дубликаты централизованной (в другом месте) EVA // TODO: сделать проверку на дубликаты централизованной (в другом месте) EVA
else if (cd.name.Equals("mainresource", StringComparison.CurrentCultureIgnoreCase)) 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); directives[cd.name].Insert(0, cd);
} }
} }
@ -865,7 +865,7 @@ namespace PascalABCCompiler
return null; return null;
} }
return new TreeRealization.location(tn.source_context.begin_position.line_num, tn.source_context.begin_position.column_num, 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() public void StartCompile()
@ -1234,14 +1234,14 @@ namespace PascalABCCompiler
compilerDirectives.ContainsKey(StringConstants.compiler_directive_description_string) || compilerDirectives.ContainsKey(StringConstants.compiler_directive_description_string) ||
compilerDirectives.ContainsKey(StringConstants.compiler_directive_copyright_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); TryThrowInvalidPath(compilerDirectivesList[0].directive, compilerDirectivesList[0].location);
// Тут не обязательно нормализовывать путь // Тут не обязательно нормализовывать путь
// И если он слишком длинный - File.Exists вернёт false // И если он слишком длинный - File.Exists вернёт false
netCompilerOptions.MainResourceFileName = Path.Combine(Path.GetDirectoryName(compilerDirectivesList[0].source_file), compilerDirectivesList[0].directive); netCompilerOptions.MainResourceFileName = Path.Combine(Path.GetDirectoryName(compilerDirectivesList[0].source_file), compilerDirectivesList[0].directive);
if (!File.Exists(netCompilerOptions.MainResourceFileName)) 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)) if (File.Exists(resourceFileName))
ResourceFiles.Add(resourceFileName); ResourceFiles.Add(resourceFileName);
else 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));
} }
} }

View file

@ -37,7 +37,7 @@ namespace PascalABCCompiler.PCU
private PCUFile pcu_file = new PCUFile(); private PCUFile pcu_file = new PCUFile();
private CompilationUnit unit; private CompilationUnit unit;
private common_unit_node cun; private common_unit_node cun;
private document cur_doc; private string cur_doc_name;
private string unit_name; private string unit_name;
private string dir; private string dir;
private int start_pos;//смещение относительно начала PCU-файла, по которому находятся описание всех сущностей модуля private int start_pos;//смещение относительно начала PCU-файла, по которому находятся описание всех сущностей модуля
@ -301,7 +301,7 @@ namespace PascalABCCompiler.PCU
if (!File.Exists(SourceFileName)) if (!File.Exists(SourceFileName))
SourceFileName = Path.Combine(Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(FileName)),"LibSource"), pcu_file.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(); AddNamespaces();
AddInterfaceNames(); AddInterfaceNames();
@ -583,9 +583,9 @@ namespace PascalABCCompiler.PCU
else else
pcu_file.SourceFileName = Path.GetFileNameWithoutExtension(FileName); pcu_file.SourceFileName = Path.GetFileNameWithoutExtension(FileName);
if (Path.GetDirectoryName(pcu_file.SourceFileName) == "") 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 else
cur_doc = new document(pcu_file.SourceFileName); cur_doc_name = pcu_file.SourceFileName;
pcu_file.languageName = br.ReadString(); pcu_file.languageName = br.ReadString();
@ -1060,7 +1060,7 @@ namespace PascalABCCompiler.PCU
{ {
if (readDebugInfo) 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) if (loc.begin_column_num == -1)
return null; return null;
else else
@ -2389,10 +2389,10 @@ namespace PascalABCCompiler.PCU
unl2.AddElement(new using_namespace(br.ReadString())); unl2.AddElement(new using_namespace(br.ReadString()));
} }
} }
document doc = null; string doc = null;
if (br.ReadByte() == 1) 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(); SyntaxTree.SyntaxTreeStreamReader str = new SyntaxTree.SyntaxTreeStreamReader();

View file

@ -2851,7 +2851,7 @@ namespace PascalABCCompiler.PCU
else else
{ {
bw.Write((byte)1); 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(); SyntaxTree.SyntaxTreeStreamWriter stw = new SyntaxTree.SyntaxTreeStreamWriter();
stw.bw = bw; stw.bw = bw;

View file

@ -59,7 +59,7 @@ namespace PascalABCCompiler
get get
{ {
if(loc!=null) 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 else
return null; return null;
} }
@ -157,9 +157,9 @@ namespace PascalABCCompiler
loc = new location( loc = new location(
Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), Convert.ToInt32(args[1]), Convert.ToInt32(args[2]),
Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
new document(args[5])); args[5]);
if (args.Length == 2) 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) switch(command)
{ {
case ConsoleCompilerConstants.Error: case ConsoleCompilerConstants.Error:

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3"; public const string Major = "3";
public const string Minor = "11"; public const string Minor = "11";
public const string Build = "0"; public const string Build = "0";
public const string Revision = "3736"; public const string Revision = "3738";
public const string MainVersion = Major + "." + Minor; public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%COREVERSION%=0 %COREVERSION%=0
%REVISION%=3736 %REVISION%=3738
%MINOR%=11 %MINOR%=11
%MAJOR%=3 %MAJOR%=3

View file

@ -275,7 +275,7 @@ namespace PascalABCCompiler.Errors
return sourceLocation; return sourceLocation;
if (Location != null) 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); Location.begin_line_num, Location.begin_column_num, Location.end_line_num, Location.end_column_num);
} }
return null; return null;

View file

@ -193,15 +193,15 @@ namespace PascalABCCompiler.NETGenerator
if (Location != null) if (Location != null)
{ {
ISymbolDocumentWriter temp_doc = 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 else
if (save_debug_info) // иногда вызывается MarkSequencePoint при save_debug_info = false if (save_debug_info) // иногда вызывается MarkSequencePoint при save_debug_info = false
{ {
temp_doc = mb.DefineDocument(Location.document.file_name, SymDocumentType.Text, SymLanguageType.Pascal, SymLanguageVendor.Microsoft); temp_doc = mb.DefineDocument(Location.file_name, SymDocumentType.Text, SymLanguageType.Pascal, SymLanguageVendor.Microsoft);
sym_docs.Add(Location.document.file_name, temp_doc); sym_docs.Add(Location.file_name, temp_doc);
} }
if (temp_doc != doc) if (temp_doc != doc)
{ {
@ -671,7 +671,7 @@ namespace PascalABCCompiler.NETGenerator
} }
catch (Exception ex) 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; string cnns_document_file_name = null;
if (cnns[iii].Location != 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); doc = mb.DefineDocument(cnns_document_file_name, SymDocumentType.Text, SymLanguageType.Pascal, SymLanguageVendor.Microsoft);
} }
else else
@ -825,7 +825,7 @@ namespace PascalABCCompiler.NETGenerator
if (cnns_document_file_name != null && !sym_docs.ContainsKey(cnns_document_file_name)) if (cnns_document_file_name != null && !sym_docs.ContainsKey(cnns_document_file_name))
sym_docs.Add(cnns_document_file_name, doc);//сохраняем его в таблице документов 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) if (p.main_function != null)
{ {
@ -842,7 +842,7 @@ namespace PascalABCCompiler.NETGenerator
//Переводим заголовки типов //Переводим заголовки типов
for (int iii = 0; iii < cnns.Length; iii++) 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 == ""; 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]; ICommonNamespaceNode cnn = cnns[iii];
// SSM 07.02.20 // SSM 07.02.20
@ -946,7 +946,7 @@ namespace PascalABCCompiler.NETGenerator
} }
for (int iii = 0; iii < cnns.Length; iii++) 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_type = NamespacesTypes[cnns[iii]];
cur_unit_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]];
MethodBuilder mb = cur_unit_type.DefineMethod("$static_init$", MethodAttributes.Public | MethodAttributes.Static); 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++) 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_type = NamespacesTypes[cnns[iii]];
cur_unit_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]];
ConvertFunctionHeaders(cnns[iii].functions, false); ConvertFunctionHeaders(cnns[iii].functions, false);
@ -976,7 +976,7 @@ namespace PascalABCCompiler.NETGenerator
for (int iii = 0; iii < cnns.Length; iii++) 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_type = NamespacesTypes[cnns[iii]];
cur_unit_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]];
ConvertFunctionHeaders(cnns[iii].functions, true); ConvertFunctionHeaders(cnns[iii].functions, true);
@ -1010,7 +1010,7 @@ namespace PascalABCCompiler.NETGenerator
//Переводим заголовки всего остального (процедур, переменных) //Переводим заголовки всего остального (процедур, переменных)
for (int iii = 0; iii < cnns.Length; iii++) 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; bool is_main_namespace = iii == cnns.Length - 1 && comp_opt.target != TargetType.Dll;
ICommonNamespaceNode cnn = cnns[iii]; ICommonNamespaceNode cnn = cnns[iii];
string tmp_unit_name = cur_unit; string tmp_unit_name = cur_unit;
@ -1061,7 +1061,7 @@ namespace PascalABCCompiler.NETGenerator
for (int iii = 0; iii < cnns.Length; iii++) 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_type = NamespacesTypes[cnns[iii]];
cur_unit_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++) 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; bool is_main_namespace = iii == 0 && comp_opt.target != TargetType.Dll;
ICommonNamespaceNode cnn = cnns[iii]; ICommonNamespaceNode cnn = cnns[iii];
string tmp_unit_name = cur_unit; string tmp_unit_name = cur_unit;
@ -1111,7 +1111,7 @@ namespace PascalABCCompiler.NETGenerator
} }
for (int iii = 0; iii < cnns.Length; iii++) 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_type = NamespacesTypes[cnns[iii]];
cur_unit_type = NamespacesTypes[cnns[iii]]; cur_unit_type = NamespacesTypes[cnns[iii]];
//вставляем ret в int_meth //вставляем ret в int_meth
@ -1277,18 +1277,18 @@ namespace PascalABCCompiler.NETGenerator
} }
catch (System.Runtime.InteropServices.COMException e) 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) catch (System.IO.IOException e)
{ {
if (tries < num_try_save) if (tries < num_try_save)
{ {
if (has_unmanaged_resources) 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++; tries++;
} }
else 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); while (not_done);
@ -1470,7 +1470,7 @@ namespace PascalABCCompiler.NETGenerator
{ {
SemanticTree.ICommonTypeNode ctn = helper.GetTypeNodeByTypeBuilder(types[i]); SemanticTree.ICommonTypeNode ctn = helper.GetTypeNodeByTypeBuilder(types[i]);
if (ctn != null) 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) 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; 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 else
throw ex; throw ex;
@ -1583,7 +1583,7 @@ namespace PascalABCCompiler.NETGenerator
{ {
SemanticTree.ICommonTypeNode ctn = helper.GetTypeNodeByTypeBuilder(failed_types[i]); SemanticTree.ICommonTypeNode ctn = helper.GetTypeNodeByTypeBuilder(failed_types[i]);
if (ctn != null) 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 else
throw ex; throw ex;
} }
@ -1760,7 +1760,7 @@ namespace PascalABCCompiler.NETGenerator
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
if (ex.Message.IndexOf("fullname") != -1) 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; throw ex;
} }
@ -2149,7 +2149,7 @@ namespace PascalABCCompiler.NETGenerator
} }
catch (ArgumentException ex) 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) 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) 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) 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 else
{ {

View file

@ -46,7 +46,7 @@ namespace PascalABCCompiler
{ {
try 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) catch (Exception e)
{ {

View file

@ -1 +1 @@
3.11.0.3736 3.11.0.3738

View file

@ -1 +1 @@
!define VERSION '3.11.0.3736' !define VERSION '3.11.0.3738'

View file

@ -109,7 +109,7 @@ namespace PascalABCCompiler.SemanticTree
} }
//Документ, в котором определен данный элемент дерева. //Документ, в котором определен данный элемент дерева.
IDocument document string file_name
{ {
get; get;
} }

View file

@ -2173,23 +2173,23 @@ namespace PascalABCCompiler.TreeConverter
{ {
if (LoopVariables.Contains(rdVarName)) 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; continue;
} }
SymbolInfo si = visitor.context.find_first(rdVarName); SymbolInfo si = visitor.context.find_first(rdVarName);
if (si == null) 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; continue;
} }
if (!(si.sym_info is SemanticTree.IVAriableDefinitionNode)) 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; continue;
} }
if (!IsValidVarForReduction(si.sym_info as SemanticTree.IVAriableDefinitionNode)) 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; continue;
} }
Result.ReductionVariables.Add(si.sym_info as SemanticTree.IVAriableDefinitionNode); Result.ReductionVariables.Add(si.sym_info as SemanticTree.IVAriableDefinitionNode);
@ -2209,12 +2209,12 @@ namespace PascalABCCompiler.TreeConverter
SymbolInfo si = visitor.context.find_first(privateVar); SymbolInfo si = visitor.context.find_first(privateVar);
if (si == null) 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; continue;
} }
if (!(si.sym_info is SemanticTree.IVAriableDefinitionNode)) 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; continue;
} }
Result.PrivateVariables.Add(si.sym_info as SemanticTree.IVAriableDefinitionNode); Result.PrivateVariables.Add(si.sym_info as SemanticTree.IVAriableDefinitionNode);

View file

@ -73,7 +73,7 @@ namespace PascalABCCompiler.TreeConverter
public string loc_to_string(ILocation loc) public string loc_to_string(ILocation loc)
{ {
if (loc == null) return "Undefined location(!)"; 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 += " line: " + loc.begin_line_num.ToString();
res += " column: " + loc.begin_column_num.ToString(); res += " column: " + loc.begin_column_num.ToString();
return res; return res;
@ -2649,12 +2649,12 @@ namespace PascalABCCompiler.TreeConverter
string message = "NOT_SUPPORTED_BY_THIS_VERSION_OF_COMPILER"; string message = "NOT_SUPPORTED_BY_THIS_VERSION_OF_COMPILER";
public NotSupportedError(location loc) public NotSupportedError(location loc)
:base(loc.document.file_name) :base(loc.document)
{ {
_loc = loc; _loc = loc;
} }
public NotSupportedError(location loc, string msg) public NotSupportedError(location loc, string msg)
: base(loc.document.file_name) : base(loc.document)
{ {
_loc = loc; _loc = loc;
message = msg; message = msg;

View file

@ -35,7 +35,7 @@ namespace PascalABCCompiler.TreeConverter
get get
{ {
if (loc != null) 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 else
return null; return null;
} }

View file

@ -32,7 +32,7 @@ namespace PascalABCCompiler.TreeConverter
//в конце за счет флага вернем состояние обратно и сгенерируем и параллельную ветку тоже //в конце за счет флага вернем состояние обратно и сгенерируем и параллельную ветку тоже
} }
else 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 //уже генерируем одну из веток else //уже генерируем одну из веток
//если это параллельная ветка - последовательную генерировать не будем //если это параллельная ветка - последовательную генерировать не будем

View file

@ -158,7 +158,7 @@ namespace PascalABCCompiler.TreeConverter
{ {
return null; return null;
} }
document doc = _stv.CurrentDocument; string doc = _stv.CurrentDocument;
location loc=null; location loc=null;
//DarkStar changed //DarkStar changed
//В PCU не сохраняются location некоторых конструкций, например //В PCU не сохраняются location некоторых конструкций, например
@ -177,7 +177,7 @@ namespace PascalABCCompiler.TreeConverter
{ {
return null; return null;
} }
document d = new document(l.document.file_name); string d = l.file_name;
if (d == null) if (d == null)
d = syntax_tree_visitor.CurrentDocument; d = syntax_tree_visitor.CurrentDocument;

View file

@ -70,7 +70,7 @@ namespace PascalABCCompiler.TreeConverter
public returner ret; public returner ret;
internal document current_document; internal string current_document;
public compilation_context context; public compilation_context context;
private bool var_def_statement_converting; private bool var_def_statement_converting;
@ -151,7 +151,7 @@ namespace PascalABCCompiler.TreeConverter
using_list.Clear(); using_list.Clear();
current_document = new document(initializationData.syntaxUnit.file_name); current_document = initializationData.syntaxUnit.file_name;
ErrorsList = initializationData.errorsList; ErrorsList = initializationData.errorsList;
WarningsList = initializationData.warningsList; WarningsList = initializationData.warningsList;
@ -712,7 +712,7 @@ namespace PascalABCCompiler.TreeConverter
} }
public PascalABCCompiler.TreeRealization.document CurrentDocument public string CurrentDocument
{ {
get get
{ {
@ -741,11 +741,11 @@ namespace PascalABCCompiler.TreeConverter
{ {
return null; return null;
} }
document d = current_document; string file_name = current_document;
if (tns.FileName != null && (d == null || d.file_name != tns.FileName)) if (tns.FileName != null && (file_name == null || file_name != tns.FileName))
d = new document(tns.FileName); file_name = tns.FileName;
return new location(tns.begin_position.line_num, tns.begin_position.column_num, 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) public location get_right_location(SyntaxTree.syntax_tree_node tn)
{ {
@ -763,11 +763,11 @@ namespace PascalABCCompiler.TreeConverter
{ {
return null; return null;
} }
document d = current_document; string file_name = current_document;
if (tn.source_context.FileName != null) 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, 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 public common_unit_node CompiledUnit
@ -3628,7 +3628,7 @@ namespace PascalABCCompiler.TreeConverter
{ {
constant_definition_node ncd = si.FirstOrDefault().sym_info as constant_definition_node; 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 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_value(ncd.type);
return; return;
@ -11506,7 +11506,7 @@ namespace PascalABCCompiler.TreeConverter
SymbolTable.Scope[] used_units = build_referenced_units(ReferencedUnits,true); 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); common_namespace_node cnsn = context.create_namespace(namespace_name, _compiled_unit, _compiled_unit.scope, loc);
cnsn.is_main = true; cnsn.is_main = true;
@ -19689,7 +19689,7 @@ namespace PascalABCCompiler.TreeConverter
bool current_record_created = _record_created; bool current_record_created = _record_created;
_record_created = false; _record_created = false;
SemanticTree.field_access_level current_fal = context.get_field_access_level(); 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; current_document = tc.cur_document;
bool current_body_exists = body_exists; bool current_body_exists = body_exists;
body_exists = false; body_exists = false;

View file

@ -461,7 +461,7 @@ namespace PascalABCCompiler.TreeConverter
ctn.const_defs.AddElement(cdn2); ctn.const_defs.AddElement(cdn2);
common_method_node get_func = new common_method_node(StringConstants.get_val_pascal_array_name, 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)); convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope, "get " + name));
common_parameter get_param = new common_parameter(StringConstants.unary_param_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, 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); 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; get_func.function_code = sn;
common_method_node set_func = new common_method_node(StringConstants.set_val_pascal_array_name, 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)); convertion_data_and_alghoritms.symbol_table.CreateScope(ctn.scope, "set " + name));
common_parameter set_ind = new common_parameter(StringConstants.left_param_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, 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; function_node assign = (function_node)si.sym_info;
statement_node assign_call = convertion_data_and_alghoritms.create_simple_function_call(assign, 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; set_func.function_code = assign_call;

View file

@ -5,42 +5,9 @@ using System;
namespace PascalABCCompiler.TreeRealization namespace PascalABCCompiler.TreeRealization
{ {
/// <summary> /// <summary>
/// Класс, описывающий файл кода. /// Класс, описывающий файл кода. Убрал. Теперь это просто имя файла string
/// Используется для указания позиции частей кода. /// Используется для указания позиции частей кода.
/// </summary> /// </summary>
[Serializable]
public class document : SemanticTree.IDocument
{
/// <summary>
/// Имя файла.
/// </summary>
private readonly string _file_name;
/// <summary>
/// Конструктор документа.
/// </summary>
/// <param name="file_name">Путь к документу.</param>
public document(string file_name)
{
_file_name=file_name;
}
/// <summary>
/// Путь к документу.
/// </summary>
public string file_name
{
get
{
return _file_name;
}
}
public override string ToString()
{
return (_file_name);
}
}
} }

View file

@ -33,7 +33,7 @@ namespace PascalABCCompiler.TreeRealization
/// <summary> /// <summary>
/// Документ, в котором расположен этот фрагмент кода. /// Документ, в котором расположен этот фрагмент кода.
/// </summary> /// </summary>
private document _doc; private string _file_name;
/// <summary> /// <summary>
/// Конструктор класса. /// Конструктор класса.
@ -43,13 +43,13 @@ namespace PascalABCCompiler.TreeRealization
/// <param name="end_line_num">Номер строки конца фрагмента кода (нумерация начинается с 1).</param> /// <param name="end_line_num">Номер строки конца фрагмента кода (нумерация начинается с 1).</param>
/// <param name="end_column_num">Номер колонки конца фрагмента кода (нумерация начинается с 1)</param> /// <param name="end_column_num">Номер колонки конца фрагмента кода (нумерация начинается с 1)</param>
/// <param name="doc">Документ, в котором расположен этот фрагмент кода.</param> /// <param name="doc">Документ, в котором расположен этот фрагмент кода.</param>
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_line_num=begin_line_num;
_begin_column_num=begin_column_num; _begin_column_num=begin_column_num;
_end_line_num=end_line_num; _end_line_num=end_line_num;
_end_column_num=end_column_num; _end_column_num=end_column_num;
_doc=doc; _file_name=file_name;
} }
/// <summary> /// <summary>
@ -115,26 +115,26 @@ namespace PascalABCCompiler.TreeRealization
/// <summary> /// <summary>
/// Документ, в котором расположен этот фрагмент кода. /// Документ, в котором расположен этот фрагмент кода.
/// </summary> /// </summary>
public document doc public string file_name
{ {
get get
{ {
return _doc; return _file_name;
} }
set set
{ {
_doc = value; _file_name = value;
} }
} }
/// <summary> /// <summary>
/// Документ, в котором расположен этот фрагмент кода. /// Документ, в котором расположен этот фрагмент кода.
/// </summary> /// </summary>
public SemanticTree.IDocument document public string document
{ {
get get
{ {
return _doc; return _file_name;
} }
} }
@ -142,7 +142,7 @@ namespace PascalABCCompiler.TreeRealization
{ {
if (loc == null) if (loc == null)
return 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() public override string ToString()

View file

@ -150,7 +150,7 @@ namespace PascalABCCompiler.TreeRealization
private SyntaxTree.type_declaration _type_decl; //Синтаксическое дерево шаблона private SyntaxTree.type_declaration _type_decl; //Синтаксическое дерево шаблона
private string _name; //Имя шаблона private string _name; //Имя шаблона
private common_namespace_node _cnn; //Пространство, где описан шаблон private common_namespace_node _cnn; //Пространство, где описан шаблон
private document _doc; //Документ, т.е. файл, где описан шаблон private string _file_name; //Документ, т.е. файл, где описан шаблон
private using_namespace_list _unl; //Список подключенных к _cnn пространств private using_namespace_list _unl; //Список подключенных к _cnn пространств
private using_namespace_list _unl2 = null; //То же для пространства внешних методов private using_namespace_list _unl2 = null; //То же для пространства внешних методов
private bool _ForwardDeclarationOnly = false; //true, если пока есть только предописание private bool _ForwardDeclarationOnly = false; //true, если пока есть только предописание
@ -219,11 +219,11 @@ namespace PascalABCCompiler.TreeRealization
} }
} }
public document cur_document public string cur_document
{ {
get 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; _cnn = cnn;
_type_decl = type_decl; _type_decl = type_decl;
_name = name; _name = name;
_doc = doc; _file_name = file_name;
//(ssyy) using - список, по-видимому, можно только копировать, т.к. Николай его периодически чистит. //(ssyy) using - список, по-видимому, можно только копировать, т.к. Николай его периодически чистит.
_unl = new using_namespace_list(); _unl = new using_namespace_list();

View file

@ -946,7 +946,7 @@ namespace VisualPascalABCPlugins
// перед входом в блок ув. отступ // перед входом в блок ув. отступ
//SemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyIncrement(); //SemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyIncrement();
mainNamespace = value.main_function.comprehensive_namespace; 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) foreach (ICommonNamespaceNode nodeNamespace in value.namespaces)
{ {
nodeNamespace.visit(this); nodeNamespace.visit(this);
@ -957,7 +957,7 @@ namespace VisualPascalABCPlugins
bodyBlock.Append(System.Environment.NewLine); bodyBlock.Append(System.Environment.NewLine);
string name = nodeNamespace.namespace_name.Replace('$', 'S'); string name = nodeNamespace.namespace_name.Replace('$', 'S');
if (name == "") 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); SaveTextInFile(outdir + "\\" +name+".cs", currNamespace, false);
nmspaceFiles.Add(outdir + "\\" + name + ".cs"); nmspaceFiles.Add(outdir + "\\" + name + ".cs");
} }