浏览代码

* some changes to handleformalcopyoutpara() so that in the future it can
also handle non-formal parameters
* do not copy in the original value in handleformalcopyoutpara() if it's
an out parameter

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

Jonas Maebe 14 年之前
父节点
当前提交
ee77d5a6f2
共有 1 个文件被更改,包括 30 次插入15 次删除
  1. 30 15
      compiler/jvm/njvmcal.pas

+ 30 - 15
compiler/jvm/njvmcal.pas

@@ -308,23 +308,35 @@ implementation
                 assignmenttempn.free;
               end;
           end;
-        { create the array temp that and assign the parameter value (typecasted
-          to java_jlobject) }
+        { create the array temp that that will serve as the paramter }
         arrdef:=tarraydef.create(0,1,s32inttype);
-        arrdef.elementdef:=java_jlobject;
+        if parasym.vardef.typ=formaldef then
+          arrdef.elementdef:=java_jlobject
+        else
+          arrdef.elementdef:=parasym.vardef;
         arraytemp:=ctempcreatenode.create(arrdef,java_jlobject.size,
           tt_persistent,true);
         addstatement(initstat,arraytemp);
-        { wrap the primitive type in an object container
-          if required }
-        if (left.resultdef.typ in [orddef,floatdef]) then
+        { in case of a non-out parameter, pass in the original value }
+        if parasym.varspez<>vs_out then
           begin
-            left:=cinlinenode.create(in_box_x,false,ccallparanode.create(left,nil));
-            typecheckpass(left);
-          end;
-        addstatement(initstat,cassignmentnode.create(
-          cvecnode.create(ctemprefnode.create(arraytemp),genintconstnode(0)),
-          ctypeconvnode.create_explicit(left,java_jlobject)));
+            { wrap the primitive type in an object container
+              if required }
+            if parasym.vardef.typ=formaldef then
+              begin
+                if (left.resultdef.typ in [orddef,floatdef]) then
+                  begin
+                    left:=cinlinenode.create(in_box_x,false,ccallparanode.create(left,nil));
+                    typecheckpass(left);
+                  end;
+                left:=ctypeconvnode.create_explicit(left,java_jlobject);
+              end;
+            addstatement(initstat,cassignmentnode.create(
+              cvecnode.create(ctemprefnode.create(arraytemp),genintconstnode(0)),
+              left));
+          end
+        else
+          left.free;
         { replace the parameter with the array }
         left:=ctemprefnode.create(arraytemp);
         { add the extraction of the parameter and assign it back to the
@@ -332,9 +344,12 @@ implementation
         fparacopyback:=internalstatements(finistat);
         tempn:=cvecnode.create(ctemprefnode.create(arraytemp),genintconstnode(0));
         { unbox if necessary }
-        if orgparadef.typ in [orddef,floatdef] then
-          tempn:=cinlinenode.create(in_unbox_x_y,false,ccallparanode.create(
-            ctypenode.create(orgparadef),ccallparanode.create(tempn,nil)));
+        if parasym.vardef.typ=formaldef then
+          begin
+            if orgparadef.typ in [orddef,floatdef] then
+              tempn:=cinlinenode.create(in_unbox_x_y,false,ccallparanode.create(
+                ctypenode.create(orgparadef),ccallparanode.create(tempn,nil)));
+          end;
         if (deref) then
           begin
             inserttypeconv_explicit(tempn,getpointerdef(derefbasedef));