Browse Source

Store and use procedure directives of generic routines.

scanner.pas, tscannerfile:
  + new method is_recording_tokens to check whether token recording is already active
pdecsub.pas, parse_proc_directives:
  * record tokens into the declaration token buffer of a generic routine if necessary
pgenutil.pas, generate_specialization_phase2:
  * process the procedure directives that had been recorded with the generic routine

git-svn-id: trunk@33824 -
svenbarth 9 years ago
parent
commit
f8def6dbc9
3 changed files with 31 additions and 0 deletions
  1. 16 0
      compiler/pdecsub.pas
  2. 9 0
      compiler/pgenutil.pas
  3. 6 0
      compiler/scanner.pas

+ 16 - 0
compiler/pdecsub.pas

@@ -3229,6 +3229,7 @@ const
         are written using ;procdir; or ['procdir'] syntax.
         are written using ;procdir; or ['procdir'] syntax.
       }
       }
       var
       var
+        stoprecording,
         res : boolean;
         res : boolean;
       begin
       begin
         if (m_mac in current_settings.modeswitches) and (cs_externally_visible in current_settings.localswitches) then
         if (m_mac in current_settings.modeswitches) and (cs_externally_visible in current_settings.localswitches) then
@@ -3257,6 +3258,17 @@ const
             include(pd.procoptions,po_staticmethod);
             include(pd.procoptions,po_staticmethod);
           end;
           end;
 
 
+        { for a generic routine we also need to record the procedure          }
+        { directives, but only if we aren't already recording for a           }
+        { surrounding generic                                                 }
+        if pd.is_generic and (pd.typ=procdef) and not current_scanner.is_recording_tokens then
+          begin
+            current_scanner.startrecordtokens(tprocdef(pd).genericdecltokenbuf);
+            stoprecording:=true;
+          end
+        else
+          stoprecording:=false;
+
         while token in [_ID,_LECKKLAMMER] do
         while token in [_ID,_LECKKLAMMER] do
          begin
          begin
            if try_to_consume(_LECKKLAMMER) then
            if try_to_consume(_LECKKLAMMER) then
@@ -3302,6 +3314,10 @@ const
            else
            else
             break;
             break;
          end;
          end;
+
+        if stoprecording then
+          current_scanner.stoprecordtokens;
+
          { nostackframe requires assembler, but assembler
          { nostackframe requires assembler, but assembler
            may be specified in the implementation part only,
            may be specified in the implementation part only,
            and in not required if the function is first forward declared
            and in not required if the function is first forward declared

+ 9 - 0
compiler/pgenutil.pas

@@ -701,6 +701,7 @@ uses
         item : tobject;
         item : tobject;
         hintsprocessed : boolean;
         hintsprocessed : boolean;
         pd : tprocdef;
         pd : tprocdef;
+        pdflags : tpdflags;
       begin
       begin
         if not assigned(context) then
         if not assigned(context) then
           internalerror(2015052203);
           internalerror(2015052203);
@@ -995,6 +996,14 @@ uses
                     end;
                     end;
                   procdef:
                   procdef:
                     begin
                     begin
+                      pdflags:=[pd_body,pd_implemen];
+                      if genericdef.owner.symtabletype=objectsymtable then
+                        include(pdflags,pd_object)
+                      else if genericdef.owner.symtabletype=recordsymtable then
+                        include(pdflags,pd_record);
+                      parse_proc_directives(pd,pdflags);
+                      while try_consume_hintdirective(pd.symoptions,pd.deprecatedmsg) do
+                        consume(_SEMICOLON);
                       handle_calling_convention(tprocdef(result),hcc_all);
                       handle_calling_convention(tprocdef(result),hcc_all);
                       proc_add_definition(tprocdef(result));
                       proc_add_definition(tprocdef(result));
                       { for partial specializations we implicitely declare the routine as
                       { for partial specializations we implicitely declare the routine as

+ 6 - 0
compiler/scanner.pas

@@ -177,6 +177,7 @@ interface
           procedure recordtoken;
           procedure recordtoken;
           procedure startrecordtokens(buf:tdynamicarray);
           procedure startrecordtokens(buf:tdynamicarray);
           procedure stoprecordtokens;
           procedure stoprecordtokens;
+          function is_recording_tokens:boolean;
           procedure replaytoken;
           procedure replaytoken;
           procedure startreplaytokens(buf:tdynamicarray);
           procedure startreplaytokens(buf:tdynamicarray);
           { bit length asizeint is target depend }
           { bit length asizeint is target depend }
@@ -2800,6 +2801,11 @@ type
         recordtokenbuf:=nil;
         recordtokenbuf:=nil;
       end;
       end;
 
 
+    function tscannerfile.is_recording_tokens: boolean;
+      begin
+        result:=assigned(recordtokenbuf);
+      end;
+
 
 
     procedure tscannerfile.writetoken(t : ttoken);
     procedure tscannerfile.writetoken(t : ttoken);
       var
       var