Skip to content

Commit

Permalink
Merge branch 'pascalabcnet:master' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
spectatorBH authored Jun 24, 2024
2 parents 8d186dc + 3197575 commit a9ad335
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Compiler/PCU/PCUReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ private type_node GetTypeReference()
loc = ReadDebugInfo();
type_node elem_type = GetTypeReference();
int rank = br.ReadInt32();
return type_constructor.instance.create_unsized_array(elem_type, null, rank, loc);
return type_constructor.instance.create_unsized_array(elem_type, rank, loc);
case 6:
return GetTemplateInstance();
case 7:
Expand Down
6 changes: 6 additions & 0 deletions TestSuite/units/u_common_arr1_0.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
unit u_common_arr1_0;

uses u_common_arr1_1;
uses u_common_arr1_2;

end.
7 changes: 7 additions & 0 deletions TestSuite/units/u_common_arr1_1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
unit u_common_arr1_1;

uses u_common_arr1_3;

var v1: array of c3;

end.
7 changes: 7 additions & 0 deletions TestSuite/units/u_common_arr1_2.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
unit u_common_arr1_2;

uses u_common_arr1_3;

var v2: array of c3;

end.
6 changes: 6 additions & 0 deletions TestSuite/units/u_common_arr1_3.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
unit u_common_arr1_3;

type
c3 = class end;

end.
5 changes: 5 additions & 0 deletions TestSuite/usesunits/use_common_arr1.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## uses u_common_arr1_1, u_common_arr1_2;

// Проверяем что типы всё ещё совместимые
v1 := v2;
v2 := v1;
7 changes: 3 additions & 4 deletions TreeConverter/TreeConversion/syntax_tree_visitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14951,8 +14951,7 @@ public override void visit(SyntaxTree.array_type _array_type)
//AddError(new VoidNotValid(get_location(_array_type.elemets_types)));
check_for_type_allowed(et,get_location(_array_type.elements_type));
check_using_static_class(et, get_location(_array_type.elements_type));
ret = convertion_data_and_alghoritms.type_constructor.create_unsized_array(et,
context.converted_namespace, rank, get_location(_array_type));
ret = convertion_data_and_alghoritms.type_constructor.create_unsized_array(et, rank, get_location(_array_type));
return_value(ret);
return;
}
Expand Down Expand Up @@ -17237,7 +17236,7 @@ private type_node DeduceType(type_node tn, location loc)
if (tn is undefined_type || tn is null_type_node)
{
if (tn is ArrayConstType)
return convertion_data_and_alghoritms.type_constructor.create_unsized_array((tn as ArrayConstType).element_type, context.converted_namespace, 1, loc);
return convertion_data_and_alghoritms.type_constructor.create_unsized_array(((ArrayConstType)tn).element_type, 1, loc);
AddError(loc, "CAN_NOT_DEDUCE_TYPE_{0}", tn.name);
}
return tn;
Expand Down Expand Up @@ -19645,7 +19644,7 @@ public override void visit(SyntaxTree.new_expr _new_expr)
//if (exprs.Count == 1)
{
//new typename[size]
type_node atn = convertion_data_and_alghoritms.type_constructor.create_unsized_array(tn, context.converted_namespace, exprs.Count, loc);
type_node atn = convertion_data_and_alghoritms.type_constructor.create_unsized_array(tn, exprs.Count, loc);
//тип элементов
typeof_operator to = new typeof_operator(tn, loc);
List<expression_node> lst = new List<expression_node>();
Expand Down
9 changes: 2 additions & 7 deletions TreeConverter/TreeConversion/type_constructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public type_constructor(convertion_data_and_alghoritms _convertion_data_and_algh
private System.Collections.Generic.Dictionary<type_node, List<type_node>> types_unsized_arrays =
new System.Collections.Generic.Dictionary<type_node, List<type_node>>();

public type_node create_unsized_array(type_node element_type, common_namespace_node cmn, int rank, location loc)
public type_node create_unsized_array(type_node element_type, int rank, location loc)
{
List<type_node> ret = null;
if(types_unsized_arrays.TryGetValue(element_type,out ret))
Expand Down Expand Up @@ -79,15 +79,10 @@ public type_node create_unsized_array(type_node element_type, common_namespace_n
SystemLibrary.SystemLibrary.init_reference_type(ctn);
return ctn;
}
SymbolTable.Scope top_scope = null;
if (cmn != null)
{
top_scope = cmn.scope;
}

common_type_node comtn = new common_type_node(SystemLibrary.SystemLibrary.array_base_type,
StringConstants.get_array_type_name(element_type.name,rank), SemanticTree.type_access_level.tal_public,
cmn, convertion_data_and_alghoritms.symbol_table.CreateClassScope(top_scope,SystemLibrary.SystemLibrary.array_base_type.Scope), loc);
null, convertion_data_and_alghoritms.symbol_table.CreateClassScope(null, SystemLibrary.SystemLibrary.array_base_type.Scope), loc);
comtn.internal_type_special_kind = SemanticTree.type_special_kind.array_kind;
comtn.is_class = true;
comtn.add_internal_interface(aii);
Expand Down
6 changes: 3 additions & 3 deletions TreeConverter/TreeRealization/generics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
//Здесь описана реализация generic-типов
//Файлом владеет ssyy.
Expand Down Expand Up @@ -508,7 +508,7 @@ public static type_node determine_type(type_node tn, List<type_node> param_types
type_node elem_tp = determine_type(ii.element_type, param_types, method_param_types, generic_param_types);
if (elem_tp != ii.element_type)
{
return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, null, ii.rank, null);
return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, ii.rank, null);
}
return tn;
}
Expand Down Expand Up @@ -555,7 +555,7 @@ public static type_node determine_type(type_node tn, List<type_node> param_types
type_node elem_tp = determine_type(comm_type.element_type, param_types, method_param_types, generic_param_types);
if (elem_tp != comm_type.element_type)
{
return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, null, 1, comm_type.loc);
return SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.type_constructor.create_unsized_array(elem_tp, 1, comm_type.loc);
}
return tn;
}
Expand Down
Binary file modified bin/TestRunner.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions bin/TestRunner.pas
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ procedure CompileAllCompilationTests(dir: string; withdll: boolean);
procedure CompileAllUnits;
begin
var comp := new Compiler();
// Не пропускать ошибки сохранения PCU, в тесте создания PCU
comp.InternalDebug.SkipPCUErrors := false;
var files := Directory.GetFiles(TestSuiteDir + PathSeparator + 'units', '*.pas');
var dir := TestSuiteDir + PathSeparator + 'units' + PathSeparator;
for var i := 0 to files.Length - 1 do
Expand Down

0 comments on commit a9ad335

Please sign in to comment.