mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 19:29:26 +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;
|
||||
Intf: TPasType;
|
||||
CurEl: TPasClassType;
|
||||
NeedIntfMap, HasInterfaces: Boolean;
|
||||
begin
|
||||
HasInterfaces:=false;
|
||||
NeedIntfMap:=true;
|
||||
CurEl:=El;
|
||||
while CurEl.Interfaces.Count=0 do
|
||||
while CurEl<>nil do
|
||||
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));
|
||||
if CurEl=nil then exit; // class and ancestor has no interfaces
|
||||
end;
|
||||
if not HasInterfaces then exit;
|
||||
|
||||
IntfMaps:=nil;
|
||||
|
||||
FinishedGUIDs:=TStringList.Create;
|
||||
try
|
||||
ObjLit:=nil;
|
||||
@ -11241,7 +11252,7 @@ var
|
||||
begin
|
||||
CurEl:=TPasClassType(Scope.Element);
|
||||
if not IsMemberNeeded(TPasElement(CurEl.Interfaces[i])) then continue;
|
||||
if IntfMaps=nil then
|
||||
if NeedIntfMap then
|
||||
begin
|
||||
// add "this.$intfmaps = {};"
|
||||
IntfMaps:=TJSSimpleAssignStatement(CreateElement(TJSSimpleAssignStatement,El));
|
||||
@ -11249,6 +11260,7 @@ var
|
||||
IntfMaps.LHS:=CreatePrimitiveDotExpr('this.'+FBuiltInNames[pbivnIntfMaps],El);
|
||||
MapsObj:=TJSObjectLiteral(CreateElement(TJSObjectLiteral,El));
|
||||
IntfMaps.Expr:=MapsObj;
|
||||
NeedIntfMap:=false;
|
||||
end;
|
||||
|
||||
o:=TObject(Scope.Interfaces[i]);
|
||||
|
@ -14663,7 +14663,6 @@ begin
|
||||
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
||||
' this.Fly = function (i) {',
|
||||
' };',
|
||||
' this.$intfmaps = {};',
|
||||
' rtl.addIntf(this, $mod.IBird);',
|
||||
' rtl.addIntf(this, $mod.IUnknown);',
|
||||
'});',
|
||||
@ -14819,7 +14818,6 @@ begin
|
||||
' rtl.addIntf(this, $mod.IDog);',
|
||||
'});',
|
||||
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
||||
' this.$intfmaps = {};',
|
||||
' rtl.addIntf(this, $mod.IUnknown);',
|
||||
' rtl.addIntf(this, $mod.IBird);',
|
||||
' rtl.addIntf(this, $mod.IDog);',
|
||||
@ -14871,19 +14869,16 @@ begin
|
||||
'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
||||
' this.Go = function () {',
|
||||
' };',
|
||||
' this.$intfmaps = {};',
|
||||
' rtl.addIntf(this, $mod.IUnknown);',
|
||||
'});',
|
||||
'rtl.createClass($mod, "TCat", $mod.TObject, function () {',
|
||||
' this.Go = function () {',
|
||||
' };',
|
||||
' this.$intfmaps = {};',
|
||||
' rtl.addIntf(this, $mod.IUnknown);',
|
||||
'});',
|
||||
'rtl.createClass($mod, "TDog", $mod.TObject, function () {',
|
||||
' this.Go = function () {',
|
||||
' };',
|
||||
' this.$intfmaps = {};',
|
||||
' rtl.addIntf(this, $mod.IUnknown);',
|
||||
'});',
|
||||
'']),
|
||||
@ -15544,6 +15539,7 @@ begin
|
||||
' };',
|
||||
' return Result;',
|
||||
' };',
|
||||
' rtl.addIntf(this, $mod.IUnknown);',
|
||||
'});',
|
||||
'']),
|
||||
LinesToStr([ // $mod.$main
|
||||
|
Loading…
Reference in New Issue
Block a user