Browse Source

* New node pruning methods

J. Gareth "Curious Kit" Moreton 2 years ago
parent
commit
7488f1e3f8
1 changed files with 39 additions and 0 deletions
  1. 39 0
      compiler/node.pas

+ 39 - 0
compiler/node.pas

@@ -420,6 +420,9 @@ interface
 {$ifdef DEBUG_NODE_XML}
          procedure XMLPrintNodeData(var T: Text); override;
 {$endif DEBUG_NODE_XML}
+         { Marks the current node for deletion and sets 'left' to nil.
+           Returns what 'left' was previously set to }
+         function PruneKeepLeft: TNode; {$ifdef USEINLINE}inline;{$endif USEINLINE}
       end;
 
       //pbinarynode = ^tbinarynode;
@@ -442,6 +445,9 @@ interface
          procedure XMLPrintNodeData(var T: Text); override;
 {$endif DEBUG_NODE_XML}
          procedure printnodelist(var t:text);
+         { Marks the current node for deletion and sets 'right' to nil.
+           Returns what 'right' was previously set to }
+         function PruneKeepRight: TNode; {$IFDEF USEINLINE}inline;{$endif USEINLINE}
       end;
 
       //ptertiarynode = ^ttertiarynode;
@@ -461,6 +467,9 @@ interface
 {$ifdef DEBUG_NODE_XML}
          procedure XMLPrintNodeData(var T: Text); override;
 {$endif DEBUG_NODE_XML}
+         { Marks the current node for deletion and sets 'third' to nil.
+           Returns what 'third' was previously set to }
+         function PruneKeepThird: TNode; {$IFDEF USEINLINE}inline;{$endif USEINLINE}
       end;
 
       tbinopnode = class(tbinarynode)
@@ -1137,6 +1146,16 @@ implementation
       end;
 
 
+    { Marks the current node for deletion and sets 'left' to nil.
+      Returns what 'left' was previously set to }
+    function tunarynode.PruneKeepLeft: TNode; {$IFDEF USEINLINE}inline;{$endif USEINLINE}
+      begin
+        Result := left;
+        left := nil;
+        Include(flags, nf_do_not_execute);
+      end;
+
+
 {****************************************************************************
                             TBINARYNODE
  ****************************************************************************}
@@ -1281,6 +1300,16 @@ implementation
       end;
 
 
+    { Marks the current node for deletion and sets 'right' to nil.
+      Returns what 'right' was previously set to }
+    function tbinarynode.PruneKeepRight: TNode; {$IFDEF USEINLINE}inline;{$endif USEINLINE}
+      begin
+        Result := right;
+        right := nil;
+        Include(flags, nf_do_not_execute);
+      end;
+
+
 {****************************************************************************
                                  TTERTIARYNODE
  ****************************************************************************}
@@ -1386,6 +1415,16 @@ implementation
       end;
 
 
+    { Marks the current node for deletion and sets 'third' to nil.
+      Returns what 'third' was previously set to }
+    function ttertiarynode.PruneKeepThird: TNode; {$IFDEF USEINLINE}inline;{$endif USEINLINE}
+      begin
+        Result := third;
+        third := nil;
+        Include(flags, nf_do_not_execute);
+      end;
+
+
 {****************************************************************************
                             TBINOPNODE
  ****************************************************************************}