Explorar o código

+ cs_unicodestrings global switch to indicate that the default string type
is unicodestring (does *not* change the type of "char" to "unicodechar"
(yet)). Not yet (un)selectable via a directive.
+ systems_default_unicodestring set containing systems on which the
default string type is unicodestring

git-svn-id: branches/jvmbackend@18415 -

Jonas Maebe %!s(int64=14) %!d(string=hai) anos
pai
achega
7200245337

+ 4 - 1
compiler/defcmp.pas

@@ -423,7 +423,10 @@ implementation
                           begin
                             doconv:=tc_string_2_string;
                             { prefered string type depends on the $H switch }
-                            if not(cs_ansistrings in current_settings.localswitches) and
+                            if (cs_unicodestrings in current_settings.localswitches) and
+                               is_wide_or_unicode_string(def_to) then
+                              eq:=te_equal
+                            else if not(cs_ansistrings in current_settings.localswitches) and
                                (tstringdef(def_to).stringtype=st_shortstring) then
                               eq:=te_equal
                             else if (cs_ansistrings in current_settings.localswitches) and

+ 2 - 2
compiler/globtype.pas

@@ -123,8 +123,8 @@ interface
          { mmx }
          cs_mmx,cs_mmx_saturation,
          { parser }
-         cs_typed_addresses,cs_strict_var_strings,cs_ansistrings,cs_bitpacking,
-         cs_varpropsetter,cs_scopedenums,cs_pointermath,
+         cs_typed_addresses,cs_strict_var_strings,cs_ansistrings,cs_unicodestrings,
+         cs_bitpacking,cs_varpropsetter,cs_scopedenums,cs_pointermath,
          { macpas specific}
          cs_external_var, cs_externally_visible
        );

+ 2 - 1
compiler/nadd.pas

@@ -1544,7 +1544,8 @@ implementation
             if (nodetype in [addn,equaln,unequaln,lten,gten,ltn,gtn]) then
               begin
                 { Is there a unicodestring? }
-                if is_unicodestring(rd) or is_unicodestring(ld) then
+                if (cs_unicodestrings in current_settings.localswitches) or
+                   is_unicodestring(rd) or is_unicodestring(ld) then
                   strtype:=st_unicodestring
                 else
                 { Is there a widestring? }

+ 1 - 1
compiler/ncon.pas

@@ -300,7 +300,7 @@ implementation
           conststring :
             begin
               len:=p.value.len;
-              if not(cs_ansistrings in current_settings.localswitches) and (len>255) then
+              if (([cs_ansistrings,cs_unicodestrings] * current_settings.localswitches) = []) and (len>255) then
                 begin
                   message(parser_e_string_const_too_long);
                   len:=255;

+ 3 - 1
compiler/pbase.pas

@@ -270,7 +270,9 @@ implementation
                       { system.string? }
                       if tmodule(tunitsym(srsym).module).globalsymtable=systemunit then
                         begin
-                          if cs_ansistrings in current_settings.localswitches then
+                          if cs_unicodestrings in current_settings.localswitches then
+                            searchsym_in_module(tunitsym(srsym).module,'UNICODESTRING',srsym,srsymtable)
+                          else if cs_ansistrings in current_settings.localswitches then
                             searchsym_in_module(tunitsym(srsym).module,'ANSISTRING',srsym,srsymtable)
                           else
                             searchsym_in_module(tunitsym(srsym).module,'SHORTSTRING',srsym,srsymtable);

+ 3 - 1
compiler/pexpr.pas

@@ -132,7 +132,9 @@ implementation
            end
           else
             begin
-              if cs_ansistrings in current_settings.localswitches then
+              if cs_unicodestrings in current_settings.localswitches then
+                def:=cunicodestringtype
+              else if cs_ansistrings in current_settings.localswitches then
                 def:=cansistringtype
               else
                 def:=cshortstringtype;

+ 8 - 1
compiler/scanner.pas

@@ -286,8 +286,15 @@ implementation
 
     Procedure HandleModeSwitches(changeInit: boolean);
       begin
+        { turn unicodestrings on by default ? }
+        if (target_info.system in systems_default_unicodestring) then
+          begin
+            include(current_settings.localswitches,cs_unicodestrings);
+            if changeinit then
+             include(init_settings.localswitches,cs_unicodestrings);
+          end
         { turn ansistrings on by default ? }
-        if (m_default_ansistring in current_settings.modeswitches) then
+        else if (m_default_ansistring in current_settings.modeswitches) then
          begin
            include(current_settings.localswitches,cs_ansistrings);
            if changeinit then

+ 5 - 0
compiler/systems.pas

@@ -306,6 +306,11 @@ interface
          system_jvm_java32
        ];
 
+       { all systems where string = unicodestring by default }
+       systems_default_unicodestring = [
+         system_jvm_java32
+       ];
+
        cpu2str : array[TSystemCpu] of string[10] =
             ('','i386','m68k','alpha','powerpc','sparc','vm','ia64','x86_64',
              'mips','arm', 'powerpc64', 'avr', 'mipsel','jvm');