Browse Source

* instead of using separate booleans use a set to keep track of pending changes for popped settings

git-svn-id: trunk@39214 -
svenbarth 7 years ago
parent
commit
da672d1344
2 changed files with 18 additions and 14 deletions
  1. 7 3
      compiler/globals.pas
  2. 11 11
      compiler/switches.pas

+ 7 - 3
compiler/globals.pas

@@ -213,6 +213,12 @@ interface
         property items[I:longint]:TLinkRec read getlinkrec; default;
         property items[I:longint]:TLinkRec read getlinkrec; default;
       end;
       end;
 
 
+      tpendingstateflag = (
+        psf_alignment_changed,
+        psf_verbosity_full_switched,
+        psf_local_switches_changed
+      );
+      tpendingstateflags = set of tpendingstateflag;
 
 
       tpendingstate = record
       tpendingstate = record
         nextverbositystr : shortstring;
         nextverbositystr : shortstring;
@@ -221,9 +227,7 @@ interface
         nextcallingstr : shortstring;
         nextcallingstr : shortstring;
         nextmessagerecord : pmessagestaterecord;
         nextmessagerecord : pmessagestaterecord;
         nextalignment : talignmentinfo;
         nextalignment : talignmentinfo;
-        alignmentchanged,
-        verbosityfullswitched,
-        localswitcheschanged : boolean;
+        flags : tpendingstateflags;
       end;
       end;
 
 
 
 

+ 11 - 11
compiler/switches.pas

@@ -310,7 +310,7 @@ procedure recordpendingmessagestate(msg: longint; state: tmsgstate);
 
 
 procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
 procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
   begin
   begin
-    if not pendingstate.localswitcheschanged then
+    if not (psf_local_switches_changed in pendingstate.flags) then
        pendingstate.nextlocalswitches:=current_settings.localswitches;
        pendingstate.nextlocalswitches:=current_settings.localswitches;
     if state='-' then
     if state='-' then
       exclude(pendingstate.nextlocalswitches,sw)
       exclude(pendingstate.nextlocalswitches,sw)
@@ -323,21 +323,21 @@ procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
         else
         else
          exclude(pendingstate.nextlocalswitches,sw);
          exclude(pendingstate.nextlocalswitches,sw);
       end;
       end;
-    pendingstate.localswitcheschanged:=true;
+    include(pendingstate.flags,psf_local_switches_changed);
   end;
   end;
 
 
 
 
 procedure recordpendingalignmentfullswitch(const alignment : talignmentinfo);
 procedure recordpendingalignmentfullswitch(const alignment : talignmentinfo);
   begin
   begin
     pendingstate.nextalignment:=alignment;
     pendingstate.nextalignment:=alignment;
-    pendingstate.alignmentchanged:=true;
+    include(pendingstate.flags,psf_alignment_changed);
   end;
   end;
 
 
 
 
 procedure recordpendinglocalfullswitch(const switches: tlocalswitches);
 procedure recordpendinglocalfullswitch(const switches: tlocalswitches);
   begin
   begin
     pendingstate.nextlocalswitches:=switches;
     pendingstate.nextlocalswitches:=switches;
-    pendingstate.localswitcheschanged:=true;
+    include(pendingstate.flags,psf_local_switches_changed);
   end;
   end;
 
 
 
 
@@ -345,7 +345,7 @@ procedure recordpendingverbosityfullswitch(verbosity: longint);
   begin
   begin
     pendingstate.nextverbositystr:='';
     pendingstate.nextverbositystr:='';
     pendingstate.nextverbosityfullswitch:=verbosity;
     pendingstate.nextverbosityfullswitch:=verbosity;
-    pendingstate.verbosityfullswitched:=true;
+    include(pendingstate.flags,psf_verbosity_full_switched);
   end;
   end;
 
 
 procedure recordpendingcallingswitch(const str: shortstring);
 procedure recordpendingcallingswitch(const str: shortstring);
@@ -360,21 +360,21 @@ procedure flushpendingswitchesstate;
     fstate, pstate : pmessagestaterecord;
     fstate, pstate : pmessagestaterecord;
   begin
   begin
     { process pending localswitches (range checking, etc) }
     { process pending localswitches (range checking, etc) }
-    if pendingstate.localswitcheschanged then
+    if psf_local_switches_changed in pendingstate.flags then
       begin
       begin
         current_settings.localswitches:=pendingstate.nextlocalswitches;
         current_settings.localswitches:=pendingstate.nextlocalswitches;
-        pendingstate.localswitcheschanged:=false;
+        exclude(pendingstate.flags,psf_local_switches_changed);
       end;
       end;
     { process pending verbosity changes (warnings on, etc) }
     { process pending verbosity changes (warnings on, etc) }
-    if pendingstate.verbosityfullswitched then
+    if psf_verbosity_full_switched in pendingstate.flags then
       begin
       begin
         status.verbosity:=pendingstate.nextverbosityfullswitch;
         status.verbosity:=pendingstate.nextverbosityfullswitch;
-        pendingstate.verbosityfullswitched:=false;
+        exclude(pendingstate.flags,psf_verbosity_full_switched);
       end;
       end;
-    if pendingstate.alignmentchanged then
+    if psf_alignment_changed in pendingstate.flags then
       begin
       begin
         current_settings.alignment:=pendingstate.nextalignment;
         current_settings.alignment:=pendingstate.nextalignment;
-        pendingstate.alignmentchanged:=false;
+        exclude(pendingstate.flags,psf_alignment_changed);
       end;
       end;
     { process pending verbosity changes (warnings on, etc) }
     { process pending verbosity changes (warnings on, etc) }
     if pendingstate.nextverbositystr<>'' then
     if pendingstate.nextverbositystr<>'' then