Ver código fonte

* Further developed state tracking in whilerepeatn

daniel 23 anos atrás
pai
commit
7d66658fd4
3 arquivos alterados com 44 adições e 16 exclusões
  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;
 	done:boolean;
 	value:boolean;
+	change:boolean;
+	factval:Tnode;
     
     begin
 	track_state_pass:=false;
 	done:=false;
-	writeln('Oeps!');
 	repeat
 	    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
 		    track_state_pass:=true;
 		    {Force new resulttype pass.}
@@ -384,7 +393,7 @@ implementation
 	    code:=right.getcopy;
 	    if is_constboolnode(condition) then
 		begin
-		    value:=Tordconstnode(condition).value<>0;
+		    value:=(Tordconstnode(condition).value<>0) xor checknegate;
 		    if value then
 			begin
 			    if code.track_state_pass(exec_known) then
@@ -418,7 +427,7 @@ implementation
     		condition.resulttype.def:=nil;
 		do_resulttypepass(condition);
 	    end;
-	aktstate.store_fact(condition,cordconstnode.create(0,booltype));
+	aktstate.store_fact(condition,cordconstnode.create(byte(checknegate),booltype));
     end;
 {$endif}
 
@@ -1204,7 +1213,10 @@ begin
 end.
 {
   $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
   * The whilen and repeatn are now completely unified into whilerepeatn. This
     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  det_resulttype:tnode;override;
           function  docompare(p: tnode): boolean; override;
+       {$ifdef extdebug}
+          procedure dowrite;override;
+       {$endif}
        end;
        tloadnodeclass = class of tloadnode;
 
@@ -400,6 +403,13 @@ implementation
           (symtableentry = tloadnode(p).symtableentry) and
           (symtable = tloadnode(p).symtable);
       end;
+    
+    procedure Tloadnode.dowrite;
+    
+    begin
+	inherited dowrite;
+	write('[',symtableentry.name,']');
+    end;
 
 
 {*****************************************************************************
@@ -983,7 +993,10 @@ begin
 end.
 {
   $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
   * The whilen and repeatn are now completely unified into whilerepeatn. This
     allows the state tracker to change while nodes automatically into

+ 13 - 10
compiler/pass_1.pas

@@ -197,15 +197,15 @@ implementation
       begin
          codegenerror:=false;
          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;
       end;
       
@@ -222,7 +222,10 @@ implementation
 end.
 {
   $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
   * The whilen and repeatn are now completely unified into whilerepeatn. This
     allows the state tracker to change while nodes automatically into