From d7e78b9f95d46f51d5976917dc1ce086a7d5480c Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 20 Aug 2011 08:09:40 +0000 Subject: [PATCH] * correct parameter encoding of formaldef (add array type for formal const, remove double array type for formal var/out) git-svn-id: branches/jvmbackend@18551 - --- compiler/jvmdef.pas | 3 +-- compiler/symdef.pas | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/compiler/jvmdef.pas b/compiler/jvmdef.pas index 3cb46dcd5a..168fd6e9a0 100644 --- a/compiler/jvmdef.pas +++ b/compiler/jvmdef.pas @@ -303,8 +303,7 @@ implementation formaldef : begin {$ifndef nounsupported} - { var x: JLObject } - encodedstr:=encodedstr+'['; + { var/const/out x: JLObject } result:=jvmaddencodedtype(java_jlobject,false,encodedstr,forcesignature,founderror); {$else} result:=false; diff --git a/compiler/symdef.pas b/compiler/symdef.pas index 1f24062fae..7e1f7ebff0 100644 --- a/compiler/symdef.pas +++ b/compiler/symdef.pas @@ -4492,16 +4492,16 @@ implementation name } if ([vo_is_funcret,vo_is_self] * vs.varoptions <> []) then continue; - { reference parameters are not yet supported } - if (vs.varspez in [vs_var,vs_out,vs_constref]) then - begin - { passing by reference is emulated by passing an array of one - element containing the value; for types that aren't pointers - in regular Pascal, simply passing the underlying pointer type - does achieve regular call-by-reference semantics though } - if not jvmimplicitpointertype(vs.vardef) then - tmpresult:=tmpresult+'['; - end; + { passing by reference is emulated by passing an array of one + element containing the value; for types that aren't pointers + in regular Pascal, simply passing the underlying pointer type + does achieve regular call-by-reference semantics though; + formaldefs always have to be passed like that because their + contents can be replaced } + if (vs.vardef.typ=formaldef) or + ((vs.varspez in [vs_var,vs_out,vs_constref]) and + not jvmimplicitpointertype(vs.vardef)) then + tmpresult:=tmpresult+'['; { Add the parameter type. } if not jvmaddencodedtype(vs.vardef,false,tmpresult,signature,founderror) then { should be checked earlier on }