Merge branch 'master' into async-await
# Conflicts: # Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.cs # Languages/Pascal/PascalABCParserNewSaushkin/ABCPascal.y # Languages/Pascal/PascalABCParserNewSaushkin/ABCPascalYacc.cs # Languages/Pascal/PascalABCParserNewSaushkin/PABC.ymc
This commit is contained in:
commit
015bd7a78c
|
|
@ -2709,16 +2709,19 @@ namespace PascalABCCompiler
|
|||
|
||||
if (!PCUFileNamesDictionary.TryGetValue(cacheKey, out var fileNameWithPriority))
|
||||
{
|
||||
if (FindFileWithExtensionInDirs(fileName, out _, currentPath) is string resultFileName1)
|
||||
if (Path.GetExtension(fileName) != CompilerOptions.CompiledUnitExtension)
|
||||
fileNameWithPriority = null;
|
||||
|
||||
else if (FindFileWithExtensionInDirs(fileName, out _, currentPath) is string resultFileName1)
|
||||
fileNameWithPriority = Tuple.Create(resultFileName1, 1);
|
||||
else if (FindFileWithExtensionInDirs(Path.GetFileName(fileName), out _, CompilerOptions.OutputDirectory) is string resultFileName2)
|
||||
else if (CompilerOptions.OutputDirectory != CompilerOptions.SourceFileDirectory && FindFileWithExtensionInDirs(Path.GetFileName(fileName), out _, CompilerOptions.OutputDirectory) is string resultFileName2)
|
||||
fileNameWithPriority = Tuple.Create(resultFileName2, 2);
|
||||
else if (FindFileWithExtensionInDirs(fileName, out var dirIndex, CompilerOptions.SearchDirectories.ToArray()) is string resultFileName3)
|
||||
fileNameWithPriority = Tuple.Create(resultFileName3, 3 + dirIndex);
|
||||
else
|
||||
fileNameWithPriority = null;
|
||||
|
||||
PCUFileNamesDictionary[cacheKey] = fileNameWithPriority;
|
||||
PCUFileNamesDictionary[cacheKey] = fileNameWithPriority;
|
||||
}
|
||||
|
||||
folderPriority = fileNameWithPriority?.Item2 ?? 0;
|
||||
|
|
@ -2730,8 +2733,9 @@ namespace PascalABCCompiler
|
|||
var cacheKey = Tuple.Create(fileName.ToLower(), currentPath?.ToLower());
|
||||
|
||||
if (!SourceFileNamesDictionary.TryGetValue(cacheKey, out var fileNameWithPriority))
|
||||
{
|
||||
if (FindSourceFileNameInDirs(fileName, out _, currentPath) is string resultFileName1)
|
||||
{
|
||||
|
||||
if (FindSourceFileNameInDirs(fileName, out _, currentPath) is string resultFileName1)
|
||||
fileNameWithPriority = Tuple.Create(resultFileName1, 1);
|
||||
else if (FindSourceFileNameInDirs(fileName, out var dirIndex, CompilerOptions.SearchDirectories.ToArray()) is string resultFileName2)
|
||||
fileNameWithPriority = Tuple.Create(resultFileName2, 3 + dirIndex);
|
||||
|
|
@ -3362,8 +3366,18 @@ namespace PascalABCCompiler
|
|||
// It's not always possible to solve by re-ordering the references, since there are cases of
|
||||
// mutually-dependent assemblies (i.e. dependency loops) in the wild.
|
||||
foreach (var reference in referenceDirectives)
|
||||
PreloadReference(reference);
|
||||
|
||||
{
|
||||
try
|
||||
{
|
||||
PreloadReference(reference);
|
||||
}
|
||||
catch (FileLoadException ex)
|
||||
{
|
||||
throw new CommonCompilerError(ex.Message, compilationUnit.SyntaxTree.file_name, reference.location.begin_line_num, reference.location.end_line_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (var reference in referenceDirectives)
|
||||
CompileReference(dlls, reference);
|
||||
|
||||
|
|
|
|||
|
|
@ -3375,8 +3375,6 @@ expr_l1_for_lambda
|
|||
expr_dq
|
||||
: relop_expr
|
||||
{ $$ = $1; }
|
||||
| tkAwait relop_expr
|
||||
{ $$ = new await_node($2 as expression, @$); }
|
||||
| expr_dq tkDoubleQuestion relop_expr
|
||||
{ $$ = new double_question_node($1 as expression, $3 as expression, @$);}
|
||||
;
|
||||
|
|
@ -4160,6 +4158,8 @@ factor
|
|||
$$ = new nil_const();
|
||||
$$.source_context = @$;
|
||||
}
|
||||
| tkAwait factor
|
||||
{ $$ = new await_node($2 as expression, @$); }
|
||||
| literal_or_number
|
||||
{ $$ = $1; }
|
||||
| default_expr
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -4707,9 +4707,12 @@ namespace PascalABCCompiler.NETGenerator
|
|||
{
|
||||
ICommonTypeNode ctn = init_value.type as ICommonTypeNode;
|
||||
IExpressionNode[] FieldValues = init_value.FieldValues;
|
||||
ICommonClassFieldNode[] Fields = ctn.fields;
|
||||
List<ICommonClassFieldNode> Fields = new List<ICommonClassFieldNode>();
|
||||
foreach (var field in ctn.fields)
|
||||
if (field.polymorphic_state != polymorphic_state.ps_static)
|
||||
Fields.Add(field);
|
||||
|
||||
for (int i = 0; i < Fields.Length; i++)
|
||||
for (int i = 0; i < Fields.Count; i++)
|
||||
{
|
||||
FldInfo field = helper.GetField(Fields[i]);
|
||||
if (FieldValues[i] is IArrayInitializer)
|
||||
|
|
@ -4750,9 +4753,12 @@ namespace PascalABCCompiler.NETGenerator
|
|||
{
|
||||
ICommonTypeNode ctn = init_value.type as ICommonTypeNode;
|
||||
IConstantNode[] FieldValues = init_value.FieldValues;
|
||||
ICommonClassFieldNode[] Fields = ctn.fields;
|
||||
List<ICommonClassFieldNode> Fields = new List<ICommonClassFieldNode>();
|
||||
foreach (var field in ctn.fields)
|
||||
if (field.polymorphic_state != polymorphic_state.ps_static)
|
||||
Fields.Add(field);
|
||||
|
||||
for (int i = 0; i < Fields.Length; i++)
|
||||
for (int i = 0; i < Fields.Count; i++)
|
||||
{
|
||||
FldInfo field = helper.GetField(Fields[i]);
|
||||
if (FieldValues[i] is IArrayConstantNode)
|
||||
|
|
|
|||
|
|
@ -113,13 +113,16 @@ namespace SyntaxVisitors
|
|||
return;
|
||||
}
|
||||
|
||||
var newNameCache = new Dictionary<string, string>();
|
||||
|
||||
var newLocalNames = var_def.vars.idents.Select(id =>
|
||||
{
|
||||
var low = id.name.ToLower();
|
||||
|
||||
var newName = this.CreateNewVariableName(low);
|
||||
//BlockNamesStack[CurrentLevel].Add(low, newName);
|
||||
BlockNamesStack[CurrentLevel][low] = newName;
|
||||
//BlockNamesStack[CurrentLevel][low] = newName;
|
||||
newNameCache[low] = newName;
|
||||
return new ident(newName, id.source_context);
|
||||
});
|
||||
|
||||
|
|
@ -130,6 +133,8 @@ namespace SyntaxVisitors
|
|||
Replace(var_def, newVS);
|
||||
listNodes[listNodes.Count - 1] = newVS; //SSM 8.11.18
|
||||
ProcessNode(newVS.inital_value); // SSM 10.06.2020 #2103
|
||||
foreach (var key in newNameCache.Keys)
|
||||
BlockNamesStack[CurrentLevel][key] = newNameCache[key];
|
||||
//base.visit(newVS); // SSM 10.06.2020 - зачем обходить всё?
|
||||
}
|
||||
|
||||
|
|
|
|||
8
TestSuite/errors/err0538.pas
Normal file
8
TestSuite/errors/err0538.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
//!Повторно объявленный идентификатор name
|
||||
type
|
||||
name = (name);
|
||||
|
||||
begin
|
||||
// Ожидался тип
|
||||
var v1: name;
|
||||
end.
|
||||
11
TestSuite/errors/err0539.pas
Normal file
11
TestSuite/errors/err0539.pas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
//!Количество полей не совпадает с количеством полей в записи
|
||||
type
|
||||
r1 = record
|
||||
a: byte;
|
||||
static b: word;
|
||||
end;
|
||||
|
||||
begin
|
||||
// Работает, но не должно
|
||||
var a: r1 := (a: 1; b: 2);
|
||||
end.
|
||||
11
TestSuite/recinit3.pas
Normal file
11
TestSuite/recinit3.pas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
type
|
||||
r1 = record
|
||||
a: byte;
|
||||
static b: word;
|
||||
end;
|
||||
|
||||
begin
|
||||
//Ошибка: Количество полей не совпадает с количеством полей в записи
|
||||
var a: r1 := (a: 1);
|
||||
assert(a.a = 1);
|
||||
end.
|
||||
29
TestSuite/yield8.pas
Normal file
29
TestSuite/yield8.pas
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
function V(n: byte) := 1;
|
||||
|
||||
function f1: sequence of integer;
|
||||
begin
|
||||
//Ошибка: Ожидалось имя процедуры или функции
|
||||
var v := V(0);
|
||||
// Если закомментировать эту строчку - предыдущая строчка работает
|
||||
yield v;
|
||||
end;
|
||||
|
||||
function f2: sequence of integer;
|
||||
begin
|
||||
//Ошибка: Ожидалось имя процедуры или функции
|
||||
var v := V(0);
|
||||
var w := v + 1;
|
||||
// Если закомментировать эту строчку - предыдущая строчка работает
|
||||
yield w;
|
||||
end;
|
||||
|
||||
begin
|
||||
var i := 0;
|
||||
foreach var j in f1 do
|
||||
i := j;
|
||||
assert(i = 1);
|
||||
|
||||
foreach var j in f2 do
|
||||
i := j;
|
||||
assert(i = 2);
|
||||
end.
|
||||
|
|
@ -111,6 +111,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
//convertion_data_and_alghoritms.__i = 0;
|
||||
Initialize(initializationData);
|
||||
|
||||
this.docs = initializationData.docs;
|
||||
//comp_units=UsedUnits;
|
||||
//visit(SyntaxUnit
|
||||
//SyntaxTreeToSemanticTreeConverter.interface_using_list = namespaces;
|
||||
|
|
@ -122,6 +124,9 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
Initialize(initializationData);
|
||||
|
||||
if (this.docs != null)
|
||||
this.docs = initializationData.docs;
|
||||
|
||||
using_list.AddRange(initializationData.interfaceNamespaces);
|
||||
interface_using_list.AddRange(initializationData.interfaceNamespaces);
|
||||
using_list.AddRange(initializationData.implementationNamespaces);
|
||||
|
|
@ -150,8 +155,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
SymbolTable.CaseSensitive = SemanticRulesConstants.SymbolTableCaseSensitive;
|
||||
|
||||
if (docs != null)
|
||||
this.docs = initializationData.docs;
|
||||
this.debug = initializationData.debug;
|
||||
this.debugging = initializationData.debugging;
|
||||
this.for_intellisense = initializationData.forIntellisense;
|
||||
|
|
@ -12208,6 +12211,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
context.check_name_free(name, loc);
|
||||
is_direct_type_decl = true;
|
||||
type_node tn = convert_strong(_type_declaration.type_def);
|
||||
if (_type_declaration.type_def is enum_type_definition)
|
||||
context.check_name_free(name, loc);
|
||||
assign_doc_info(tn,_type_declaration);
|
||||
is_direct_type_decl = false;
|
||||
if (_type_declaration.type_def is SyntaxTree.named_type_reference||
|
||||
|
|
@ -15592,13 +15597,14 @@ namespace PascalABCCompiler.TreeConverter
|
|||
private record_initializer ConvertRecordInitializer(common_type_node ctn, record_initializer constant)
|
||||
{
|
||||
location loc = constant.location;
|
||||
var non_static_fields = ctn.fields.Where(x => !x.IsStatic).ToArray();
|
||||
if (!ctn.is_value_type)
|
||||
AddError(loc, "RECORD_CONST_NOT_ALLOWED_{0}", ctn.name);
|
||||
if (ctn.fields.Count != constant.record_const_definition_list.Count)
|
||||
if (non_static_fields.Length != constant.record_const_definition_list.Count)
|
||||
AddError(loc, "INVALID_RECORD_CONST_FIELD_COUNT");
|
||||
constant.type = ctn;
|
||||
constant.field_values.Clear();
|
||||
for (int i = 0; i < ctn.fields.Count; i++)
|
||||
for (int i = 0; i < non_static_fields.Length; i++)
|
||||
{
|
||||
class_field cf = ctn.fields[i];
|
||||
if (cf.name.ToLower() != constant.record_const_definition_list[i].name.name.ToLower())
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ unit ABCObjects;
|
|||
//{$apptype windows}
|
||||
{$reference '%GAC%\System.Windows.Forms.dll'}
|
||||
{$reference '%GAC%\System.Drawing.dll'}
|
||||
{$gendoc true}
|
||||
|
||||
interface
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doc>
|
||||
<unit name="ABCObjects" />
|
||||
<members />
|
||||
</doc>
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
unit CRT;
|
||||
|
||||
{$apptype console}
|
||||
{$gendoc true}
|
||||
|
||||
interface
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doc>
|
||||
<unit name="CRT" />
|
||||
<members />
|
||||
</doc>
|
||||
|
|
@ -8,7 +8,6 @@ unit GraphABC;
|
|||
{$apptype windows}
|
||||
{$reference '%GAC%\System.Windows.Forms.dll'}
|
||||
{$reference '%GAC%\System.Drawing.dll'}
|
||||
{$gendoc true}
|
||||
|
||||
interface
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doc>
|
||||
<unit name="GraphABC" />
|
||||
<members />
|
||||
</doc>
|
||||
|
|
@ -7,8 +7,6 @@ unit PABCSystem;
|
|||
|
||||
{$zerobasedstrings off}
|
||||
|
||||
{$gendoc true}
|
||||
|
||||
// Default Application type
|
||||
{$apptype console}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<doc>
|
||||
<unit name="PABCSystem" />
|
||||
<members />
|
||||
</doc>
|
||||
Loading…
Reference in a new issue