Browse Source

* New 'do not execute' flag for notes and respective internal error triggering

J. Gareth "Curious Kit" Moreton 2 years ago
parent
commit
1b43913408
4 changed files with 21 additions and 12 deletions
  1. 8 11
      compiler/node.pas
  2. 7 0
      compiler/pass_1.pas
  3. 5 0
      compiler/pass_2.pas
  4. 1 1
      compiler/ppu.pas

+ 8 - 11
compiler/node.pas

@@ -279,14 +279,11 @@ interface
          nf_ignore_for_wpo, { we know that this loadvmtaddrnode cannot be used to construct a class instance }
 
          { node is derived from generic parameter }
-         nf_generic_para
-
-         { WARNING: there are now 32 elements in this type, and a set of this
-             type is written to the PPU. So before adding more elements,
-             either move some flags to specific nodes, or stream a normalset
-             to the ppu
-         }
+         nf_generic_para,
 
+         { internal flag to indicate that this node has been removed from the tree or must otherwise not be
+           execute.  Running it through firstpass etc. will raise an internal error }
+         nf_do_not_execute
        );
 
        tnodeflags = set of tnodeflag;
@@ -777,7 +774,7 @@ implementation
         ppufile.getset(tppuset5(localswitches));
         verbosity:=ppufile.getlongint;
         ppufile.getderef(resultdefderef);
-        ppufile.getset(tppuset4(flags));
+        ppufile.getset(tppuset5(flags));
         { updated by firstpass }
         expectloc:=LOC_INVALID;
         { updated by secondpass }
@@ -792,7 +789,7 @@ implementation
         ppufile.putset(tppuset5(localswitches));
         ppufile.putlongint(verbosity);
         ppufile.putderef(resultdefderef);
-        ppufile.putset(tppuset4(flags));
+        ppufile.putset(tppuset5(flags));
       end;
 
 
@@ -1425,9 +1422,9 @@ begin
   { tvaroption must fit into a 4 byte set for speed reasons }
   if ord(high(tvaroption))>31 then
     internalerror(201110301);
-  { tnodeflags must fit into a 4 byte set for speed reasons }
+(*  { tnodeflags must fit into a 4 byte set for speed reasons }
   if ord(high(tnodeflags))>31 then
-    internalerror(2014020701);
+    internalerror(2014020701); *)
 {$pop}
 end.
 

+ 7 - 0
compiler/pass_1.pas

@@ -45,6 +45,7 @@ implementation
       globtype,comphook,
       globals,
       procinfo,
+      verbose,
       symdef
 {$ifdef extdebug}
       ,verbose,htypechk
@@ -157,6 +158,7 @@ implementation
       begin
          if (nf_pass1_done in p.flags) then
            exit;
+
          if not(nf_error in p.flags) then
            begin
              oldcodegenerror:=codegenerror;
@@ -165,6 +167,11 @@ implementation
              oldverbosity:=status.verbosity;
              codegenerror:=false;
              repeat
+               { The error flag takes precedence over the 'do not execute' flag,
+                 as its assumed the node tree isn't tenable beyond this point }
+               if (nf_do_not_execute in p.flags) then
+                 InternalError(2022112401);
+
                { checks make always a call }
                if ([cs_check_range,cs_check_overflow,cs_check_stack] * current_settings.localswitches <> []) then
                  include(current_procinfo.flags,pi_do_call);

+ 5 - 0
compiler/pass_2.pas

@@ -189,6 +189,11 @@ implementation
           internalerror(200208221);
          if not(nf_error in p.flags) then
           begin
+            { The error flag takes precedence over the 'do not execute' flag,
+              as its assumed the node tree isn't tenable beyond this point }
+            if (nf_do_not_execute in p.flags) then
+              InternalError(2022112402);
+
             oldcodegenerror:=codegenerror;
             oldlocalswitches:=current_settings.localswitches;
             oldpos:=current_filepos;

+ 1 - 1
compiler/ppu.pas

@@ -48,7 +48,7 @@ const
   CurrentPPUVersion = 208;
   { for any other changes to the ppu format, increase this version number
     (it's a cardinal) }
-  CurrentPPULongVersion = 17;
+  CurrentPPULongVersion = 18;
 
 { unit flags }
   uf_big_endian          = $000004;