From 32c7ba29ea1057f9f88c8e935abf45b1ed06ceb6 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 13 Oct 2006 19:15:00 +0000 Subject: [PATCH] * when calling an inherited methode by msg, any var parameters are compatible, if somebody knows how to implement it better, feel free to do so git-svn-id: trunk@4889 - --- compiler/pexpr.pas | 20 +++++++++++++++----- compiler/symtable.pas | 7 ++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index d9a7aea0bc..e1cec53174 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -88,8 +88,8 @@ implementation const { true, if the inherited call is anonymous } anon_inherited : boolean = false; - - + { last def found, only used by anon. inherited calls to insert proper type casts } + srdef : tdef = nil; procedure string_dec(var t: ttype); { reads a string type with optional length } @@ -990,7 +990,17 @@ implementation begin currpara:=tparavarsym(current_procinfo.procdef.paras[i]); if not(vo_is_hidden_para in currpara.varoptions) then - para:=ccallparanode.create(cloadnode.create(currpara,currpara.owner),para); + begin + { inheritance by msgint? } + if assigned(srdef) then + { anonymous inherited via msgid calls only require a var parameter for + both methods, so we need some type casting here } + para:=ccallparanode.create(ctypeconvnode.create_internal(ctypeconvnode.create_internal( + cloadnode.create(currpara,currpara.owner),cformaltype),tparavarsym(tprocdef(srdef).paras[i]).vartype), + para) + else + para:=ccallparanode.create(cloadnode.create(currpara,currpara.owner),para); + end; end; end else @@ -1181,7 +1191,6 @@ implementation { the ID token has to be consumed before calling this function } procedure do_member_read(classh:tobjectdef;getaddr : boolean;sym : tsym;var p1 : tnode;var again : boolean;callflags:tcallnodeflags); - var static_name : string; isclassref : boolean; @@ -2131,8 +2140,9 @@ implementation { For message methods we need to search using the message number or string } pd:=tprocsym(current_procinfo.procdef.procsym).first_procdef; + srdef:=nil; if (po_msgint in pd.procoptions) then - searchsym_in_class_by_msgint(classh,pd.messageinf.i,srsym,srsymtable) + searchsym_in_class_by_msgint(classh,pd.messageinf.i,srdef,srsym,srsymtable) else if (po_msgstr in pd.procoptions) then searchsym_in_class_by_msgstr(classh,pd.messageinf.str^,srsym,srsymtable) diff --git a/compiler/symtable.pas b/compiler/symtable.pas index 29a4f6a324..18150ddd39 100644 --- a/compiler/symtable.pas +++ b/compiler/symtable.pas @@ -221,7 +221,7 @@ interface function searchsym_type(const s : stringid;out srsym:tsym;out srsymtable:tsymtable):boolean; function searchsym_in_module(pm:pointer;const s : stringid;out srsym:tsym;out srsymtable:tsymtable):boolean; function searchsym_in_class(classh,contextclassh:tobjectdef;const s : stringid;out srsym:tsym;out srsymtable:tsymtable):boolean; - function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint;out srsym:tsym;out srsymtable:tsymtable):boolean; + function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint;out srdef : tdef;out srsym:tsym;out srsymtable:tsymtable):boolean; function searchsym_in_class_by_msgstr(classh:tobjectdef;const s:string;out srsym:tsym;out srsymtable:tsymtable):boolean; function search_system_type(const s: stringid): ttypesym; function search_class_member(pd : tobjectdef;const s : string):tsym; @@ -994,7 +994,7 @@ implementation varalign:=size_2_align(l); if (usefieldalignment<> bit_alignment) then varalignfield:=used_align(varalign,aktalignment.recordalignmin,fieldalignment); - + sym.fieldoffset:=align(_datasize,varalignfield); if (int64(l)+sym.fieldoffset)>high(aint) then begin @@ -1853,7 +1853,7 @@ implementation end; - function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint;out srsym:tsym;out srsymtable:tsymtable):boolean; + function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint;out srdef : tdef;out srsym:tsym;out srsymtable:tsymtable):boolean; var def : tdef; begin @@ -1870,6 +1870,7 @@ implementation (po_msgint in tprocdef(def).procoptions) and (tprocdef(def).messageinf.i=i) then begin + srdef:=def; srsym:=tprocdef(def).procsym; srsymtable:=classh.symtable; result:=true;