mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 16:19:21 +02:00
fcl-passrc: paswrite: allow to write class variables in classes/records
git-svn-id: trunk@37039 -
This commit is contained in:
parent
9c6b78f11e
commit
ae15dfbc06
@ -35,6 +35,7 @@ type
|
|||||||
procedure IncDeclSectionLevel;
|
procedure IncDeclSectionLevel;
|
||||||
procedure DecDeclSectionLevel;
|
procedure DecDeclSectionLevel;
|
||||||
procedure PrepareDeclSection(const ADeclSection: string);
|
procedure PrepareDeclSection(const ADeclSection: string);
|
||||||
|
procedure PrepareDeclSectionInStruct(const ADeclSection: string);
|
||||||
public
|
public
|
||||||
constructor Create(AStream: TStream);
|
constructor Create(AStream: TStream);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -283,6 +284,7 @@ begin
|
|||||||
wrtln('['+AClass.InterfaceGUID+']');
|
wrtln('['+AClass.InterfaceGUID+']');
|
||||||
|
|
||||||
IncIndent;
|
IncIndent;
|
||||||
|
IncDeclSectionLevel;
|
||||||
LastVisibility := visDefault;
|
LastVisibility := visDefault;
|
||||||
LastMember := nil;
|
LastMember := nil;
|
||||||
for i := 0 to AClass.Members.Count - 1 do
|
for i := 0 to AClass.Members.Count - 1 do
|
||||||
@ -301,20 +303,31 @@ begin
|
|||||||
end;
|
end;
|
||||||
IncIndent;
|
IncIndent;
|
||||||
LastVisibility := CurVisibility;
|
LastVisibility := CurVisibility;
|
||||||
|
CurDeclSection := '';
|
||||||
end;
|
end;
|
||||||
WriteElement(Member);
|
WriteElement(Member);
|
||||||
LastMember := Member;
|
LastMember := Member;
|
||||||
end;
|
end;
|
||||||
|
DecDeclSectionLevel;
|
||||||
DecIndent;
|
DecIndent;
|
||||||
wrtln('end;');
|
wrtln('end;');
|
||||||
wrtln;
|
wrtln;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPasWriter.WriteVariable(AVar: TPasVariable);
|
procedure TPasWriter.WriteVariable(AVar: TPasVariable);
|
||||||
|
var
|
||||||
|
LParentIsClassOrRecord: boolean;
|
||||||
begin
|
begin
|
||||||
if (AVar.Parent.ClassType <> TPasClassType) and
|
LParentIsClassOrRecord:= (AVar.Parent.ClassType = TPasClassType) or
|
||||||
(AVar.Parent.ClassType <> TPasRecordType) then
|
(AVar.Parent.ClassType = TPasRecordType);
|
||||||
PrepareDeclSection('var');
|
if not LParentIsClassOrRecord then
|
||||||
|
PrepareDeclSection('var')
|
||||||
|
// handle variables in classes/records
|
||||||
|
else if vmClass in AVar.VarModifiers then
|
||||||
|
PrepareDeclSectionInStruct('class var')
|
||||||
|
else if CurDeclSection<>'' then
|
||||||
|
PrepareDeclSectionInStruct('var');
|
||||||
|
|
||||||
wrt(AVar.Name + ': ');
|
wrt(AVar.Name + ': ');
|
||||||
WriteType(AVar.VarType);
|
WriteType(AVar.VarType);
|
||||||
wrtln(';');
|
wrtln(';');
|
||||||
@ -682,6 +695,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPasWriter.PrepareDeclSectionInStruct(const ADeclSection: string);
|
||||||
|
begin
|
||||||
|
if ADeclSection <> CurDeclSection then
|
||||||
|
begin
|
||||||
|
if ADeclSection <> '' then
|
||||||
|
begin
|
||||||
|
DecIndent;
|
||||||
|
wrtln(ADeclSection);
|
||||||
|
IncIndent;
|
||||||
|
end;
|
||||||
|
CurDeclSection := ADeclSection;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure WritePasFile(AElement: TPasElement; const AFilename: string);
|
procedure WritePasFile(AElement: TPasElement; const AFilename: string);
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user