Browse Source

* change boolean parameters for try_consume_unitsym to a set

git-svn-id: trunk@42360 -
svenbarth 6 years ago
parent
commit
ed5f19e7e3
4 changed files with 26 additions and 12 deletions
  1. 17 9
      compiler/pbase.pas
  2. 7 1
      compiler/pexpr.pas
  3. 1 1
      compiler/pstatmnt.pas
  4. 1 1
      compiler/ptype.pas

+ 17 - 9
compiler/pbase.pas

@@ -89,8 +89,15 @@ interface
     function consume_sym(var srsym:tsym;var srsymtable:TSymtable):boolean;
     function consume_sym_orgid(var srsym:tsym;var srsymtable:TSymtable;var s : string):boolean;
 
-    function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;consume_id,allow_specialize:boolean;out is_specialize:boolean;sympattern:TSymStr):boolean;
-    function try_consume_unitsym_no_specialize(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;consume_id:boolean;sympattern:TSymStr):boolean;
+    type
+      tconsume_unitsym_flag = (
+        cuf_consume_id,
+        cuf_allow_specialize
+      );
+      tconsume_unitsym_flags = set of tconsume_unitsym_flag;
+
+    function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;flags:tconsume_unitsym_flags;out is_specialize:boolean;sympattern:TSymStr):boolean;
+    function try_consume_unitsym_no_specialize(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;flags:tconsume_unitsym_flags;sympattern:TSymStr):boolean;
 
     function try_consume_hintdirective(var symopt:tsymoptions; var deprecatedmsg:pshortstring):boolean;
 
@@ -205,7 +212,7 @@ implementation
           end;
         searchsym(pattern,srsym,srsymtable);
         { handle unit specification like System.Writeln }
-        try_consume_unitsym_no_specialize(srsym,srsymtable,t,true,pattern);
+        try_consume_unitsym_no_specialize(srsym,srsymtable,t,[cuf_consume_id],pattern);
         { if nothing found give error and return errorsym }
         if assigned(srsym) then
           check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg)
@@ -238,7 +245,7 @@ implementation
           end;
         searchsym(pattern,srsym,srsymtable);
         { handle unit specification like System.Writeln }
-        try_consume_unitsym_no_specialize(srsym,srsymtable,t,true,pattern);
+        try_consume_unitsym_no_specialize(srsym,srsymtable,t,[cuf_consume_id],pattern);
         { if nothing found give error and return errorsym }
         if assigned(srsym) then
           check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg)
@@ -254,7 +261,7 @@ implementation
       end;
 
 
-    function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;consume_id,allow_specialize:boolean;out is_specialize:boolean;sympattern:TSymStr):boolean;
+    function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;flags:tconsume_unitsym_flags;out is_specialize:boolean;sympattern:TSymStr):boolean;
       var
         hmodule: tmodule;
         ns:ansistring;
@@ -318,7 +325,7 @@ implementation
               internalerror(201001120);
             if hmodule.unit_index=current_filepos.moduleindex then
               begin
-                if consume_id then
+                if cuf_consume_id in flags then
                   consume(_ID);
                 consume(_POINT);
                 if srsym.typ=namespacesym then
@@ -365,7 +372,7 @@ implementation
                           searchsym_in_module(tunitsym(srsym).module,'ANSICHAR',srsym,srsymtable)
                       end
                     else
-                      if allow_specialize and (idtoken=_SPECIALIZE) then
+                      if (cuf_allow_specialize in flags) and (idtoken=_SPECIALIZE) then
                         begin
                           consume(_ID);
                           is_specialize:=true;
@@ -405,11 +412,12 @@ implementation
       end;
 
 
-    function try_consume_unitsym_no_specialize(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;consume_id:boolean;sympattern:TSymStr):boolean;
+    function try_consume_unitsym_no_specialize(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume:ttoken;flags:tconsume_unitsym_flags;sympattern:TSymStr):boolean;
       var
         dummy: Boolean;
       begin
-        result:=try_consume_unitsym(srsym,srsymtable,tokentoconsume,consume_id,false,dummy,sympattern);
+        exclude(flags,cuf_allow_specialize);
+        result:=try_consume_unitsym(srsym,srsymtable,tokentoconsume,flags,dummy,sympattern);
       end;
 
     function try_consume_hintdirective(var symopt:tsymoptions; var deprecatedmsg:pshortstring):boolean;

+ 7 - 1
compiler/pexpr.pas

@@ -2833,6 +2833,7 @@ implementation
            dummypos,
            tokenpos: tfileposinfo;
            spezcontext : tspecializationcontext;
+           cufflags : tconsume_unitsym_flags;
          begin
            { allow post fix operators }
            again:=true;
@@ -2872,7 +2873,12 @@ implementation
                  searchsym(pattern,srsym,srsymtable);
                { handle unit specification like System.Writeln }
                if not isspecialize then
-                 unit_found:=try_consume_unitsym(srsym,srsymtable,t,true,allowspecialize,isspecialize,pattern)
+                 begin
+                   cufflags:=[cuf_consume_id];
+                   if allowspecialize then
+                     include(cufflags,cuf_allow_specialize);
+                   unit_found:=try_consume_unitsym(srsym,srsymtable,t,cufflags,isspecialize,pattern)
+                 end
                else
                  begin
                    unit_found:=false;

+ 1 - 1
compiler/pstatmnt.pas

@@ -951,7 +951,7 @@ implementation
                                  with "e: Exception" the e is not necessary }
 
                                { support unit.identifier }
-                               unit_found:=try_consume_unitsym_no_specialize(srsym,srsymtable,t,false,objname);
+                               unit_found:=try_consume_unitsym_no_specialize(srsym,srsymtable,t,[],objname);
                                if srsym=nil then
                                  begin
                                    identifier_not_found(orgpattern);

+ 1 - 1
compiler/ptype.pas

@@ -376,7 +376,7 @@ implementation
            not_a_type:=false;
          { handle unit specification like System.Writeln }
          if allowunitsym then
-           is_unit_specific:=try_consume_unitsym(srsym,srsymtable,t,true,true,is_specialize,s)
+           is_unit_specific:=try_consume_unitsym(srsym,srsymtable,t,[cuf_consume_id,cuf_allow_specialize],is_specialize,s)
          else
            begin
              t:=_ID;