From 6ece72a5f51756ba92b501a5cd47af5a21d70685 Mon Sep 17 00:00:00 2001 From: Mattias Gaertner Date: Mon, 19 Oct 2020 07:21:16 +0000 Subject: [PATCH] pastojs: fixed compile git-svn-id: trunk@47136 - (cherry picked from commit 764b035c23fa60c1bad4a572b11dbe41b2bd3df6) --- packages/pastojs/src/pas2jsfiler.pp | 6 +-- packages/pastojs/tests/tcfiler.pas | 65 +++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/packages/pastojs/src/pas2jsfiler.pp b/packages/pastojs/src/pas2jsfiler.pp index f9fc99526b..e9a328088b 100644 --- a/packages/pastojs/src/pas2jsfiler.pp +++ b/packages/pastojs/src/pas2jsfiler.pp @@ -5738,15 +5738,15 @@ end; function TPCUReader.AddElReference(Id: integer; ErrorEl: TPasElement; El: TPasElement): TPCUFilerElementRef; var + {$IF defined(VerbosePCUFiler) or defined(memcheck)} + Node: TAVLTreeNode; + {$ENDIF} Ref: TPCUFilerElementRef; RefItem: TPCUFilerPendingElRef; PendingElRef: TPCUReaderPendingElRef; PendingElListRef: TPCUReaderPendingElListRef; PendingElArrRef: TPCUReaderPendingElArrRef; - {$IF defined(VerbosePCUFiler) or defined(memcheck)} - Node: TAVLTreeNode; PendingElScopeRef: TPCUReaderPendingElScopeRef; - {$ENDIF} begin if Id<=0 then RaiseMsg(20180207151233,ErrorEl); diff --git a/packages/pastojs/tests/tcfiler.pas b/packages/pastojs/tests/tcfiler.pas index ff8677667f..928f14cb32 100644 --- a/packages/pastojs/tests/tcfiler.pas +++ b/packages/pastojs/tests/tcfiler.pas @@ -253,7 +253,7 @@ var Ref1: TPasScopeReference absolute Item1; Ref2: TPasScopeReference absolute Item2; begin - Result:=CompareText(Ref1.Element.Name,Ref2.Element.Name); + Result:=CompareText(GetObjPath(Ref1.Element),GetObjPath(Ref2.Element)); if Result<>0 then exit; Result:=ComparePointer(Ref1.Element,Ref2.Element); end; @@ -644,11 +644,31 @@ procedure TCustomTestPrecompile.CheckRestoredDeclarations(const Path: string; and (TPasGenericScope(El.CustomData).SpecializedFromItem<>nil); end; + function GetSubPath(const Path: string; OrigIndex: integer; OrigDecl: TPasElement): string; + begin + Result:=Path+'['+IntToStr(OrigIndex)+']'; + if OrigDecl.Name<>'' then + Result:=Result+'"'+OrigDecl.Name+'"' + else + Result:=Result+'?noname?'; + end; + +{ procedure WriteList; + var + i: Integer; + begin + writeln('CheckRestoredDeclarations.WriteList'); + for i:=0 to Orig.Declarations.Count-1 do + if i'' then - SubPath:=SubPath+'"'+OrigDecl.Name+'"' - else - SubPath:=SubPath+'?noname?'; - // skip to next non specializations in restored declarations + SubPath:=GetSubPath(Path,OrigIndex,OrigDecl); + // skip to next non specialization in restored declarations while RestIndex'' then - SubPath:=SubPath+'"'+OrigDecl.Name+'"' - else - SubPath:=SubPath+'?noname?'; + SubPath:=GetSubPath(Path,OrigIndex,OrigDecl); // search specialization with same name RestIndex:=0; repeat @@ -699,14 +711,33 @@ begin until false; if (OrigIndexRestIndex) then + begin // move restored element to original place to generate the same JS - Rest.Declarations.Move(RestIndex,OrigIndex); + //writeln('TCustomTestPrecompile.CheckRestoredDeclarations Orig[',OrigIndex,']=',GetObjName(OrigDecl),' Rest[',RestIndex,']=',GetObjName(RestDecl)); + if RestIndex>OrigIndex then + Rest.Declarations.Move(RestIndex,OrigIndex) + else + Rest.Declarations.Exchange(RestIndex,OrigIndex); + //writeln('TCustomTestPrecompile.CheckRestoredDeclarations RestIndex=',RestIndex,' ->',OrigIndex); + //WriteList; + end; // check CheckRestoredElement(SubPath,OrigDecl,RestDecl,Flags); end; - AssertEquals(Path+'.Declarations.Count',Orig.Declarations.Count,Rest.Declarations.Count); + + //WriteList; + for OrigIndex:=0 to Orig.Declarations.Count-1 do + begin + OrigDecl:=TPasElement(Orig.Declarations[OrigIndex]); + RestDecl:=TPasElement(Rest.Declarations[OrigIndex]); + if OrigDecl.Name<>RestDecl.Name then + begin + SubPath:=GetSubPath(Path,OrigIndex,OrigDecl); + AssertEquals(SubPath+'.Name',GetObjPath(OrigDecl),GetObjPath(RestDecl)); + end; + end; end; procedure TCustomTestPrecompile.CheckRestoredSection(const Path: string; Orig, @@ -3241,9 +3272,9 @@ begin ' TBird = class', ' a: T;', ' end;', - //' TDoubleBird = TBIrd;', - //'var', - //' db: TDoubleBird;', + ' TDoubleBird = TBIrd;', + 'var', + ' db: TDoubleBird;', 'procedure Fly;', 'implementation', 'type',