Browse Source

* preparations to use generic string concatentation/comparison code for JVM
targets:
o initialize managed temps that are passed as var-parameters to the
dests-parameter of the concat routines, because they will be read and
stored in the var-parameter array (they are finalized and hence work
fine on native targets, but finalization is a nop on the JVM target)
o do not take the shortcut of comparing with nil when checking for an
empty ansi/unicodestring on managed VM targets

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

Jonas Maebe 14 years ago
parent
commit
1fbd8750f2
1 changed files with 12 additions and 1 deletions
  1. 12 1
      compiler/nadd.pas

+ 12 - 1
compiler/nadd.pas

@@ -1982,6 +1982,16 @@ implementation
                   result:=internalstatements(newstatement);
                   result:=internalstatements(newstatement);
                   tempnode:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true);
                   tempnode:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true);
                   addstatement(newstatement,tempnode);
                   addstatement(newstatement,tempnode);
+                  { initialize the temp, since it will be passed to a
+                    var-parameter (and finalization, which is performed by the
+                    ttempcreate node and which takes care of the initialization
+                    on native targets, is a noop on managed VM targets) }
+                  if (target_info.system in systems_managed_vm) and
+                     is_managed_type(resultdef) then
+                    addstatement(newstatement,cinlinenode.create(in_setlength_x,
+                      false,
+                      ccallparanode.create(genintconstnode(0),
+                        ccallparanode.create(ctemprefnode.create(tempnode),nil))));
                   addstatement(newstatement,ccallnode.createintern('fpc_'+
                   addstatement(newstatement,ccallnode.createintern('fpc_'+
                     tstringdef(resultdef).stringtypname+'_concat',
                     tstringdef(resultdef).stringtypname+'_concat',
                     ccallparanode.create(right,
                     ccallparanode.create(right,
@@ -2013,7 +2023,8 @@ implementation
                       nodetype:=swap_relation[nodetype];
                       nodetype:=swap_relation[nodetype];
                     end;
                     end;
                   if is_shortstring(left.resultdef) or
                   if is_shortstring(left.resultdef) or
-                     (nodetype in [gtn,gten,ltn,lten]) then
+                     (nodetype in [gtn,gten,ltn,lten]) or
+                     (target_info.system in systems_managed_vm) then
                     { compare the length with 0 }
                     { compare the length with 0 }
                     result := caddnode.create(nodetype,
                     result := caddnode.create(nodetype,
                       cinlinenode.create(in_length_x,false,left),
                       cinlinenode.create(in_length_x,false,left),