mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-06 07:13:32 +02:00
pastojs: skip generic type
git-svn-id: trunk@42524 -
This commit is contained in:
parent
a2e96cd459
commit
847ac91d1d
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8156,6 +8156,7 @@ packages/pastojs/src/pas2jsuseanalyzer.pp svneol=native#text/plain
|
||||
packages/pastojs/src/pas2jsutils.pp svneol=native#text/plain
|
||||
packages/pastojs/tests/tcconverter.pp svneol=native#text/plain
|
||||
packages/pastojs/tests/tcfiler.pas svneol=native#text/plain
|
||||
packages/pastojs/tests/tcgenerics.pas svneol=native#text/plain
|
||||
packages/pastojs/tests/tcmodules.pas svneol=native#text/plain
|
||||
packages/pastojs/tests/tcoptimizations.pas svneol=native#text/plain
|
||||
packages/pastojs/tests/tcprecompile.pas svneol=native#text/plain
|
||||
|
@ -13326,6 +13326,9 @@ var
|
||||
aResolver: TPas2JSResolver;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (El.GenericTemplateTypes<>nil) and (El.GenericTemplateTypes.Count>0) then
|
||||
exit;
|
||||
|
||||
{$IFDEF VerbosePas2JS}
|
||||
writeln('TPasToJSConverter.ConvertClassType START ',GetObjName(El));
|
||||
{$ENDIF}
|
||||
@ -13983,6 +13986,8 @@ var
|
||||
Prop: TJSObjectLiteralElement;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (El.GenericTemplateTypes<>nil) and (El.GenericTemplateTypes.Count>0) then
|
||||
exit;
|
||||
if El.IsNested then
|
||||
DoError(20170222231636,nPasElementNotSupported,sPasElementNotSupported,
|
||||
['is nested'],El);
|
||||
@ -14106,6 +14111,8 @@ var
|
||||
ReturnSt: TJSReturnStatement;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (El.GenericTemplateTypes<>nil) and (El.GenericTemplateTypes.Count>0) then
|
||||
exit;
|
||||
if El.PackMode<>pmNone then
|
||||
DoError(20170222231648,nPasElementNotSupported,sPasElementNotSupported,
|
||||
['packed'],El);
|
||||
@ -22860,6 +22867,8 @@ var
|
||||
VarSt: TJSVariableStatement;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (El.GenericTemplateTypes<>nil) and (El.GenericTemplateTypes.Count>0) then
|
||||
exit;
|
||||
if El.Name='' then
|
||||
RaiseNotSupported(El,AContext,20190105101258,'anonymous record');
|
||||
{$IFDEF VerbosePas2JS}
|
||||
|
56
packages/pastojs/tests/tcgenerics.pas
Normal file
56
packages/pastojs/tests/tcgenerics.pas
Normal file
@ -0,0 +1,56 @@
|
||||
unit TCGenerics;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testregistry,
|
||||
TCModules;
|
||||
|
||||
type
|
||||
|
||||
{ TTestGenerics }
|
||||
|
||||
TTestGenerics = class(TCustomTestModule)
|
||||
Published
|
||||
Procedure TestGeneric_RecordEmpty;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestGenerics }
|
||||
|
||||
procedure TTestGenerics.TestGeneric_RecordEmpty;
|
||||
begin
|
||||
StartProgram(false);
|
||||
Add([
|
||||
'type',
|
||||
' generic TRecA<T> = record',
|
||||
' end;',
|
||||
'var a,b: specialize TRecA<word>;',
|
||||
'begin',
|
||||
' if a=b then ;']);
|
||||
ConvertProgram;
|
||||
CheckSource('TestGeneric_RecordEmpty',
|
||||
LinesToStr([ // statements
|
||||
'rtl.recNewT($mod, "TRecA$G1", function () {',
|
||||
' this.$eq = function (b) {',
|
||||
' return true;',
|
||||
' };',
|
||||
' this.$assign = function (s) {',
|
||||
' return this;',
|
||||
' };',
|
||||
'});',
|
||||
'this.a = $mod.TRecA$G1.$new();',
|
||||
'this.b = $mod.TRecA$G1.$new();',
|
||||
'']),
|
||||
LinesToStr([ // $mod.$main
|
||||
'if ($mod.a.$eq($mod.b)) ;'
|
||||
]));
|
||||
end;
|
||||
|
||||
Initialization
|
||||
RegisterTests([TTestGenerics]);
|
||||
end.
|
||||
|
@ -37,7 +37,7 @@
|
||||
<PackageName Value="FCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="12">
|
||||
<Units Count="13">
|
||||
<Unit0>
|
||||
<Filename Value="testpas2js.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -93,6 +93,11 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="Pas2jsUseAnalyzer"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="tcgenerics.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TCGenerics"/>
|
||||
</Unit12>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
@ -20,8 +20,8 @@ uses
|
||||
{$IFDEF EnableMemCheck}
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, consoletestrunner, tcconverter, tcmodules, tcoptimizations, tcsrcmap,
|
||||
tcfiler, Pas2JsFiler, tcunitsearch, tcprecompile, pas2jsuseanalyzer;
|
||||
Classes, consoletestrunner, tcconverter, TCModules, tcoptimizations, tcsrcmap,
|
||||
tcfiler, tcunitsearch, tcprecompile, TCGenerics;
|
||||
|
||||
type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user