Переглянути джерело

* inline directive enabled by default for fpc,objfpc,delphi modes
* -Si and $inline directive control are now local switches and
have finer control on whether a function will really inlined or not

git-svn-id: trunk@4553 -

peter 19 роки тому
батько
коміт
d0156354a6

+ 3 - 3
compiler/globals.pas

@@ -54,15 +54,15 @@ interface
          [m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
           m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
           m_out,m_default_para,m_duplicate_names,m_hintdirective,m_add_pointer,
-          m_property];
+          m_property,m_default_inline];
        fpcmodeswitches    : tmodeswitches=
          [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
           m_cvar_support,m_initfinal,m_add_pointer,m_hintdirective,
-          m_property];
+          m_property,m_default_inline];
        objfpcmodeswitches : tmodeswitches=
          [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,m_out,m_default_para,m_hintdirective,
-          m_property];
+          m_property,m_default_inline];
        tpmodeswitches     : tmodeswitches=
          [m_tp7,m_all,m_tp_procvar,m_duplicate_names];
        gpcmodeswitches    : tmodeswitches=

+ 4 - 2
compiler/globtype.pas

@@ -97,6 +97,7 @@ than 255 characters. That's why using Ansi Strings}
          cs_checkpointer,
          cs_generate_stackframes,cs_do_assertion,cs_generate_rtti,
          cs_full_boolean_eval,cs_typed_const_writable,cs_allow_enum_calc,
+         cs_do_inline,
          { mmx }
          cs_mmx,cs_mmx_saturation,
          { parser }
@@ -111,7 +112,7 @@ than 255 characters. That's why using Ansi Strings}
          { parser }
          cs_fp_emulation,cs_extsyntax,cs_openstring,
          { support }
-         cs_support_inline,cs_support_goto,cs_support_macro,
+         cs_support_goto,cs_support_macro,
          cs_support_c_operators,cs_static_keyword,
          { generation }
          cs_profile,cs_debuginfo,cs_browser,cs_local_browser,cs_compilesystem,
@@ -187,7 +188,8 @@ than 255 characters. That's why using Ansi Strings}
          m_default_para,        { support default parameters }
          m_hintdirective,       { support hint directives }
          m_duplicate_names,     { allow locals/paras to have duplicate names of globals }
-         m_property             { allow properties }
+         m_property,            { allow properties }
+         m_default_inline       { allow inline proc directive }
        );
        tmodeswitches = set of tmodeswitch;
 

+ 3 - 3
compiler/options.pas

@@ -1028,7 +1028,7 @@ begin
                        'h' :
                          include(initlocalswitches,cs_ansistrings);
                        'i' :
-                         include(initmoduleswitches,cs_support_inline);
+                         include(initlocalswitches,cs_do_inline);
                        'k' :
                          include(initglobalswitches,cs_load_fpcylix_unit);
                        'm' :
@@ -1044,9 +1044,9 @@ begin
                        '-' :
                          begin
                            exclude(initglobalswitches,cs_constructor_name);
-                           initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_ansistrings];
+                           initlocalswitches:=InitLocalswitches - [cs_do_assertion, cs_do_inline, cs_ansistrings];
                            initmoduleswitches:=initmoduleswitches - [cs_support_c_operators, cs_support_goto,
-                                                                     cs_support_inline, cs_support_macro,
+                                                                     cs_support_macro,
                                                                      cs_static_keyword];
                          end;
                        else

+ 12 - 8
compiler/pdecsub.pas

@@ -2235,14 +2235,18 @@ const
             end;
         end;
 
-        if (po_inline in pd.procoptions) then
-            begin
-              if not(cs_support_inline in aktmoduleswitches) then
-               begin
-                 Message(parser_e_proc_inline_not_supported);
-                 exclude(pd.procoptions,po_inline);
-               end;
-            end;
+        { Inlining is enabled and supported? }
+        if (po_inline in pd.procoptions) and
+           not(cs_do_inline in aktlocalswitches) then
+          begin
+            { Give an error if inline is not supported by the compiler mode,
+              otherwise only give a warning that this procedure will not be inlined }
+            if not(m_default_inline in aktmodeswitches) then
+              Message(parser_e_proc_inline_not_supported)
+            else
+              Message(parser_w_inlining_disabled);
+            exclude(pd.procoptions,po_inline);
+          end;
 
         { For varargs directive also cdecl and external must be defined }
         if (po_varargs in pd.procoptions) then

+ 1 - 1
compiler/scandir.pas

@@ -430,7 +430,7 @@ implementation
 
     procedure dir_inline;
       begin
-        do_moduleswitch(cs_support_inline);
+        do_localswitch(cs_do_inline);
       end;
 
     procedure dir_interfaces;

+ 16 - 1
compiler/scanner.pas

@@ -288,8 +288,9 @@ implementation
                aktlocalswitches:=nextaktlocalswitches;
                localswitcheschanged:=false;
              end;
+
            { turn ansistrings on by default ? }
-           if (m_delphi in aktmodeswitches) then
+           if (m_default_ansistring in aktmodeswitches) then
             begin
               include(aktlocalswitches,cs_ansistrings);
               if changeinit then
@@ -302,6 +303,20 @@ implementation
                exclude(initlocalswitches,cs_ansistrings);
             end;
 
+           { turn inline on by default ? }
+           if (m_default_inline in aktmodeswitches) then
+            begin
+              include(aktlocalswitches,cs_do_inline);
+              if changeinit then
+               include(initlocalswitches,cs_do_inline);
+            end
+           else
+            begin
+              exclude(aktlocalswitches,cs_ansistrings);
+              if changeinit then
+               exclude(initlocalswitches,cs_ansistrings);
+            end;
+
            { turn on bitpacking for mode macpas }
            if (m_mac in aktmodeswitches) then
              begin