Browse Source

* ansistring fixes, decr_ansistr called after all temp ansi reuses

peter 26 years ago
parent
commit
20d56ae2a4
3 changed files with 36 additions and 24 deletions
  1. 6 2
      compiler/cg386add.pas
  2. 12 5
      compiler/cg386cnv.pas
  3. 18 17
      compiler/temp_gen.pas

+ 6 - 2
compiler/cg386add.pas

@@ -179,7 +179,8 @@ implementation
                         { push data }
                         { push data }
                         clear_location(p^.location);
                         clear_location(p^.location);
                         p^.location.loc:=LOC_MEM;
                         p^.location.loc:=LOC_MEM;
-                        gettempansistringreference(p^.location.reference);
+                        if gettempansistringreference(p^.location.reference) then
+                          decrstringref(cansistringdef,p^.location.reference);
                         emitpushreferenceaddr(p^.location.reference);
                         emitpushreferenceaddr(p^.location.reference);
                         emit_push_loc(p^.right^.location);
                         emit_push_loc(p^.right^.location);
                         emit_push_loc(p^.left^.location);
                         emit_push_loc(p^.left^.location);
@@ -2110,7 +2111,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.62  1999-05-27 19:44:04  peter
+  Revision 1.63  1999-05-31 20:35:45  peter
+    * ansistring fixes, decr_ansistr called after all temp ansi reuses
+
+  Revision 1.62  1999/05/27 19:44:04  peter
     * removed oldasm
     * removed oldasm
     * plabel -> pasmlabel
     * plabel -> pasmlabel
     * -a switches to source writing automaticly
     * -a switches to source writing automaticly

+ 12 - 5
compiler/cg386cnv.pas

@@ -312,7 +312,8 @@ implementation
                    begin
                    begin
                       clear_location(pto^.location);
                       clear_location(pto^.location);
                       pto^.location.loc:=LOC_REFERENCE;
                       pto^.location.loc:=LOC_REFERENCE;
-                      gettempansistringreference(pto^.location.reference);
+                      if gettempansistringreference(pto^.location.reference) then
+                       decrstringref(cansistringdef,pto^.location.reference);
                       pushusedregisters(pushed,$ff);
                       pushusedregisters(pushed,$ff);
                       emit_push_lea_loc(pfrom^.location);
                       emit_push_lea_loc(pfrom^.location);
                       emit_push_lea_loc(pto^.location);
                       emit_push_lea_loc(pto^.location);
@@ -489,7 +490,8 @@ implementation
              end;
              end;
            st_ansistring :
            st_ansistring :
              begin
              begin
-               gettempansistringreference(pto^.location.reference);
+               if gettempansistringreference(pto^.location.reference) then
+                 decrstringref(cansistringdef,pto^.location.reference);
                release_loc(pfrom^.location);
                release_loc(pfrom^.location);
                pushusedregisters(pushed,$ff);
                pushusedregisters(pushed,$ff);
                push_int(l);
                push_int(l);
@@ -534,7 +536,8 @@ implementation
              end;
              end;
            st_ansistring :
            st_ansistring :
              begin
              begin
-               gettempansistringreference(pto^.location.reference);
+               if gettempansistringreference(pto^.location.reference) then
+                 decrstringref(cansistringdef,pto^.location.reference);
                release_loc(pfrom^.location);
                release_loc(pfrom^.location);
                pushusedregisters(pushed,$ff);
                pushusedregisters(pushed,$ff);
                emit_pushw_loc(pfrom^.location);
                emit_pushw_loc(pfrom^.location);
@@ -1052,7 +1055,8 @@ implementation
            st_ansistring:
            st_ansistring:
              begin
              begin
                 pto^.location.loc:=LOC_REFERENCE;
                 pto^.location.loc:=LOC_REFERENCE;
-                gettempansistringreference(pto^.location.reference);
+                if gettempansistringreference(pto^.location.reference) then
+                  decrstringref(cansistringdef,pto^.location.reference);
                 case pfrom^.location.loc of
                 case pfrom^.location.loc of
                   LOC_REFERENCE,LOC_MEM:
                   LOC_REFERENCE,LOC_MEM:
                     begin
                     begin
@@ -1296,7 +1300,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.74  1999-05-27 19:44:09  peter
+  Revision 1.75  1999-05-31 20:35:46  peter
+    * ansistring fixes, decr_ansistr called after all temp ansi reuses
+
+  Revision 1.74  1999/05/27 19:44:09  peter
     * removed oldasm
     * removed oldasm
     * plabel -> pasmlabel
     * plabel -> pasmlabel
     * -a switches to source writing automaticly
     * -a switches to source writing automaticly

+ 18 - 17
compiler/temp_gen.pas

@@ -76,7 +76,8 @@ unit temp_gen;
     function istemp(const ref : treference) : boolean;
     function istemp(const ref : treference) : boolean;
     procedure ungetiftemp(const ref : treference);
     procedure ungetiftemp(const ref : treference);
     function ungetiftempansi(const ref : treference) : boolean;
     function ungetiftempansi(const ref : treference) : boolean;
-    procedure gettempansistringreference(var ref : treference);
+    function gettempansistringreference(var ref : treference):boolean;
+
 
 
   implementation
   implementation
 
 
@@ -287,11 +288,13 @@ unit temp_gen;
       end;
       end;
 
 
 
 
-    function gettempansioffset : longint;
+    function gettempansistringreference(var ref : treference):boolean;
       var
       var
-         ofs      : longint;
          foundslot,tl : ptemprecord;
          foundslot,tl : ptemprecord;
       begin
       begin
+         { do a reset, because the reference isn't used }
+         reset_reference(ref);
+         ref.base:=procinfo.framepointer;
          { Reuse old ansi slot ? }
          { Reuse old ansi slot ? }
          foundslot:=nil;
          foundslot:=nil;
          tl:=templist;
          tl:=templist;
@@ -310,27 +313,22 @@ unit temp_gen;
          if assigned(foundslot) then
          if assigned(foundslot) then
           begin
           begin
             foundslot^.temptype:=tt_ansistring;
             foundslot^.temptype:=tt_ansistring;
-            ofs:=foundslot^.pos;
+            ref.offset:=foundslot^.pos;
+            { we're reusing an old slot then set the function result to true
+              so that we can call a decr_ansistr }
+            gettempansistringreference:=true;
           end
           end
          else
          else
           begin
           begin
-            ofs:=newtempofsize(target_os.size_of_pointer);
+            ref.offset:=newtempofsize(target_os.size_of_pointer);
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
             templist^.posinfo:=aktfilepos;
             templist^.posinfo:=aktfilepos;
 {$endif}
 {$endif}
             templist^.temptype:=tt_ansistring;
             templist^.temptype:=tt_ansistring;
+            { set result to false, we don't need an decr_ansistr }
+            gettempansistringreference:=false;
           end;
           end;
-         exprasmlist^.concat(new(paitempalloc,alloc(ofs,target_os.size_of_pointer)));
-         gettempansioffset:=ofs;
-      end;
-
-
-    procedure gettempansistringreference(var ref : treference);
-      begin
-         { do a reset, because the reference isn't used }
-         reset_reference(ref);
-         ref.offset:=gettempansioffset;
-         ref.base:=procinfo.framepointer;
+         exprasmlist^.concat(new(paitempalloc,alloc(ref.offset,target_os.size_of_pointer)));
       end;
       end;
 
 
 
 
@@ -526,7 +524,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.29  1999-05-27 19:45:26  peter
+  Revision 1.30  1999-05-31 20:35:47  peter
+    * ansistring fixes, decr_ansistr called after all temp ansi reuses
+
+  Revision 1.29  1999/05/27 19:45:26  peter
     * removed oldasm
     * removed oldasm
     * plabel -> pasmlabel
     * plabel -> pasmlabel
     * -a switches to source writing automaticly
     * -a switches to source writing automaticly