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.
       }
       var
+        stoprecording,
         res : boolean;
       begin
         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);
           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
          begin
            if try_to_consume(_LECKKLAMMER) then
@@ -3302,6 +3314,10 @@ const
            else
             break;
          end;
+
+        if stoprecording then
+          current_scanner.stoprecordtokens;
+
          { nostackframe requires assembler, but assembler
            may be specified in the implementation part only,
            and in not required if the function is first forward declared

+ 9 - 0
compiler/pgenutil.pas

@@ -701,6 +701,7 @@ uses
         item : tobject;
         hintsprocessed : boolean;
         pd : tprocdef;
+        pdflags : tpdflags;
       begin
         if not assigned(context) then
           internalerror(2015052203);
@@ -995,6 +996,14 @@ uses
                     end;
                   procdef:
                     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);
                       proc_add_definition(tprocdef(result));
                       { for partial specializations we implicitely declare the routine as

+ 6 - 0
compiler/scanner.pas

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