htypechk.pas 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit exports some help routines for the type checking
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit htypechk;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. tokens,cpuinfo,
  23. node,
  24. symconst,symtype,symdef,symsym,symbase;
  25. type
  26. Ttok2nodeRec=record
  27. tok : ttoken;
  28. nod : tnodetype;
  29. op_overloading_supported : boolean;
  30. end;
  31. pcandidate = ^tcandidate;
  32. tcandidate = record
  33. next : pcandidate;
  34. data : tprocdef;
  35. wrongpara,
  36. firstpara : tparaitem;
  37. exact_count,
  38. equal_count,
  39. cl1_count,
  40. cl2_count,
  41. cl3_count,
  42. coper_count : integer; { should be signed }
  43. ordinal_distance : bestreal;
  44. invalid : boolean;
  45. wrongparanr : byte;
  46. end;
  47. tcallcandidates = class
  48. private
  49. FProcSym : tprocsym;
  50. FProcs : pcandidate;
  51. FProcVisibleCnt,
  52. FProcCnt : integer;
  53. FParaNode : tnode;
  54. FParaLength : smallint;
  55. FAllowVariant : boolean;
  56. function proc_add(pd:tprocdef):pcandidate;
  57. public
  58. constructor create(sym:tprocsym;st:tsymtable;ppn:tnode;isprop:boolean);
  59. constructor create_operator(op:ttoken;ppn:tnode);
  60. destructor destroy;override;
  61. procedure list(all:boolean);
  62. {$ifdef EXTDEBUG}
  63. procedure dump_info(lvl:longint);
  64. {$endif EXTDEBUG}
  65. procedure get_information;
  66. function choose_best(var bestpd:tabstractprocdef):integer;
  67. procedure find_wrong_para;
  68. property Count:integer read FProcCnt;
  69. property VisibleCount:integer read FProcVisibleCnt;
  70. end;
  71. const
  72. tok2nodes=25;
  73. tok2node:array[1..tok2nodes] of ttok2noderec=(
  74. (tok:_PLUS ;nod:addn;op_overloading_supported:true), { binary overloading supported }
  75. (tok:_MINUS ;nod:subn;op_overloading_supported:true), { binary and unary overloading supported }
  76. (tok:_STAR ;nod:muln;op_overloading_supported:true), { binary overloading supported }
  77. (tok:_SLASH ;nod:slashn;op_overloading_supported:true), { binary overloading supported }
  78. (tok:_EQUAL ;nod:equaln;op_overloading_supported:true), { binary overloading supported }
  79. (tok:_GT ;nod:gtn;op_overloading_supported:true), { binary overloading supported }
  80. (tok:_LT ;nod:ltn;op_overloading_supported:true), { binary overloading supported }
  81. (tok:_GTE ;nod:gten;op_overloading_supported:true), { binary overloading supported }
  82. (tok:_LTE ;nod:lten;op_overloading_supported:true), { binary overloading supported }
  83. (tok:_SYMDIF ;nod:symdifn;op_overloading_supported:true), { binary overloading supported }
  84. (tok:_STARSTAR;nod:starstarn;op_overloading_supported:true), { binary overloading supported }
  85. (tok:_OP_AS ;nod:asn;op_overloading_supported:false), { binary overloading NOT supported }
  86. (tok:_OP_IN ;nod:inn;op_overloading_supported:false), { binary overloading NOT supported }
  87. (tok:_OP_IS ;nod:isn;op_overloading_supported:false), { binary overloading NOT supported }
  88. (tok:_OP_OR ;nod:orn;op_overloading_supported:true), { binary overloading supported }
  89. (tok:_OP_AND ;nod:andn;op_overloading_supported:true), { binary overloading supported }
  90. (tok:_OP_DIV ;nod:divn;op_overloading_supported:true), { binary overloading supported }
  91. (tok:_OP_NOT ;nod:notn;op_overloading_supported:true), { unary overloading supported }
  92. (tok:_OP_MOD ;nod:modn;op_overloading_supported:true), { binary overloading supported }
  93. (tok:_OP_SHL ;nod:shln;op_overloading_supported:true), { binary overloading supported }
  94. (tok:_OP_SHR ;nod:shrn;op_overloading_supported:true), { binary overloading supported }
  95. (tok:_OP_XOR ;nod:xorn;op_overloading_supported:true), { binary overloading supported }
  96. (tok:_ASSIGNMENT;nod:assignn;op_overloading_supported:true), { unary overloading supported }
  97. (tok:_CARET ;nod:caretn;op_overloading_supported:false), { binary overloading NOT supported }
  98. (tok:_UNEQUAL ;nod:unequaln;op_overloading_supported:false) { binary overloading NOT supported overload = instead }
  99. );
  100. const
  101. { firstcallparan without varspez we don't count the ref }
  102. {$ifdef extdebug}
  103. count_ref : boolean = true;
  104. {$endif def extdebug}
  105. allow_array_constructor : boolean = false;
  106. function node2opstr(nt:tnodetype):string;
  107. { check operator args and result type }
  108. function isbinaryoperatoroverloadable(treetyp:tnodetype;ld:tdef;lt:tnodetype;rd:tdef;rt:tnodetype) : boolean;
  109. function isoperatoracceptable(pf : tprocdef; optoken : ttoken) : boolean;
  110. function isunaryoverloaded(var t : tnode) : boolean;
  111. function isbinaryoverloaded(var t : tnode) : boolean;
  112. { Register Allocation }
  113. procedure make_not_regable(p : tnode);
  114. procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
  115. { subroutine handling }
  116. function is_procsym_load(p:tnode):boolean;
  117. procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
  118. { sets varsym varstate field correctly }
  119. procedure set_varstate(p:tnode;newstate:tvarstate;must_be_valid:boolean);
  120. { sets the callunique flag, if the node is a vecn, }
  121. { takes care of type casts etc. }
  122. procedure set_unique(p : tnode);
  123. function valid_for_formal_var(p : tnode) : boolean;
  124. function valid_for_formal_const(p : tnode) : boolean;
  125. function valid_for_var(p:tnode):boolean;
  126. function valid_for_assignment(p:tnode):boolean;
  127. implementation
  128. uses
  129. globtype,systems,
  130. cutils,verbose,globals,
  131. symtable,
  132. defutil,defcmp,
  133. nbas,ncnv,nld,nmem,ncal,nmat,nutils,
  134. cgbase,procinfo
  135. ;
  136. type
  137. TValidAssign=(Valid_Property,Valid_Void,Valid_Const);
  138. TValidAssigns=set of TValidAssign;
  139. function node2opstr(nt:tnodetype):string;
  140. var
  141. i : integer;
  142. begin
  143. result:='<unknown>';
  144. for i:=1 to tok2nodes do
  145. if tok2node[i].nod=nt then
  146. begin
  147. result:=tokeninfo^[tok2node[i].tok].str;
  148. break;
  149. end;
  150. end;
  151. function isbinaryoperatoroverloadable(treetyp:tnodetype;ld:tdef;lt:tnodetype;rd:tdef;rt:tnodetype) : boolean;
  152. function internal_check(treetyp:tnodetype;ld:tdef;lt:tnodetype;rd:tdef;rt:tnodetype;var allowed:boolean):boolean;
  153. begin
  154. internal_check:=true;
  155. case ld.deftype of
  156. formaldef,
  157. recorddef,
  158. variantdef :
  159. begin
  160. allowed:=true;
  161. end;
  162. procvardef :
  163. begin
  164. if (rd.deftype in [pointerdef,procdef,procvardef]) then
  165. begin
  166. allowed:=false;
  167. exit;
  168. end;
  169. allowed:=true;
  170. end;
  171. pointerdef :
  172. begin
  173. if ((rd.deftype in [orddef,enumdef,pointerdef,classrefdef,procvardef]) or
  174. is_class_or_interface(rd)) then
  175. begin
  176. allowed:=false;
  177. exit;
  178. end;
  179. { don't allow pchar+string }
  180. if (is_pchar(ld) or is_pwidechar(ld)) and
  181. ((rd.deftype=stringdef) or
  182. is_pchar(rd) or
  183. is_pwidechar(rd) or
  184. is_chararray(rd) or
  185. is_widechararray(rd)) then
  186. begin
  187. allowed:=false;
  188. exit;
  189. end;
  190. allowed:=true;
  191. end;
  192. arraydef :
  193. begin
  194. { not mmx }
  195. if (cs_mmx in aktlocalswitches) and
  196. is_mmx_able_array(ld) then
  197. begin
  198. allowed:=false;
  199. exit;
  200. end;
  201. { not chararray+[(wide)char,(wide)string,(wide)chararray] }
  202. if (is_chararray(ld) or is_widechararray(ld)) and
  203. ((rd.deftype in [stringdef,orddef,enumdef]) or
  204. is_pchar(rd) or
  205. is_pwidechar(rd) or
  206. is_chararray(rd) or
  207. is_widechararray(rd) or
  208. (rt=niln)) then
  209. begin
  210. allowed:=false;
  211. exit;
  212. end;
  213. { dynamic array compare with niln }
  214. if ((is_dynamic_array(ld) and
  215. (rt=niln)) or
  216. (is_dynamic_array(ld) and is_dynamic_array(rd)))
  217. and
  218. (treetyp in [equaln,unequaln]) then
  219. begin
  220. allowed:=false;
  221. exit;
  222. end;
  223. allowed:=true;
  224. end;
  225. objectdef :
  226. begin
  227. { <> and = are defined for classes }
  228. if (treetyp in [equaln,unequaln]) and
  229. is_class_or_interface(ld) then
  230. begin
  231. allowed:=false;
  232. exit;
  233. end;
  234. allowed:=true;
  235. end;
  236. stringdef :
  237. begin
  238. if ((rd.deftype in [orddef,enumdef,stringdef]) or
  239. is_pchar(rd) or
  240. is_pwidechar(rd) or
  241. is_chararray(rd) or
  242. is_widechararray(rd)) then
  243. begin
  244. allowed:=false;
  245. exit;
  246. end;
  247. allowed:=true;
  248. end;
  249. else
  250. internal_check:=false;
  251. end;
  252. end;
  253. var
  254. allowed : boolean;
  255. begin
  256. { power ** is always possible }
  257. if (treetyp=starstarn) then
  258. begin
  259. isbinaryoperatoroverloadable:=true;
  260. exit;
  261. end;
  262. { order of arguments does not matter so we have to check also
  263. the reversed order }
  264. allowed:=false;
  265. if not internal_check(treetyp,ld,lt,rd,rt,allowed) then
  266. internal_check(treetyp,rd,rt,ld,lt,allowed);
  267. isbinaryoperatoroverloadable:=allowed;
  268. end;
  269. function isunaryoperatoroverloadable(treetyp : tnodetype;ld : tdef) : boolean;
  270. begin
  271. result:=false;
  272. case treetyp of
  273. subn,
  274. unaryminusn :
  275. begin
  276. if is_integer(ld) or
  277. (ld.deftype=floatdef) then
  278. exit;
  279. {$ifdef SUPPORT_MMX}
  280. if (cs_mmx in aktlocalswitches) and
  281. is_mmx_able_array(ld) then
  282. exit;
  283. {$endif SUPPORT_MMX}
  284. result:=true;
  285. end;
  286. notn :
  287. begin
  288. if is_integer(ld) or
  289. is_boolean(ld) then
  290. exit;
  291. {$ifdef SUPPORT_MMX}
  292. if (cs_mmx in aktlocalswitches) and
  293. is_mmx_able_array(ld) then
  294. exit;
  295. {$endif SUPPORT_MMX}
  296. result:=true;
  297. end;
  298. end;
  299. end;
  300. function isoperatoracceptable(pf : tprocdef; optoken : ttoken) : boolean;
  301. var
  302. ld,rd : tdef;
  303. i : longint;
  304. eq : tequaltype;
  305. conv : tconverttype;
  306. pd : tprocdef;
  307. begin
  308. result:=false;
  309. case pf.parast.symindex.count of
  310. 1 : begin
  311. ld:=tvarsym(pf.parast.symindex.first).vartype.def;
  312. { assignment is a special case }
  313. if optoken=_ASSIGNMENT then
  314. begin
  315. eq:=compare_defs_ext(ld,pf.rettype.def,nothingn,conv,pd,[cdo_explicit]);
  316. result:=(eq=te_incompatible);
  317. end
  318. else
  319. begin
  320. for i:=1 to tok2nodes do
  321. if tok2node[i].tok=optoken then
  322. begin
  323. result:=
  324. tok2node[i].op_overloading_supported and
  325. isunaryoperatoroverloadable(tok2node[i].nod,ld);
  326. break;
  327. end;
  328. end;
  329. end;
  330. 2 : begin
  331. for i:=1 to tok2nodes do
  332. if tok2node[i].tok=optoken then
  333. begin
  334. ld:=tvarsym(pf.parast.symindex.first).vartype.def;
  335. rd:=tvarsym(pf.parast.symindex.first.indexnext).vartype.def;
  336. result:=
  337. tok2node[i].op_overloading_supported and
  338. isbinaryoperatoroverloadable(tok2node[i].nod,ld,nothingn,rd,nothingn);
  339. break;
  340. end;
  341. end;
  342. end;
  343. end;
  344. function isunaryoverloaded(var t : tnode) : boolean;
  345. var
  346. ld : tdef;
  347. optoken : ttoken;
  348. operpd : tprocdef;
  349. ppn : tcallparanode;
  350. candidates : tcallcandidates;
  351. cand_cnt : integer;
  352. begin
  353. result:=false;
  354. operpd:=nil;
  355. { load easier access variables }
  356. ld:=tunarynode(t).left.resulttype.def;
  357. if not isunaryoperatoroverloadable(t.nodetype,ld) then
  358. exit;
  359. { operator overload is possible }
  360. result:=true;
  361. case t.nodetype of
  362. notn:
  363. optoken:=_OP_NOT;
  364. unaryminusn:
  365. optoken:=_MINUS;
  366. else
  367. begin
  368. CGMessage(parser_e_operator_not_overloaded);
  369. t:=cnothingnode.create;
  370. exit;
  371. end;
  372. end;
  373. { generate parameter nodes }
  374. ppn:=ccallparanode.create(tunarynode(t).left.getcopy,nil);
  375. ppn.get_paratype;
  376. candidates:=tcallcandidates.create_operator(optoken,ppn);
  377. { stop when there are no operators found }
  378. if candidates.count=0 then
  379. begin
  380. CGMessage(parser_e_operator_not_overloaded);
  381. candidates.free;
  382. ppn.free;
  383. t:=cnothingnode.create;
  384. exit;
  385. end;
  386. { Retrieve information about the candidates }
  387. candidates.get_information;
  388. {$ifdef EXTDEBUG}
  389. { Display info when multiple candidates are found }
  390. candidates.dump_info(V_Debug);
  391. {$endif EXTDEBUG}
  392. cand_cnt:=candidates.choose_best(operpd);
  393. { exit when no overloads are found }
  394. if cand_cnt=0 then
  395. begin
  396. CGMessage(parser_e_operator_not_overloaded);
  397. candidates.free;
  398. ppn.free;
  399. t:=cnothingnode.create;
  400. exit;
  401. end;
  402. { Multiple candidates left? }
  403. if cand_cnt>1 then
  404. begin
  405. CGMessage(type_e_cant_choose_overload_function);
  406. {$ifdef EXTDEBUG}
  407. candidates.dump_info(V_Hint);
  408. {$else EXTDEBUG}
  409. candidates.list(false);
  410. {$endif EXTDEBUG}
  411. { we'll just use the first candidate to make the
  412. call }
  413. end;
  414. candidates.free;
  415. inc(operpd.procsym.refs);
  416. { the nil as symtable signs firstcalln that this is
  417. an overloaded operator }
  418. t:=ccallnode.create(ppn,Tprocsym(operpd.procsym),nil,nil,[]);
  419. { we already know the procdef to use, so it can
  420. skip the overload choosing in callnode.det_resulttype }
  421. tcallnode(t).procdefinition:=operpd;
  422. end;
  423. function isbinaryoverloaded(var t : tnode) : boolean;
  424. var
  425. rd,ld : tdef;
  426. optoken : ttoken;
  427. operpd : tprocdef;
  428. ht : tnode;
  429. ppn : tcallparanode;
  430. candidates : tcallcandidates;
  431. cand_cnt : integer;
  432. begin
  433. isbinaryoverloaded:=false;
  434. operpd:=nil;
  435. { load easier access variables }
  436. ld:=tbinarynode(t).left.resulttype.def;
  437. rd:=tbinarynode(t).right.resulttype.def;
  438. if not isbinaryoperatoroverloadable(t.nodetype,ld,tbinarynode(t).left.nodetype,rd,tbinarynode(t).right.nodetype) then
  439. exit;
  440. { operator overload is possible }
  441. result:=true;
  442. case t.nodetype of
  443. equaln,
  444. unequaln :
  445. optoken:=_EQUAL;
  446. addn:
  447. optoken:=_PLUS;
  448. subn:
  449. optoken:=_MINUS;
  450. muln:
  451. optoken:=_STAR;
  452. starstarn:
  453. optoken:=_STARSTAR;
  454. slashn:
  455. optoken:=_SLASH;
  456. ltn:
  457. optoken:=_LT;
  458. gtn:
  459. optoken:=_GT;
  460. lten:
  461. optoken:=_LTE;
  462. gten:
  463. optoken:=_GTE;
  464. symdifn :
  465. optoken:=_SYMDIF;
  466. modn :
  467. optoken:=_OP_MOD;
  468. orn :
  469. optoken:=_OP_OR;
  470. xorn :
  471. optoken:=_OP_XOR;
  472. andn :
  473. optoken:=_OP_AND;
  474. divn :
  475. optoken:=_OP_DIV;
  476. shln :
  477. optoken:=_OP_SHL;
  478. shrn :
  479. optoken:=_OP_SHR;
  480. else
  481. begin
  482. CGMessage(parser_e_operator_not_overloaded);
  483. t:=cnothingnode.create;
  484. exit;
  485. end;
  486. end;
  487. { generate parameter nodes }
  488. ppn:=ccallparanode.create(tbinarynode(t).right.getcopy,ccallparanode.create(tbinarynode(t).left.getcopy,nil));
  489. ppn.get_paratype;
  490. candidates:=tcallcandidates.create_operator(optoken,ppn);
  491. { for commutative operators we can swap arguments and try again }
  492. if (candidates.count=0) and
  493. not(optoken in [_OP_SHL,_OP_SHR,_OP_DIV,_OP_MOD,_STARSTAR,_SLASH,_MINUS]) then
  494. begin
  495. candidates.free;
  496. reverseparameters(ppn);
  497. { reverse compare operators }
  498. case optoken of
  499. _LT:
  500. optoken:=_GTE;
  501. _GT:
  502. optoken:=_LTE;
  503. _LTE:
  504. optoken:=_GT;
  505. _GTE:
  506. optoken:=_LT;
  507. end;
  508. candidates:=tcallcandidates.create_operator(optoken,ppn);
  509. end;
  510. { stop when there are no operators found }
  511. if candidates.count=0 then
  512. begin
  513. CGMessage(parser_e_operator_not_overloaded);
  514. candidates.free;
  515. ppn.free;
  516. t:=cnothingnode.create;
  517. exit;
  518. end;
  519. { Retrieve information about the candidates }
  520. candidates.get_information;
  521. {$ifdef EXTDEBUG}
  522. { Display info when multiple candidates are found }
  523. candidates.dump_info(V_Debug);
  524. {$endif EXTDEBUG}
  525. cand_cnt:=candidates.choose_best(operpd);
  526. { exit when no overloads are found }
  527. if cand_cnt=0 then
  528. begin
  529. CGMessage(parser_e_operator_not_overloaded);
  530. candidates.free;
  531. ppn.free;
  532. t:=cnothingnode.create;
  533. exit;
  534. end;
  535. { Multiple candidates left? }
  536. if cand_cnt>1 then
  537. begin
  538. CGMessage(type_e_cant_choose_overload_function);
  539. {$ifdef EXTDEBUG}
  540. candidates.dump_info(V_Hint);
  541. {$else EXTDEBUG}
  542. candidates.list(false);
  543. {$endif EXTDEBUG}
  544. { we'll just use the first candidate to make the
  545. call }
  546. end;
  547. candidates.free;
  548. inc(operpd.procsym.refs);
  549. { the nil as symtable signs firstcalln that this is
  550. an overloaded operator }
  551. ht:=ccallnode.create(ppn,Tprocsym(operpd.procsym),nil,nil,[]);
  552. { we already know the procdef to use, so it can
  553. skip the overload choosing in callnode.det_resulttype }
  554. tcallnode(ht).procdefinition:=operpd;
  555. if t.nodetype=unequaln then
  556. ht:=cnotnode.create(ht);
  557. t:=ht;
  558. end;
  559. {****************************************************************************
  560. Register Calculation
  561. ****************************************************************************}
  562. { marks an lvalue as "unregable" }
  563. procedure make_not_regable(p : tnode);
  564. begin
  565. case p.nodetype of
  566. typeconvn :
  567. make_not_regable(ttypeconvnode(p).left);
  568. loadn :
  569. if tloadnode(p).symtableentry.typ=varsym then
  570. tvarsym(tloadnode(p).symtableentry).varoptions:=tvarsym(tloadnode(p).symtableentry).varoptions-[vo_regable,vo_fpuregable];
  571. end;
  572. end;
  573. { calculates the needed registers for a binary operator }
  574. procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
  575. begin
  576. p.left_right_max;
  577. { Only when the difference between the left and right registers < the
  578. wanted registers allocate the amount of registers }
  579. if assigned(p.left) then
  580. begin
  581. if assigned(p.right) then
  582. begin
  583. { the location must be already filled in because we need it to }
  584. { calculate the necessary number of registers (JM) }
  585. if p.expectloc = LOC_INVALID then
  586. internalerror(200110101);
  587. if (abs(p.left.registersint-p.right.registersint)<r32) or
  588. ((p.expectloc = LOC_FPUREGISTER) and
  589. (p.right.registersfpu <= p.left.registersfpu) and
  590. ((p.right.registersfpu <> 0) or (p.left.registersfpu <> 0)) and
  591. (p.left.registersint < p.right.registersint)) then
  592. inc(p.registersint,r32);
  593. if (abs(p.left.registersfpu-p.right.registersfpu)<fpu) then
  594. inc(p.registersfpu,fpu);
  595. {$ifdef SUPPORT_MMX}
  596. if (abs(p.left.registersmmx-p.right.registersmmx)<mmx) then
  597. inc(p.registersmmx,mmx);
  598. {$endif SUPPORT_MMX}
  599. { the following is a little bit guessing but I think }
  600. { it's the only way to solve same internalerrors: }
  601. { if the left and right node both uses registers }
  602. { and return a mem location, but the current node }
  603. { doesn't use an integer register we get probably }
  604. { trouble when restoring a node }
  605. if (p.left.registersint=p.right.registersint) and
  606. (p.registersint=p.left.registersint) and
  607. (p.registersint>0) and
  608. (p.left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE]) and
  609. (p.right.expectloc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  610. inc(p.registersint);
  611. end
  612. else
  613. begin
  614. if (p.left.registersint<r32) then
  615. inc(p.registersint,r32);
  616. if (p.left.registersfpu<fpu) then
  617. inc(p.registersfpu,fpu);
  618. {$ifdef SUPPORT_MMX}
  619. if (p.left.registersmmx<mmx) then
  620. inc(p.registersmmx,mmx);
  621. {$endif SUPPORT_MMX}
  622. end;
  623. end;
  624. end;
  625. {****************************************************************************
  626. Subroutine Handling
  627. ****************************************************************************}
  628. function is_procsym_load(p:tnode):boolean;
  629. begin
  630. { ignore vecn,subscriptn }
  631. repeat
  632. case p.nodetype of
  633. vecn :
  634. p:=tvecnode(p).left;
  635. subscriptn :
  636. p:=tsubscriptnode(p).left;
  637. else
  638. break;
  639. end;
  640. until false;
  641. is_procsym_load:=((p.nodetype=loadn) and (tloadnode(p).symtableentry.typ=procsym)) or
  642. ((p.nodetype=addrn) and (taddrnode(p).left.nodetype=loadn)
  643. and (tloadnode(taddrnode(p).left).symtableentry.typ=procsym)) ;
  644. end;
  645. { local routines can't be assigned to procvars }
  646. procedure test_local_to_procvar(from_def:tprocvardef;to_def:tdef);
  647. begin
  648. if (from_def.parast.symtablelevel>normal_function_level) and
  649. (to_def.deftype=procvardef) then
  650. CGMessage(type_e_cannot_local_proc_to_procvar);
  651. end;
  652. procedure set_varstate(p:tnode;newstate:tvarstate;must_be_valid:boolean);
  653. var
  654. hsym : tvarsym;
  655. begin
  656. while assigned(p) do
  657. begin
  658. case p.nodetype of
  659. typeconvn :
  660. begin
  661. case ttypeconvnode(p).convtype of
  662. tc_cchar_2_pchar,
  663. tc_cstring_2_pchar,
  664. tc_array_2_pointer :
  665. must_be_valid:=false;
  666. tc_pchar_2_string,
  667. tc_pointer_2_array :
  668. must_be_valid:=true;
  669. end;
  670. p:=tunarynode(p).left;
  671. end;
  672. subscriptn :
  673. p:=tunarynode(p).left;
  674. vecn:
  675. begin
  676. set_varstate(tbinarynode(p).right,vs_used,true);
  677. if not(tunarynode(p).left.resulttype.def.deftype in [stringdef,arraydef]) then
  678. must_be_valid:=true;
  679. p:=tunarynode(p).left;
  680. end;
  681. { do not parse calln }
  682. calln :
  683. break;
  684. loadn :
  685. begin
  686. if (tloadnode(p).symtableentry.typ=varsym) then
  687. begin
  688. hsym:=tvarsym(tloadnode(p).symtableentry);
  689. if must_be_valid and (hsym.varstate=vs_declared) then
  690. begin
  691. { Give warning/note for uninitialized locals }
  692. if assigned(hsym.owner) and
  693. not(vo_is_external in hsym.varoptions) and
  694. (hsym.owner.symtabletype in [localsymtable,staticsymtable]) and
  695. (hsym.owner=current_procinfo.procdef.localst) then
  696. begin
  697. if (vo_is_funcret in hsym.varoptions) then
  698. CGMessage(sym_w_function_result_not_set)
  699. else
  700. if tloadnode(p).symtable.symtabletype=localsymtable then
  701. CGMessage1(sym_n_uninitialized_local_variable,hsym.realname)
  702. else
  703. CGMessage1(sym_n_uninitialized_variable,hsym.realname);
  704. end;
  705. end;
  706. { don't override vs_used with vs_assigned }
  707. if hsym.varstate<>vs_used then
  708. hsym.varstate:=newstate;
  709. end;
  710. break;
  711. end;
  712. callparan :
  713. internalerror(200310081);
  714. else
  715. break;
  716. end;{case }
  717. end;
  718. end;
  719. procedure set_unique(p : tnode);
  720. begin
  721. while assigned(p) do
  722. begin
  723. case p.nodetype of
  724. vecn:
  725. begin
  726. include(p.flags,nf_callunique);
  727. break;
  728. end;
  729. typeconvn,
  730. subscriptn,
  731. derefn:
  732. p:=tunarynode(p).left;
  733. else
  734. break;
  735. end;
  736. end;
  737. end;
  738. function valid_for_assign(p:tnode;opts:TValidAssigns):boolean;
  739. var
  740. hp : tnode;
  741. gotwith,
  742. gotsubscript,
  743. gotpointer,
  744. gotvec,
  745. gotclass,
  746. gotderef : boolean;
  747. fromdef,
  748. todef : tdef;
  749. begin
  750. valid_for_assign:=false;
  751. gotsubscript:=false;
  752. gotvec:=false;
  753. gotderef:=false;
  754. gotclass:=false;
  755. gotpointer:=false;
  756. gotwith:=false;
  757. hp:=p;
  758. if not(valid_void in opts) and
  759. is_void(hp.resulttype.def) then
  760. begin
  761. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  762. exit;
  763. end;
  764. while assigned(hp) do
  765. begin
  766. { property allowed? calln has a property check itself }
  767. if (nf_isproperty in hp.flags) then
  768. begin
  769. if (valid_property in opts) then
  770. valid_for_assign:=true
  771. else
  772. begin
  773. { check return type }
  774. case hp.resulttype.def.deftype of
  775. pointerdef :
  776. gotpointer:=true;
  777. objectdef :
  778. gotclass:=is_class_or_interface(hp.resulttype.def);
  779. recorddef, { handle record like class it needs a subscription }
  780. classrefdef :
  781. gotclass:=true;
  782. end;
  783. { 1. if it returns a pointer and we've found a deref,
  784. 2. if it returns a class or record and a subscription or with is found }
  785. if (gotpointer and gotderef) or
  786. (gotclass and (gotsubscript or gotwith)) then
  787. valid_for_assign:=true
  788. else
  789. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  790. end;
  791. exit;
  792. end;
  793. if (Valid_Const in opts) and is_constnode(hp) then
  794. begin
  795. valid_for_assign:=true;
  796. exit;
  797. end;
  798. case hp.nodetype of
  799. temprefn :
  800. begin
  801. valid_for_assign := true;
  802. exit;
  803. end;
  804. derefn :
  805. begin
  806. gotderef:=true;
  807. hp:=tderefnode(hp).left;
  808. end;
  809. typeconvn :
  810. begin
  811. { typecast sizes must match, exceptions:
  812. - implicit typecast made by absolute
  813. - from formaldef
  814. - from void
  815. - from/to open array
  816. - typecast from pointer to array }
  817. fromdef:=ttypeconvnode(hp).left.resulttype.def;
  818. todef:=hp.resulttype.def;
  819. if not((nf_absolute in ttypeconvnode(hp).flags) or
  820. (fromdef.deftype=formaldef) or
  821. is_void(fromdef) or
  822. is_open_array(fromdef) or
  823. is_open_array(todef) or
  824. ((fromdef.deftype=pointerdef) and (todef.deftype=arraydef)) or
  825. ((fromdef.deftype = objectdef) and (todef.deftype = objectdef) and
  826. (tobjectdef(fromdef).is_related(tobjectdef(todef))))) and
  827. (fromdef.size<>todef.size) then
  828. begin
  829. { in TP it is allowed to typecast to smaller types }
  830. if not(m_tp7 in aktmodeswitches) or
  831. (todef.size>fromdef.size) then
  832. CGMessagePos2(hp.fileinfo,type_e_typecast_wrong_size_for_assignment,tostr(fromdef.size),tostr(todef.size));
  833. end;
  834. { don't allow assignments to typeconvs that need special code }
  835. if not(gotsubscript or gotvec or gotderef) and
  836. not(ttypeconvnode(hp).assign_allowed) then
  837. begin
  838. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  839. exit;
  840. end;
  841. case hp.resulttype.def.deftype of
  842. pointerdef :
  843. gotpointer:=true;
  844. objectdef :
  845. gotclass:=is_class_or_interface(hp.resulttype.def);
  846. classrefdef :
  847. gotclass:=true;
  848. arraydef :
  849. begin
  850. { pointer -> array conversion is done then we need to see it
  851. as a deref, because a ^ is then not required anymore }
  852. if (ttypeconvnode(hp).left.resulttype.def.deftype=pointerdef) then
  853. gotderef:=true;
  854. end;
  855. end;
  856. hp:=ttypeconvnode(hp).left;
  857. end;
  858. vecn :
  859. begin
  860. gotvec:=true;
  861. hp:=tunarynode(hp).left;
  862. end;
  863. asn :
  864. begin
  865. { asn can't be assigned directly, it returns the value in a register instead
  866. of reference. }
  867. if not(gotsubscript or gotderef or gotvec) then
  868. begin
  869. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  870. exit;
  871. end;
  872. hp:=tunarynode(hp).left;
  873. end;
  874. subscriptn :
  875. begin
  876. gotsubscript:=true;
  877. { loop counter? }
  878. if not(Valid_Const in opts) and
  879. (vo_is_loop_counter in tsubscriptnode(hp).vs.varoptions) then
  880. CGMessage1(parser_e_illegal_assignment_to_count_var,tsubscriptnode(hp).vs.realname);
  881. { a class/interface access is an implicit }
  882. { dereferencing }
  883. hp:=tsubscriptnode(hp).left;
  884. if is_class_or_interface(hp.resulttype.def) then
  885. gotderef:=true;
  886. end;
  887. subn,
  888. addn :
  889. begin
  890. { Allow add/sub operators on a pointer, or an integer
  891. and a pointer typecast and deref has been found }
  892. if ((hp.resulttype.def.deftype=pointerdef) or
  893. (is_integer(hp.resulttype.def) and gotpointer)) and
  894. gotderef then
  895. valid_for_assign:=true
  896. else
  897. CGMessagePos(hp.fileinfo,type_e_variable_id_expected);
  898. exit;
  899. end;
  900. addrn :
  901. begin
  902. if gotderef or
  903. (nf_procvarload in hp.flags) then
  904. valid_for_assign:=true
  905. else
  906. CGMessagePos(hp.fileinfo,type_e_no_assign_to_addr);
  907. exit;
  908. end;
  909. calln :
  910. begin
  911. { check return type }
  912. case hp.resulttype.def.deftype of
  913. arraydef :
  914. begin
  915. { dynamic arrays are allowed when there is also a
  916. vec node }
  917. if is_dynamic_array(hp.resulttype.def) and
  918. gotvec then
  919. begin
  920. gotderef:=true;
  921. gotpointer:=true;
  922. end;
  923. end;
  924. pointerdef :
  925. gotpointer:=true;
  926. objectdef :
  927. gotclass:=is_class_or_interface(hp.resulttype.def);
  928. recorddef, { handle record like class it needs a subscription }
  929. classrefdef :
  930. gotclass:=true;
  931. end;
  932. { 1. if it returns a pointer and we've found a deref,
  933. 2. if it returns a class or record and a subscription or with is found }
  934. if (gotpointer and gotderef) or
  935. (gotclass and (gotsubscript or gotwith)) then
  936. valid_for_assign:=true
  937. else
  938. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  939. exit;
  940. end;
  941. loadn :
  942. begin
  943. case tloadnode(hp).symtableentry.typ of
  944. absolutesym,
  945. varsym :
  946. begin
  947. { loop counter? }
  948. if not(Valid_Const in opts) and
  949. (vo_is_loop_counter in tvarsym(tloadnode(hp).symtableentry).varoptions) then
  950. CGMessage1(parser_e_illegal_assignment_to_count_var,tloadnode(hp).symtableentry.realname);
  951. { derefed pointer }
  952. if (tvarsym(tloadnode(hp).symtableentry).varspez=vs_const) then
  953. begin
  954. { allow p^:= constructions with p is const parameter }
  955. if gotderef or (Valid_Const in opts) then
  956. valid_for_assign:=true
  957. else
  958. CGMessagePos(tloadnode(hp).fileinfo,type_e_no_assign_to_const);
  959. exit;
  960. end;
  961. { Are we at a with symtable, then we need to process the
  962. withrefnode also to check for maybe a const load }
  963. if (tloadnode(hp).symtable.symtabletype=withsymtable) then
  964. begin
  965. { continue with processing the withref node }
  966. hp:=tnode(twithsymtable(tloadnode(hp).symtable).withrefnode);
  967. gotwith:=true;
  968. end
  969. else
  970. begin
  971. valid_for_assign:=true;
  972. exit;
  973. end;
  974. end;
  975. typedconstsym :
  976. begin
  977. if ttypedconstsym(tloadnode(hp).symtableentry).is_writable then
  978. valid_for_assign:=true
  979. else
  980. CGMessagePos(hp.fileinfo,type_e_no_assign_to_const);
  981. exit;
  982. end;
  983. else
  984. begin
  985. CGMessagePos(hp.fileinfo,type_e_variable_id_expected);
  986. exit;
  987. end;
  988. end;
  989. end;
  990. else
  991. begin
  992. CGMessagePos(hp.fileinfo,type_e_variable_id_expected);
  993. exit;
  994. end;
  995. end;
  996. end;
  997. end;
  998. function valid_for_var(p:tnode):boolean;
  999. begin
  1000. valid_for_var:=valid_for_assign(p,[]);
  1001. end;
  1002. function valid_for_formal_var(p : tnode) : boolean;
  1003. begin
  1004. valid_for_formal_var:=valid_for_assign(p,[valid_void]);
  1005. end;
  1006. function valid_for_formal_const(p : tnode) : boolean;
  1007. begin
  1008. valid_for_formal_const:=is_procsym_load(p) or (p.resulttype.def.deftype=formaldef) or
  1009. valid_for_assign(p,[valid_void,valid_const,valid_property]);
  1010. end;
  1011. function valid_for_assignment(p:tnode):boolean;
  1012. begin
  1013. valid_for_assignment:=valid_for_assign(p,[valid_property]);
  1014. end;
  1015. procedure var_para_allowed(var eq:tequaltype;def_from,def_to:Tdef);
  1016. begin
  1017. { Note: eq must be already valid, it will only be updated! }
  1018. case def_to.deftype of
  1019. formaldef :
  1020. begin
  1021. { all types can be passed to a formaldef }
  1022. eq:=te_equal;
  1023. end;
  1024. orddef :
  1025. begin
  1026. { allows conversion from word to integer and
  1027. byte to shortint, but only for TP7 compatibility }
  1028. if (m_tp7 in aktmodeswitches) and
  1029. (def_from.deftype=orddef) and
  1030. (def_from.size=def_to.size) then
  1031. eq:=te_convert_l1;
  1032. end;
  1033. arraydef :
  1034. begin
  1035. if is_open_array(def_to) and
  1036. is_dynamic_array(def_from) and
  1037. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  1038. eq:=te_convert_l2;
  1039. end;
  1040. pointerdef :
  1041. begin
  1042. { an implicit pointer conversion is allowed }
  1043. if (def_from.deftype=pointerdef) then
  1044. eq:=te_convert_l1;
  1045. end;
  1046. stringdef :
  1047. begin
  1048. { all shortstrings are allowed, size is not important }
  1049. if is_shortstring(def_from) and
  1050. is_shortstring(def_to) then
  1051. eq:=te_equal;
  1052. end;
  1053. objectdef :
  1054. begin
  1055. { child objects can be also passed }
  1056. { in non-delphi mode, otherwise }
  1057. { they must match exactly, except }
  1058. { if they are objects }
  1059. if (def_from.deftype=objectdef) and
  1060. (
  1061. not(m_delphi in aktmodeswitches) or
  1062. (
  1063. (tobjectdef(def_from).objecttype=odt_object) and
  1064. (tobjectdef(def_to).objecttype=odt_object)
  1065. )
  1066. ) and
  1067. (tobjectdef(def_from).is_related(tobjectdef(def_to))) then
  1068. eq:=te_convert_l1;
  1069. end;
  1070. filedef :
  1071. begin
  1072. { an implicit file conversion is also allowed }
  1073. { from a typed file to an untyped one }
  1074. if (def_from.deftype=filedef) and
  1075. (tfiledef(def_from).filetyp = ft_typed) and
  1076. (tfiledef(def_to).filetyp = ft_untyped) then
  1077. eq:=te_convert_l1;
  1078. end;
  1079. end;
  1080. end;
  1081. procedure para_allowed(var eq:tequaltype;p:tcallparanode;def_to:tdef);
  1082. begin
  1083. { Note: eq must be already valid, it will only be updated! }
  1084. case def_to.deftype of
  1085. formaldef :
  1086. begin
  1087. { all types can be passed to a formaldef }
  1088. eq:=te_equal;
  1089. end;
  1090. stringdef :
  1091. begin
  1092. { to support ansi/long/wide strings in a proper way }
  1093. { string and string[10] are assumed as equal }
  1094. { when searching the correct overloaded procedure }
  1095. if (p.resulttype.def.deftype=stringdef) and
  1096. (tstringdef(def_to).string_typ=tstringdef(p.resulttype.def).string_typ) then
  1097. eq:=te_equal
  1098. else
  1099. { Passing a constant char to ansistring or shortstring or
  1100. a widechar to widestring then handle it as equal. }
  1101. if (p.left.nodetype=ordconstn) and
  1102. (
  1103. is_char(p.resulttype.def) and
  1104. (is_shortstring(def_to) or is_ansistring(def_to))
  1105. ) or
  1106. (
  1107. is_widechar(p.resulttype.def) and
  1108. is_widestring(def_to)
  1109. ) then
  1110. eq:=te_equal
  1111. end;
  1112. setdef :
  1113. begin
  1114. { set can also be a not yet converted array constructor }
  1115. if (p.resulttype.def.deftype=arraydef) and
  1116. (tarraydef(p.resulttype.def).IsConstructor) and
  1117. not(tarraydef(p.resulttype.def).IsVariant) then
  1118. eq:=te_equal;
  1119. end;
  1120. procvardef :
  1121. begin
  1122. { in tp7 mode proc -> procvar is allowed }
  1123. if (m_tp_procvar in aktmodeswitches) and
  1124. (p.left.nodetype=calln) and
  1125. (proc_to_procvar_equal(tprocdef(tcallnode(p.left).procdefinition),tprocvardef(def_to),true)>=te_equal) then
  1126. eq:=te_equal;
  1127. end;
  1128. end;
  1129. end;
  1130. {****************************************************************************
  1131. TCallCandidates
  1132. ****************************************************************************}
  1133. constructor tcallcandidates.create(sym:tprocsym;st:tsymtable;ppn:tnode;isprop:boolean);
  1134. var
  1135. j : integer;
  1136. pd : tprocdef;
  1137. hp : pcandidate;
  1138. found,
  1139. has_overload_directive : boolean;
  1140. topclassh : tobjectdef;
  1141. srsymtable : tsymtable;
  1142. srprocsym : tprocsym;
  1143. pt : tcallparanode;
  1144. begin
  1145. FProcSym:=sym;
  1146. FProcs:=nil;
  1147. FProccnt:=0;
  1148. FProcvisiblecnt:=0;
  1149. FParanode:=ppn;
  1150. FAllowVariant:=true;
  1151. { determine length of parameter list }
  1152. pt:=tcallparanode(ppn);
  1153. FParalength:=0;
  1154. while assigned(pt) do
  1155. begin
  1156. inc(FParalength);
  1157. pt:=tcallparanode(pt.right);
  1158. end;
  1159. { when the definition has overload directive set, we search for
  1160. overloaded definitions in the class, this only needs to be done once
  1161. for class entries as the tree keeps always the same }
  1162. if (not sym.overloadchecked) and
  1163. (sym.owner.symtabletype=objectsymtable) and
  1164. (po_overload in sym.first_procdef.procoptions) then
  1165. search_class_overloads(sym);
  1166. { when the class passed is defined in this unit we
  1167. need to use the scope of that class. This is a trick
  1168. that can be used to access protected members in other
  1169. units. At least kylix supports it this way (PFV) }
  1170. if assigned(st) and
  1171. (st.symtabletype=objectsymtable) and
  1172. (st.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  1173. (st.defowner.owner.unitid=0) then
  1174. topclassh:=tobjectdef(st.defowner)
  1175. else
  1176. begin
  1177. if assigned(current_procinfo) then
  1178. topclassh:=current_procinfo.procdef._class
  1179. else
  1180. topclassh:=nil;
  1181. end;
  1182. { link all procedures which have the same # of parameters }
  1183. for j:=1 to sym.procdef_count do
  1184. begin
  1185. pd:=sym.procdef[j];
  1186. { Is the procdef visible? This needs to be checked on
  1187. procdef level since a symbol can contain both private and
  1188. public declarations. But the check should not be done
  1189. when the callnode is generated by a property }
  1190. if isprop or
  1191. (pd.owner.symtabletype<>objectsymtable) or
  1192. pd.is_visible_for_object(topclassh) then
  1193. begin
  1194. { we have at least one procedure that is visible }
  1195. inc(FProcvisiblecnt);
  1196. { only when the # of parameter are supported by the
  1197. procedure }
  1198. if (FParalength>=pd.minparacount) and
  1199. ((po_varargs in pd.procoptions) or { varargs }
  1200. (FParalength<=pd.maxparacount)) then
  1201. proc_add(pd);
  1202. end;
  1203. end;
  1204. { remember if the procedure is declared with the overload directive,
  1205. it's information is still needed also after all procs are removed }
  1206. has_overload_directive:=(po_overload in sym.first_procdef.procoptions);
  1207. { when the definition has overload directive set, we search for
  1208. overloaded definitions in the symtablestack. The found
  1209. entries are only added to the procs list and not the procsym, because
  1210. the list can change in every situation }
  1211. if has_overload_directive and
  1212. (sym.owner.symtabletype<>objectsymtable) then
  1213. begin
  1214. srsymtable:=sym.owner.next;
  1215. while assigned(srsymtable) do
  1216. begin
  1217. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  1218. begin
  1219. srprocsym:=tprocsym(srsymtable.speedsearch(sym.name,sym.speedvalue));
  1220. { process only visible procsyms }
  1221. if assigned(srprocsym) and
  1222. (srprocsym.typ=procsym) and
  1223. srprocsym.is_visible_for_object(topclassh) then
  1224. begin
  1225. { if this procedure doesn't have overload we can stop
  1226. searching }
  1227. if not(po_overload in srprocsym.first_procdef.procoptions) then
  1228. break;
  1229. { process all overloaded definitions }
  1230. for j:=1 to srprocsym.procdef_count do
  1231. begin
  1232. pd:=srprocsym.procdef[j];
  1233. { only when the # of parameter are supported by the
  1234. procedure }
  1235. if (FParalength>=pd.minparacount) and
  1236. ((po_varargs in pd.procoptions) or { varargs }
  1237. (FParalength<=pd.maxparacount)) then
  1238. begin
  1239. found:=false;
  1240. hp:=FProcs;
  1241. while assigned(hp) do
  1242. begin
  1243. { Only compare visible parameters for the user }
  1244. if compare_paras(hp^.data.para,pd.para,cp_value_equal_const,[cpo_ignorehidden])>=te_equal then
  1245. begin
  1246. found:=true;
  1247. break;
  1248. end;
  1249. hp:=hp^.next;
  1250. end;
  1251. if not found then
  1252. proc_add(pd);
  1253. end;
  1254. end;
  1255. end;
  1256. end;
  1257. srsymtable:=srsymtable.next;
  1258. end;
  1259. end;
  1260. end;
  1261. constructor tcallcandidates.create_operator(op:ttoken;ppn:tnode);
  1262. var
  1263. j : integer;
  1264. pd : tprocdef;
  1265. hp : pcandidate;
  1266. found : boolean;
  1267. srsymtable : tsymtable;
  1268. srprocsym : tprocsym;
  1269. pt : tcallparanode;
  1270. sv : cardinal;
  1271. begin
  1272. FProcSym:=nil;
  1273. FProcs:=nil;
  1274. FProccnt:=0;
  1275. FProcvisiblecnt:=0;
  1276. FParanode:=ppn;
  1277. FAllowVariant:=false;
  1278. { determine length of parameter list }
  1279. pt:=tcallparanode(ppn);
  1280. FParalength:=0;
  1281. while assigned(pt) do
  1282. begin
  1283. if pt.resulttype.def.deftype=variantdef then
  1284. FAllowVariant:=true;
  1285. inc(FParalength);
  1286. pt:=tcallparanode(pt.right);
  1287. end;
  1288. { we search all overloaded operator definitions in the symtablestack. The found
  1289. entries are only added to the procs list and not the procsym, because
  1290. the list can change in every situation }
  1291. sv:=getspeedvalue(overloaded_names[op]);
  1292. srsymtable:=symtablestack;
  1293. while assigned(srsymtable) do
  1294. begin
  1295. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  1296. begin
  1297. srprocsym:=tprocsym(srsymtable.speedsearch(overloaded_names[op],sv));
  1298. if assigned(srprocsym) and
  1299. (srprocsym.typ=procsym) then
  1300. begin
  1301. { Store first procsym found }
  1302. if not assigned(FProcsym) then
  1303. FProcsym:=srprocsym;
  1304. { process all overloaded definitions }
  1305. for j:=1 to srprocsym.procdef_count do
  1306. begin
  1307. pd:=srprocsym.procdef[j];
  1308. { only when the # of parameter are supported by the
  1309. procedure }
  1310. if (FParalength>=pd.minparacount) and
  1311. (FParalength<=pd.maxparacount) then
  1312. begin
  1313. found:=false;
  1314. hp:=FProcs;
  1315. while assigned(hp) do
  1316. begin
  1317. { Only compare visible parameters for the user }
  1318. if compare_paras(hp^.data.para,pd.para,cp_value_equal_const,[cpo_ignorehidden])>=te_equal then
  1319. begin
  1320. found:=true;
  1321. break;
  1322. end;
  1323. hp:=hp^.next;
  1324. end;
  1325. if not found then
  1326. proc_add(pd);
  1327. end;
  1328. end;
  1329. end;
  1330. end;
  1331. srsymtable:=srsymtable.next;
  1332. end;
  1333. end;
  1334. destructor tcallcandidates.destroy;
  1335. var
  1336. hpnext,
  1337. hp : pcandidate;
  1338. begin
  1339. hp:=FProcs;
  1340. while assigned(hp) do
  1341. begin
  1342. hpnext:=hp^.next;
  1343. dispose(hp);
  1344. hp:=hpnext;
  1345. end;
  1346. end;
  1347. function tcallcandidates.proc_add(pd:tprocdef):pcandidate;
  1348. var
  1349. i : integer;
  1350. begin
  1351. { generate new candidate entry }
  1352. new(result);
  1353. fillchar(result^,sizeof(tcandidate),0);
  1354. result^.data:=pd;
  1355. result^.next:=FProcs;
  1356. FProcs:=result;
  1357. inc(FProccnt);
  1358. { Find last parameter, skip all default parameters
  1359. that are not passed. Ignore this skipping for varargs }
  1360. result^.firstpara:=tparaitem(pd.Para.last);
  1361. if not(po_varargs in pd.procoptions) then
  1362. begin
  1363. { ignore hidden parameters }
  1364. while assigned(result^.firstpara) and (result^.firstpara.is_hidden) do
  1365. result^.firstpara:=tparaitem(result^.firstpara.previous);
  1366. for i:=1 to pd.maxparacount-FParalength do
  1367. begin
  1368. if not assigned(result^.firstpara) then
  1369. internalerror(200401141);
  1370. result^.firstpara:=tparaitem(result^.firstPara.previous);
  1371. end;
  1372. end;
  1373. end;
  1374. procedure tcallcandidates.list(all:boolean);
  1375. var
  1376. hp : pcandidate;
  1377. begin
  1378. hp:=FProcs;
  1379. while assigned(hp) do
  1380. begin
  1381. if all or
  1382. (not hp^.invalid) then
  1383. MessagePos1(hp^.data.fileinfo,sym_h_param_list,hp^.data.fullprocname(false));
  1384. hp:=hp^.next;
  1385. end;
  1386. end;
  1387. {$ifdef EXTDEBUG}
  1388. procedure tcallcandidates.dump_info(lvl:longint);
  1389. function ParaTreeStr(p:tcallparanode):string;
  1390. begin
  1391. result:='';
  1392. while assigned(p) do
  1393. begin
  1394. if result<>'' then
  1395. result:=result+',';
  1396. result:=result+p.resulttype.def.typename;
  1397. p:=tcallparanode(p.right);
  1398. end;
  1399. end;
  1400. var
  1401. hp : pcandidate;
  1402. currpara : tparaitem;
  1403. begin
  1404. if not CheckVerbosity(lvl) then
  1405. exit;
  1406. Comment(lvl+V_LineInfo,'Overloaded callnode: '+FProcSym.name+'('+ParaTreeStr(tcallparanode(FParaNode))+')');
  1407. hp:=FProcs;
  1408. while assigned(hp) do
  1409. begin
  1410. Comment(lvl,' '+hp^.data.fullprocname(false));
  1411. if (hp^.invalid) then
  1412. Comment(lvl,' invalid')
  1413. else
  1414. begin
  1415. Comment(lvl,' ex: '+tostr(hp^.exact_count)+
  1416. ' eq: '+tostr(hp^.equal_count)+
  1417. ' l1: '+tostr(hp^.cl1_count)+
  1418. ' l2: '+tostr(hp^.cl2_count)+
  1419. ' l3: '+tostr(hp^.cl3_count)+
  1420. ' oper: '+tostr(hp^.coper_count)+
  1421. ' ord: '+realtostr(hp^.exact_count));
  1422. { Print parameters in left-right order }
  1423. currpara:=hp^.firstpara;
  1424. if assigned(currpara) then
  1425. begin
  1426. while assigned(currpara.next) do
  1427. currpara:=tparaitem(currpara.next);
  1428. end;
  1429. while assigned(currpara) do
  1430. begin
  1431. if (not currpara.is_hidden) then
  1432. Comment(lvl,' - '+currpara.paratype.def.typename+' : '+EqualTypeName[currpara.eqval]);
  1433. currpara:=tparaitem(currpara.previous);
  1434. end;
  1435. end;
  1436. hp:=hp^.next;
  1437. end;
  1438. end;
  1439. {$endif EXTDEBUG}
  1440. procedure tcallcandidates.get_information;
  1441. var
  1442. hp : pcandidate;
  1443. currpara : tparaitem;
  1444. currparanr : byte;
  1445. def_from,
  1446. def_to : tdef;
  1447. currpt,
  1448. pt : tcallparanode;
  1449. eq : tequaltype;
  1450. convtype : tconverttype;
  1451. pdoper : tprocdef;
  1452. releasecurrpt : boolean;
  1453. cdoptions : tcompare_defs_options;
  1454. begin
  1455. cdoptions:=[cdo_check_operator];
  1456. if FAllowVariant then
  1457. include(cdoptions,cdo_allow_variant);
  1458. { process all procs }
  1459. hp:=FProcs;
  1460. while assigned(hp) do
  1461. begin
  1462. { We compare parameters in reverse order (right to left),
  1463. the firstpara is already pointing to the last parameter
  1464. were we need to start comparing }
  1465. currparanr:=FParalength;
  1466. currpara:=hp^.firstpara;
  1467. while assigned(currpara) and (currpara.is_hidden) do
  1468. currpara:=tparaitem(currpara.previous);
  1469. pt:=tcallparanode(FParaNode);
  1470. while assigned(pt) and assigned(currpara) do
  1471. begin
  1472. { currpt can be changed from loadn to calln when a procvar
  1473. is passed. This is to prevent that the change is permanent }
  1474. currpt:=pt;
  1475. releasecurrpt:=false;
  1476. { retrieve current parameter definitions to compares }
  1477. eq:=te_incompatible;
  1478. def_from:=currpt.resulttype.def;
  1479. def_to:=currpara.paratype.def;
  1480. if not(assigned(def_from)) then
  1481. internalerror(200212091);
  1482. if not(
  1483. assigned(def_to) or
  1484. ((po_varargs in hp^.data.procoptions) and
  1485. (currparanr>hp^.data.minparacount))
  1486. ) then
  1487. internalerror(200212092);
  1488. { Convert tp procvars when not expecting a procvar }
  1489. if (def_to.deftype<>procvardef) and
  1490. (currpt.left.resulttype.def.deftype=procvardef) then
  1491. begin
  1492. releasecurrpt:=true;
  1493. currpt:=tcallparanode(pt.getcopy);
  1494. if maybe_call_procvar(currpt.left,true) then
  1495. begin
  1496. currpt.resulttype:=currpt.left.resulttype;
  1497. def_from:=currpt.left.resulttype.def;
  1498. end;
  1499. end;
  1500. { varargs are always equal, but not exact }
  1501. if (po_varargs in hp^.data.procoptions) and
  1502. (currparanr>hp^.data.minparacount) then
  1503. begin
  1504. eq:=te_equal;
  1505. end
  1506. else
  1507. { same definition -> exact }
  1508. if (def_from=def_to) then
  1509. begin
  1510. eq:=te_exact;
  1511. end
  1512. else
  1513. { for value and const parameters check if a integer is constant or
  1514. included in other integer -> equal and calc ordinal_distance }
  1515. if not(currpara.paratyp in [vs_var,vs_out]) and
  1516. is_integer(def_from) and
  1517. is_integer(def_to) and
  1518. is_in_limit(def_from,def_to) then
  1519. begin
  1520. eq:=te_equal;
  1521. hp^.ordinal_distance:=hp^.ordinal_distance+
  1522. abs(bestreal(torddef(def_from).low)-bestreal(torddef(def_to).low));
  1523. hp^.ordinal_distance:=hp^.ordinal_distance+
  1524. abs(bestreal(torddef(def_to).high)-bestreal(torddef(def_from).high));
  1525. { Give wrong sign a small penalty, this is need to get a diffrence
  1526. from word->[longword,longint] }
  1527. if is_signed(def_from)<>is_signed(def_to) then
  1528. hp^.ordinal_distance:=hp^.ordinal_distance+1.0;
  1529. end
  1530. else
  1531. { generic type comparision }
  1532. begin
  1533. eq:=compare_defs_ext(def_from,def_to,currpt.left.nodetype,convtype,pdoper,cdoptions);
  1534. { when the types are not equal we need to check
  1535. some special case for parameter passing }
  1536. if (eq<te_equal) then
  1537. begin
  1538. if currpara.paratyp in [vs_var,vs_out] then
  1539. begin
  1540. { para requires an equal type so the previous found
  1541. match was not good enough, reset to incompatible }
  1542. eq:=te_incompatible;
  1543. { var_para_allowed will return te_equal and te_convert_l1 to
  1544. make a difference for best matching }
  1545. var_para_allowed(eq,currpt.resulttype.def,currpara.paratype.def)
  1546. end
  1547. else
  1548. para_allowed(eq,currpt,def_to);
  1549. end;
  1550. end;
  1551. { when a procvar was changed to a call an exact much is
  1552. downgraded to equal. This way an overload call with the
  1553. procvar is choosen. See tb0471 (PFV) }
  1554. if (pt<>currpt) and (eq=te_exact) then
  1555. eq:=te_equal;
  1556. { increase correct counter }
  1557. case eq of
  1558. te_exact :
  1559. inc(hp^.exact_count);
  1560. te_equal :
  1561. inc(hp^.equal_count);
  1562. te_convert_l1 :
  1563. inc(hp^.cl1_count);
  1564. te_convert_l2 :
  1565. inc(hp^.cl2_count);
  1566. te_convert_l3 :
  1567. inc(hp^.cl3_count);
  1568. te_convert_operator :
  1569. inc(hp^.coper_count);
  1570. te_incompatible :
  1571. hp^.invalid:=true;
  1572. else
  1573. internalerror(200212072);
  1574. end;
  1575. { stop checking when an incompatible parameter is found }
  1576. if hp^.invalid then
  1577. begin
  1578. { store the current parameter info for
  1579. a nice error message when no procedure is found }
  1580. hp^.wrongpara:=currpara;
  1581. hp^.wrongparanr:=currparanr;
  1582. break;
  1583. end;
  1584. {$ifdef EXTDEBUG}
  1585. { store equal in node tree for dump }
  1586. currpara.eqval:=eq;
  1587. {$endif EXTDEBUG}
  1588. { maybe release temp currpt }
  1589. if releasecurrpt then
  1590. currpt.free;
  1591. { next parameter in the call tree }
  1592. pt:=tcallparanode(pt.right);
  1593. { next parameter for definition, only goto next para
  1594. if we're out of the varargs }
  1595. if not(po_varargs in hp^.data.procoptions) or
  1596. (currparanr<=hp^.data.maxparacount) then
  1597. begin
  1598. { Ignore vs_hidden parameters }
  1599. repeat
  1600. currpara:=tparaitem(currpara.previous);
  1601. until (not assigned(currpara)) or (not currpara.is_hidden);
  1602. end;
  1603. dec(currparanr);
  1604. end;
  1605. if not(hp^.invalid) and
  1606. (assigned(pt) or assigned(currpara) or (currparanr<>0)) then
  1607. internalerror(200212141);
  1608. { next candidate }
  1609. hp:=hp^.next;
  1610. end;
  1611. end;
  1612. function is_better_candidate(currpd,bestpd:pcandidate):integer;
  1613. var
  1614. res : integer;
  1615. begin
  1616. {
  1617. Return values:
  1618. > 0 when currpd is better than bestpd
  1619. < 0 when bestpd is better than currpd
  1620. = 0 when both are equal
  1621. To choose the best candidate we use the following order:
  1622. - Incompatible flag
  1623. - (Smaller) Number of convert operator parameters.
  1624. - (Smaller) Number of convertlevel 2 parameters.
  1625. - (Smaller) Number of convertlevel 1 parameters.
  1626. - (Bigger) Number of exact parameters.
  1627. - (Smaller) Number of equal parameters.
  1628. - (Smaller) Total of ordinal distance. For example, the distance of a word
  1629. to a byte is 65535-255=65280.
  1630. }
  1631. if bestpd^.invalid then
  1632. begin
  1633. if currpd^.invalid then
  1634. res:=0
  1635. else
  1636. res:=1;
  1637. end
  1638. else
  1639. if currpd^.invalid then
  1640. res:=-1
  1641. else
  1642. begin
  1643. { less operator parameters? }
  1644. res:=(bestpd^.coper_count-currpd^.coper_count);
  1645. if (res=0) then
  1646. begin
  1647. { less cl3 parameters? }
  1648. res:=(bestpd^.cl3_count-currpd^.cl3_count);
  1649. if (res=0) then
  1650. begin
  1651. { less cl2 parameters? }
  1652. res:=(bestpd^.cl2_count-currpd^.cl2_count);
  1653. if (res=0) then
  1654. begin
  1655. { less cl1 parameters? }
  1656. res:=(bestpd^.cl1_count-currpd^.cl1_count);
  1657. if (res=0) then
  1658. begin
  1659. { more exact parameters? }
  1660. res:=(currpd^.exact_count-bestpd^.exact_count);
  1661. if (res=0) then
  1662. begin
  1663. { less equal parameters? }
  1664. res:=(bestpd^.equal_count-currpd^.equal_count);
  1665. if (res=0) then
  1666. begin
  1667. { smaller ordinal distance? }
  1668. if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
  1669. res:=1
  1670. else
  1671. if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
  1672. res:=-1
  1673. else
  1674. res:=0;
  1675. end;
  1676. end;
  1677. end;
  1678. end;
  1679. end;
  1680. end;
  1681. end;
  1682. is_better_candidate:=res;
  1683. end;
  1684. function tcallcandidates.choose_best(var bestpd:tabstractprocdef):integer;
  1685. var
  1686. besthpstart,
  1687. hp : pcandidate;
  1688. cntpd,
  1689. res : integer;
  1690. begin
  1691. {
  1692. Returns the number of candidates left and the
  1693. first candidate is returned in pdbest
  1694. }
  1695. { Setup the first procdef as best, only count it as a result
  1696. when it is valid }
  1697. bestpd:=FProcs^.data;
  1698. if FProcs^.invalid then
  1699. cntpd:=0
  1700. else
  1701. cntpd:=1;
  1702. if assigned(FProcs^.next) then
  1703. begin
  1704. besthpstart:=FProcs;
  1705. hp:=FProcs^.next;
  1706. while assigned(hp) do
  1707. begin
  1708. res:=is_better_candidate(hp,besthpstart);
  1709. if (res>0) then
  1710. begin
  1711. { hp is better, flag all procs to be incompatible }
  1712. while (besthpstart<>hp) do
  1713. begin
  1714. besthpstart^.invalid:=true;
  1715. besthpstart:=besthpstart^.next;
  1716. end;
  1717. { besthpstart is already set to hp }
  1718. bestpd:=besthpstart^.data;
  1719. cntpd:=1;
  1720. end
  1721. else
  1722. if (res<0) then
  1723. begin
  1724. { besthpstart is better, flag current hp to be incompatible }
  1725. hp^.invalid:=true;
  1726. end
  1727. else
  1728. begin
  1729. { res=0, both are valid }
  1730. if not hp^.invalid then
  1731. inc(cntpd);
  1732. end;
  1733. hp:=hp^.next;
  1734. end;
  1735. end;
  1736. result:=cntpd;
  1737. end;
  1738. procedure tcallcandidates.find_wrong_para;
  1739. var
  1740. currparanr : smallint;
  1741. hp : pcandidate;
  1742. pt : tcallparanode;
  1743. begin
  1744. { Only process the first overloaded procdef }
  1745. hp:=FProcs;
  1746. { Find callparanode corresponding to the argument }
  1747. pt:=tcallparanode(FParanode);
  1748. currparanr:=FParalength;
  1749. while assigned(pt) and
  1750. (currparanr>hp^.wrongparanr) do
  1751. begin
  1752. pt:=tcallparanode(pt.right);
  1753. dec(currparanr);
  1754. end;
  1755. if (currparanr<>hp^.wrongparanr) or
  1756. not assigned(pt) then
  1757. internalerror(200212094);
  1758. { Show error message, when it was a var or out parameter
  1759. guess that it is a missing typeconv }
  1760. if hp^.wrongpara.paratyp in [vs_var,vs_out] then
  1761. begin
  1762. { Maybe passing the correct type but passing a const to var parameter }
  1763. if (compare_defs(pt.resulttype.def,hp^.wrongpara.paratype.def,pt.nodetype)<>te_incompatible) and
  1764. not valid_for_var(pt.left) then
  1765. CGMessagePos(pt.left.fileinfo,type_e_variable_id_expected)
  1766. else
  1767. CGMessagePos2(pt.left.fileinfo,parser_e_call_by_ref_without_typeconv,
  1768. FullTypeName(pt.left.resulttype.def,hp^.wrongpara.paratype.def),
  1769. FullTypeName(hp^.wrongpara.paratype.def,pt.left.resulttype.def))
  1770. end
  1771. else
  1772. CGMessagePos3(pt.left.fileinfo,type_e_wrong_parameter_type,tostr(hp^.wrongparanr),
  1773. FullTypeName(pt.left.resulttype.def,hp^.wrongpara.paratype.def),
  1774. FullTypeName(hp^.wrongpara.paratype.def,pt.left.resulttype.def));
  1775. end;
  1776. end.
  1777. {
  1778. $Log$
  1779. Revision 1.98 2004-09-27 15:15:52 peter
  1780. * register loopvarsym for fields instead of record variable
  1781. * don't allow class fields as loop var
  1782. Revision 1.97 2004/09/13 20:28:27 peter
  1783. * for loop variable assignment is not allowed anymore
  1784. Revision 1.96 2004/08/22 11:24:09 peter
  1785. * fix error when passing constant to var parameter
  1786. Revision 1.95 2004/06/23 16:22:45 peter
  1787. * include unit name in error messages when types are the same
  1788. Revision 1.94 2004/06/20 08:55:29 florian
  1789. * logs truncated
  1790. Revision 1.93 2004/06/16 20:07:07 florian
  1791. * dwarf branch merged
  1792. Revision 1.92 2004/05/25 21:27:35 florian
  1793. * fixed another formal const problem caused by yesterday's changes
  1794. Revision 1.91 2004/05/24 21:24:40 florian
  1795. * properties are allowed as formal const parameters as well
  1796. Revision 1.90 2004/05/24 21:04:31 florian
  1797. * fixed more formal const problems
  1798. Revision 1.89 2004/05/24 20:39:41 florian
  1799. * stricter handling of formal const parameters and IE fixed
  1800. }