Преглед изворни кода

Merged revisions 7370-7373,7375-7376,7379,7381,7383-7388,7391-7392,7400,7404-7406,7411,7422,7425,7428,7435-7437 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r7370 | florian | 2007-05-16 23:25:55 +0200 (Wed, 16 May 2007) | 2 lines

* changed some message handling to ansistring, no slow down measurable with make cycle, resolves #8890
........
r7371 | florian | 2007-05-16 23:31:27 +0200 (Wed, 16 May 2007) | 2 lines

* fixed ide building using the new comment hook
........
r7428 | peter | 2007-05-23 15:33:53 +0200 (Wed, 23 May 2007) | 6 lines

* cleanup current module status
* new set_current_module function that sets the current_module and
all related variables. Also closes scanner files if required, but
that might still need some optimization to prevent closing/opening
files too often
........
r7435 | peter | 2007-05-24 08:21:31 +0200 (Thu, 24 May 2007) | 2 lines

* added status.currentmodulestate
........
r7437 | peter | 2007-05-24 08:40:37 +0200 (Thu, 24 May 2007) | 2 lines

* use new currentmodulestate
........

git-svn-id: branches/fixes_2_2@8544 -

peter пре 18 година
родитељ
комит
ef58c569fd
9 измењених фајлова са 73 додато и 91 уклоњено
  1. 4 4
      compiler/cmsgs.pas
  2. 19 19
      compiler/comphook.pas
  3. 1 1
      compiler/compiler.pas
  4. 35 0
      compiler/fmodule.pas
  5. 2 21
      compiler/fppu.pas
  6. 7 27
      compiler/parser.pas
  7. 2 2
      compiler/psystem.pas
  8. 1 15
      compiler/verbose.pas
  9. 2 2
      ide/fpcompil.pas

+ 4 - 4
compiler/cmsgs.pas

@@ -52,7 +52,7 @@ type
     procedure ClearIdx;
     procedure CreateIdx;
     function  GetPChar(nr:longint):pchar;
-    function  Get(nr:longint;const args:array of string):string;
+    function  Get(nr:longint;const args:array of string):ansistring;
   end;
 
 { this will read a line until #10 or #0 and also increase p }
@@ -66,11 +66,11 @@ uses
   cutils;
 
 
-function MsgReplace(const s:string;const args:array of string):string;
+function MsgReplace(const s:string;const args:array of string):ansistring;
 var
   last,
   i  : longint;
-  hs : string;
+  hs : ansistring;
 
 begin
   if s='' then
@@ -375,7 +375,7 @@ begin
 end;
 
 
-function TMessage.Get(nr:longint;const args:array of string):string;
+function TMessage.Get(nr:longint;const args:array of string):ansistring;
 var
   hp : pchar;
 begin

+ 19 - 19
compiler/comphook.pas

@@ -76,6 +76,7 @@ type
     currentsource : string;   { filename }
     currentline,
     currentcolumn : longint;  { current line and column }
+		currentmodulestate : string[20];
   { Total Status }
     compiledlines : longint;  { the number of lines which are compiled }
     errorcount,
@@ -98,8 +99,7 @@ type
     use_redir,
     use_bugreport,
     use_gccoutput,
-    print_source_path,
-    compiling_current : boolean;
+    print_source_path : boolean;
   { Redirection support }
     redirfile : text;
   { Special file for bug report }
@@ -121,7 +121,7 @@ var
 
 { Default Functions }
 Function  def_status:boolean;
-Function  def_comment(Level:Longint;const s:string):boolean;
+Function  def_comment(Level:Longint;const s:ansistring):boolean;
 function  def_internalerror(i:longint):boolean;
 procedure def_initsymbolinfo;
 procedure def_donesymbolinfo;
@@ -132,7 +132,7 @@ Function  def_getnamedfiletime(Const F : String) : Longint;
 type
   tstopprocedure         = procedure(err:longint);
   tstatusfunction        = function:boolean;
-  tcommentfunction       = function(Level:Longint;const s:string):boolean;
+  tcommentfunction       = function(Level:Longint;const s:ansistring):boolean;
   tinternalerrorfunction = function(i:longint):boolean;
 
   tinitsymbolinfoproc = procedure;
@@ -198,22 +198,22 @@ end;
                           Stopping the compiler
 ****************************************************************************}
 
-     constructor EControlCAbort.Create;
-       begin
-         inherited Create('Ctrl-C Signaled!');
-       end;
+constructor EControlCAbort.Create;
+  begin
+    inherited Create('Ctrl-C Signaled!');
+  end;
 
 
-     constructor ECompilerAbort.Create;
-       begin
-         inherited Create('Compilation Aborted');
-       end;
+constructor ECompilerAbort.Create;
+  begin
+    inherited Create('Compilation Aborted');
+  end;
 
 
-     constructor ECompilerAbortSilent.Create;
-       begin
-         inherited Create('Compilation Aborted');
-       end;
+constructor ECompilerAbortSilent.Create;
+  begin
+    inherited Create('Compilation Aborted');
+  end;
 
 
 {****************************************************************************
@@ -243,13 +243,13 @@ begin
 end;
 
 
-Function def_comment(Level:Longint;const s:string):boolean;
+Function def_comment(Level:Longint;const s:ansistring):boolean;
 const
   rh_errorstr   = 'error:';
   rh_warningstr = 'warning:';
 var
-  hs : string;
-  hs2 : string;
+  hs : ansistring;
+  hs2 : ansistring;
 begin
   def_comment:=false; { never stop }
   hs:='';

+ 1 - 1
compiler/compiler.pas

@@ -178,7 +178,7 @@ begin
 { this is needed here for the IDE
   in case of compilation failure
   at the previous compile }
-  current_module:=nil;
+  set_current_module(nil);
 { read the arguments }
   read_arguments(cmd);
 { inits which depend on arguments }

+ 35 - 0
compiler/fmodule.pas

@@ -195,6 +195,7 @@ interface
        SmartLinkOFiles   : TCmdStrList; { List of .o files which are generated,
                                           used to delete them after linking }
 
+    procedure set_current_module(p:tmodule);
     function get_module(moduleindex : longint) : tmodule;
     function get_source_file(moduleindex,fileindex : longint) : tinputfile;
     procedure addloadedunit(hp:tmodule);
@@ -218,6 +219,40 @@ implementation
                              Global Functions
 *****************************************************************************}
 
+    procedure set_current_module(p:tmodule);
+      begin
+        { save the state of the scanner }
+        if assigned(current_scanner) then
+          current_scanner.tempcloseinputfile;
+        { set new module }
+        current_module:=p;
+        { restore previous module settings }
+        Fillchar(current_filepos,0,sizeof(current_filepos));
+        if assigned(current_module) then
+          begin
+            current_asmdata:=tasmdata(current_module.asmdata);
+            { restore scanner and file positions }
+            current_scanner:=tscannerfile(current_module.scanner);
+            if assigned(current_scanner) then
+              begin
+                current_scanner.tempopeninputfile;
+                current_scanner.gettokenpos;
+                parser_current_file:=current_scanner.inputfile.name^;
+              end
+            else
+              begin
+                current_filepos.moduleindex:=current_module.unit_index;
+                parser_current_file:='';
+              end;
+          end
+        else
+          begin
+            current_asmdata:=nil;
+            current_scanner:=nil;
+          end;
+      end;
+
+
     function get_module(moduleindex : longint) : tmodule;
       var
          hp : tmodule;

+ 2 - 21
compiler/fppu.pas

@@ -1343,9 +1343,7 @@ uses
         { reset }
         do_load:=true;
         second_time:=false;
-        current_module:=self;
-        SetCompileModule(current_module);
-        Fillchar(current_filepos,0,sizeof(current_filepos));
+        set_current_module(self);
 
         { A force reload }
         if do_reload then
@@ -1378,12 +1376,6 @@ uses
 
         if do_load then
          begin
-           { we are loading a new module, save the state of the scanner
-             and reset scanner+module }
-           if assigned(current_scanner) then
-             current_scanner.tempcloseinputfile;
-           current_scanner:=nil;
-
            { loading the unit for a second time? }
            if state=ms_registered then
             state:=ms_load
@@ -1495,21 +1487,10 @@ uses
               assigned(tppumodule(old_current_module).ppufile) then
              tppumodule(old_current_module).ppufile.tempopen;
 {$endif SHORT_ON_FILE_HANDLES}
-
-           { reload old scanner }
-           current_scanner:=tscannerfile(old_current_module.scanner);
-           if assigned(current_scanner) then
-            begin
-              current_scanner.tempopeninputfile;
-              current_scanner.gettokenpos
-            end
-           else
-            fillchar(current_filepos,sizeof(current_filepos),0);
          end;
 
         { we are back, restore current_module }
-        current_module:=old_current_module;
-        SetCompileModule(current_module);
+        set_current_module(old_current_module);
       end;
 
 

+ 7 - 27
compiler/parser.pas

@@ -60,11 +60,10 @@ implementation
          testcurobject:=0;
 
          { Current compiled module/proc }
+         set_current_module(nil);
          current_module:=nil;
-         compiled_module:=nil;
          current_asmdata:=nil;
          current_procinfo:=nil;
-         SetCompileModule(nil);
 
          loaded_units:=TLinkedList.Create;
 
@@ -134,11 +133,10 @@ implementation
       begin
          { Reset current compiling info, so destroy routines can't
            reference the data that might already be destroyed }
+         set_current_module(nil);
          current_module:=nil;
-         compiled_module:=nil;
          current_procinfo:=nil;
          current_asmdata:=nil;
-         SetCompileModule(nil);
 
          { unload units }
          if assigned(loaded_units) then
@@ -183,7 +181,7 @@ implementation
       begin
          new(preprocfile,init('pre'));
        { initialize a module }
-         current_module:=new(pmodule,init(filename,false));
+         set_current_module(new(pmodule,init(filename,false)));
 
          macrosymtablestack:= initialmacrosymtable;
          current_module.localmacrosymtable:= tmacrosymtable.create(false);
@@ -275,7 +273,7 @@ implementation
           oldparse_only  : boolean;
         { akt.. things }
           oldcurrent_filepos      : tfileposinfo;
-          old_compiled_module : tmodule;
+          old_current_module : tmodule;
           oldcurrent_procinfo : tprocinfo;
           old_settings : tsettings;
           oldsourcecodepage : tcodepagestring;
@@ -293,7 +291,7 @@ implementation
          new(olddata);
          with olddata^ do
           begin
-            old_compiled_module:=compiled_module;
+            old_current_module:=current_module;
           { save symtable state }
             oldsymtablestack:=symtablestack;
             oldmacrosymtablestack:=macrosymtablestack;
@@ -343,7 +341,7 @@ implementation
            begin
              if assigned(current_module) then
                internalerror(200501158);
-             current_module:=tppumodule.create(nil,filename,'',false);
+             set_current_module(tppumodule.create(nil,filename,'',false));
              addloadedunit(current_module);
              main_module:=current_module;
              current_module.state:=ms_compile;
@@ -352,11 +350,6 @@ implementation
                 (current_module.state in [ms_compile,ms_second_compile])) then
            internalerror(200212281);
 
-         { Set the module to use for verbose }
-         compiled_module:=current_module;
-         SetCompileModule(current_module);
-         Fillchar(current_filepos,0,sizeof(current_filepos));
-
          { Load current state from the init values }
          current_settings:=init_settings;
 
@@ -457,18 +450,6 @@ implementation
                 block_type:=old_block_type;
                 { restore cg }
                 parse_only:=oldparse_only;
-                { asm data }
-                if assigned(old_compiled_module) then
-                  current_asmdata:=tasmdata(old_compiled_module.asmdata)
-                else
-                  current_asmdata:=nil;
-                { restore previous scanner }
-                if assigned(old_compiled_module) then
-                  current_scanner:=tscannerfile(old_compiled_module.scanner)
-                else
-                  current_scanner:=nil;
-                if assigned(current_scanner) then
-                  parser_current_file:=current_scanner.inputfile.name^;
                 { restore symtable state }
                 symtablestack:=oldsymtablestack;
                 macrosymtablestack:=oldmacrosymtablestack;
@@ -508,8 +489,7 @@ implementation
                end;
              end;
            dec(compile_level);
-           compiled_module:=olddata^.old_compiled_module;
-           SetCompileModule(compiled_module);
+           set_current_module(olddata^.old_current_module);
 
            dispose(olddata);
          end;

+ 2 - 2
compiler/psystem.pas

@@ -346,7 +346,7 @@ implementation
           pbestrealtype:=@s64floattype;
 
         oldcurrentmodule:=current_module;
-        current_module:=nil;
+        set_current_module(nil);
         loadtype('byte',u8inttype);
         loadtype('shortint',s8inttype);
         loadtype('word',u16inttype);
@@ -397,7 +397,7 @@ implementation
         ptruinttype:=u32inttype;
         ptrsinttype:=s32inttype;
 {$endif cpu64bit}
-        current_module:=oldcurrentmodule;
+        set_current_module(oldcurrentmodule);
       end;
 
 

+ 1 - 15
compiler/verbose.pas

@@ -79,7 +79,6 @@ interface
     procedure PrepareReport;
 
     function  CheckVerbosity(v:longint):boolean;
-    procedure SetCompileModule(p:tmodulebase);
     procedure ShowStatus;
     function  ErrorCount:longint;
     procedure SetErrorFlags(const s:string);
@@ -120,9 +119,6 @@ implementation
     uses
       comphook,fmodule;
 
-var
-  compiling_module : tmodulebase;
-
 
 {****************************************************************************
                        Extra Handlers for default compiler
@@ -367,12 +363,6 @@ var
       end;
 
 
-    procedure SetCompileModule(p:tmodulebase);
-      begin
-        compiling_module:=p;
-      end;
-
-
     var
       lastfileidx,
       lastmoduleidx : longint;
@@ -393,6 +383,7 @@ var
          begin
            { update status record }
            status.currentmodule:=module.modulename^;
+					 status.currentmodulestate:=ModuleStateStr[module.state];
            status.currentsource:=module.sourcefiles.get_file_name(current_filepos.fileindex);
            status.currentsourcepath:=module.sourcefiles.get_file_path(current_filepos.fileindex);
 
@@ -403,9 +394,6 @@ var
              lastfileidx:=0;
            lastmoduleidx:=module.unit_index;
          end;
-        status.compiling_current:=assigned(compiling_module) and
-                                  (module=compiling_module) and
-                                  (compiling_module.state in [ms_compile,ms_second_compile]);
       end;
 
 
@@ -871,8 +859,6 @@ end;
         status.currentmodule:='';
         status.currentsource:='';
         status.currentsourcepath:='';
-        status.compiling_current:=false;
-        compiling_module:=nil;
         { Register internalerrorproc for cutils/cclasses }
         internalerrorproc:=@internalerror;
       end;

+ 2 - 2
ide/fpcompil.pas

@@ -587,7 +587,7 @@ begin
     cpCompiling :
       begin
         ClearFormatParams;
-        if Status.Compiling_current then
+        if Upcase(Status.currentmodulestate)='COMPILE' then
           begin
             AddFormatParamStr(ShrinkPath(SmartPath(Status.Currentsourcepath+Status.CurrentSource),
               MaxFileNameSize - Length(msg_compilingfile)));
@@ -753,7 +753,7 @@ begin
   CompilerOpenInputFile:=f;
 end;
 
-function CompilerComment(Level:Longint; const s:string):boolean; {$ifndef FPC}far;{$endif}
+function CompilerComment(Level:Longint; const s:ansistring):boolean; {$ifndef FPC}far;{$endif}
 begin
   CompilerComment:=false;
   if (status.verbosity and Level)<>0 then