peter 26 years ago
parent
commit
02576a8279
5 changed files with 146 additions and 46 deletions
  1. 68 13
      compiler/globals.pas
  2. 18 4
      compiler/globtype.pas
  3. 34 8
      compiler/systems.pas
  4. 16 9
      compiler/tokens.pas
  5. 10 12
      compiler/verbose.pas

+ 68 - 13
compiler/globals.pas

@@ -60,13 +60,13 @@ unit globals;
 
 
        delphimodeswitches : tmodeswitches=
        delphimodeswitches : tmodeswitches=
          [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
          [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
-          m_pointer_2_procedure,m_autoderef,m_tp_procvar];
+          m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal];
        fpcmodeswitches    : tmodeswitches=
        fpcmodeswitches    : tmodeswitches=
          [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
          [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
-          m_cvar_support];
+          m_cvar_support,m_initfinal];
        objfpcmodeswitches : tmodeswitches=
        objfpcmodeswitches : tmodeswitches=
-         [m_fpc,m_all,m_objpas,m_class,m_result,m_string_pchar,m_nested_comment,
-          m_repeat_forward,m_cvar_support];
+         [m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
+          m_repeat_forward,m_cvar_support,m_initfinal];
        tpmodeswitches     : tmodeswitches=
        tpmodeswitches     : tmodeswitches=
          [m_tp,m_all,m_tp_procvar];
          [m_tp,m_all,m_tp_procvar];
        gpcmodeswitches    : tmodeswitches=
        gpcmodeswitches    : tmodeswitches=
@@ -184,7 +184,8 @@ unit globals;
     function min(a,b : longint) : longint;
     function min(a,b : longint) : longint;
     function max(a,b : longint) : longint;
     function max(a,b : longint) : longint;
     function align(i,a:longint):longint;
     function align(i,a:longint):longint;
-    procedure Replace(var s:string;const s1,s2:string);
+    procedure Replace(var s:string;s1:string;const s2:string);
+    procedure ReplaceCase(var s:string;const s1,s2:string);
     function upper(const s : string) : string;
     function upper(const s : string) : string;
     function lower(const s : string) : string;
     function lower(const s : string) : string;
     function trimspace(const s:string):string;
     function trimspace(const s:string):string;
@@ -204,6 +205,8 @@ unit globals;
     function gettimestr:string;
     function gettimestr:string;
     function filetimestring( t : longint) : string;
     function filetimestring( t : longint) : string;
 
 
+    procedure DefaultReplacements(var s:string);
+
     function path_absolute(const s : string) : boolean;
     function path_absolute(const s : string) : boolean;
     Function FileExists ( Const F : String) : Boolean;
     Function FileExists ( Const F : String) : Boolean;
     Function RemoveFile(const f:string):boolean;
     Function RemoveFile(const f:string):boolean;
@@ -363,21 +366,44 @@ unit globals;
       end;
       end;
 
 
 
 
-    procedure Replace(var s:string;const s1,s2:string);
-    {
-      replace all s1 with s2 in string s
-    }
+    procedure Replace(var s:string;s1:string;const s2:string);
       var
       var
+         last,
          i  : longint;
          i  : longint;
       begin
       begin
+        s1:=upper(s1);
+        last:=0;
+        repeat
+          i:=pos(s1,upper(s));
+          if i=last then
+           i:=0;
+          if (i>0) then
+           begin
+             Delete(s,i,length(s1));
+             Insert(s2,s,i);
+             last:=i;
+           end;
+        until (i=0);
+      end;
+
+
+    procedure ReplaceCase(var s:string;const s1,s2:string);
+      var
+         last,
+         i  : longint;
+      begin
+        last:=0;
         repeat
         repeat
           i:=pos(s1,s);
           i:=pos(s1,s);
-          if i>0 then
+          if i=last then
+           i:=0;
+          if (i>0) then
            begin
            begin
              Delete(s,i,length(s1));
              Delete(s,i,length(s1));
              Insert(s2,s,i);
              Insert(s2,s,i);
+             last:=i;
            end;
            end;
-        until i=0;
+        until (i=0);
       end;
       end;
 
 
 
 
@@ -680,6 +706,19 @@ unit globals;
        filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
        filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
      end;
      end;
 
 
+{****************************************************************************
+                          Default Macro Handling
+****************************************************************************}
+
+     procedure DefaultReplacements(var s:string);
+       begin
+         { Replace some macro's }
+         Replace(s,'$FPCVER',full_version_string);
+         Replace(s,'$FPCDATE',date_string);
+         Replace(s,'$FPCTARGET',target_cpu_string);
+         Replace(s,'$TARGET',target_path);
+       end;
+
 
 
 {****************************************************************************
 {****************************************************************************
                                File Handling
                                File Handling
@@ -832,14 +871,18 @@ unit globals;
       var
       var
         i : longint;
         i : longint;
       begin
       begin
+        { Fix separator }
         for i:=1 to length(s) do
         for i:=1 to length(s) do
          if s[i] in ['/','\'] then
          if s[i] in ['/','\'] then
           s[i]:=DirSep;
           s[i]:=DirSep;
+        { Fix ending / }
         if (length(s)>0) and (s[length(s)]<>DirSep) and
         if (length(s)>0) and (s[length(s)]<>DirSep) and
            (s[length(s)]<>':') then
            (s[length(s)]<>':') then
          s:=s+DirSep;
          s:=s+DirSep;
+        { Remove ./ }
         if (not allowdot) and (s='.'+DirSep) then
         if (not allowdot) and (s='.'+DirSep) then
          s:='';
          s:='';
+        { return }
         FixPath:=s;
         FixPath:=s;
       end;
       end;
 
 
@@ -893,7 +936,9 @@ unit globals;
      begin
      begin
        if s='' then
        if s='' then
         exit;
         exit;
-     {Fix List}
+     { Support default macro's }
+       DefaultReplacements(s);
+     { Fix List }
        if (length(list)>0) and (list[length(list)]<>';') then
        if (length(list)>0) and (list[length(list)]<>';') then
         list:=list+';';
         list:=list+';';
        GetDir(0,CurrentDir);
        GetDir(0,CurrentDir);
@@ -1162,7 +1207,17 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  1999-07-06 21:48:16  florian
+  Revision 1.11  1999-07-10 10:26:18  peter
+    * merged
+
+  Revision 1.8.2.2  1999/07/10 10:03:04  peter
+    * fixed initialization/finalization in fpc mode
+    * allow $TARGET also in search paths
+
+  Revision 1.8.2.1  1999/07/07 07:53:21  michael
+  + Merged patches from florian
+
+  Revision 1.10  1999/07/06 21:48:16  florian
     * a lot bug fixes:
     * a lot bug fixes:
        - po_external isn't any longer necessary for procedure compatibility
        - po_external isn't any longer necessary for procedure compatibility
        - m_tp_procvar is in -Sd now available
        - m_tp_procvar is in -Sd now available

+ 18 - 4
compiler/globtype.pas

@@ -98,11 +98,18 @@ interface
          { generic }
          { generic }
          m_fpc,m_delphi,m_tp,m_gpc,
          m_fpc,m_delphi,m_tp,m_gpc,
          { more specific }
          { more specific }
-         m_class,m_objpas,m_result,m_string_pchar,m_cvar_support,
-         m_nested_comment,m_tp_procvar,m_repeat_forward,
+         m_class,               { delphi class model }
+         m_objpas,              { load objpas unit }
+         m_result,              { result in functions }
+         m_string_pchar,        { pchar 2 string conversion }
+         m_cvar_support,        { cvar variable directive }
+         m_nested_comment,      { nested comments }
+         m_tp_procvar,          { tp style procvars (no @ needed) }
+         m_repeat_forward,      { repeating forward declarations is needed }
          m_pointer_2_procedure, { allows the assignement of pointers to
          m_pointer_2_procedure, { allows the assignement of pointers to
                                   procedure variables                     }
                                   procedure variables                     }
-         m_autoderef            { does auto dereferencing of struct. vars }
+         m_autoderef,           { does auto dereferencing of struct. vars }
+         m_initfinal            { initialization/finalization for units }
        );
        );
        tmodeswitches = set of tmodeswitch;
        tmodeswitches = set of tmodeswitch;
 
 
@@ -142,10 +149,17 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  1999-07-03 00:29:49  peter
+  Revision 1.12  1999-07-10 10:26:19  peter
+    * merged
+
+  Revision 1.11  1999/07/03 00:29:49  peter
     * new link writing to the ppu, one .ppu is needed for all link types,
     * new link writing to the ppu, one .ppu is needed for all link types,
       static (.o) is now always created also when smartlinking is used
       static (.o) is now always created also when smartlinking is used
 
 
+  Revision 1.10.2.1  1999/07/10 10:03:06  peter
+    * fixed initialization/finalization in fpc mode
+    * allow $TARGET also in search paths
+
   Revision 1.10  1999/05/17 14:30:39  pierre
   Revision 1.10  1999/05/17 14:30:39  pierre
    + cs_checkpointer
    + cs_checkpointer
 
 

+ 34 - 8
compiler/systems.pas

@@ -234,6 +234,7 @@ unit systems;
        target_link : tlinkinfo;
        target_link : tlinkinfo;
        target_ar   : tarinfo;
        target_ar   : tarinfo;
        target_res  : tresinfo;
        target_res  : tresinfo;
+       target_path : string[12]; { for rtl/<X>/,fcl/<X>/, etc. }
        source_os   : tosinfo;
        source_os   : tosinfo;
 
 
     function set_target_os(t:tos):boolean;
     function set_target_os(t:tos):boolean;
@@ -1217,6 +1218,26 @@ begin
 {$endif}
 {$endif}
 end;
 end;
 
 
+function lower(const s : string) : string;
+var
+  i : longint;
+begin
+  for i:=1 to length(s) do
+   if s[i] in ['A'..'Z'] then
+    lower[i]:=char(byte(s[i])+32)
+   else
+    lower[i]:=s[i];
+  {$ifndef TP}
+    {$ifopt H+}
+      setlength(lower,length(s));
+    {$else}
+      lower[0]:=s[0];
+    {$endif}
+  {$else}
+    lower[0]:=s[0];
+  {$endif}
+end;
+
 
 
 function set_target_os(t:tos):boolean;
 function set_target_os(t:tos):boolean;
 var
 var
@@ -1308,6 +1329,7 @@ begin
       set_target_link(target_info.link);
       set_target_link(target_info.link);
       set_target_ar(target_info.ar);
       set_target_ar(target_info.ar);
       set_target_res(target_info.res);
       set_target_res(target_info.res);
+      target_path:=lower(target_info.short_name);
       target_cpu:=target_info.cpu;
       target_cpu:=target_info.cpu;
       set_target_info:=true;
       set_target_info:=true;
       exit;
       exit;
@@ -1329,13 +1351,7 @@ begin
   for i:=1 to targetcnt do
   for i:=1 to targetcnt do
    if target_infos[i].short_name=s then
    if target_infos[i].short_name=s then
     begin
     begin
-      target_info:=target_infos[i];
-      set_target_os(target_info.os);
-      set_target_asm(target_info.assem);
-      set_target_link(target_info.link);
-      set_target_ar(target_info.ar);
-      set_target_res(target_info.res);
-      target_cpu:=target_info.cpu;
+      set_target_info(target_infos[i].target);
       set_string_target:=true;
       set_string_target:=true;
       exit;
       exit;
     end;
     end;
@@ -1500,7 +1516,17 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.82  1999-06-08 11:50:28  peter
+  Revision 1.83  1999-07-10 10:26:20  peter
+    * merged
+
+  Revision 1.82.2.2  1999/07/10 10:03:16  peter
+    * fixed initialization/finalization in fpc mode
+    * allow $TARGET also in search paths
+
+  Revision 1.82.2.1  1999/07/02 12:52:58  pierre
+   * pecoff still buggy, as_I386_asw again default
+
+  Revision 1.82  1999/06/08 11:50:28  peter
     * 2mb again for go32v2/v1
     * 2mb again for go32v2/v1
 
 
   Revision 1.81  1999/06/02 20:46:39  peter
   Revision 1.81  1999/06/02 20:46:39  peter

+ 16 - 9
compiler/tokens.pas

@@ -265,7 +265,7 @@ const
       (str:'IN'            ;special:false;keyword:m_all),
       (str:'IN'            ;special:false;keyword:m_all),
       (str:'IS'            ;special:false;keyword:m_class),
       (str:'IS'            ;special:false;keyword:m_class),
       (str:'OF'            ;special:false;keyword:m_all),
       (str:'OF'            ;special:false;keyword:m_all),
-      (str:'ON'            ;special:false;keyword:m_objpas),
+      (str:'ON'            ;special:false;keyword:m_class),
       (str:'OR'            ;special:false;keyword:m_all),
       (str:'OR'            ;special:false;keyword:m_all),
       (str:'TO'            ;special:false;keyword:m_all),
       (str:'TO'            ;special:false;keyword:m_all),
       (str:'AND'           ;special:false;keyword:m_all),
       (str:'AND'           ;special:false;keyword:m_all),
@@ -281,7 +281,7 @@ const
       (str:'SET'           ;special:false;keyword:m_all),
       (str:'SET'           ;special:false;keyword:m_all),
       (str:'SHL'           ;special:false;keyword:m_all),
       (str:'SHL'           ;special:false;keyword:m_all),
       (str:'SHR'           ;special:false;keyword:m_all),
       (str:'SHR'           ;special:false;keyword:m_all),
-      (str:'TRY'           ;special:false;keyword:m_objpas),
+      (str:'TRY'           ;special:false;keyword:m_class),
       (str:'VAR'           ;special:false;keyword:m_all),
       (str:'VAR'           ;special:false;keyword:m_all),
       (str:'XOR'           ;special:false;keyword:m_all),
       (str:'XOR'           ;special:false;keyword:m_all),
       (str:'CASE'          ;special:false;keyword:m_all),
       (str:'CASE'          ;special:false;keyword:m_all),
@@ -311,12 +311,12 @@ const
       (str:'FALSE'         ;special:false;keyword:m_all),
       (str:'FALSE'         ;special:false;keyword:m_all),
       (str:'INDEX'         ;special:false;keyword:m_none),
       (str:'INDEX'         ;special:false;keyword:m_none),
       (str:'LABEL'         ;special:false;keyword:m_all),
       (str:'LABEL'         ;special:false;keyword:m_all),
-      (str:'RAISE'         ;special:false;keyword:m_objpas),
+      (str:'RAISE'         ;special:false;keyword:m_class),
       (str:'UNTIL'         ;special:false;keyword:m_all),
       (str:'UNTIL'         ;special:false;keyword:m_all),
       (str:'WHILE'         ;special:false;keyword:m_all),
       (str:'WHILE'         ;special:false;keyword:m_all),
       (str:'WRITE'         ;special:false;keyword:m_none),
       (str:'WRITE'         ;special:false;keyword:m_none),
       (str:'DOWNTO'        ;special:false;keyword:m_all),
       (str:'DOWNTO'        ;special:false;keyword:m_all),
-      (str:'EXCEPT'        ;special:false;keyword:m_objpas),
+      (str:'EXCEPT'        ;special:false;keyword:m_class),
       (str:'EXPORT'        ;special:false;keyword:m_none),
       (str:'EXPORT'        ;special:false;keyword:m_none),
       (str:'INLINE'        ;special:false;keyword:m_none),
       (str:'INLINE'        ;special:false;keyword:m_none),
       (str:'OBJECT'        ;special:false;keyword:m_all),
       (str:'OBJECT'        ;special:false;keyword:m_all),
@@ -335,7 +335,7 @@ const
       (str:'DISPOSE'       ;special:false;keyword:m_all),
       (str:'DISPOSE'       ;special:false;keyword:m_all),
       (str:'DYNAMIC'       ;special:false;keyword:m_none),
       (str:'DYNAMIC'       ;special:false;keyword:m_none),
       (str:'EXPORTS'       ;special:false;keyword:m_all),
       (str:'EXPORTS'       ;special:false;keyword:m_all),
-      (str:'FINALLY'       ;special:false;keyword:m_objpas),
+      (str:'FINALLY'       ;special:false;keyword:m_class),
       (str:'FORWARD'       ;special:false;keyword:m_none),
       (str:'FORWARD'       ;special:false;keyword:m_none),
       (str:'IOCHECK'       ;special:false;keyword:m_none),
       (str:'IOCHECK'       ;special:false;keyword:m_none),
       (str:'LIBRARY'       ;special:false;keyword:m_all),
       (str:'LIBRARY'       ;special:false;keyword:m_all),
@@ -366,16 +366,16 @@ const
       (str:'PROCEDURE'     ;special:false;keyword:m_all),
       (str:'PROCEDURE'     ;special:false;keyword:m_all),
       (str:'PROTECTED'     ;special:false;keyword:m_none),
       (str:'PROTECTED'     ;special:false;keyword:m_none),
       (str:'PUBLISHED'     ;special:false;keyword:m_none),
       (str:'PUBLISHED'     ;special:false;keyword:m_none),
-      (str:'THREADVAR'     ;special:false;keyword:m_objpas),
+      (str:'THREADVAR'     ;special:false;keyword:m_class),
       (str:'DESTRUCTOR'    ;special:false;keyword:m_all),
       (str:'DESTRUCTOR'    ;special:false;keyword:m_all),
       (str:'INTERNPROC'    ;special:false;keyword:m_none),
       (str:'INTERNPROC'    ;special:false;keyword:m_none),
       (str:'OPENSTRING'    ;special:false;keyword:m_none),
       (str:'OPENSTRING'    ;special:false;keyword:m_none),
       (str:'CONSTRUCTOR'   ;special:false;keyword:m_all),
       (str:'CONSTRUCTOR'   ;special:false;keyword:m_all),
       (str:'INTERNCONST'   ;special:false;keyword:m_none),
       (str:'INTERNCONST'   ;special:false;keyword:m_none),
       (str:'SHORTSTRING'   ;special:false;keyword:m_none),
       (str:'SHORTSTRING'   ;special:false;keyword:m_none),
-      (str:'FINALIZATION'  ;special:false;keyword:m_class),
+      (str:'FINALIZATION'  ;special:false;keyword:m_initfinal),
       (str:'IMPLEMENTATION';special:false;keyword:m_all),
       (str:'IMPLEMENTATION';special:false;keyword:m_all),
-      (str:'INITIALIZATION';special:false;keyword:m_class)
+      (str:'INITIALIZATION';special:false;keyword:m_initfinal)
   );
   );
 
 
 implementation
 implementation
@@ -383,7 +383,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  1999-05-24 08:55:30  florian
+  Revision 1.8  1999-07-10 10:26:21  peter
+    * merged
+
+  Revision 1.7.2.1  1999/07/10 10:03:18  peter
+    * fixed initialization/finalization in fpc mode
+    * allow $TARGET also in search paths
+
+  Revision 1.7  1999/05/24 08:55:30  florian
     * non working safecall directiv implemented, I don't know if we
     * non working safecall directiv implemented, I don't know if we
       need it
       need it
 
 

+ 10 - 12
compiler/verbose.pas

@@ -67,7 +67,6 @@ procedure SetRedirectFile(const fn:string);
 function  SetVerbosity(const s:string):boolean;
 function  SetVerbosity(const s:string):boolean;
 
 
 procedure LoadMsgFile(const fn:string);
 procedure LoadMsgFile(const fn:string);
-procedure UpdateReplacement(var s:string);
 
 
 procedure Stop;
 procedure Stop;
 procedure ShowStatus;
 procedure ShowStatus;
@@ -247,14 +246,6 @@ begin
 end;
 end;
 
 
 
 
-procedure UpdateReplacement(var s:string);
-begin
-  Replace(s,'$FPCVER',full_version_string);
-  Replace(s,'$FPCDATE',date_string);
-  Replace(s,'$FPCTARGET',target_cpu_string);
-end;
-
-
 var
 var
   lastfileidx,
   lastfileidx,
   lastmoduleidx : longint;
   lastmoduleidx : longint;
@@ -341,7 +332,7 @@ begin
 { Create status info }
 { Create status info }
   UpdateStatus;
   UpdateStatus;
 { Fix replacements }
 { Fix replacements }
-  UpdateReplacement(s);
+  DefaultReplacements(s);
 { show comment }
 { show comment }
   if do_comment(l,s) or dostop then
   if do_comment(l,s) or dostop then
    stop;
    stop;
@@ -408,7 +399,7 @@ begin
 { fix status }
 { fix status }
   UpdateStatus;
   UpdateStatus;
 { Fix replacements }
 { Fix replacements }
-  UpdateReplacement(s);
+  DefaultReplacements(s);
 { show comment }
 { show comment }
   if do_comment(v,s) or dostop then
   if do_comment(v,s) or dostop then
    stop;
    stop;
@@ -515,9 +506,16 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.40  1999-06-18 11:03:09  peter
+  Revision 1.41  1999-07-10 10:26:22  peter
     * merged
     * merged
 
 
+  Revision 1.40  1999/06/18 11:03:09  peter
+    * merged
+
+  Revision 1.39.2.2  1999/07/10 10:03:19  peter
+    * fixed initialization/finalization in fpc mode
+    * allow $TARGET also in search paths
+
   Revision 1.39.2.1  1999/06/18 10:55:32  peter
   Revision 1.39.2.1  1999/06/18 10:55:32  peter
     * version fixes
     * version fixes
     * EXTRAUNITS to set extra units that are build and needs to be cleaned
     * EXTRAUNITS to set extra units that are build and needs to be cleaned