浏览代码

* source linebuf as dyn array

Michaël Van Canneyt 4 月之前
父节点
当前提交
25e955b6e4
共有 5 个文件被更改,包括 20 次插入24 次删除
  1. 5 5
      compiler/assemble.pas
  2. 6 10
      compiler/finput.pas
  3. 3 3
      compiler/jvm/agjasmin.pas
  4. 3 3
      compiler/wasm32/agbinaryen.pas
  5. 3 3
      compiler/wasm32/agwasa.pas

+ 5 - 5
compiler/assemble.pas

@@ -1039,8 +1039,8 @@ Implementation
           if not assigned(f) then
           if not assigned(f) then
             exit;
             exit;
           for i:=0 to f.maxlinebuf-1 do
           for i:=0 to f.maxlinebuf-1 do
-            if f.linebuf^[i]<0 then
-              f.linebuf^[i]:=-f.linebuf^[i]-1;
+            if f.linebuf[i]<0 then
+              f.linebuf[i]:=-f.linebuf[i]-1;
         end;
         end;
 
 
       begin
       begin
@@ -1094,13 +1094,13 @@ Implementation
               (hp.fileinfo.line<infile.maxlinebuf) then
               (hp.fileinfo.line<infile.maxlinebuf) then
               begin
               begin
                 if (hp.fileinfo.line<>0) and
                 if (hp.fileinfo.line<>0) and
-                  (infile.linebuf^[hp.fileinfo.line]>=0) then
+                  (infile.linebuf[hp.fileinfo.line]>=0) then
                   writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp.fileinfo.line)+'] '+
                   writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp.fileinfo.line)+'] '+
                   fixline(infile.GetLineStr(hp.fileinfo.line)));
                   fixline(infile.GetLineStr(hp.fileinfo.line)));
                 { set it to a negative value !
                 { set it to a negative value !
                   to make that is has been read already !! PM }
                   to make that is has been read already !! PM }
-                if (infile.linebuf^[hp.fileinfo.line]>=0) then
-                  infile.linebuf^[hp.fileinfo.line]:=-infile.linebuf^[hp.fileinfo.line]-1;
+                if (infile.linebuf[hp.fileinfo.line]>=0) then
+                  infile.linebuf[hp.fileinfo.line]:=-infile.linebuf[hp.fileinfo.line]-1;
               end;
               end;
           end;
           end;
         lastfileinfo:=hp.fileinfo;
         lastfileinfo:=hp.fileinfo;

+ 6 - 10
compiler/finput.pas

@@ -33,8 +33,7 @@ interface
        linebufincrease=512;
        linebufincrease=512;
 
 
     type
     type
-       tlongintarr = array[0..1000000] of longint;
-       plongintarr = ^tlongintarr;
+       tlongintarr = array of longint;
 
 
        tinputfile = class
        tinputfile = class
          path,name : TPathStr;       { path and filename }
          path,name : TPathStr;       { path and filename }
@@ -50,7 +49,7 @@ interface
          savelastlinepos,
          savelastlinepos,
          saveline_no      : longint;
          saveline_no      : longint;
 
 
-         linebuf    : plongintarr;  { line buffer to retrieve lines }
+         linebuf    : tlongintarr;  { line buffer to retrieve lines }
          maxlinebuf : longint;
          maxlinebuf : longint;
 
 
          ref_index  : longint;
          ref_index  : longint;
@@ -248,9 +247,7 @@ uses
       begin
       begin
         if not closed then
         if not closed then
          close;
          close;
-      { free memory }
-        if assigned(linebuf) then
-         freemem(linebuf,maxlinebuf*sizeof(linebuf^[0]));
+        linebuf:=Nil;
       end;
       end;
 
 
 
 
@@ -387,11 +384,10 @@ uses
         while (line>=maxlinebuf) do
         while (line>=maxlinebuf) do
           begin
           begin
             { create new linebuf and move old info }
             { create new linebuf and move old info }
-            linebuf:=reallocmem(linebuf,(maxlinebuf+linebufincrease)*sizeof(linebuf^[0]));
-            fillchar(linebuf^[maxlinebuf],linebufincrease*sizeof(linebuf^[0]),0);
+            SetLength(linebuf,(maxlinebuf+linebufincrease));
             inc(maxlinebuf,linebufincrease);
             inc(maxlinebuf,linebufincrease);
           end;
           end;
-        linebuf^[line]:=linepos;
+        linebuf[line]:=linepos;
       end;
       end;
 
 
 
 
@@ -405,7 +401,7 @@ uses
         getlinestr:='';
         getlinestr:='';
         if l<maxlinebuf then
         if l<maxlinebuf then
          begin
          begin
-           fpos:=linebuf^[l];
+           fpos:=linebuf[l];
            { fpos is set negativ if the line was already written }
            { fpos is set negativ if the line was already written }
            { but we still know the correct value                 }
            { but we still know the correct value                 }
            if fpos<0 then
            if fpos<0 then

+ 3 - 3
compiler/jvm/agjasmin.pas

@@ -346,13 +346,13 @@ implementation
                         ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
                         ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
                        begin
                        begin
                          if (hp1.fileinfo.line<>0) and
                          if (hp1.fileinfo.line<>0) and
-                            ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
+                            ((infile.linebuf[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
                            writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
                            writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
                              fixline(infile.GetLineStr(hp1.fileinfo.line)));
                              fixline(infile.GetLineStr(hp1.fileinfo.line)));
                          { set it to a negative value !
                          { set it to a negative value !
                          to make that is has been read already !! PM }
                          to make that is has been read already !! PM }
-                         if (infile.linebuf^[hp1.fileinfo.line]>=0) then
-                           infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
+                         if (infile.linebuf[hp1.fileinfo.line]>=0) then
+                           infile.linebuf[hp1.fileinfo.line]:=-infile.linebuf[hp1.fileinfo.line]-1;
                        end;
                        end;
                    end;
                    end;
                   lastfileinfo:=hp1.fileinfo;
                   lastfileinfo:=hp1.fileinfo;

+ 3 - 3
compiler/wasm32/agbinaryen.pas

@@ -283,13 +283,13 @@ implementation
                         ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
                         ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
                        begin
                        begin
                          if (hp1.fileinfo.line<>0) and
                          if (hp1.fileinfo.line<>0) and
-                            ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
+                            ((infile.linebuf[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
                            writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
                            writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
                              fixline(infile.GetLineStr(hp1.fileinfo.line)));
                              fixline(infile.GetLineStr(hp1.fileinfo.line)));
                          { set it to a negative value !
                          { set it to a negative value !
                          to make that is has been read already !! PM }
                          to make that is has been read already !! PM }
-                         if (infile.linebuf^[hp1.fileinfo.line]>=0) then
-                           infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
+                         if (infile.linebuf[hp1.fileinfo.line]>=0) then
+                           infile.linebuf[hp1.fileinfo.line]:=-infile.linebuf[hp1.fileinfo.line]-1;
                        end;
                        end;
                    end;
                    end;
                   lastfileinfo:=hp1.fileinfo;
                   lastfileinfo:=hp1.fileinfo;

+ 3 - 3
compiler/wasm32/agwasa.pas

@@ -455,13 +455,13 @@ implementation
                         ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
                         ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
                        begin
                        begin
                          if (hp1.fileinfo.line<>0) and
                          if (hp1.fileinfo.line<>0) and
-                            ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
+                            ((infile.linebuf[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
                            writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
                            writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
                              fixline(infile.GetLineStr(hp1.fileinfo.line)));
                              fixline(infile.GetLineStr(hp1.fileinfo.line)));
                          { set it to a negative value !
                          { set it to a negative value !
                          to make that is has been read already !! PM }
                          to make that is has been read already !! PM }
-                         if (infile.linebuf^[hp1.fileinfo.line]>=0) then
-                           infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
+                         if (infile.linebuf[hp1.fileinfo.line]>=0) then
+                           infile.linebuf[hp1.fileinfo.line]:=-infile.linebuf[hp1.fileinfo.line]-1;
                        end;
                        end;
                    end;
                    end;
                   lastfileinfo:=hp1.fileinfo;
                   lastfileinfo:=hp1.fileinfo;