Browse Source

fcl-passrc: new GlobalDirectivesSection (section between unit and interface) to allow writing $IFDEFS and global directives from paswrite.pp by TPasImplCommand/TPasImplCommands

git-svn-id: trunk@36628 -
maciej-izak 8 years ago
parent
commit
f5b8825662
2 changed files with 9 additions and 0 deletions
  1. 4 0
      packages/fcl-passrc/src/pastree.pp
  2. 5 0
      packages/fcl-passrc/src/paswrite.pp

+ 4 - 0
packages/fcl-passrc/src/pastree.pp

@@ -371,6 +371,7 @@ type
     function ElementTypeName: string; override;
   end;
 
+  TPasImplCommandBase = class;
   TInitializationSection = class;
   TFinalizationSection = class;
 
@@ -384,6 +385,7 @@ type
     procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
       const Arg: Pointer); override;
   public
+    GlobalDirectivesSection: TPasImplCommandBase; // not used by pparser
     InterfaceSection: TInterfaceSection;
     ImplementationSection: TImplementationSection;
     InitializationSection: TInitializationSection; // in TPasProgram the begin..end.
@@ -2306,6 +2308,8 @@ end;
 
 destructor TPasModule.Destroy;
 begin
+  {$IFDEF VerbosePasTreeMem}writeln('TPasModule.Destroy global directives');{$ENDIF}
+  ReleaseAndNil(TPasElement(GlobalDirectivesSection));
   {$IFDEF VerbosePasTreeMem}writeln('TPasModule.Destroy interface');{$ENDIF}
   ReleaseAndNil(TPasElement(InterfaceSection));
   {$IFDEF VerbosePasTreeMem}writeln('TPasModule.Destroy implementation');{$ENDIF}

+ 5 - 0
packages/fcl-passrc/src/paswrite.pp

@@ -163,6 +163,11 @@ end;
 procedure TPasWriter.WriteModule(AModule: TPasModule);
 begin
   wrtln('unit ' + AModule.Name + ';');
+  if Assigned(AModule.GlobalDirectivesSection) then
+  begin
+    wrtln;
+    WriteImplElement(AModule.GlobalDirectivesSection,false);
+  end;
   wrtln;
   wrtln('interface');
   wrtln;