This commit is contained in:
Бондарев Иван 2020-05-24 18:07:51 +02:00
parent 80779d1f1b
commit 02f150a99a
5 changed files with 51 additions and 9 deletions

View file

@ -2700,6 +2700,8 @@ function InternalRange(l,r: char): CharRange;
///--
function InternalRange(l,r: real): RealRange;
///--
function IsInputPipedOrRedirectedFromFile: boolean;
// -----------------------------------------------------
// Internal procedures for PABCRTL.dll

View file

@ -57,7 +57,8 @@ end;
procedure SendReadlnRequest;
begin
ReadlnSignalSended := true;
WriteToProcessErrorStream(ReadlnSignalCommand);
if not IsInputPipedOrRedirectedFromFile then
WriteToProcessErrorStream(ReadlnSignalCommand);
end;
function __ReadSignalOISystem.peek: integer;

30
TestSuite/operators1.pas Normal file
View file

@ -0,0 +1,30 @@
var i: integer;
type TRec<T> = record
a, b: integer;
class function operator=(a, b: TRec<T>): boolean;
begin
Result := false;
i := 2;
end;
end;
TRec2 = record
a, b: integer;
class function operator=(a, b: TRec2): boolean;
begin
Result := false;
i := 3;
end;
end;
begin
var r1, r2: TRec<integer>;
assert(not (r1 = r2));
assert(i = 2);
var r3, r4: TRec2;
assert(not (r3 = r4));
assert(i = 3);
assert(not (r3 <> r4));
end.

View file

@ -1019,10 +1019,12 @@ namespace PascalABCCompiler.TreeConverter
private void add_notequal_operator_if_need()
{
SymbolInfo si = _ctn.find_first_in_type(compiler_string_consts.noteq_name);
if (si.sym_info is common_method_node)
return;
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.scope, _cmn.scope, null, si.ToString());
List<SymbolInfo> si_list = _ctn.find_in_type(compiler_string_consts.noteq_name);
foreach (SymbolInfo si2 in si_list)
if (si2.sym_info is common_method_node)
return;
SymbolInfo si = si_list[0];
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.scope, _cmn.scope, null, si.ToString());
common_method_node cmn = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.noteq_name),SystemLibrary.SystemLibrary.bool_type,null,_ctn,
SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope);
cmn.IsOperator = true;
@ -1053,10 +1055,12 @@ namespace PascalABCCompiler.TreeConverter
private void add_equal_operator_if_need()
{
SymbolInfo si = _ctn.find_first_in_type(compiler_string_consts.eq_name);
if (si.sym_info is common_method_node)
return;
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope( _ctn.scope, _cmn.scope, null, si.ToString());
List<SymbolInfo> si_list = _ctn.find_in_type(compiler_string_consts.eq_name);
foreach (SymbolInfo si2 in si_list)
if (si2.sym_info is common_method_node)
return;
SymbolInfo si = si_list[0];
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope( _ctn.scope, _cmn.scope, null, si.ToString());
common_method_node cmn = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.eq_name),SystemLibrary.SystemLibrary.bool_type,null,_ctn,
SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope);
cmn.IsOperator = true;

View file

@ -541,6 +541,11 @@ namespace PascalABCCompiler.TreeRealization
}
}
public void SetName(string name)
{
_name = name;
}
//TODO: Нужно ли is_overload для basic_function_node?
public bool is_overload
{