htypechk.pas 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  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. wrongparaidx,
  36. firstparaidx : integer;
  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:=tparavarsym(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:=tparavarsym(pf.parast.symindex.first).vartype.def;
  335. rd:=tparavarsym(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 in [globalvarsym,localvarsym,paravarsym] then
  570. tabstractvarsym(tloadnode(p).symtableentry).varregable:=vr_none;
  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 : tabstractvarsym;
  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 in [localvarsym,paravarsym,globalvarsym]) then
  687. begin
  688. hsym:=tabstractvarsym(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. But the variable can't
  830. be in a register }
  831. if (m_tp7 in aktmodeswitches) or
  832. (todef.size<fromdef.size) then
  833. make_not_regable(hp)
  834. else
  835. CGMessagePos2(hp.fileinfo,type_e_typecast_wrong_size_for_assignment,tostr(fromdef.size),tostr(todef.size));
  836. end;
  837. { don't allow assignments to typeconvs that need special code }
  838. if not(gotsubscript or gotvec or gotderef) and
  839. not(ttypeconvnode(hp).assign_allowed) then
  840. begin
  841. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  842. exit;
  843. end;
  844. case hp.resulttype.def.deftype of
  845. pointerdef :
  846. gotpointer:=true;
  847. objectdef :
  848. gotclass:=is_class_or_interface(hp.resulttype.def);
  849. classrefdef :
  850. gotclass:=true;
  851. arraydef :
  852. begin
  853. { pointer -> array conversion is done then we need to see it
  854. as a deref, because a ^ is then not required anymore }
  855. if (ttypeconvnode(hp).left.resulttype.def.deftype=pointerdef) then
  856. gotderef:=true;
  857. end;
  858. end;
  859. hp:=ttypeconvnode(hp).left;
  860. end;
  861. vecn :
  862. begin
  863. gotvec:=true;
  864. hp:=tunarynode(hp).left;
  865. end;
  866. asn :
  867. begin
  868. { asn can't be assigned directly, it returns the value in a register instead
  869. of reference. }
  870. if not(gotsubscript or gotderef or gotvec) then
  871. begin
  872. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  873. exit;
  874. end;
  875. hp:=tunarynode(hp).left;
  876. end;
  877. subscriptn :
  878. begin
  879. gotsubscript:=true;
  880. { loop counter? }
  881. if not(Valid_Const in opts) and
  882. (vo_is_loop_counter in tsubscriptnode(hp).vs.varoptions) then
  883. CGMessage1(parser_e_illegal_assignment_to_count_var,tsubscriptnode(hp).vs.realname);
  884. { a class/interface access is an implicit }
  885. { dereferencing }
  886. hp:=tsubscriptnode(hp).left;
  887. if is_class_or_interface(hp.resulttype.def) then
  888. gotderef:=true;
  889. end;
  890. subn,
  891. addn :
  892. begin
  893. { Allow add/sub operators on a pointer, or an integer
  894. and a pointer typecast and deref has been found }
  895. if ((hp.resulttype.def.deftype=pointerdef) or
  896. (is_integer(hp.resulttype.def) and gotpointer)) and
  897. gotderef then
  898. valid_for_assign:=true
  899. else
  900. CGMessagePos(hp.fileinfo,type_e_variable_id_expected);
  901. exit;
  902. end;
  903. addrn :
  904. begin
  905. if gotderef or
  906. (nf_procvarload in hp.flags) then
  907. valid_for_assign:=true
  908. else
  909. CGMessagePos(hp.fileinfo,type_e_no_assign_to_addr);
  910. exit;
  911. end;
  912. calln :
  913. begin
  914. { check return type }
  915. case hp.resulttype.def.deftype of
  916. arraydef :
  917. begin
  918. { dynamic arrays are allowed when there is also a
  919. vec node }
  920. if is_dynamic_array(hp.resulttype.def) and
  921. gotvec then
  922. begin
  923. gotderef:=true;
  924. gotpointer:=true;
  925. end;
  926. end;
  927. pointerdef :
  928. gotpointer:=true;
  929. objectdef :
  930. gotclass:=is_class_or_interface(hp.resulttype.def);
  931. recorddef, { handle record like class it needs a subscription }
  932. classrefdef :
  933. gotclass:=true;
  934. end;
  935. { 1. if it returns a pointer and we've found a deref,
  936. 2. if it returns a class or record and a subscription or with is found }
  937. if (gotpointer and gotderef) or
  938. (gotclass and (gotsubscript or gotwith)) then
  939. valid_for_assign:=true
  940. else
  941. CGMessagePos(hp.fileinfo,type_e_argument_cant_be_assigned);
  942. exit;
  943. end;
  944. loadn :
  945. begin
  946. case tloadnode(hp).symtableentry.typ of
  947. absolutevarsym,
  948. globalvarsym,
  949. localvarsym,
  950. paravarsym :
  951. begin
  952. { loop counter? }
  953. if not(Valid_Const in opts) and
  954. (vo_is_loop_counter in tabstractvarsym(tloadnode(hp).symtableentry).varoptions) then
  955. CGMessage1(parser_e_illegal_assignment_to_count_var,tloadnode(hp).symtableentry.realname);
  956. { derefed pointer }
  957. if (tabstractvarsym(tloadnode(hp).symtableentry).varspez=vs_const) then
  958. begin
  959. { allow p^:= constructions with p is const parameter }
  960. if gotderef or (Valid_Const in opts) then
  961. valid_for_assign:=true
  962. else
  963. CGMessagePos(tloadnode(hp).fileinfo,type_e_no_assign_to_const);
  964. exit;
  965. end;
  966. { Are we at a with symtable, then we need to process the
  967. withrefnode also to check for maybe a const load }
  968. if (tloadnode(hp).symtable.symtabletype=withsymtable) then
  969. begin
  970. { continue with processing the withref node }
  971. hp:=tnode(twithsymtable(tloadnode(hp).symtable).withrefnode);
  972. gotwith:=true;
  973. end
  974. else
  975. begin
  976. valid_for_assign:=true;
  977. exit;
  978. end;
  979. end;
  980. typedconstsym :
  981. begin
  982. if ttypedconstsym(tloadnode(hp).symtableentry).is_writable then
  983. valid_for_assign:=true
  984. else
  985. CGMessagePos(hp.fileinfo,type_e_no_assign_to_const);
  986. exit;
  987. end;
  988. else
  989. begin
  990. CGMessagePos(hp.fileinfo,type_e_variable_id_expected);
  991. exit;
  992. end;
  993. end;
  994. end;
  995. else
  996. begin
  997. CGMessagePos(hp.fileinfo,type_e_variable_id_expected);
  998. exit;
  999. end;
  1000. end;
  1001. end;
  1002. end;
  1003. function valid_for_var(p:tnode):boolean;
  1004. begin
  1005. valid_for_var:=valid_for_assign(p,[]);
  1006. end;
  1007. function valid_for_formal_var(p : tnode) : boolean;
  1008. begin
  1009. valid_for_formal_var:=valid_for_assign(p,[valid_void]);
  1010. end;
  1011. function valid_for_formal_const(p : tnode) : boolean;
  1012. begin
  1013. valid_for_formal_const:=is_procsym_load(p) or (p.resulttype.def.deftype=formaldef) or
  1014. valid_for_assign(p,[valid_void,valid_const,valid_property]);
  1015. end;
  1016. function valid_for_assignment(p:tnode):boolean;
  1017. begin
  1018. valid_for_assignment:=valid_for_assign(p,[valid_property]);
  1019. end;
  1020. procedure var_para_allowed(var eq:tequaltype;def_from,def_to:Tdef);
  1021. begin
  1022. { Note: eq must be already valid, it will only be updated! }
  1023. case def_to.deftype of
  1024. formaldef :
  1025. begin
  1026. { all types can be passed to a formaldef }
  1027. eq:=te_equal;
  1028. end;
  1029. orddef :
  1030. begin
  1031. { allows conversion from word to integer and
  1032. byte to shortint, but only for TP7 compatibility }
  1033. if (m_tp7 in aktmodeswitches) and
  1034. (def_from.deftype=orddef) and
  1035. (def_from.size=def_to.size) then
  1036. eq:=te_convert_l1;
  1037. end;
  1038. arraydef :
  1039. begin
  1040. if is_open_array(def_to) and
  1041. is_dynamic_array(def_from) and
  1042. equal_defs(tarraydef(def_from).elementtype.def,tarraydef(def_to).elementtype.def) then
  1043. eq:=te_convert_l2;
  1044. end;
  1045. pointerdef :
  1046. begin
  1047. { an implicit pointer conversion is allowed }
  1048. if (def_from.deftype=pointerdef) then
  1049. eq:=te_convert_l1;
  1050. end;
  1051. stringdef :
  1052. begin
  1053. { all shortstrings are allowed, size is not important }
  1054. if is_shortstring(def_from) and
  1055. is_shortstring(def_to) then
  1056. eq:=te_equal;
  1057. end;
  1058. objectdef :
  1059. begin
  1060. { child objects can be also passed }
  1061. { in non-delphi mode, otherwise }
  1062. { they must match exactly, except }
  1063. { if they are objects }
  1064. if (def_from.deftype=objectdef) and
  1065. (
  1066. not(m_delphi in aktmodeswitches) or
  1067. (
  1068. (tobjectdef(def_from).objecttype=odt_object) and
  1069. (tobjectdef(def_to).objecttype=odt_object)
  1070. )
  1071. ) and
  1072. (tobjectdef(def_from).is_related(tobjectdef(def_to))) then
  1073. eq:=te_convert_l1;
  1074. end;
  1075. filedef :
  1076. begin
  1077. { an implicit file conversion is also allowed }
  1078. { from a typed file to an untyped one }
  1079. if (def_from.deftype=filedef) and
  1080. (tfiledef(def_from).filetyp = ft_typed) and
  1081. (tfiledef(def_to).filetyp = ft_untyped) then
  1082. eq:=te_convert_l1;
  1083. end;
  1084. end;
  1085. end;
  1086. procedure para_allowed(var eq:tequaltype;p:tcallparanode;def_to:tdef);
  1087. begin
  1088. { Note: eq must be already valid, it will only be updated! }
  1089. case def_to.deftype of
  1090. formaldef :
  1091. begin
  1092. { all types can be passed to a formaldef }
  1093. eq:=te_equal;
  1094. end;
  1095. stringdef :
  1096. begin
  1097. { to support ansi/long/wide strings in a proper way }
  1098. { string and string[10] are assumed as equal }
  1099. { when searching the correct overloaded procedure }
  1100. if (p.resulttype.def.deftype=stringdef) and
  1101. (tstringdef(def_to).string_typ=tstringdef(p.resulttype.def).string_typ) then
  1102. eq:=te_equal
  1103. else
  1104. { Passing a constant char to ansistring or shortstring or
  1105. a widechar to widestring then handle it as equal. }
  1106. if (p.left.nodetype=ordconstn) and
  1107. (
  1108. is_char(p.resulttype.def) and
  1109. (is_shortstring(def_to) or is_ansistring(def_to))
  1110. ) or
  1111. (
  1112. is_widechar(p.resulttype.def) and
  1113. is_widestring(def_to)
  1114. ) then
  1115. eq:=te_equal
  1116. end;
  1117. setdef :
  1118. begin
  1119. { set can also be a not yet converted array constructor }
  1120. if (p.resulttype.def.deftype=arraydef) and
  1121. (tarraydef(p.resulttype.def).IsConstructor) and
  1122. not(tarraydef(p.resulttype.def).IsVariant) then
  1123. eq:=te_equal;
  1124. end;
  1125. procvardef :
  1126. begin
  1127. { in tp7 mode proc -> procvar is allowed }
  1128. if (m_tp_procvar in aktmodeswitches) and
  1129. (p.left.nodetype=calln) and
  1130. (proc_to_procvar_equal(tprocdef(tcallnode(p.left).procdefinition),tprocvardef(def_to),true)>=te_equal) then
  1131. eq:=te_equal;
  1132. end;
  1133. end;
  1134. end;
  1135. {****************************************************************************
  1136. TCallCandidates
  1137. ****************************************************************************}
  1138. constructor tcallcandidates.create(sym:tprocsym;st:tsymtable;ppn:tnode;isprop:boolean);
  1139. var
  1140. j : integer;
  1141. pd : tprocdef;
  1142. hp : pcandidate;
  1143. found,
  1144. has_overload_directive : boolean;
  1145. topclassh : tobjectdef;
  1146. srsymtable : tsymtable;
  1147. srprocsym : tprocsym;
  1148. pt : tcallparanode;
  1149. begin
  1150. if not assigned(sym) then
  1151. internalerror(200411015);
  1152. FProcSym:=sym;
  1153. FProcs:=nil;
  1154. FProccnt:=0;
  1155. FProcvisiblecnt:=0;
  1156. FParanode:=ppn;
  1157. FAllowVariant:=true;
  1158. { determine length of parameter list }
  1159. pt:=tcallparanode(ppn);
  1160. FParalength:=0;
  1161. while assigned(pt) do
  1162. begin
  1163. inc(FParalength);
  1164. pt:=tcallparanode(pt.right);
  1165. end;
  1166. { when the definition has overload directive set, we search for
  1167. overloaded definitions in the class, this only needs to be done once
  1168. for class entries as the tree keeps always the same }
  1169. if (not sym.overloadchecked) and
  1170. (sym.owner.symtabletype=objectsymtable) and
  1171. (po_overload in sym.first_procdef.procoptions) then
  1172. search_class_overloads(sym);
  1173. { when the class passed is defined in this unit we
  1174. need to use the scope of that class. This is a trick
  1175. that can be used to access protected members in other
  1176. units. At least kylix supports it this way (PFV) }
  1177. if assigned(st) and
  1178. (st.symtabletype=objectsymtable) and
  1179. (st.defowner.owner.symtabletype in [globalsymtable,staticsymtable]) and
  1180. (st.defowner.owner.unitid=0) then
  1181. topclassh:=tobjectdef(st.defowner)
  1182. else
  1183. begin
  1184. if assigned(current_procinfo) then
  1185. topclassh:=current_procinfo.procdef._class
  1186. else
  1187. topclassh:=nil;
  1188. end;
  1189. { link all procedures which have the same # of parameters }
  1190. for j:=1 to sym.procdef_count do
  1191. begin
  1192. pd:=sym.procdef[j];
  1193. { Is the procdef visible? This needs to be checked on
  1194. procdef level since a symbol can contain both private and
  1195. public declarations. But the check should not be done
  1196. when the callnode is generated by a property }
  1197. if isprop or
  1198. (pd.owner.symtabletype<>objectsymtable) or
  1199. pd.is_visible_for_object(topclassh) then
  1200. begin
  1201. { we have at least one procedure that is visible }
  1202. inc(FProcvisiblecnt);
  1203. { only when the # of parameter are supported by the
  1204. procedure }
  1205. if (FParalength>=pd.minparacount) and
  1206. ((po_varargs in pd.procoptions) or { varargs }
  1207. (FParalength<=pd.maxparacount)) then
  1208. proc_add(pd);
  1209. end;
  1210. end;
  1211. { remember if the procedure is declared with the overload directive,
  1212. it's information is still needed also after all procs are removed }
  1213. has_overload_directive:=(po_overload in sym.first_procdef.procoptions);
  1214. { when the definition has overload directive set, we search for
  1215. overloaded definitions in the symtablestack. The found
  1216. entries are only added to the procs list and not the procsym, because
  1217. the list can change in every situation }
  1218. if has_overload_directive and
  1219. (sym.owner.symtabletype<>objectsymtable) then
  1220. begin
  1221. srsymtable:=sym.owner.next;
  1222. while assigned(srsymtable) do
  1223. begin
  1224. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  1225. begin
  1226. srprocsym:=tprocsym(srsymtable.speedsearch(sym.name,sym.speedvalue));
  1227. if assigned(srprocsym) and
  1228. (srprocsym.typ=procsym) then
  1229. begin
  1230. { if this visible procedure doesn't have overload we can stop
  1231. searching }
  1232. if not(po_overload in srprocsym.first_procdef.procoptions) and
  1233. srprocsym.first_procdef.is_visible_for_object(topclassh) then
  1234. break;
  1235. { process all overloaded definitions }
  1236. for j:=1 to srprocsym.procdef_count do
  1237. begin
  1238. pd:=srprocsym.procdef[j];
  1239. { only visible procedures need to be added }
  1240. if pd.is_visible_for_object(topclassh) then
  1241. begin
  1242. { only when the # of parameter are supported by the
  1243. procedure }
  1244. if (FParalength>=pd.minparacount) and
  1245. ((po_varargs in pd.procoptions) or { varargs }
  1246. (FParalength<=pd.maxparacount)) then
  1247. begin
  1248. found:=false;
  1249. hp:=FProcs;
  1250. while assigned(hp) do
  1251. begin
  1252. { Only compare visible parameters for the user }
  1253. if compare_paras(hp^.data.paras,pd.paras,cp_value_equal_const,[cpo_ignorehidden])>=te_equal then
  1254. begin
  1255. found:=true;
  1256. break;
  1257. end;
  1258. hp:=hp^.next;
  1259. end;
  1260. if not found then
  1261. proc_add(pd);
  1262. end;
  1263. end;
  1264. end;
  1265. end;
  1266. end;
  1267. srsymtable:=srsymtable.next;
  1268. end;
  1269. end;
  1270. end;
  1271. constructor tcallcandidates.create_operator(op:ttoken;ppn:tnode);
  1272. var
  1273. j : integer;
  1274. pd : tprocdef;
  1275. hp : pcandidate;
  1276. found : boolean;
  1277. srsymtable : tsymtable;
  1278. srprocsym : tprocsym;
  1279. pt : tcallparanode;
  1280. sv : cardinal;
  1281. begin
  1282. FProcSym:=nil;
  1283. FProcs:=nil;
  1284. FProccnt:=0;
  1285. FProcvisiblecnt:=0;
  1286. FParanode:=ppn;
  1287. FAllowVariant:=false;
  1288. { determine length of parameter list }
  1289. pt:=tcallparanode(ppn);
  1290. FParalength:=0;
  1291. while assigned(pt) do
  1292. begin
  1293. if pt.resulttype.def.deftype=variantdef then
  1294. FAllowVariant:=true;
  1295. inc(FParalength);
  1296. pt:=tcallparanode(pt.right);
  1297. end;
  1298. { we search all overloaded operator definitions in the symtablestack. The found
  1299. entries are only added to the procs list and not the procsym, because
  1300. the list can change in every situation }
  1301. sv:=getspeedvalue(overloaded_names[op]);
  1302. srsymtable:=symtablestack;
  1303. while assigned(srsymtable) do
  1304. begin
  1305. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  1306. begin
  1307. srprocsym:=tprocsym(srsymtable.speedsearch(overloaded_names[op],sv));
  1308. if assigned(srprocsym) and
  1309. (srprocsym.typ=procsym) then
  1310. begin
  1311. { Store first procsym found }
  1312. if not assigned(FProcsym) then
  1313. FProcsym:=srprocsym;
  1314. { process all overloaded definitions }
  1315. for j:=1 to srprocsym.procdef_count do
  1316. begin
  1317. pd:=srprocsym.procdef[j];
  1318. { only when the # of parameter are supported by the
  1319. procedure }
  1320. if (FParalength>=pd.minparacount) and
  1321. (FParalength<=pd.maxparacount) then
  1322. begin
  1323. found:=false;
  1324. hp:=FProcs;
  1325. while assigned(hp) do
  1326. begin
  1327. { Only compare visible parameters for the user }
  1328. if compare_paras(hp^.data.paras,pd.paras,cp_value_equal_const,[cpo_ignorehidden])>=te_equal then
  1329. begin
  1330. found:=true;
  1331. break;
  1332. end;
  1333. hp:=hp^.next;
  1334. end;
  1335. if not found then
  1336. proc_add(pd);
  1337. end;
  1338. end;
  1339. end;
  1340. end;
  1341. srsymtable:=srsymtable.next;
  1342. end;
  1343. end;
  1344. destructor tcallcandidates.destroy;
  1345. var
  1346. hpnext,
  1347. hp : pcandidate;
  1348. begin
  1349. hp:=FProcs;
  1350. while assigned(hp) do
  1351. begin
  1352. hpnext:=hp^.next;
  1353. dispose(hp);
  1354. hp:=hpnext;
  1355. end;
  1356. end;
  1357. function tcallcandidates.proc_add(pd:tprocdef):pcandidate;
  1358. var
  1359. defaultparacnt : integer;
  1360. begin
  1361. { generate new candidate entry }
  1362. new(result);
  1363. fillchar(result^,sizeof(tcandidate),0);
  1364. result^.data:=pd;
  1365. result^.next:=FProcs;
  1366. FProcs:=result;
  1367. inc(FProccnt);
  1368. { Find last parameter, skip all default parameters
  1369. that are not passed. Ignore this skipping for varargs }
  1370. result^.firstparaidx:=pd.paras.count-1;
  1371. if not(po_varargs in pd.procoptions) then
  1372. begin
  1373. { ignore hidden parameters }
  1374. while (result^.firstparaidx>=0) and (vo_is_hidden_para in tparavarsym(pd.paras[result^.firstparaidx]).varoptions) do
  1375. dec(result^.firstparaidx);
  1376. defaultparacnt:=pd.maxparacount-FParalength;
  1377. if defaultparacnt>0 then
  1378. begin
  1379. if defaultparacnt>result^.firstparaidx then
  1380. internalerror(200401141);
  1381. dec(result^.firstparaidx,defaultparacnt);
  1382. end;
  1383. end;
  1384. end;
  1385. procedure tcallcandidates.list(all:boolean);
  1386. var
  1387. hp : pcandidate;
  1388. begin
  1389. hp:=FProcs;
  1390. while assigned(hp) do
  1391. begin
  1392. if all or
  1393. (not hp^.invalid) then
  1394. MessagePos1(hp^.data.fileinfo,sym_h_param_list,hp^.data.fullprocname(false));
  1395. hp:=hp^.next;
  1396. end;
  1397. end;
  1398. {$ifdef EXTDEBUG}
  1399. procedure tcallcandidates.dump_info(lvl:longint);
  1400. function ParaTreeStr(p:tcallparanode):string;
  1401. begin
  1402. result:='';
  1403. while assigned(p) do
  1404. begin
  1405. if result<>'' then
  1406. result:=result+',';
  1407. result:=result+p.resulttype.def.typename;
  1408. p:=tcallparanode(p.right);
  1409. end;
  1410. end;
  1411. var
  1412. hp : pcandidate;
  1413. i : integer;
  1414. currpara : tparavarsym;
  1415. begin
  1416. if not CheckVerbosity(lvl) then
  1417. exit;
  1418. Comment(lvl+V_LineInfo,'Overloaded callnode: '+FProcSym.name+'('+ParaTreeStr(tcallparanode(FParaNode))+')');
  1419. hp:=FProcs;
  1420. while assigned(hp) do
  1421. begin
  1422. Comment(lvl,' '+hp^.data.fullprocname(false));
  1423. if (hp^.invalid) then
  1424. Comment(lvl,' invalid')
  1425. else
  1426. begin
  1427. Comment(lvl,' ex: '+tostr(hp^.exact_count)+
  1428. ' eq: '+tostr(hp^.equal_count)+
  1429. ' l1: '+tostr(hp^.cl1_count)+
  1430. ' l2: '+tostr(hp^.cl2_count)+
  1431. ' l3: '+tostr(hp^.cl3_count)+
  1432. ' oper: '+tostr(hp^.coper_count)+
  1433. ' ord: '+realtostr(hp^.exact_count));
  1434. { Print parameters in left-right order }
  1435. for i:=0 to hp^.data.paras.count-1 do
  1436. begin
  1437. currpara:=tparavarsym(hp^.data.paras[i]);
  1438. if (vo_is_hidden_para in currpara.varoptions) then
  1439. Comment(lvl,' - '+currpara.vartype.def.typename+' : '+EqualTypeName[currpara.eqval]);
  1440. end;
  1441. end;
  1442. hp:=hp^.next;
  1443. end;
  1444. end;
  1445. {$endif EXTDEBUG}
  1446. procedure tcallcandidates.get_information;
  1447. var
  1448. hp : pcandidate;
  1449. currpara : tparavarsym;
  1450. paraidx : integer;
  1451. currparanr : byte;
  1452. def_from,
  1453. def_to : tdef;
  1454. currpt,
  1455. pt : tcallparanode;
  1456. eq : tequaltype;
  1457. convtype : tconverttype;
  1458. pdoper : tprocdef;
  1459. releasecurrpt : boolean;
  1460. cdoptions : tcompare_defs_options;
  1461. begin
  1462. cdoptions:=[cdo_check_operator];
  1463. if FAllowVariant then
  1464. include(cdoptions,cdo_allow_variant);
  1465. { process all procs }
  1466. hp:=FProcs;
  1467. while assigned(hp) do
  1468. begin
  1469. { We compare parameters in reverse order (right to left),
  1470. the firstpara is already pointing to the last parameter
  1471. were we need to start comparing }
  1472. currparanr:=FParalength;
  1473. paraidx:=hp^.firstparaidx;
  1474. while (paraidx>=0) and (vo_is_hidden_para in tparavarsym(hp^.data.paras[paraidx]).varoptions) do
  1475. dec(paraidx);
  1476. pt:=tcallparanode(FParaNode);
  1477. while assigned(pt) and (paraidx>=0) do
  1478. begin
  1479. currpara:=tparavarsym(hp^.data.paras[paraidx]);
  1480. { currpt can be changed from loadn to calln when a procvar
  1481. is passed. This is to prevent that the change is permanent }
  1482. currpt:=pt;
  1483. releasecurrpt:=false;
  1484. { retrieve current parameter definitions to compares }
  1485. eq:=te_incompatible;
  1486. def_from:=currpt.resulttype.def;
  1487. def_to:=currpara.vartype.def;
  1488. if not(assigned(def_from)) then
  1489. internalerror(200212091);
  1490. if not(
  1491. assigned(def_to) or
  1492. ((po_varargs in hp^.data.procoptions) and
  1493. (currparanr>hp^.data.minparacount))
  1494. ) then
  1495. internalerror(200212092);
  1496. { Convert tp procvars when not expecting a procvar }
  1497. if (def_to.deftype<>procvardef) and
  1498. (currpt.left.resulttype.def.deftype=procvardef) then
  1499. begin
  1500. releasecurrpt:=true;
  1501. currpt:=tcallparanode(pt.getcopy);
  1502. if maybe_call_procvar(currpt.left,true) then
  1503. begin
  1504. currpt.resulttype:=currpt.left.resulttype;
  1505. def_from:=currpt.left.resulttype.def;
  1506. end;
  1507. end;
  1508. { varargs are always equal, but not exact }
  1509. if (po_varargs in hp^.data.procoptions) and
  1510. (currparanr>hp^.data.minparacount) then
  1511. begin
  1512. eq:=te_equal;
  1513. end
  1514. else
  1515. { same definition -> exact }
  1516. if (def_from=def_to) then
  1517. begin
  1518. eq:=te_exact;
  1519. end
  1520. else
  1521. { for value and const parameters check if a integer is constant or
  1522. included in other integer -> equal and calc ordinal_distance }
  1523. if not(currpara.varspez in [vs_var,vs_out]) and
  1524. is_integer(def_from) and
  1525. is_integer(def_to) and
  1526. is_in_limit(def_from,def_to) then
  1527. begin
  1528. eq:=te_equal;
  1529. hp^.ordinal_distance:=hp^.ordinal_distance+
  1530. abs(bestreal(torddef(def_from).low)-bestreal(torddef(def_to).low));
  1531. hp^.ordinal_distance:=hp^.ordinal_distance+
  1532. abs(bestreal(torddef(def_to).high)-bestreal(torddef(def_from).high));
  1533. { Give wrong sign a small penalty, this is need to get a diffrence
  1534. from word->[longword,longint] }
  1535. if is_signed(def_from)<>is_signed(def_to) then
  1536. hp^.ordinal_distance:=hp^.ordinal_distance+1.0;
  1537. end
  1538. else
  1539. { generic type comparision }
  1540. begin
  1541. eq:=compare_defs_ext(def_from,def_to,currpt.left.nodetype,convtype,pdoper,cdoptions);
  1542. { when the types are not equal we need to check
  1543. some special case for parameter passing }
  1544. if (eq<te_equal) then
  1545. begin
  1546. if currpara.varspez in [vs_var,vs_out] then
  1547. begin
  1548. { para requires an equal type so the previous found
  1549. match was not good enough, reset to incompatible }
  1550. eq:=te_incompatible;
  1551. { var_para_allowed will return te_equal and te_convert_l1 to
  1552. make a difference for best matching }
  1553. var_para_allowed(eq,currpt.resulttype.def,currpara.vartype.def)
  1554. end
  1555. else
  1556. para_allowed(eq,currpt,def_to);
  1557. end;
  1558. end;
  1559. { when a procvar was changed to a call an exact much is
  1560. downgraded to equal. This way an overload call with the
  1561. procvar is choosen. See tb0471 (PFV) }
  1562. if (pt<>currpt) and (eq=te_exact) then
  1563. eq:=te_equal;
  1564. { increase correct counter }
  1565. case eq of
  1566. te_exact :
  1567. inc(hp^.exact_count);
  1568. te_equal :
  1569. inc(hp^.equal_count);
  1570. te_convert_l1 :
  1571. inc(hp^.cl1_count);
  1572. te_convert_l2 :
  1573. inc(hp^.cl2_count);
  1574. te_convert_l3 :
  1575. inc(hp^.cl3_count);
  1576. te_convert_operator :
  1577. inc(hp^.coper_count);
  1578. te_incompatible :
  1579. hp^.invalid:=true;
  1580. else
  1581. internalerror(200212072);
  1582. end;
  1583. { stop checking when an incompatible parameter is found }
  1584. if hp^.invalid then
  1585. begin
  1586. { store the current parameter info for
  1587. a nice error message when no procedure is found }
  1588. hp^.wrongparaidx:=paraidx;
  1589. hp^.wrongparanr:=currparanr;
  1590. break;
  1591. end;
  1592. {$ifdef EXTDEBUG}
  1593. { store equal in node tree for dump }
  1594. currpara.eqval:=eq;
  1595. {$endif EXTDEBUG}
  1596. { maybe release temp currpt }
  1597. if releasecurrpt then
  1598. currpt.free;
  1599. { next parameter in the call tree }
  1600. pt:=tcallparanode(pt.right);
  1601. { next parameter for definition, only goto next para
  1602. if we're out of the varargs }
  1603. if not(po_varargs in hp^.data.procoptions) or
  1604. (currparanr<=hp^.data.maxparacount) then
  1605. begin
  1606. { Ignore vs_hidden parameters }
  1607. repeat
  1608. dec(paraidx);
  1609. until (paraidx<0) or not(vo_is_hidden_para in tparavarsym(hp^.data.paras[paraidx]).varoptions);
  1610. end;
  1611. dec(currparanr);
  1612. end;
  1613. if not(hp^.invalid) and
  1614. (assigned(pt) or (paraidx>=0) or (currparanr<>0)) then
  1615. internalerror(200212141);
  1616. { next candidate }
  1617. hp:=hp^.next;
  1618. end;
  1619. end;
  1620. function is_better_candidate(currpd,bestpd:pcandidate):integer;
  1621. var
  1622. res : integer;
  1623. begin
  1624. {
  1625. Return values:
  1626. > 0 when currpd is better than bestpd
  1627. < 0 when bestpd is better than currpd
  1628. = 0 when both are equal
  1629. To choose the best candidate we use the following order:
  1630. - Incompatible flag
  1631. - (Smaller) Number of convert operator parameters.
  1632. - (Smaller) Number of convertlevel 2 parameters.
  1633. - (Smaller) Number of convertlevel 1 parameters.
  1634. - (Bigger) Number of exact parameters.
  1635. - (Smaller) Number of equal parameters.
  1636. - (Smaller) Total of ordinal distance. For example, the distance of a word
  1637. to a byte is 65535-255=65280.
  1638. }
  1639. if bestpd^.invalid then
  1640. begin
  1641. if currpd^.invalid then
  1642. res:=0
  1643. else
  1644. res:=1;
  1645. end
  1646. else
  1647. if currpd^.invalid then
  1648. res:=-1
  1649. else
  1650. begin
  1651. { less operator parameters? }
  1652. res:=(bestpd^.coper_count-currpd^.coper_count);
  1653. if (res=0) then
  1654. begin
  1655. { less cl3 parameters? }
  1656. res:=(bestpd^.cl3_count-currpd^.cl3_count);
  1657. if (res=0) then
  1658. begin
  1659. { less cl2 parameters? }
  1660. res:=(bestpd^.cl2_count-currpd^.cl2_count);
  1661. if (res=0) then
  1662. begin
  1663. { less cl1 parameters? }
  1664. res:=(bestpd^.cl1_count-currpd^.cl1_count);
  1665. if (res=0) then
  1666. begin
  1667. { more exact parameters? }
  1668. res:=(currpd^.exact_count-bestpd^.exact_count);
  1669. if (res=0) then
  1670. begin
  1671. { less equal parameters? }
  1672. res:=(bestpd^.equal_count-currpd^.equal_count);
  1673. if (res=0) then
  1674. begin
  1675. { smaller ordinal distance? }
  1676. if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
  1677. res:=1
  1678. else
  1679. if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
  1680. res:=-1
  1681. else
  1682. res:=0;
  1683. end;
  1684. end;
  1685. end;
  1686. end;
  1687. end;
  1688. end;
  1689. end;
  1690. is_better_candidate:=res;
  1691. end;
  1692. function tcallcandidates.choose_best(var bestpd:tabstractprocdef):integer;
  1693. var
  1694. besthpstart,
  1695. hp : pcandidate;
  1696. cntpd,
  1697. res : integer;
  1698. begin
  1699. {
  1700. Returns the number of candidates left and the
  1701. first candidate is returned in pdbest
  1702. }
  1703. { Setup the first procdef as best, only count it as a result
  1704. when it is valid }
  1705. bestpd:=FProcs^.data;
  1706. if FProcs^.invalid then
  1707. cntpd:=0
  1708. else
  1709. cntpd:=1;
  1710. if assigned(FProcs^.next) then
  1711. begin
  1712. besthpstart:=FProcs;
  1713. hp:=FProcs^.next;
  1714. while assigned(hp) do
  1715. begin
  1716. res:=is_better_candidate(hp,besthpstart);
  1717. if (res>0) then
  1718. begin
  1719. { hp is better, flag all procs to be incompatible }
  1720. while (besthpstart<>hp) do
  1721. begin
  1722. besthpstart^.invalid:=true;
  1723. besthpstart:=besthpstart^.next;
  1724. end;
  1725. { besthpstart is already set to hp }
  1726. bestpd:=besthpstart^.data;
  1727. cntpd:=1;
  1728. end
  1729. else
  1730. if (res<0) then
  1731. begin
  1732. { besthpstart is better, flag current hp to be incompatible }
  1733. hp^.invalid:=true;
  1734. end
  1735. else
  1736. begin
  1737. { res=0, both are valid }
  1738. if not hp^.invalid then
  1739. inc(cntpd);
  1740. end;
  1741. hp:=hp^.next;
  1742. end;
  1743. end;
  1744. result:=cntpd;
  1745. end;
  1746. procedure tcallcandidates.find_wrong_para;
  1747. var
  1748. currparanr : smallint;
  1749. hp : pcandidate;
  1750. pt : tcallparanode;
  1751. wrongpara : tparavarsym;
  1752. begin
  1753. { Only process the first overloaded procdef }
  1754. hp:=FProcs;
  1755. { Find callparanode corresponding to the argument }
  1756. pt:=tcallparanode(FParanode);
  1757. currparanr:=FParalength;
  1758. while assigned(pt) and
  1759. (currparanr>hp^.wrongparanr) do
  1760. begin
  1761. pt:=tcallparanode(pt.right);
  1762. dec(currparanr);
  1763. end;
  1764. if (currparanr<>hp^.wrongparanr) or
  1765. not assigned(pt) then
  1766. internalerror(200212094);
  1767. { Show error message, when it was a var or out parameter
  1768. guess that it is a missing typeconv }
  1769. wrongpara:=tparavarsym(hp^.data.paras[hp^.wrongparaidx]);
  1770. if wrongpara.varspez in [vs_var,vs_out] then
  1771. begin
  1772. { Maybe passing the correct type but passing a const to var parameter }
  1773. if (compare_defs(pt.resulttype.def,wrongpara.vartype.def,pt.nodetype)<>te_incompatible) and
  1774. not valid_for_var(pt.left) then
  1775. CGMessagePos(pt.left.fileinfo,type_e_variable_id_expected)
  1776. else
  1777. CGMessagePos2(pt.left.fileinfo,parser_e_call_by_ref_without_typeconv,
  1778. FullTypeName(pt.left.resulttype.def,wrongpara.vartype.def),
  1779. FullTypeName(wrongpara.vartype.def,pt.left.resulttype.def))
  1780. end
  1781. else
  1782. CGMessagePos3(pt.left.fileinfo,type_e_wrong_parameter_type,tostr(hp^.wrongparanr),
  1783. FullTypeName(pt.left.resulttype.def,wrongpara.vartype.def),
  1784. FullTypeName(wrongpara.vartype.def,pt.left.resulttype.def));
  1785. end;
  1786. end.
  1787. {
  1788. $Log$
  1789. Revision 1.104 2004-11-15 23:35:31 peter
  1790. * tparaitem removed, use tparavarsym instead
  1791. * parameter order is now calculated from paranr value in tparavarsym
  1792. Revision 1.103 2004/11/08 22:09:58 peter
  1793. * tvarsym splitted
  1794. Revision 1.102 2004/11/01 16:58:57 peter
  1795. * give IE instead of crash when no procsym is passed for calln
  1796. Revision 1.101 2004/10/24 11:44:28 peter
  1797. * small regvar fixes
  1798. * loadref parameter removed from concatcopy,incrrefcount,etc
  1799. Revision 1.100 2004/10/12 14:34:49 peter
  1800. * fixed visibility for procsyms
  1801. * fixed override check when there was no entry yet
  1802. Revision 1.99 2004/10/08 17:09:43 peter
  1803. * tvarsym.varregable added, split vo_regable from varoptions
  1804. Revision 1.98 2004/09/27 15:15:52 peter
  1805. * register loopvarsym for fields instead of record variable
  1806. * don't allow class fields as loop var
  1807. Revision 1.97 2004/09/13 20:28:27 peter
  1808. * for loop variable assignment is not allowed anymore
  1809. Revision 1.96 2004/08/22 11:24:09 peter
  1810. * fix error when passing constant to var parameter
  1811. Revision 1.95 2004/06/23 16:22:45 peter
  1812. * include unit name in error messages when types are the same
  1813. Revision 1.94 2004/06/20 08:55:29 florian
  1814. * logs truncated
  1815. Revision 1.93 2004/06/16 20:07:07 florian
  1816. * dwarf branch merged
  1817. Revision 1.92 2004/05/25 21:27:35 florian
  1818. * fixed another formal const problem caused by yesterday's changes
  1819. Revision 1.91 2004/05/24 21:24:40 florian
  1820. * properties are allowed as formal const parameters as well
  1821. Revision 1.90 2004/05/24 21:04:31 florian
  1822. * fixed more formal const problems
  1823. Revision 1.89 2004/05/24 20:39:41 florian
  1824. * stricter handling of formal const parameters and IE fixed
  1825. }