mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 03:06:34 +02:00
pastojs: create intfmap only for first class
git-svn-id: trunk@39548 -
This commit is contained in:
parent
e5cc0731ec
commit
6211847176
@ -11220,16 +11220,27 @@ var
|
|||||||
FinishedGUIDs: TStringList;
|
FinishedGUIDs: TStringList;
|
||||||
Intf: TPasType;
|
Intf: TPasType;
|
||||||
CurEl: TPasClassType;
|
CurEl: TPasClassType;
|
||||||
|
NeedIntfMap, HasInterfaces: Boolean;
|
||||||
begin
|
begin
|
||||||
|
HasInterfaces:=false;
|
||||||
|
NeedIntfMap:=true;
|
||||||
CurEl:=El;
|
CurEl:=El;
|
||||||
while CurEl.Interfaces.Count=0 do
|
while CurEl<>nil do
|
||||||
begin
|
begin
|
||||||
|
if CurEl.Interfaces.Count>0 then
|
||||||
|
begin
|
||||||
|
HasInterfaces:=true;
|
||||||
|
if CurEl<>El then
|
||||||
|
begin
|
||||||
|
NeedIntfMap:=false;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
CurEl:=TPasClassType(AContext.Resolver.GetPasClassAncestor(CurEl,true));
|
CurEl:=TPasClassType(AContext.Resolver.GetPasClassAncestor(CurEl,true));
|
||||||
if CurEl=nil then exit; // class and ancestor has no interfaces
|
|
||||||
end;
|
end;
|
||||||
|
if not HasInterfaces then exit;
|
||||||
|
|
||||||
IntfMaps:=nil;
|
IntfMaps:=nil;
|
||||||
|
|
||||||
FinishedGUIDs:=TStringList.Create;
|
FinishedGUIDs:=TStringList.Create;
|
||||||
try
|
try
|
||||||
ObjLit:=nil;
|
ObjLit:=nil;
|
||||||
@ -11241,7 +11252,7 @@ var
|
|||||||
begin
|
begin
|
||||||
CurEl:=TPasClassType(Scope.Element);
|
CurEl:=TPasClassType(Scope.Element);
|
||||||
if not IsMemberNeeded(TPasElement(CurEl.Interfaces[i])) then continue;
|
if not IsMemberNeeded(TPasElement(CurEl.Interfaces[i])) then continue;
|
||||||
if IntfMaps=nil then
|
if NeedIntfMap then
|
||||||
begin
|
begin
|
||||||
// add "this.$intfmaps = {};"
|
// add "this.$intfmaps = {};"
|
||||||
IntfMaps:=TJSSimpleAssignStatement(CreateElement(TJSSimpleAssignStatement,El));
|
IntfMaps:=TJSSimpleAssignStatement(CreateElement(TJSSimpleAssignStatement,El));
|
||||||
@ -11249,6 +11260,7 @@ var
|
|||||||
IntfMaps.LHS:=CreatePrimitiveDotExpr('this.'+FBuiltInNames[pbivnIntfMaps],El);
|
IntfMaps.LHS:=CreatePrimitiveDotExpr('this.'+FBuiltInNames[pbivnIntfMaps],El);
|
||||||
MapsObj:=TJSObjectLiteral(CreateElement(TJSObjectLiteral,El));
|
MapsObj:=TJSObjectLiteral(CreateElement(TJSObjectLiteral,El));
|
||||||
IntfMaps.Expr:=MapsObj;
|
IntfMaps.Expr:=MapsObj;
|
||||||
|
NeedIntfMap:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
o:=TObject(Scope.Interfaces[i]);
|
o:=TObject(Scope.Interfaces[i]);
|
||||||
|
@ -14663,7 +14663,6 @@ begin
|
|||||||
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
||||||
' this.Fly = function (i) {',
|
' this.Fly = function (i) {',
|
||||||
' };',
|
' };',
|
||||||
' this.$intfmaps = {};',
|
|
||||||
' rtl.addIntf(this, $mod.IBird);',
|
' rtl.addIntf(this, $mod.IBird);',
|
||||||
' rtl.addIntf(this, $mod.IUnknown);',
|
' rtl.addIntf(this, $mod.IUnknown);',
|
||||||
'});',
|
'});',
|
||||||
@ -14819,7 +14818,6 @@ begin
|
|||||||
' rtl.addIntf(this, $mod.IDog);',
|
' rtl.addIntf(this, $mod.IDog);',
|
||||||
'});',
|
'});',
|
||||||
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
||||||
' this.$intfmaps = {};',
|
|
||||||
' rtl.addIntf(this, $mod.IUnknown);',
|
' rtl.addIntf(this, $mod.IUnknown);',
|
||||||
' rtl.addIntf(this, $mod.IBird);',
|
' rtl.addIntf(this, $mod.IBird);',
|
||||||
' rtl.addIntf(this, $mod.IDog);',
|
' rtl.addIntf(this, $mod.IDog);',
|
||||||
@ -14871,19 +14869,16 @@ begin
|
|||||||
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
||||||
' this.Go = function () {',
|
' this.Go = function () {',
|
||||||
' };',
|
' };',
|
||||||
' this.$intfmaps = {};',
|
|
||||||
' rtl.addIntf(this, $mod.IUnknown);',
|
' rtl.addIntf(this, $mod.IUnknown);',
|
||||||
'});',
|
'});',
|
||||||
'rtl.createClass($mod, "TCat", $mod.TObject, function () {',
|
'rtl.createClass($mod, "TCat", $mod.TObject, function () {',
|
||||||
' this.Go = function () {',
|
' this.Go = function () {',
|
||||||
' };',
|
' };',
|
||||||
' this.$intfmaps = {};',
|
|
||||||
' rtl.addIntf(this, $mod.IUnknown);',
|
' rtl.addIntf(this, $mod.IUnknown);',
|
||||||
'});',
|
'});',
|
||||||
'rtl.createClass($mod, "TDog", $mod.TObject, function () {',
|
'rtl.createClass($mod, "TDog", $mod.TObject, function () {',
|
||||||
' this.Go = function () {',
|
' this.Go = function () {',
|
||||||
' };',
|
' };',
|
||||||
' this.$intfmaps = {};',
|
|
||||||
' rtl.addIntf(this, $mod.IUnknown);',
|
' rtl.addIntf(this, $mod.IUnknown);',
|
||||||
'});',
|
'});',
|
||||||
'']),
|
'']),
|
||||||
@ -15544,6 +15539,7 @@ begin
|
|||||||
' };',
|
' };',
|
||||||
' return Result;',
|
' return Result;',
|
||||||
' };',
|
' };',
|
||||||
|
' rtl.addIntf(this, $mod.IUnknown);',
|
||||||
'});',
|
'});',
|
||||||
'']),
|
'']),
|
||||||
LinesToStr([ // $mod.$main
|
LinesToStr([ // $mod.$main
|
||||||
|
Loading…
Reference in New Issue
Block a user