* translate_disp_call, support passing Variants by-value (still pass a pointer, but reset ByRef bit in CallDesc.Args[]).

git-svn-id: trunk@16389 -
This commit is contained in:
sergei 2010-11-20 21:43:15 +00:00
parent 49013587a9
commit 9d8d518029

View File

@ -299,6 +299,7 @@ implementation
vardatadef, vardatadef,
pvardatadef : tdef; pvardatadef : tdef;
useresult: boolean; useresult: boolean;
byrefpara: boolean;
restype: byte; restype: byte;
names : ansistring; names : ansistring;
@ -309,10 +310,9 @@ implementation
begin begin
// !! This condition is subject to change, see Mantis #17904 // !! This condition is subject to change, see Mantis #17904
result:=(assigned(para.parasym) and (para.parasym.varspez in [vs_var,vs_out,vs_constref])) or result:=(assigned(para.parasym) and (para.parasym.varspez in [vs_var,vs_out,vs_constref])) or
(para.left.resultdef.typ in [variantdef]) or
(variantdispatch and valid_for_var(para.left,false)); (variantdispatch and valid_for_var(para.left,false));
if result then if result or (para.left.resultdef.typ in [variantdef]) then
assign_type:=voidpointertype assign_type:=voidpointertype
else else
case para.left.resultdef.size of case para.left.resultdef.size of
@ -450,10 +450,14 @@ implementation
end; end;
restype:=getvardef(para.left.resultdef); restype:=getvardef(para.left.resultdef);
if is_byref_para(assignmenttype) then
restype:=restype or $80;
{ assign the argument/parameter to the temporary location } { assign the argument/parameter to the temporary location }
{ we always pass Variants by reference, RTL helpers must handle it
depending on byref bit }
if is_byref_para(assignmenttype) then if assignmenttype=voidpointertype then
begin begin
addstatement(statements,cassignmentnode.create( addstatement(statements,cassignmentnode.create(
ctypeconvnode.create_internal(cderefnode.create(caddnode.create(addn, ctypeconvnode.create_internal(cderefnode.create(caddnode.create(addn,
@ -461,7 +465,6 @@ implementation
cordconstnode.create(qword(paramssize),ptruinttype,false) cordconstnode.create(qword(paramssize),ptruinttype,false)
)),voidpointertype), )),voidpointertype),
ctypeconvnode.create_internal(caddrnode.create_internal(para.left),voidpointertype))); ctypeconvnode.create_internal(caddrnode.create_internal(para.left),voidpointertype)));
restype:=restype or $80;
end end
else else
addstatement(statements,cassignmentnode.create( addstatement(statements,cassignmentnode.create(