ソースを参照

* define FPC_DELPHI,FPC_OBJFPC,FPC_TP,FPC_GPC
* initial support for ansistring default with modes

peter 26 年 前
コミット
225bbac550
3 ファイル変更62 行追加14 行削除
  1. 6 2
      compiler/globals.pas
  2. 8 3
      compiler/globtype.pas
  3. 48 9
      compiler/pmodules.pas

+ 6 - 2
compiler/globals.pas

@@ -66,7 +66,7 @@ unit globals;
          [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
           m_cvar_support,m_initfinal,m_add_pointer];
        objfpcmodeswitches : tmodeswitches=
-         [m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
+         [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
           m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer];
        tpmodeswitches     : tmodeswitches=
          [m_tp,m_all,m_tp_procvar];
@@ -1320,7 +1320,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.30  1999-11-08 16:27:20  pierre
+  Revision 1.31  1999-11-09 13:00:38  peter
+    * define FPC_DELPHI,FPC_OBJFPC,FPC_TP,FPC_GPC
+    * initial support for ansistring default with modes
+
+  Revision 1.30  1999/11/08 16:27:20  pierre
    + Reset AnsiStrings to clean up memory
 
   Revision 1.29  1999/11/06 14:34:20  peter

+ 8 - 3
compiler/globtype.pas

@@ -124,7 +124,7 @@ interface
        { Switches which can be changed by a mode (fpc,tp7,delphi) }
        tmodeswitch = (m_none,m_all, { needed for keyword }
          { generic }
-         m_fpc,m_delphi,m_tp,m_gpc,
+         m_fpc,m_objfpc,m_delphi,m_tp,m_gpc,
          { more specific }
          m_class,               { delphi class model }
          m_objpas,              { load objpas unit }
@@ -138,7 +138,8 @@ interface
                                   procedure variables                     }
          m_autoderef,           { does auto dereferencing of struct. vars }
          m_initfinal,           { initialization/finalization for units }
-         m_add_pointer          { allow pointer add/sub operations }
+         m_add_pointer,         { allow pointer add/sub operations }
+         m_default_ansistring   { ansistring turned on by default }
        );
        tmodeswitches = set of tmodeswitch;
 
@@ -191,7 +192,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.22  1999-11-06 14:34:21  peter
+  Revision 1.23  1999-11-09 13:00:38  peter
+    * define FPC_DELPHI,FPC_OBJFPC,FPC_TP,FPC_GPC
+    * initial support for ansistring default with modes
+
+  Revision 1.22  1999/11/06 14:34:21  peter
     * truncated log to 20 revs
 
   Revision 1.21  1999/11/04 10:55:31  peter

+ 48 - 9
compiler/pmodules.pas

@@ -804,6 +804,7 @@ unit pmodules;
        end;
 {$EndIf GDB}
 
+
     procedure parse_implementation_uses(symt:Psymtable);
       begin
          if token=_USES then
@@ -818,6 +819,43 @@ unit pmodules;
       end;
 
 
+    procedure setupglobalswitches;
+
+        procedure def_symbol(const s:string);
+        var
+          mac : pmacrosym;
+        begin
+          mac:=new(pmacrosym,init(s));
+          mac^.defined:=true;
+          Message1(parser_m_macro_defined,mac^.name);
+          macros^.insert(mac);
+        end;
+
+      begin
+        { can't have local browser when no global browser }
+        if (cs_local_browser in aktmoduleswitches) and
+           not(cs_browser in aktmoduleswitches) then
+          aktmoduleswitches:=aktmoduleswitches-[cs_local_browser];
+
+        { define a symbol in delphi,objfpc,tp,gpc mode }
+        if (m_delphi in aktmodeswitches) then
+         def_symbol('FPC_DELPHI')
+        else
+         if (m_tp in aktmodeswitches) then
+          def_symbol('FPC_TP')
+        else
+         if (m_objfpc in aktmodeswitches) then
+          def_symbol('FPC_OBJFPC')
+        else
+         if (m_gpc in aktmodeswitches) then
+          def_symbol('FPC_GPC');
+
+        { turn ansistrings on by default ? }
+        if (m_default_ansistring in aktmodeswitches) then
+          aktlocalswitches:=aktlocalswitches+[cs_ansistrings];
+      end;
+
+
     procedure gen_main_procsym(const name:string;options:tproctypeoption;st:psymtable);
       var
         stt : psymtable;
@@ -918,10 +956,8 @@ unit pmodules;
          { global switches are read, so further changes aren't allowed }
          current_module^.in_global:=false;
 
-         { can't have local browser when no global browser }
-         if (cs_local_browser in aktmoduleswitches) and
-            not(cs_browser in aktmoduleswitches) then
-           aktmoduleswitches:=aktmoduleswitches-[cs_local_browser];
+         { handle the global switches }
+         setupglobalswitches;
 
          Message1(unit_u_start_parse_interface,current_module^.modulename^);
 
@@ -1294,10 +1330,9 @@ unit pmodules;
          { global switches are read, so further changes aren't allowed }
          current_module^.in_global:=false;
 
-         { can't have local browser when no global browser }
-         if (cs_local_browser in aktmoduleswitches) and
-            not(cs_browser in aktmoduleswitches) then
-           aktmoduleswitches:=aktmoduleswitches-[cs_local_browser];
+         { setup things using the global switches }
+         setupglobalswitches;
+
          { set implementation flag }
          current_module^.in_implementation:=true;
 
@@ -1446,7 +1481,11 @@ unit pmodules;
 end.
 {
   $Log$
-  Revision 1.162  1999-11-06 14:34:22  peter
+  Revision 1.163  1999-11-09 13:00:37  peter
+    * define FPC_DELPHI,FPC_OBJFPC,FPC_TP,FPC_GPC
+    * initial support for ansistring default with modes
+
+  Revision 1.162  1999/11/06 14:34:22  peter
     * truncated log to 20 revs
 
   Revision 1.161  1999/11/02 15:06:57  peter