Browse Source

* moved more inputfile things from tscannerfile to tinputfile
* changed ifdef Sourceline to cs_asm_source

peter 27 years ago
parent
commit
2f528ca8d9
4 changed files with 347 additions and 291 deletions
  1. 240 41
      compiler/files.pas
  2. 10 6
      compiler/pmodules.pas
  3. 7 4
      compiler/scandir.inc
  4. 90 240
      compiler/scanner.pas

+ 240 - 41
compiler/files.pas

@@ -32,43 +32,59 @@ unit files;
 {$ifdef FPC}
        maxunits = 1024;
        InputFileBufSize=32*1024;
+       linebufincrease=512;
 {$else}
        maxunits = 128;
        InputFileBufSize=1024;
+       linebufincrease=64;
 {$endif}
 
     type
+{$ifdef FPC}
+       tlongintarr = array[0..1000000] of longint;
+{$else}
+       tlongintarr = array[0..16000] of longint;
+{$endif}
+       plongintarr = ^tlongintarr;
+
        pinputfile = ^tinputfile;
        tinputfile = object
-         path,name : pstring;    { path and filename }
-         next      : pinputfile; { next file for reading }
+         path,name : pstring;       { path and filename }
+         next      : pinputfile;    { next file for reading }
 
          f            : file;       { current file handle }
          is_macro,
          endoffile,                 { still bytes left to read }
          closed       : boolean;    { is the file closed }
-         inputbufsize : longint;    { max size of the input buffer }
 
-         savebufstart,                  { save fields for scanner }
-         savebufsize,
+         buf          : pchar;      { buffer }
+         bufstart,                  { buffer start position in the file }
+         bufsize,                   { amount of bytes in the buffer }
+         maxbufsize   : longint;    { size in memory for the buffer }
+
+         saveinputpointer : pchar;  { save fields for scanner variables }
          savelastlinepos,
          saveline_no      : longint;
 
-         saveinputbuffer,
-         saveinputpointer : pchar;
-
-         linebuf    : plongint;   { line buffer to retrieve lines }
+         linebuf    : plongintarr;  { line buffer to retrieve lines }
          maxlinebuf : longint;
 
-         ref_count  : longint;    { to handle the browser refs }
+         ref_count  : longint;      { to handle the browser refs }
          ref_index  : longint;
          ref_next   : pinputfile;
 
          constructor init(const fn:string);
          destructor done;
-{$ifdef SourceLine}
+         procedure setpos(l:longint);
+         procedure seekbuf(fpos:longint);
+         procedure readbuf;
+         function  open:boolean;
+         procedure close;
+         procedure tempclose;
+         function  tempopen:boolean;
+         procedure setmacro(p:pchar;len:longint);
+         procedure setline(line,linepos:longint);
          function  getlinestr(l:longint):string;
-{$endif SourceLine}
        end;
 
        pfilemanager = ^tfilemanager;
@@ -118,7 +134,6 @@ unit files;
 
           { used in firstpass for faster settings }
           scanner       : pointer;
-          current_index : word;
 
           path,                     { path where the module is find/created }
           modulename,               { name of the module in uppercase }
@@ -183,22 +198,21 @@ unit files;
         is_macro:=false;
         endoffile:=false;
         closed:=true;
-        inputbufsize:=InputFileBufSize;
-        saveinputbuffer:=nil;
+        buf:=nil;
+        bufstart:=0;
+        bufsize:=0;
+        maxbufsize:=InputFileBufSize;
+      { save fields }
         saveinputpointer:=nil;
-        savebufstart:=0;
-        savebufsize:=0;
         saveline_no:=0;
         savelastlinepos:=0;
       { indexing refs }
         ref_next:=nil;
         ref_count:=0;
         ref_index:=0;
-{$ifdef SourceLine}
       { line buffer }
         linebuf:=nil;
         maxlinebuf:=0;
-{$endif SourceLine}
       end;
 
 
@@ -206,24 +220,204 @@ unit files;
       begin
         stringdispose(path);
         stringdispose(name);
-{$ifdef SourceLine}
       { free memory }
         if assigned(linebuf) then
          freemem(linebuf,maxlinebuf shl 2);
-{$endif SourceLine}
       end;
 
 
-{$ifdef SourceLine}
+    procedure tinputfile.setpos(l:longint);
+      begin
+        bufstart:=l;
+      end;
+
+
+    procedure tinputfile.seekbuf(fpos:longint);
+      begin
+        if closed then
+         exit;
+        seek(f,fpos);
+        bufstart:=fpos;
+        bufsize:=0;
+      end;
+
+
+    procedure tinputfile.readbuf;
+    {$ifdef TP}
+      var
+        w : word;
+    {$endif}
+      begin
+        if is_macro then
+         endoffile:=true;
+        if closed then
+         exit;
+        inc(bufstart,bufsize);
+      {$ifdef TP}
+        blockread(f,buf^,maxbufsize-1,w);
+        bufsize:=w;
+      {$else}
+        blockread(f,buf^,maxbufsize-1,bufsize);
+      {$endif}
+        buf[bufsize]:=#0;
+        endoffile:=not(bufsize=maxbufsize-1);
+      end;
+
+
+    function tinputfile.open:boolean;
+      var
+        ofm : byte;
+      begin
+        open:=false;
+        if not closed then
+         Close;
+        ofm:=filemode;
+        filemode:=0;
+        Assign(f,path^+name^);
+        {$I-}
+         reset(f,1);
+        {$I+}
+        filemode:=ofm;
+        if ioresult<>0 then
+         exit;
+      { file }
+        endoffile:=false;
+        closed:=false;
+        Getmem(buf,MaxBufsize);
+        bufstart:=0;
+        bufsize:=0;
+        open:=true;
+      end;
+
+
+    procedure tinputfile.close;
+      var
+        i : word;
+      begin
+        if is_macro then
+         begin
+           Freemem(buf,maxbufsize);
+           is_macro:=false;
+           closed:=true;
+           exit;
+         end;
+        if not closed then
+         begin
+           {$I-}
+            system.close(f);
+           {$I+}
+           i:=ioresult;
+           Freemem(buf,maxbufsize);
+           closed:=true;
+         end;
+        buf:=nil;
+        bufstart:=0;
+      end;
+
+
+    procedure tinputfile.tempclose;
+      var
+        i : word;
+      begin
+        if is_macro then
+         exit;
+        if not closed then
+         begin
+           {$I-}
+            system.close(f);
+           {$I+}
+           i:=ioresult;
+           Freemem(buf,maxbufsize);
+           buf:=nil;
+           closed:=true;
+         end;
+      end;
+
+
+    function tinputfile.tempopen:boolean;
+      var
+        ofm : byte;
+      begin
+        tempopen:=false;
+        if is_macro then
+         begin
+           tempopen:=true;
+           exit;
+         end;
+        if not closed then
+         exit;
+        ofm:=filemode;
+        filemode:=0;
+        Assign(f,path^+name^);
+        {$I-}
+         reset(f,1);
+        {$I+}
+        filemode:=ofm;
+        if ioresult<>0 then
+         exit;
+        closed:=false;
+      { get new mem }
+        Getmem(buf,maxbufsize);
+      { restore state }
+        seek(f,BufStart);
+        bufsize:=0;
+        readbuf;
+        tempopen:=true;
+      end;
+
+
+    procedure tinputfile.setmacro(p:pchar;len:longint);
+      begin
+      { create new buffer }
+        getmem(buf,len+1);
+        move(p^,buf^,len);
+        buf[len]:=#0;
+      { reset }
+        bufstart:=0;
+        bufsize:=len;
+        maxbufsize:=len+1;
+        is_macro:=true;
+        endoffile:=true;
+        closed:=true;
+      end;
+
+
+    procedure tinputfile.setline(line,linepos:longint);
+      var
+        oldlinebuf  : plongintarr;
+      begin
+        if line<1 then
+         exit;
+        while (line>=maxlinebuf) do
+         begin
+           oldlinebuf:=linebuf;
+         { create new linebuf and move old info }
+           getmem(linebuf,(maxlinebuf+linebufincrease) shl 2);
+           if assigned(oldlinebuf) then
+            begin
+              move(oldlinebuf^,linebuf^,maxlinebuf shl 2);
+              freemem(oldlinebuf,maxlinebuf shl 2);
+            end;
+           fillchar(linebuf^[maxlinebuf],linebufincrease shl 2,0);
+           inc(maxlinebuf,linebufincrease);
+         end;
+        linebuf^[line]:=linepos;
+      end;
+
+
     function tinputfile.getlinestr(l:longint):string;
       var
-        c : char;
-        i,fpos : longint;
+        c    : char;
+        i,
+        fpos : longint;
+        p    : pchar;
       begin
         getlinestr:='';
         if l<maxlinebuf then
          begin
-           fpos:=plongint(longint(linebuf)+line_no*2)^;
+           fpos:=linebuf^[l];
+           if closed then
+            open;
          { in current buf ? }
            if (fpos<bufstart) or (fpos>bufstart+bufsize) then
             begin
@@ -232,23 +426,25 @@ unit files;
             end;
          { the begin is in the buf now simply read until #13,#10 }
            i:=0;
-
-           inputpointer:=inputbuffer;
-           c:=inputpointer^;
-           while (i<255) and not(c in [#13,#10]) do
-            begin
-              inc(i);
-              getlinestr[i]:=c;
-              c:=inputpointer^;
-              if c=#0 then
-               reload
-              else
-               inc(longint(inputpointer));
-            end;
+           p:=@buf[fpos-bufstart];
+           repeat
+             c:=p^;
+             if c=#0 then
+              begin
+                readbuf;
+                p:=buf;
+                c:=p^;
+              end;
+             if c in [#10,#13] then
+              break;
+             inc(i);
+             getlinestr[i]:=c;
+             inc(longint(p));
+           until (i=255);
            getlinestr[0]:=chr(i);
          end;
       end;
-{$endif SourceLine}
+
 
 {****************************************************************************
                                 TFILEMANAGER
@@ -568,7 +764,6 @@ unit files;
          linkofiles.init;
          linkstaticlibs.init;
          linksharedlibs.init;
-         current_index:=0;
          ppufile:=nil;
          scanner:=nil;
          map:=nil;
@@ -665,7 +860,11 @@ unit files;
 end.
 {
   $Log$
-  Revision 1.41  1998-08-26 15:35:30  peter
+  Revision 1.42  1998-09-03 11:24:00  peter
+    * moved more inputfile things from tscannerfile to tinputfile
+    * changed ifdef Sourceline to cs_asm_source
+
+  Revision 1.41  1998/08/26 15:35:30  peter
     * fixed scannerfiles for macros
     + $I %<environment>%
 

+ 10 - 6
compiler/pmodules.pas

@@ -166,7 +166,7 @@ unit pmodules;
                          datasegment^.concat(new(pai_symbol,init_global('__stklen')));
                          datasegment^.concat(new(pai_const,init_32bit(stacksize)));
                        end;
-{$endif m68k}           
+{$endif m68k}
 
         end;
       end;
@@ -282,10 +282,10 @@ unit pmodules;
               Message1(unit_f_cant_compile_unit,current_module^.modulename^)
              else
               begin
-                current_scanner^.tempclose;
+                current_scanner^.tempcloseinputfile;
                 compile(current_module^.mainsource^,compile_system);
                 if (not old_current_module^.compiled) then
-                 current_scanner^.tempopen;
+                 current_scanner^.tempopeninputfile;
               end;
            end
           else
@@ -865,11 +865,11 @@ unit pmodules;
          names.insert('program_init');
          names.insert('PASCALMAIN');
          names.insert(target_os.cprefix+'main');
-{$ifdef m68k}   
+{$ifdef m68k}
 
          if target_info.target=target_PalmOS then
            names.insert('PilotMain');
-{$endif}        
+{$endif}
 
          compile_proc_body(names,true,false);
          names.done;
@@ -915,7 +915,11 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.45  1998-08-31 12:26:28  peter
+  Revision 1.46  1998-09-03 11:24:01  peter
+    * moved more inputfile things from tscannerfile to tinputfile
+    * changed ifdef Sourceline to cs_asm_source
+
+  Revision 1.45  1998/08/31 12:26:28  peter
     * m68k and palmos updates from surebugfixes
 
   Revision 1.44  1998/08/26 15:35:33  peter

+ 7 - 4
compiler/scandir.inc

@@ -553,17 +553,16 @@ const
          { first look in the path of _d then currentmodule }
            path:=search(name+ext,path+';'+current_scanner^.inputfile^.path^+';'+includesearchpath,found);
          { shutdown current file }
-           current_scanner^.tempclose;
+           current_scanner^.tempcloseinputfile;
          { load new file }
            hp:=new(pinputfile,init(path+name+ext));
            current_scanner^.addfile(hp);
-           if not current_scanner^.open then
+           if not current_scanner^.openinputfile then
             Message1(scan_f_cannot_open_includefile,hs);
            Message1(scan_u_start_include_file,current_scanner^.inputfile^.path^+current_scanner^.inputfile^.name^);
            current_scanner^.reload;
          { register for refs }
            current_module^.sourcefiles.register_file(hp);
-           current_module^.current_index:=hp^.ref_index;
          end;
       end;
 
@@ -916,7 +915,11 @@ const
 
 {
   $Log$
-  Revision 1.25  1998-09-02 15:13:31  peter
+  Revision 1.26  1998-09-03 11:24:02  peter
+    * moved more inputfile things from tscannerfile to tinputfile
+    * changed ifdef Sourceline to cs_asm_source
+
+  Revision 1.25  1998/09/02 15:13:31  peter
     * fixed typo in directive table
 
   Revision 1.24  1998/09/01 12:52:06  peter

+ 90 - 240
compiler/scanner.pas

@@ -33,10 +33,8 @@ unit scanner;
     const
 {$ifdef TP}
        maxmacrolen=1024;
-       linebufincrease=64;
 {$else}
        maxmacrolen=16*1024;
-       linebufincrease=512;
 {$endif}
 
        id_len = 14;
@@ -144,18 +142,16 @@ unit scanner;
 
        pscannerfile = ^tscannerfile;
        tscannerfile = object
-          inputfile    : pinputfile; { current inputfile list }
+          inputfile    : pinputfile;  { current inputfile list }
 
-          { these fields are called save* in inputfile, and are here
-            for speed reasons (PFV) }
-          bufstart,
-          bufsize,
-          line_no,
-          lastlinepos  : longint;
-          inputbuffer,
+          inputbuffer,                { input buffer }
           inputpointer : pchar;
+          inputstart   : longint;
+
+          line_no,                    { line }
+          lastlinepos  : longint;
 
-          lasttokenpos : longint;
+          lasttokenpos : longint;     { token }
           lasttoken    : ttoken;
 
           do_special,                 { 1=point after nr, 2=caret after id }
@@ -167,18 +163,15 @@ unit scanner;
           constructor init(const fn:string);
           destructor done;
         { File buffer things }
-          function  open:boolean;
-          procedure close;
-          procedure tempclose;
-          function  tempopen:boolean;
-          procedure seekbuf(fpos:longint);
-          procedure readbuf;
+          function  openinputfile:boolean;
+          procedure closeinputfile;
+          function  tempopeninputfile:boolean;
+          procedure tempcloseinputfile;
           procedure saveinputfile;
           procedure restoreinputfile;
           procedure nextfile;
           procedure addfile(hp:pinputfile);
           procedure reload;
-          procedure setbuf(p:pchar;l:longint);
           procedure insertmacro(p:pchar;len:longint);
         { Scanner things }
           procedure gettokenpos;
@@ -305,20 +298,23 @@ implementation
       begin
         inputfile:=new(pinputfile,init(fn));
         current_module^.sourcefiles.register_file(inputfile);
-        current_module^.current_index:=inputfile^.ref_index;
-      { load inputfile values }
-        restoreinputfile;
+      { reset localinput }
+        inputbuffer:=nil;
+        inputpointer:=nil;
+        inputstart:=0;
       { reset scanner }
         preprocstack:=nil;
         comment_level:=0;
         do_special:=0;
         yylexcount:=0;
         block_type:=bt_general;
+        line_no:=0;
+        lastlinepos:=0;
         lasttokenpos:=0;
         lasttoken:=_END;
         lastasmgetchar:=#0;
       { load block }
-        if not open then
+        if not openinputfile then
          Message1(scan_f_cannot_open_input,fn);
         reload;
       end;
@@ -329,178 +325,61 @@ implementation
         checkpreprocstack;
       { close file }
         if not inputfile^.closed then
-         close;
+         closeinputfile;
        end;
 
 
-    procedure tscannerfile.seekbuf(fpos:longint);
-      begin
-        with inputfile^ do
-         begin
-           if closed then
-            exit;
-           seek(f,fpos);
-           bufstart:=fpos;
-           bufsize:=0;
-         end;
-      end;
-
-
-    procedure tscannerfile.readbuf;
-    {$ifdef TP}
-      var
-        w : word;
-    {$endif}
-      begin
-        with inputfile^ do
-         begin
-           if is_macro then
-            endoffile:=true;
-           if closed then
-            exit;
-           inc(bufstart,bufsize);
-         {$ifdef TP}
-           blockread(f,inputbuffer^,inputbufsize-1,w);
-           bufsize:=w;
-         {$else}
-           blockread(f,inputbuffer^,inputbufsize-1,bufsize);
-         {$endif}
-           inputbuffer[bufsize]:=#0;
-           endoffile:=not(bufsize=inputbufsize-1);
-         end;
-      end;
-
-
-    function tscannerfile.open:boolean;
-      var
-        ofm : byte;
+    function tscannerfile.openinputfile:boolean;
       begin
-        with inputfile^ do
-         begin
-           open:=false;
-           if not closed then
-            Close;
-           ofm:=filemode;
-           filemode:=0;
-           Assign(f,path^+name^);
-           {$I-}
-            reset(f,1);
-           {$I+}
-           filemode:=ofm;
-           if ioresult<>0 then
-            exit;
-         { file }
-           endoffile:=false;
-           closed:=false;
-           Getmem(inputbuffer,inputbufsize);
-           inputpointer:=inputbuffer;
-           bufstart:=0;
-           bufsize:=0;
-         { line }
-           line_no:=0;
-           lastlinepos:=0;
-           lasttokenpos:=0;
-           open:=true;
-         end;
+        openinputfile:=inputfile^.open;
+      { load buffer }
+        inputbuffer:=inputfile^.buf;
+        inputpointer:=inputfile^.buf;
+        inputstart:=inputfile^.bufstart;
+      { line }
+        line_no:=0;
+        lastlinepos:=0;
+        lasttokenpos:=0;
       end;
 
 
-    procedure tscannerfile.close;
-      var
-        i : word;
+    procedure tscannerfile.closeinputfile;
       begin
-        with inputfile^ do
-         begin
-           if is_macro then
-            begin
-              Freemem(inputbuffer,inputbufsize);
-              is_macro:=false;
-              closed:=true;
-              exit;
-            end;
-           if not closed then
-            begin
-              {$I-}
-               system.close(f);
-              {$I+}
-              i:=ioresult;
-              Freemem(inputbuffer,inputbufsize);
-              closed:=true;
-            end;
-           inputbuffer:=nil;
-           inputpointer:=nil;
-           lastlinepos:=0;
-           lasttokenpos:=0;
-           bufstart:=0;
-         end;
+        inputfile^.close;
+      { reset buffer }
+        inputbuffer:=nil;
+        inputpointer:=nil;
+        inputstart:=0;
+      { reset line }
+        line_no:=0;
+        lastlinepos:=0;
+        lasttokenpos:=0;
       end;
 
 
-    procedure tscannerfile.tempclose;
-      var
-        i : word;
+    function tscannerfile.tempopeninputfile:boolean;
       begin
-        with inputfile^ do
-         begin
-           inc(bufstart,inputpointer-inputbuffer);
-           if is_macro then
-            exit;
-           if not closed then
-            begin
-              {$I-}
-               system.close(f);
-              {$I+}
-              i:=ioresult;
-              Freemem(inputbuffer,inputbufsize);
-              inputbuffer:=nil;
-              inputpointer:=nil;
-              closed:=true;
-            end;
-         end;
+        tempopeninputfile:=inputfile^.tempopen;
+      { reload buffer }
+        inputbuffer:=inputfile^.buf;
+        inputpointer:=inputfile^.buf;
+        inputstart:=inputfile^.bufstart;
       end;
 
 
-    function tscannerfile.tempopen:boolean;
-      var
-        ofm : byte;
+    procedure tscannerfile.tempcloseinputfile;
       begin
-        with inputfile^ do
-         begin
-           tempopen:=false;
-           if is_macro then
-            begin
-              tempopen:=true;
-              exit;
-            end;
-           if not closed then
-            exit;
-           ofm:=filemode;
-           filemode:=0;
-           Assign(f,path^+name^);
-           {$I-}
-            reset(f,1);
-           {$I+}
-           filemode:=ofm;
-           if ioresult<>0 then
-            exit;
-           closed:=false;
-         { get new mem }
-           Getmem(inputbuffer,inputbufsize);
-           inputpointer:=inputbuffer;
-         { restore state }
-           seek(f,BufStart);
-           bufsize:=0;
-           readbuf;
-           tempopen:=true;
-         end;
+        inputfile^.setpos(inputstart+(inputpointer-inputbuffer));
+        inputfile^.tempclose;
+      { reset buffer }
+        inputbuffer:=nil;
+        inputpointer:=nil;
+        inputstart:=0;
       end;
 
 
     procedure tscannerfile.saveinputfile;
       begin
-        inputfile^.savebufstart:=bufstart;
-        inputfile^.savebufsize:=bufsize;
-        inputfile^.saveinputbuffer:=inputbuffer;
         inputfile^.saveinputpointer:=inputpointer;
         inputfile^.savelastlinepos:=lastlinepos;
         inputfile^.saveline_no:=line_no;
@@ -509,12 +388,9 @@ implementation
 
     procedure tscannerfile.restoreinputfile;
       begin
-        bufstart:=inputfile^.savebufstart;
-        bufsize:=inputfile^.savebufsize;
+        inputpointer:=inputfile^.saveinputpointer;
         lastlinepos:=inputfile^.savelastlinepos;
         line_no:=inputfile^.saveline_no;
-        inputbuffer:=inputfile^.saveinputbuffer;
-        inputpointer:=inputfile^.saveinputpointer;
       end;
 
 
@@ -556,13 +432,20 @@ implementation
              if not endoffile then
               begin
                 readbuf;
+                inputpointer:=buf;
+                inputbuffer:=buf;
+                inputstart:=bufstart;
+              { first line? }
                 if line_no=0 then
-                 line_no:=1;
-                inputpointer:=inputbuffer;
+                 begin
+                   line_no:=1;
+                   if cs_asm_source in aktglobalswitches then
+                     inputfile^.setline(line_no,bufstart);
+                 end;
               end
              else
               begin
-                close;
+                closeinputfile;
               { no next module, than EOF }
                 if not assigned(inputfile^.next) then
                  begin
@@ -571,11 +454,9 @@ implementation
                  end;
               { load next file and reopen it }
                 nextfile;
-                tempopen;
+                tempopeninputfile;
               { status }
-                Message1(scan_d_back_in,inputfile^.name^);
-              { load some current_module fields }
-                current_module^.current_index:=inputfile^.ref_index;
+                Message1(scan_d_back_in,name^);
               end;
            { load next char }
              c:=inputpointer^;
@@ -585,60 +466,41 @@ implementation
       end;
 
 
-    procedure tscannerfile.setbuf(p:pchar;l:longint);
-      begin
-        with inputfile^ do
-         begin
-           inputbufsize:=l;
-           inputbuffer:=p;
-           inputpointer:=p;
-         end;
-      end;
-
-
     procedure tscannerfile.insertmacro(p:pchar;len:longint);
-    { load the values of tokenpos and lasttokenpos }
       var
-        macbuf : pchar;
-        hp     : pinputfile;
+        hp : pinputfile;
       begin
       { save old postion }
         dec(longint(inputpointer));
-        current_scanner^.tempclose;
+        tempcloseinputfile;
       { create macro 'file' }
         hp:=new(pinputfile,init('Macro'));
         addfile(hp);
-        getmem(macbuf,len+1);
-        setbuf(macbuf,len+1);
-      { fill buffer }
         with inputfile^ do
          begin
-           move(p^,inputbuffer^,len);
-           inputbuffer[len]:=#0;
-         { reset }
-           inputpointer:=inputbuffer;
-           bufstart:=0;
-           bufsize:=len;
-           line_no:=0;
-           lastlinepos:=0;
-           lasttokenpos:=0;
-           is_macro:=true;
-           endoffile:=true;
-           closed:=true;
-         { load new c }
-           c:=inputpointer^;
-           inc(longint(inputpointer));
+           setmacro(p,len);
+         { local buffer }
+           inputbuffer:=buf;
+           inputpointer:=buf;
+           inputstart:=bufstart;
          end;
+      { reset line }
+        line_no:=0;
+        lastlinepos:=0;
+        lasttokenpos:=0;
+      { load new c }
+        c:=inputpointer^;
+        inc(longint(inputpointer));
       end;
 
 
     procedure tscannerfile.gettokenpos;
     { load the values of tokenpos and lasttokenpos }
       begin
-        lasttokenpos:=bufstart+(inputpointer-inputbuffer);
+        lasttokenpos:=inputstart+(inputpointer-inputbuffer);
         tokenpos.line:=line_no;
         tokenpos.column:=lasttokenpos-lastlinepos;
-        tokenpos.fileindex:=current_module^.current_index;
+        tokenpos.fileindex:=inputfile^.ref_index;
         aktfilepos:=tokenpos;
       end;
 
@@ -671,10 +533,8 @@ implementation
     procedure tscannerfile.linebreak;
       var
          cur : char;
-{$ifdef SourceLine}
-         hp  : plongint;
-{$endif SourceLine}
-         oldtokenpos,oldaktfilepos : tfileposinfo;
+         oldtokenpos,
+         oldaktfilepos : tfileposinfo;
       begin
         with inputfile^ do
          begin
@@ -696,22 +556,8 @@ implementation
            lastlinepos:=bufstart+(inputpointer-inputbuffer);
            inc(line_no);
          { update linebuffer }
-   {$ifdef SourceLine}
-           if line_no>maxlinebuf then
-            begin
-              { create new linebuf and move old info }
-              getmem(hp,maxlinebuf+linebufincrease);
-              if assigned(linebuf) then
-               begin
-                 move(linebuf^,hp^,maxlinebuf shl 2);
-                 freemem(linebuf,maxlinebuf);
-               end;
-              { set new linebuf }
-              linebuf:=hp;
-              inc(maxlinebuf,linebufincrease);
-            end;
-           plongint(longint(linebuf)+line_no*2)^:=lastlinepos;
-   {$endif SourceLine}
+           if cs_asm_source in aktglobalswitches then
+             inputfile^.setline(line_no,lastlinepos);
          { update for status and call the show status routine,
            but don't touch aktfilepos ! }
            oldaktfilepos:=aktfilepos;
@@ -1623,7 +1469,11 @@ exit_label:
 end.
 {
   $Log$
-  Revision 1.48  1998-09-01 12:51:02  peter
+  Revision 1.49  1998-09-03 11:24:03  peter
+    * moved more inputfile things from tscannerfile to tinputfile
+    * changed ifdef Sourceline to cs_asm_source
+
+  Revision 1.48  1998/09/01 12:51:02  peter
     * close also resets lastlinepos
 
   Revision 1.47  1998/09/01 09:01:52  peter