Browse Source

* Further developed state tracking in whilerepeatn

daniel 23 years ago
parent
commit
7d66658fd4
3 changed files with 44 additions and 16 deletions
  1. 17 5
      compiler/nflw.pas
  2. 14 1
      compiler/nld.pas
  3. 13 10
      compiler/pass_1.pas

+ 17 - 5
compiler/nflw.pas

@@ -367,14 +367,23 @@ implementation
 	code:Tnode;
 	code:Tnode;
 	done:boolean;
 	done:boolean;
 	value:boolean;
 	value:boolean;
+	change:boolean;
+	factval:Tnode;
     
     
     begin
     begin
 	track_state_pass:=false;
 	track_state_pass:=false;
 	done:=false;
 	done:=false;
-	writeln('Oeps!');
 	repeat
 	repeat
 	    condition:=left.getcopy;
 	    condition:=left.getcopy;
-	    if condition.track_state_pass(exec_known) then
+	    change:=condition.track_state_pass(exec_known);
+	    factval:=aktstate.find_fact(left);
+	    if factval<>nil then
+		begin
+		    condition.destroy;
+		    condition:=factval.getcopy;
+		    change:=true;
+		end;
+	    if change then
 		begin
 		begin
 		    track_state_pass:=true;
 		    track_state_pass:=true;
 		    {Force new resulttype pass.}
 		    {Force new resulttype pass.}
@@ -384,7 +393,7 @@ implementation
 	    code:=right.getcopy;
 	    code:=right.getcopy;
 	    if is_constboolnode(condition) then
 	    if is_constboolnode(condition) then
 		begin
 		begin
-		    value:=Tordconstnode(condition).value<>0;
+		    value:=(Tordconstnode(condition).value<>0) xor checknegate;
 		    if value then
 		    if value then
 			begin
 			begin
 			    if code.track_state_pass(exec_known) then
 			    if code.track_state_pass(exec_known) then
@@ -418,7 +427,7 @@ implementation
     		condition.resulttype.def:=nil;
     		condition.resulttype.def:=nil;
 		do_resulttypepass(condition);
 		do_resulttypepass(condition);
 	    end;
 	    end;
-	aktstate.store_fact(condition,cordconstnode.create(0,booltype));
+	aktstate.store_fact(condition,cordconstnode.create(byte(checknegate),booltype));
     end;
     end;
 {$endif}
 {$endif}
 
 
@@ -1204,7 +1213,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  2002-07-19 11:41:35  daniel
+  Revision 1.39  2002-07-19 12:55:27  daniel
+  * Further developed state tracking in whilerepeatn
+
+  Revision 1.38  2002/07/19 11:41:35  daniel
   * State tracker work
   * State tracker work
   * The whilen and repeatn are now completely unified into whilerepeatn. This
   * The whilen and repeatn are now completely unified into whilerepeatn. This
     allows the state tracker to change while nodes automatically into
     allows the state tracker to change while nodes automatically into

+ 14 - 1
compiler/nld.pas

@@ -45,6 +45,9 @@ interface
           function  pass_1 : tnode;override;
           function  pass_1 : tnode;override;
           function  det_resulttype:tnode;override;
           function  det_resulttype:tnode;override;
           function  docompare(p: tnode): boolean; override;
           function  docompare(p: tnode): boolean; override;
+       {$ifdef extdebug}
+          procedure dowrite;override;
+       {$endif}
        end;
        end;
        tloadnodeclass = class of tloadnode;
        tloadnodeclass = class of tloadnode;
 
 
@@ -400,6 +403,13 @@ implementation
           (symtableentry = tloadnode(p).symtableentry) and
           (symtableentry = tloadnode(p).symtableentry) and
           (symtable = tloadnode(p).symtable);
           (symtable = tloadnode(p).symtable);
       end;
       end;
+    
+    procedure Tloadnode.dowrite;
+    
+    begin
+	inherited dowrite;
+	write('[',symtableentry.name,']');
+    end;
 
 
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -983,7 +993,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.46  2002-07-19 11:41:36  daniel
+  Revision 1.47  2002-07-19 12:55:27  daniel
+  * Further developed state tracking in whilerepeatn
+
+  Revision 1.46  2002/07/19 11:41:36  daniel
   * State tracker work
   * State tracker work
   * The whilen and repeatn are now completely unified into whilerepeatn. This
   * The whilen and repeatn are now completely unified into whilerepeatn. This
     allows the state tracker to change while nodes automatically into
     allows the state tracker to change while nodes automatically into

+ 13 - 10
compiler/pass_1.pas

@@ -197,15 +197,15 @@ implementation
       begin
       begin
          codegenerror:=false;
          codegenerror:=false;
          firstpass(p);
          firstpass(p);
-	     {$ifdef state_tracking}
-	         writeln('TRACKSTART');
-		 writeln('before');
-		        writenode(p);
-	    	        do_track_state_pass(p);
-		writeln('after');
-			writenode(p);
-		writeln('TRACKDONE');
-	     {$endif}
+{$ifdef state_tracking}
+         writeln('TRACKSTART');
+	 writeln('before');
+         writenode(p);
+         do_track_state_pass(p);
+         writeln('after');
+	 writenode(p);
+	 writeln('TRACKDONE');
+{$endif}
          do_firstpass:=codegenerror;
          do_firstpass:=codegenerror;
       end;
       end;
       
       
@@ -222,7 +222,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  2002-07-19 11:41:36  daniel
+  Revision 1.27  2002-07-19 12:55:27  daniel
+  * Further developed state tracking in whilerepeatn
+
+  Revision 1.26  2002/07/19 11:41:36  daniel
   * State tracker work
   * State tracker work
   * The whilen and repeatn are now completely unified into whilerepeatn. This
   * The whilen and repeatn are now completely unified into whilerepeatn. This
     allows the state tracker to change while nodes automatically into
     allows the state tracker to change while nodes automatically into