|
@@ -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
|
|
|
|
- (AVar.Parent.ClassType <> TPasRecordType) then
|
|
|
|
- PrepareDeclSection('var');
|
|
|
|
|
|
+ LParentIsClassOrRecord:= (AVar.Parent.ClassType = TPasClassType) or
|
|
|
|
+ (AVar.Parent.ClassType = TPasRecordType);
|
|
|
|
+ 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
|