ncal.pas 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This file implements the node for sub procedure calling.
  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 ncal;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cutils,cclasses,
  23. globtype,cpuinfo,
  24. paramgr,
  25. node,nbas,
  26. {$ifdef state_tracking}
  27. nstate,
  28. {$endif state_tracking}
  29. symbase,symtype,symsym,symdef,symtable;
  30. type
  31. tcallnodeflags = (
  32. cnf_restypeset
  33. );
  34. tcallnodeflagset = set of tcallnodeflags;
  35. tcallnode = class(tbinarynode)
  36. private
  37. { number of parameters passed from the source, this does not include the hidden parameters }
  38. paralength : smallint;
  39. function gen_self_tree_methodpointer:tnode;
  40. function gen_self_tree:tnode;
  41. function gen_vmt_tree:tnode;
  42. procedure bind_paraitem;
  43. { function return node, this is used to pass the data for a
  44. ret_in_param return value }
  45. _funcretnode : tnode;
  46. procedure setfuncretnode(const returnnode: tnode);
  47. procedure convert_carg_array_of_const;
  48. procedure order_parameters;
  49. public
  50. { the symbol containing the definition of the procedure }
  51. { to call }
  52. symtableprocentry : tprocsym;
  53. symtableprocentryderef : tderef;
  54. { symtable where the entry was found, needed for with support }
  55. symtableproc : tsymtable;
  56. { the definition of the procedure to call }
  57. procdefinition : tabstractprocdef;
  58. procdefinitionderef : tderef;
  59. { tree that contains the pointer to the object for this method }
  60. methodpointer : tnode;
  61. { inline function body }
  62. inlinecode : tnode;
  63. { varargs tparaitems }
  64. varargsparas : tvarargspara;
  65. { node that specifies where the result should be put for calls }
  66. { that return their result in a parameter }
  67. property funcretnode: tnode read _funcretnode write setfuncretnode;
  68. { separately specified resulttype for some compilerprocs (e.g. }
  69. { you can't have a function with an "array of char" resulttype }
  70. { the RTL) (JM) }
  71. restype: ttype;
  72. callnodeflags : tcallnodeflagset;
  73. { only the processor specific nodes need to override this }
  74. { constructor }
  75. constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
  76. constructor create_def(l:tnode;def:tprocdef;mp:tnode);virtual;
  77. constructor create_procvar(l,r:tnode);
  78. constructor createintern(const name: string; params: tnode);
  79. constructor createinternres(const name: string; params: tnode; const res: ttype);
  80. constructor createinternreturn(const name: string; params: tnode; returnnode : tnode);
  81. destructor destroy;override;
  82. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  83. procedure ppuwrite(ppufile:tcompilerppufile);override;
  84. procedure buildderefimpl;override;
  85. procedure derefimpl;override;
  86. function getcopy : tnode;override;
  87. { Goes through all symbols in a class and subclasses and calls
  88. verify abstract for each .
  89. }
  90. procedure verifyabstractcalls;
  91. { called for each definition in a class and verifies if a method
  92. is abstract or not, if it is abstract, give out a warning
  93. }
  94. procedure verifyabstract(p : tnamedindexitem;arg:pointer);
  95. procedure insertintolist(l : tnodelist);override;
  96. function pass_1 : tnode;override;
  97. function det_resulttype:tnode;override;
  98. {$ifdef state_tracking}
  99. function track_state_pass(exec_known:boolean):boolean;override;
  100. {$endif state_tracking}
  101. function docompare(p: tnode): boolean; override;
  102. procedure printnodedata(var t:text);override;
  103. function para_count:longint;
  104. private
  105. AbstractMethodsList : TStringList;
  106. end;
  107. tcallnodeclass = class of tcallnode;
  108. tcallparaflags = (
  109. { flags used by tcallparanode }
  110. cpf_is_colon_para
  111. );
  112. tcallparanode = class(tbinarynode)
  113. public
  114. callparaflags : set of tcallparaflags;
  115. paraitem : tparaitem;
  116. used_by_callnode : boolean;
  117. { only the processor specific nodes need to override this }
  118. { constructor }
  119. constructor create(expr,next : tnode);virtual;
  120. destructor destroy;override;
  121. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  122. procedure ppuwrite(ppufile:tcompilerppufile);override;
  123. function getcopy : tnode;override;
  124. procedure insertintolist(l : tnodelist);override;
  125. procedure get_paratype;
  126. procedure insert_typeconv(do_count : boolean);
  127. procedure det_registers;
  128. procedure firstcallparan;
  129. procedure secondcallparan;virtual;abstract;
  130. function docompare(p: tnode): boolean; override;
  131. procedure printnodetree(var t:text);override;
  132. end;
  133. tcallparanodeclass = class of tcallparanode;
  134. function reverseparameters(p: tcallparanode): tcallparanode;
  135. var
  136. ccallnode : tcallnodeclass;
  137. ccallparanode : tcallparanodeclass;
  138. { Current callnode, this is needed for having a link
  139. between the callparanodes and the callnode they belong to }
  140. aktcallnode : tcallnode;
  141. implementation
  142. uses
  143. systems,
  144. verbose,globals,
  145. symconst,defutil,defcmp,
  146. htypechk,pass_1,
  147. ncnv,nld,ninl,nadd,ncon,nmem,nutils,
  148. procinfo,
  149. cgbase
  150. ;
  151. type
  152. tobjectinfoitem = class(tlinkedlistitem)
  153. objinfo : tobjectdef;
  154. constructor create(def : tobjectdef);
  155. end;
  156. {****************************************************************************
  157. HELPERS
  158. ****************************************************************************}
  159. function reverseparameters(p: tcallparanode): tcallparanode;
  160. var
  161. hp1, hp2: tcallparanode;
  162. begin
  163. hp1:=nil;
  164. while assigned(p) do
  165. begin
  166. { pull out }
  167. hp2:=p;
  168. p:=tcallparanode(p.right);
  169. { pull in }
  170. hp2.right:=hp1;
  171. hp1:=hp2;
  172. end;
  173. reverseparameters:=hp1;
  174. end;
  175. function gen_high_tree(p:tnode;openstring:boolean):tnode;
  176. var
  177. temp: tnode;
  178. len : integer;
  179. loadconst : boolean;
  180. hightree : tnode;
  181. begin
  182. len:=-1;
  183. loadconst:=true;
  184. hightree:=nil;
  185. case p.resulttype.def.deftype of
  186. arraydef :
  187. begin
  188. { handle via a normal inline in_high_x node }
  189. loadconst := false;
  190. hightree := geninlinenode(in_high_x,false,p.getcopy);
  191. { only substract low(array) if it's <> 0 }
  192. temp := geninlinenode(in_low_x,false,p.getcopy);
  193. resulttypepass(temp);
  194. if (temp.nodetype <> ordconstn) or
  195. (tordconstnode(temp).value <> 0) then
  196. hightree := caddnode.create(subn,hightree,temp)
  197. else
  198. temp.free;
  199. end;
  200. stringdef :
  201. begin
  202. if openstring then
  203. begin
  204. { handle via a normal inline in_high_x node }
  205. loadconst := false;
  206. hightree := geninlinenode(in_high_x,false,p.getcopy);
  207. end
  208. else
  209. begin
  210. { passing a string to an array of char }
  211. if (p.nodetype=stringconstn) then
  212. begin
  213. len:=str_length(p);
  214. if len>0 then
  215. dec(len);
  216. end
  217. else
  218. begin
  219. hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,p.getcopy),
  220. cordconstnode.create(1,s32inttype,false));
  221. loadconst:=false;
  222. end;
  223. end;
  224. end;
  225. else
  226. len:=0;
  227. end;
  228. if loadconst then
  229. hightree:=cordconstnode.create(len,s32inttype,true)
  230. else
  231. begin
  232. if not assigned(hightree) then
  233. internalerror(200304071);
  234. { Need to use explicit, because it can also be a enum }
  235. hightree:=ctypeconvnode.create_explicit(hightree,s32inttype);
  236. end;
  237. result:=hightree;
  238. end;
  239. {****************************************************************************
  240. TOBJECTINFOITEM
  241. ****************************************************************************}
  242. constructor tobjectinfoitem.create(def : tobjectdef);
  243. begin
  244. inherited create;
  245. objinfo := def;
  246. end;
  247. {****************************************************************************
  248. TCALLPARANODE
  249. ****************************************************************************}
  250. constructor tcallparanode.create(expr,next : tnode);
  251. begin
  252. inherited create(callparan,expr,next);
  253. if not assigned(expr) then
  254. internalerror(200305091);
  255. expr.set_file_line(self);
  256. callparaflags:=[];
  257. end;
  258. destructor tcallparanode.destroy;
  259. begin
  260. { When the node is used by callnode then
  261. we don't destroy left, the callnode takes care of it }
  262. if used_by_callnode then
  263. left:=nil;
  264. inherited destroy;
  265. end;
  266. constructor tcallparanode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  267. begin
  268. inherited ppuload(t,ppufile);
  269. ppufile.getsmallset(callparaflags);
  270. end;
  271. procedure tcallparanode.ppuwrite(ppufile:tcompilerppufile);
  272. begin
  273. inherited ppuwrite(ppufile);
  274. ppufile.putsmallset(callparaflags);
  275. end;
  276. function tcallparanode.getcopy : tnode;
  277. var
  278. n : tcallparanode;
  279. begin
  280. n:=tcallparanode(inherited getcopy);
  281. n.callparaflags:=callparaflags;
  282. n.paraitem:=paraitem;
  283. result:=n;
  284. end;
  285. procedure tcallparanode.insertintolist(l : tnodelist);
  286. begin
  287. end;
  288. procedure tcallparanode.get_paratype;
  289. var
  290. old_array_constructor : boolean;
  291. begin
  292. inc(parsing_para_level);
  293. if assigned(right) then
  294. tcallparanode(right).get_paratype;
  295. old_array_constructor:=allow_array_constructor;
  296. allow_array_constructor:=true;
  297. resulttypepass(left);
  298. allow_array_constructor:=old_array_constructor;
  299. if codegenerror then
  300. resulttype:=generrortype
  301. else
  302. resulttype:=left.resulttype;
  303. dec(parsing_para_level);
  304. end;
  305. procedure tcallparanode.insert_typeconv(do_count : boolean);
  306. var
  307. oldtype : ttype;
  308. {$ifdef extdebug}
  309. store_count_ref : boolean;
  310. {$endif def extdebug}
  311. begin
  312. inc(parsing_para_level);
  313. {$ifdef extdebug}
  314. if do_count then
  315. begin
  316. store_count_ref:=count_ref;
  317. count_ref:=true;
  318. end;
  319. {$endif def extdebug}
  320. { Be sure to have the resulttype }
  321. if not assigned(left.resulttype.def) then
  322. resulttypepass(left);
  323. if (left.nodetype<>nothingn) then
  324. begin
  325. { Convert tp procvars, this is needs to be done
  326. here to make the change permanent. in the overload
  327. choosing the changes are only made temporary }
  328. if (left.resulttype.def.deftype=procvardef) and
  329. (paraitem.paratype.def.deftype<>procvardef) then
  330. begin
  331. if maybe_call_procvar(left,true) then
  332. resulttype:=left.resulttype;
  333. end;
  334. { Handle varargs and hidden paras directly, no typeconvs or }
  335. { typechecking needed }
  336. if (nf_varargs_para in flags) then
  337. begin
  338. { convert pascal to C types }
  339. case left.resulttype.def.deftype of
  340. stringdef :
  341. inserttypeconv(left,charpointertype);
  342. floatdef :
  343. inserttypeconv(left,s64floattype);
  344. end;
  345. set_varstate(left,vs_used,true);
  346. resulttype:=left.resulttype;
  347. end
  348. else
  349. if (paraitem.is_hidden) then
  350. begin
  351. set_varstate(left,vs_used,true);
  352. resulttype:=left.resulttype;
  353. end
  354. else
  355. begin
  356. { Do we need arrayconstructor -> set conversion, then insert
  357. it here before the arrayconstructor node breaks the tree
  358. with its conversions of enum->ord }
  359. if (left.nodetype=arrayconstructorn) and
  360. (paraitem.paratype.def.deftype=setdef) then
  361. inserttypeconv(left,paraitem.paratype);
  362. { set some settings needed for arrayconstructor }
  363. if is_array_constructor(left.resulttype.def) then
  364. begin
  365. if is_array_of_const(paraitem.paratype.def) then
  366. begin
  367. { force variant array }
  368. include(left.flags,nf_forcevaria);
  369. end
  370. else
  371. begin
  372. include(left.flags,nf_novariaallowed);
  373. { now that the resultting type is know we can insert the required
  374. typeconvs for the array constructor }
  375. tarrayconstructornode(left).force_type(tarraydef(paraitem.paratype.def).elementtype);
  376. end;
  377. end;
  378. { check if local proc/func is assigned to procvar }
  379. if left.resulttype.def.deftype=procvardef then
  380. test_local_to_procvar(tprocvardef(left.resulttype.def),paraitem.paratype.def);
  381. { test conversions }
  382. if not(is_shortstring(left.resulttype.def) and
  383. is_shortstring(paraitem.paratype.def)) and
  384. (paraitem.paratype.def.deftype<>formaldef) then
  385. begin
  386. { Process open parameters }
  387. if paramanager.push_high_param(paraitem.paratyp,paraitem.paratype.def,aktcallnode.procdefinition.proccalloption) then
  388. begin
  389. { insert type conv but hold the ranges of the array }
  390. oldtype:=left.resulttype;
  391. inserttypeconv(left,paraitem.paratype);
  392. left.resulttype:=oldtype;
  393. end
  394. else
  395. begin
  396. { for ordinals, floats and enums, verify if we might cause
  397. some range-check errors. }
  398. if (paraitem.paratype.def.deftype in [enumdef,orddef,floatdef]) and
  399. (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) and
  400. (left.nodetype in [vecn,loadn,calln]) then
  401. begin
  402. if (left.resulttype.def.size>paraitem.paratype.def.size) then
  403. begin
  404. if (cs_check_range in aktlocalswitches) then
  405. Message(type_w_smaller_possible_range_check)
  406. else
  407. Message(type_h_smaller_possible_range_check);
  408. end;
  409. end;
  410. inserttypeconv(left,paraitem.paratype);
  411. end;
  412. if codegenerror then
  413. begin
  414. dec(parsing_para_level);
  415. exit;
  416. end;
  417. end;
  418. { check var strings }
  419. if (cs_strict_var_strings in aktlocalswitches) and
  420. is_shortstring(left.resulttype.def) and
  421. is_shortstring(paraitem.paratype.def) and
  422. (paraitem.paratyp in [vs_out,vs_var]) and
  423. not(is_open_string(paraitem.paratype.def)) and
  424. not(equal_defs(left.resulttype.def,paraitem.paratype.def)) then
  425. begin
  426. aktfilepos:=left.fileinfo;
  427. CGMessage(type_e_strict_var_string_violation);
  428. end;
  429. { Handle formal parameters separate }
  430. if (paraitem.paratype.def.deftype=formaldef) then
  431. begin
  432. { load procvar if a procedure is passed }
  433. if (m_tp_procvar in aktmodeswitches) and
  434. (left.nodetype=calln) and
  435. (is_void(left.resulttype.def)) then
  436. load_procvar_from_calln(left);
  437. case paraitem.paratyp of
  438. vs_var,
  439. vs_out :
  440. begin
  441. if not valid_for_formal_var(left) then
  442. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  443. end;
  444. vs_const :
  445. begin
  446. if not valid_for_formal_const(left) then
  447. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  448. end;
  449. end;
  450. end
  451. else
  452. begin
  453. { check if the argument is allowed }
  454. if (paraitem.paratyp in [vs_out,vs_var]) then
  455. valid_for_var(left);
  456. end;
  457. if paraitem.paratyp in [vs_var,vs_const] then
  458. begin
  459. { Causes problems with const ansistrings if also }
  460. { done for vs_const (JM) }
  461. if paraitem.paratyp = vs_var then
  462. set_unique(left);
  463. make_not_regable(left);
  464. end;
  465. { ansistrings out paramaters doesn't need to be }
  466. { unique, they are finalized }
  467. if paraitem.paratyp=vs_out then
  468. make_not_regable(left);
  469. if do_count then
  470. begin
  471. if paraitem.paratyp in [vs_var,vs_out] then
  472. set_varstate(left,vs_used,false)
  473. else
  474. set_varstate(left,vs_used,true);
  475. end;
  476. { must only be done after typeconv PM }
  477. resulttype:=paraitem.paratype;
  478. end;
  479. end;
  480. { process next node }
  481. if assigned(right) then
  482. tcallparanode(right).insert_typeconv(do_count);
  483. dec(parsing_para_level);
  484. {$ifdef extdebug}
  485. if do_count then
  486. count_ref:=store_count_ref;
  487. {$endif def extdebug}
  488. end;
  489. procedure tcallparanode.det_registers;
  490. begin
  491. if assigned(right) then
  492. begin
  493. tcallparanode(right).det_registers;
  494. registersint:=right.registersint;
  495. registersfpu:=right.registersfpu;
  496. {$ifdef SUPPORT_MMX}
  497. registersmmx:=right.registersmmx;
  498. {$endif}
  499. end;
  500. firstpass(left);
  501. if left.registersint>registersint then
  502. registersint:=left.registersint;
  503. if left.registersfpu>registersfpu then
  504. registersfpu:=left.registersfpu;
  505. {$ifdef SUPPORT_MMX}
  506. if left.registersmmx>registersmmx then
  507. registersmmx:=left.registersmmx;
  508. {$endif SUPPORT_MMX}
  509. end;
  510. procedure tcallparanode.firstcallparan;
  511. begin
  512. if not assigned(left.resulttype.def) then
  513. get_paratype;
  514. det_registers;
  515. end;
  516. function tcallparanode.docompare(p: tnode): boolean;
  517. begin
  518. docompare :=
  519. inherited docompare(p) and
  520. (callparaflags = tcallparanode(p).callparaflags)
  521. ;
  522. end;
  523. procedure tcallparanode.printnodetree(var t:text);
  524. begin
  525. printnodelist(t);
  526. end;
  527. {****************************************************************************
  528. TCALLNODE
  529. ****************************************************************************}
  530. constructor tcallnode.create(l:tnode;v : tprocsym;st : tsymtable; mp : tnode);
  531. begin
  532. inherited create(calln,l,nil);
  533. symtableprocentry:=v;
  534. symtableproc:=st;
  535. include(flags,nf_return_value_used);
  536. methodpointer:=mp;
  537. procdefinition:=nil;
  538. callnodeflags:=[];
  539. _funcretnode:=nil;
  540. inlinecode:=nil;
  541. paralength:=-1;
  542. varargsparas:=nil;
  543. end;
  544. constructor tcallnode.create_def(l:tnode;def:tprocdef;mp:tnode);
  545. begin
  546. inherited create(calln,l,nil);
  547. symtableprocentry:=nil;
  548. symtableproc:=nil;
  549. include(flags,nf_return_value_used);
  550. methodpointer:=mp;
  551. procdefinition:=def;
  552. callnodeflags:=[];
  553. _funcretnode:=nil;
  554. inlinecode:=nil;
  555. paralength:=-1;
  556. varargsparas:=nil;
  557. end;
  558. constructor tcallnode.create_procvar(l,r:tnode);
  559. begin
  560. inherited create(calln,l,r);
  561. symtableprocentry:=nil;
  562. symtableproc:=nil;
  563. include(flags,nf_return_value_used);
  564. methodpointer:=nil;
  565. procdefinition:=nil;
  566. callnodeflags:=[];
  567. _funcretnode:=nil;
  568. inlinecode:=nil;
  569. paralength:=-1;
  570. varargsparas:=nil;
  571. end;
  572. constructor tcallnode.createintern(const name: string; params: tnode);
  573. var
  574. srsym: tsym;
  575. symowner: tsymtable;
  576. begin
  577. if not (cs_compilesystem in aktmoduleswitches) then
  578. begin
  579. srsym := searchsymonlyin(systemunit,name);
  580. symowner := systemunit;
  581. end
  582. else
  583. begin
  584. searchsym(name,srsym,symowner);
  585. if not assigned(srsym) then
  586. searchsym(upper(name),srsym,symowner);
  587. end;
  588. if not assigned(srsym) or
  589. (srsym.typ <> procsym) then
  590. begin
  591. {$ifdef EXTDEBUG}
  592. Comment(V_Error,'unknown compilerproc '+name);
  593. {$endif EXTDEBUG}
  594. internalerror(200107271);
  595. end;
  596. self.create(params,tprocsym(srsym),symowner,nil);
  597. end;
  598. constructor tcallnode.createinternres(const name: string; params: tnode; const res: ttype);
  599. begin
  600. self.createintern(name,params);
  601. restype := res;
  602. include(callnodeflags,cnf_restypeset);
  603. { both the normal and specified resulttype either have to be returned via a }
  604. { parameter or not, but no mixing (JM) }
  605. if paramanager.ret_in_param(restype.def,pocall_compilerproc) xor
  606. paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  607. internalerror(200108291);
  608. end;
  609. constructor tcallnode.createinternreturn(const name: string; params: tnode; returnnode : tnode);
  610. begin
  611. self.createintern(name,params);
  612. _funcretnode:=returnnode;
  613. if not paramanager.ret_in_param(symtableprocentry.first_procdef.rettype.def,symtableprocentry.first_procdef.proccalloption) then
  614. internalerror(200204247);
  615. end;
  616. procedure tcallnode.setfuncretnode(const returnnode: tnode);
  617. var
  618. para: tcallparanode;
  619. begin
  620. if assigned(_funcretnode) then
  621. _funcretnode.free;
  622. _funcretnode := returnnode;
  623. { if the resulttype pass hasn't occurred yet, that one will do }
  624. { everything }
  625. if assigned(resulttype.def) then
  626. begin
  627. { these are returned as values, but we can optimize their loading }
  628. { as well }
  629. if is_ansistring(resulttype.def) or
  630. is_widestring(resulttype.def) then
  631. exit;
  632. para := tcallparanode(left);
  633. while assigned(para) do
  634. begin
  635. if para.paraitem.is_hidden and
  636. (vo_is_funcret in tvarsym(para.paraitem.parasym).varoptions) then
  637. begin
  638. para.left.free;
  639. para.left := _funcretnode.getcopy;
  640. exit;
  641. end;
  642. para := tcallparanode(para.right);
  643. end;
  644. { no hidden resultpara found, error! }
  645. internalerror(200306087);
  646. end;
  647. end;
  648. destructor tcallnode.destroy;
  649. begin
  650. methodpointer.free;
  651. _funcretnode.free;
  652. inlinecode.free;
  653. if assigned(varargsparas) then
  654. varargsparas.free;
  655. inherited destroy;
  656. end;
  657. constructor tcallnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  658. begin
  659. inherited ppuload(t,ppufile);
  660. ppufile.getderef(symtableprocentryderef);
  661. {$ifdef fpc}
  662. {$warning FIXME: No withsymtable support}
  663. {$endif}
  664. symtableproc:=nil;
  665. ppufile.getderef(procdefinitionderef);
  666. ppufile.getsmallset(callnodeflags);
  667. methodpointer:=ppuloadnode(ppufile);
  668. _funcretnode:=ppuloadnode(ppufile);
  669. inlinecode:=ppuloadnode(ppufile);
  670. end;
  671. procedure tcallnode.ppuwrite(ppufile:tcompilerppufile);
  672. begin
  673. inherited ppuwrite(ppufile);
  674. ppufile.putderef(symtableprocentryderef);
  675. ppufile.putderef(procdefinitionderef);
  676. ppufile.putsmallset(callnodeflags);
  677. ppuwritenode(ppufile,methodpointer);
  678. ppuwritenode(ppufile,_funcretnode);
  679. ppuwritenode(ppufile,inlinecode);
  680. end;
  681. procedure tcallnode.buildderefimpl;
  682. begin
  683. inherited buildderefimpl;
  684. symtableprocentryderef.build(symtableprocentry);
  685. procdefinitionderef.build(procdefinition);
  686. if assigned(methodpointer) then
  687. methodpointer.buildderefimpl;
  688. if assigned(_funcretnode) then
  689. _funcretnode.buildderefimpl;
  690. if assigned(inlinecode) then
  691. inlinecode.buildderefimpl;
  692. end;
  693. procedure tcallnode.derefimpl;
  694. var
  695. pt : tcallparanode;
  696. currpara : tparaitem;
  697. begin
  698. inherited derefimpl;
  699. symtableprocentry:=tprocsym(symtableprocentryderef.resolve);
  700. symtableproc:=symtableprocentry.owner;
  701. procdefinition:=tprocdef(procdefinitionderef.resolve);
  702. if assigned(methodpointer) then
  703. methodpointer.derefimpl;
  704. if assigned(_funcretnode) then
  705. _funcretnode.derefimpl;
  706. if assigned(inlinecode) then
  707. inlinecode.derefimpl;
  708. { Connect paraitems }
  709. pt:=tcallparanode(left);
  710. while assigned(pt) and
  711. (nf_varargs_para in pt.flags) do
  712. pt:=tcallparanode(pt.right);
  713. currpara:=tparaitem(procdefinition.Para.last);
  714. while assigned(currpara) do
  715. begin
  716. if not assigned(pt) then
  717. internalerror(200311077);
  718. pt.paraitem:=currpara;
  719. pt:=tcallparanode(pt.right);
  720. currpara:=tparaitem(currpara.previous);
  721. end;
  722. if assigned(currpara) or assigned(pt) then
  723. internalerror(200311078);
  724. end;
  725. function tcallnode.getcopy : tnode;
  726. var
  727. n : tcallnode;
  728. hp : tparaitem;
  729. begin
  730. n:=tcallnode(inherited getcopy);
  731. n.symtableprocentry:=symtableprocentry;
  732. n.symtableproc:=symtableproc;
  733. n.procdefinition:=procdefinition;
  734. n.restype := restype;
  735. n.callnodeflags := callnodeflags;
  736. if assigned(methodpointer) then
  737. n.methodpointer:=methodpointer.getcopy
  738. else
  739. n.methodpointer:=nil;
  740. if assigned(_funcretnode) then
  741. n._funcretnode:=_funcretnode.getcopy
  742. else
  743. n._funcretnode:=nil;
  744. if assigned(inlinecode) then
  745. n.inlinecode:=inlinecode.getcopy
  746. else
  747. n.inlinecode:=nil;
  748. if assigned(varargsparas) then
  749. begin
  750. n.varargsparas:=tvarargspara.create;
  751. hp:=tparaitem(varargsparas.first);
  752. while assigned(hp) do
  753. begin
  754. n.varargsparas.concat(hp.getcopy);
  755. hp:=tparaitem(hp.next);
  756. end;
  757. end
  758. else
  759. n.varargsparas:=nil;
  760. result:=n;
  761. end;
  762. procedure tcallnode.insertintolist(l : tnodelist);
  763. begin
  764. end;
  765. procedure tcallnode.convert_carg_array_of_const;
  766. var
  767. hp : tarrayconstructornode;
  768. oldleft : tcallparanode;
  769. begin
  770. oldleft:=tcallparanode(left);
  771. if oldleft.left.nodetype<>arrayconstructorn then
  772. begin
  773. CGMessage1(type_e_wrong_type_in_array_constructor,oldleft.left.resulttype.def.typename);
  774. exit;
  775. end;
  776. { Get arrayconstructor node and insert typeconvs }
  777. hp:=tarrayconstructornode(oldleft.left);
  778. hp.insert_typeconvs;
  779. { Add c args parameters }
  780. { It could be an empty set }
  781. if assigned(hp) and
  782. assigned(hp.left) then
  783. begin
  784. while assigned(hp) do
  785. begin
  786. left:=ccallparanode.create(hp.left,left);
  787. { set callparanode resulttype and flags }
  788. left.resulttype:=hp.left.resulttype;
  789. include(left.flags,nf_varargs_para);
  790. hp.left:=nil;
  791. hp:=tarrayconstructornode(hp.right);
  792. end;
  793. end;
  794. { Remove value of old array of const parameter, but keep it
  795. in the list because it is required for bind_paraitem.
  796. Generate a nothign to keep callparanoed.left valid }
  797. oldleft.left.free;
  798. oldleft.left:=cnothingnode.create;
  799. end;
  800. procedure tcallnode.verifyabstract(p : tnamedindexitem;arg:pointer);
  801. var
  802. hp : tprocdef;
  803. j: integer;
  804. begin
  805. if (tsym(p).typ=procsym) then
  806. begin
  807. for j:=1 to tprocsym(p).procdef_count do
  808. begin
  809. { index starts at 1 }
  810. hp:=tprocsym(p).procdef[j];
  811. { If this is an abstract method insert into the list }
  812. if (po_abstractmethod in hp.procoptions) then
  813. AbstractMethodsList.Insert(hp.procsym.name)
  814. else
  815. { If this symbol is already in the list, and it is
  816. an overriding method or dynamic, then remove it from the list
  817. }
  818. begin
  819. { symbol was found }
  820. if AbstractMethodsList.Find(hp.procsym.name) <> nil then
  821. begin
  822. if po_overridingmethod in hp.procoptions then
  823. AbstractMethodsList.Remove(hp.procsym.name);
  824. end;
  825. end;
  826. end;
  827. end;
  828. end;
  829. procedure tcallnode.verifyabstractcalls;
  830. var
  831. objectdf : tobjectdef;
  832. parents : tlinkedlist;
  833. objectinfo : tobjectinfoitem;
  834. stritem : tstringlistitem;
  835. begin
  836. objectdf := nil;
  837. { verify if trying to create an instance of a class which contains
  838. non-implemented abstract methods }
  839. { first verify this class type, no class than exit }
  840. { also, this checking can only be done if the constructor is directly
  841. called, indirect constructor calls cannot be checked.
  842. }
  843. if assigned(methodpointer) then
  844. begin
  845. if (methodpointer.resulttype.def.deftype = objectdef) then
  846. objectdf:=tobjectdef(methodpointer.resulttype.def)
  847. else
  848. if (methodpointer.resulttype.def.deftype = classrefdef) and
  849. (tclassrefdef(methodpointer.resulttype.def).pointertype.def.deftype = objectdef) and
  850. (methodpointer.nodetype in [typen,loadvmtaddrn]) then
  851. objectdf:=tobjectdef(tclassrefdef(methodpointer.resulttype.def).pointertype.def);
  852. end;
  853. if not assigned(objectdf) then
  854. exit;
  855. parents := tlinkedlist.create;
  856. AbstractMethodsList := tstringlist.create;
  857. { insert all parents in this class : the first item in the
  858. list will be the base parent of the class .
  859. }
  860. while assigned(objectdf) do
  861. begin
  862. objectinfo:=tobjectinfoitem.create(objectdf);
  863. parents.insert(objectinfo);
  864. objectdf := objectdf.childof;
  865. end;
  866. { now all parents are in the correct order
  867. insert all abstract methods in the list, and remove
  868. those which are overriden by parent classes.
  869. }
  870. objectinfo:=tobjectinfoitem(parents.first);
  871. while assigned(objectinfo) do
  872. begin
  873. objectdf := objectinfo.objinfo;
  874. if assigned(objectdf.symtable) then
  875. objectdf.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}verifyabstract,nil);
  876. objectinfo:=tobjectinfoitem(objectinfo.next);
  877. end;
  878. if assigned(parents) then
  879. parents.free;
  880. { Finally give out a warning for each abstract method still in the list }
  881. stritem := tstringlistitem(AbstractMethodsList.first);
  882. if assigned(stritem) then
  883. Message1(type_w_instance_with_abstract,objectdf.objname^);
  884. while assigned(stritem) do
  885. begin
  886. if assigned(stritem.fpstr) then
  887. Message1(sym_h_param_list,stritem.str);
  888. stritem := tstringlistitem(stritem.next);
  889. end;
  890. if assigned(AbstractMethodsList) then
  891. AbstractMethodsList.Free;
  892. end;
  893. function tcallnode.gen_self_tree_methodpointer:tnode;
  894. var
  895. hsym : tvarsym;
  896. begin
  897. { find self field in methodpointer record }
  898. hsym:=tvarsym(trecorddef(methodpointertype.def).symtable.search('self'));
  899. if not assigned(hsym) then
  900. internalerror(200305251);
  901. { Load tmehodpointer(right).self }
  902. result:=csubscriptnode.create(
  903. hsym,
  904. ctypeconvnode.create_explicit(right.getcopy,methodpointertype));
  905. end;
  906. function tcallnode.gen_self_tree:tnode;
  907. var
  908. selftree : tnode;
  909. begin
  910. selftree:=nil;
  911. { inherited }
  912. if (nf_inherited in flags) then
  913. selftree:=load_self_node
  914. else
  915. { constructors }
  916. if (procdefinition.proctypeoption=potype_constructor) then
  917. begin
  918. { push 0 as self when allocation is needed }
  919. if (methodpointer.resulttype.def.deftype=classrefdef) or
  920. (nf_new_call in flags) then
  921. selftree:=cpointerconstnode.create(0,voidpointertype)
  922. else
  923. begin
  924. if methodpointer.nodetype=typen then
  925. selftree:=load_self_node
  926. else
  927. selftree:=methodpointer.getcopy;
  928. end;
  929. end
  930. else
  931. { Calling a static/class method }
  932. if (po_classmethod in procdefinition.procoptions) or
  933. (po_staticmethod in procdefinition.procoptions) then
  934. begin
  935. if (procdefinition.deftype<>procdef) then
  936. internalerror(200305062);
  937. if (oo_has_vmt in tprocdef(procdefinition)._class.objectoptions) then
  938. begin
  939. { we only need the vmt, loading self is not required and there is no
  940. need to check for typen, because that will always get the
  941. loadvmtaddrnode added }
  942. selftree:=methodpointer.getcopy;
  943. if methodpointer.resulttype.def.deftype<>classrefdef then
  944. selftree:=cloadvmtaddrnode.create(selftree);
  945. end
  946. else
  947. selftree:=cpointerconstnode.create(0,voidpointertype);
  948. end
  949. else
  950. begin
  951. if methodpointer.nodetype=typen then
  952. selftree:=load_self_node
  953. else
  954. selftree:=methodpointer.getcopy;
  955. end;
  956. result:=selftree;
  957. end;
  958. function tcallnode.gen_vmt_tree:tnode;
  959. var
  960. vmttree : tnode;
  961. begin
  962. vmttree:=nil;
  963. if not(procdefinition.proctypeoption in [potype_constructor,potype_destructor]) then
  964. internalerror(200305051);
  965. { inherited call, no create/destroy }
  966. if (nf_inherited in flags) then
  967. vmttree:=cpointerconstnode.create(0,voidpointertype)
  968. else
  969. { do not create/destroy when called from member function
  970. without specifying self explicit }
  971. if (nf_member_call in flags) then
  972. begin
  973. if (methodpointer.resulttype.def.deftype=classrefdef) and
  974. (procdefinition.proctypeoption=potype_constructor) then
  975. vmttree:=methodpointer.getcopy
  976. else
  977. vmttree:=cpointerconstnode.create(0,voidpointertype);
  978. end
  979. else
  980. { constructor with extended syntax called from new }
  981. if (nf_new_call in flags) then
  982. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  983. else
  984. { destructor with extended syntax called from dispose }
  985. if (nf_dispose_call in flags) then
  986. vmttree:=cloadvmtaddrnode.create(methodpointer.getcopy)
  987. else
  988. if (methodpointer.resulttype.def.deftype=classrefdef) then
  989. begin
  990. { constructor call via classreference => allocate memory }
  991. if (procdefinition.proctypeoption=potype_constructor) and
  992. is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
  993. begin
  994. vmttree:=methodpointer.getcopy;
  995. { Only a typenode can be passed when it is called with <class of xx>.create }
  996. if vmttree.nodetype=typen then
  997. vmttree:=cloadvmtaddrnode.create(vmttree);
  998. end
  999. else
  1000. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1001. end
  1002. else
  1003. { class }
  1004. if is_class(methodpointer.resulttype.def) then
  1005. begin
  1006. { destructor: release instance, flag(vmt)=1
  1007. constructor: direct call, do nothing, leave vmt=0 }
  1008. if (procdefinition.proctypeoption=potype_destructor) then
  1009. vmttree:=cpointerconstnode.create(1,voidpointertype)
  1010. else
  1011. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1012. end
  1013. else
  1014. { object }
  1015. begin
  1016. { destructor: direct call, no dispose, vmt=0
  1017. constructor: initialize object, load vmt }
  1018. if (procdefinition.proctypeoption=potype_constructor) then
  1019. { old styled inherited call? }
  1020. if (methodpointer.nodetype=typen) then
  1021. vmttree:=cpointerconstnode.create(0,voidpointertype)
  1022. else
  1023. vmttree:=cloadvmtaddrnode.create(ctypenode.create(methodpointer.resulttype))
  1024. else
  1025. vmttree:=cpointerconstnode.create(0,voidpointertype);
  1026. end;
  1027. result:=vmttree;
  1028. end;
  1029. procedure tcallnode.bind_paraitem;
  1030. var
  1031. i : integer;
  1032. pt : tcallparanode;
  1033. oldppt : ^tcallparanode;
  1034. varargspara,
  1035. currpara : tparaitem;
  1036. used_by_callnode : boolean;
  1037. hiddentree : tnode;
  1038. newstatement : tstatementnode;
  1039. temp : ttempcreatenode;
  1040. begin
  1041. pt:=tcallparanode(left);
  1042. oldppt:=@left;
  1043. { flag all callparanodes that belong to the varargs }
  1044. i:=paralength;
  1045. while (i>procdefinition.maxparacount) do
  1046. begin
  1047. include(pt.flags,nf_varargs_para);
  1048. oldppt:[email protected];
  1049. pt:=tcallparanode(pt.right);
  1050. dec(i);
  1051. end;
  1052. { skip varargs that are inserted by array of const }
  1053. while assigned(pt) and
  1054. (nf_varargs_para in pt.flags) do
  1055. pt:=tcallparanode(pt.right);
  1056. { process normal parameters and insert hidden parameters }
  1057. currpara:=tparaitem(procdefinition.Para.last);
  1058. while assigned(currpara) do
  1059. begin
  1060. if currpara.is_hidden then
  1061. begin
  1062. { generate hidden tree }
  1063. used_by_callnode:=false;
  1064. hiddentree:=nil;
  1065. if (vo_is_funcret in tvarsym(currpara.parasym).varoptions) then
  1066. begin
  1067. { Generate funcretnode if not specified }
  1068. if assigned(funcretnode) then
  1069. begin
  1070. hiddentree:=funcretnode.getcopy;
  1071. end
  1072. else
  1073. begin
  1074. hiddentree:=internalstatements(newstatement);
  1075. { need to use resulttype instead of procdefinition.rettype,
  1076. because they can be different }
  1077. temp:=ctempcreatenode.create(resulttype,resulttype.def.size,tt_persistent);
  1078. addstatement(newstatement,temp);
  1079. addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
  1080. addstatement(newstatement,ctemprefnode.create(temp));
  1081. end;
  1082. end
  1083. else
  1084. if vo_is_high_value in tvarsym(currpara.parasym).varoptions then
  1085. begin
  1086. if not assigned(pt) then
  1087. internalerror(200304082);
  1088. { we need the information of the next parameter }
  1089. hiddentree:=gen_high_tree(pt.left,is_open_string(tparaitem(currpara.previous).paratype.def));
  1090. end
  1091. else
  1092. if vo_is_self in tvarsym(currpara.parasym).varoptions then
  1093. begin
  1094. if assigned(right) then
  1095. hiddentree:=gen_self_tree_methodpointer
  1096. else
  1097. hiddentree:=gen_self_tree;
  1098. end
  1099. else
  1100. if vo_is_vmt in tvarsym(currpara.parasym).varoptions then
  1101. begin
  1102. hiddentree:=gen_vmt_tree;
  1103. end
  1104. else
  1105. if vo_is_parentfp in tvarsym(currpara.parasym).varoptions then
  1106. begin
  1107. if not(assigned(procdefinition.owner.defowner)) then
  1108. internalerror(200309287);
  1109. hiddentree:=cloadparentfpnode.create(tprocdef(procdefinition.owner.defowner));
  1110. end
  1111. {$ifdef powerpc}
  1112. else
  1113. { lib parameter has no special type but proccalloptions must be a syscall }
  1114. if (target_info.system in [system_powerpc_morphos,system_m68k_amiga]) and
  1115. (procdefinition.proccalloption=pocall_syscall) then
  1116. begin
  1117. hiddentree:=cloadnode.create(tprocdef(procdefinition).libsym,tprocdef(procdefinition).libsym.owner);
  1118. end
  1119. {$endif powerpc}
  1120. else
  1121. { add the hidden parameter }
  1122. if not assigned(hiddentree) then
  1123. internalerror(200304073);
  1124. { Already insert para and let the previous node point to
  1125. this new node }
  1126. pt:=ccallparanode.create(hiddentree,oldppt^);
  1127. pt.used_by_callnode:=used_by_callnode;
  1128. oldppt^:=pt;
  1129. end;
  1130. if not assigned(pt) then
  1131. internalerror(200310052);
  1132. pt.paraitem:=currpara;
  1133. oldppt:[email protected];
  1134. pt:=tcallparanode(pt.right);
  1135. currpara:=tparaitem(currpara.previous)
  1136. end;
  1137. { Create paraitems for varargs }
  1138. pt:=tcallparanode(left);
  1139. while assigned(pt) do
  1140. begin
  1141. if nf_varargs_para in pt.flags then
  1142. begin
  1143. if not assigned(varargsparas) then
  1144. varargsparas:=tvarargspara.create;
  1145. varargspara:=tparaitem.create;
  1146. varargspara.paratyp:=vs_value;
  1147. varargspara.paratype:=pt.resulttype;
  1148. { varargspara is left-right, use insert
  1149. instead of concat }
  1150. varargsparas.insert(varargspara);
  1151. pt.paraitem:=varargspara;
  1152. end;
  1153. pt:=tcallparanode(pt.right);
  1154. end;
  1155. end;
  1156. function tcallnode.det_resulttype:tnode;
  1157. var
  1158. candidates : tcallcandidates;
  1159. oldcallnode : tcallnode;
  1160. hpt : tnode;
  1161. pt : tcallparanode;
  1162. lastpara : longint;
  1163. currpara : tparaitem;
  1164. cand_cnt : integer;
  1165. i : longint;
  1166. method_must_be_valid,
  1167. is_const : boolean;
  1168. label
  1169. errorexit;
  1170. begin
  1171. result:=nil;
  1172. candidates:=nil;
  1173. oldcallnode:=aktcallnode;
  1174. aktcallnode:=nil;
  1175. { determine length of parameter list }
  1176. pt:=tcallparanode(left);
  1177. paralength:=0;
  1178. while assigned(pt) do
  1179. begin
  1180. inc(paralength);
  1181. pt:=tcallparanode(pt.right);
  1182. end;
  1183. { determine the type of the parameters }
  1184. if assigned(left) then
  1185. begin
  1186. tcallparanode(left).get_paratype;
  1187. if codegenerror then
  1188. goto errorexit;
  1189. end;
  1190. { procedure variable ? }
  1191. if assigned(right) then
  1192. begin
  1193. set_varstate(right,vs_used,true);
  1194. resulttypepass(right);
  1195. if codegenerror then
  1196. exit;
  1197. procdefinition:=tabstractprocdef(right.resulttype.def);
  1198. { Compare parameters from right to left }
  1199. currpara:=tparaitem(procdefinition.Para.last);
  1200. { Skip default parameters }
  1201. if not(po_varargs in procdefinition.procoptions) then
  1202. begin
  1203. { ignore hidden parameters }
  1204. while assigned(currpara) and (currpara.is_hidden) do
  1205. currpara:=tparaitem(currpara.previous);
  1206. for i:=1 to procdefinition.maxparacount-paralength do
  1207. begin
  1208. if not assigned(currpara) then
  1209. internalerror(200402261);
  1210. if not assigned(currpara.defaultvalue) then
  1211. begin
  1212. CGMessage(parser_e_wrong_parameter_size);
  1213. goto errorexit;
  1214. end;
  1215. currpara:=tparaitem(currpara.previous);
  1216. end;
  1217. end;
  1218. while assigned(currpara) and (currpara.is_hidden) do
  1219. currpara:=tparaitem(currpara.previous);
  1220. pt:=tcallparanode(left);
  1221. lastpara:=paralength;
  1222. while assigned(currpara) and assigned(pt) do
  1223. begin
  1224. { only goto next para if we're out of the varargs }
  1225. if not(po_varargs in procdefinition.procoptions) or
  1226. (lastpara<=procdefinition.maxparacount) then
  1227. begin
  1228. repeat
  1229. currpara:=tparaitem(currpara.previous);
  1230. until (not assigned(currpara)) or (not currpara.is_hidden);
  1231. end;
  1232. pt:=tcallparanode(pt.right);
  1233. dec(lastpara);
  1234. end;
  1235. if assigned(pt) or
  1236. (assigned(currpara) and
  1237. not assigned(currpara.defaultvalue)) then
  1238. begin
  1239. if assigned(pt) then
  1240. aktfilepos:=pt.fileinfo;
  1241. CGMessage(parser_e_wrong_parameter_size);
  1242. goto errorexit;
  1243. end;
  1244. end
  1245. else
  1246. { not a procedure variable }
  1247. begin
  1248. { do we know the procedure to call ? }
  1249. if not(assigned(procdefinition)) then
  1250. begin
  1251. candidates:=tcallcandidates.create(symtableprocentry,symtableproc,left,(nf_isproperty in flags));
  1252. { no procedures found? then there is something wrong
  1253. with the parameter size or the procedures are
  1254. not accessible }
  1255. if candidates.count=0 then
  1256. begin
  1257. { when it's an auto inherited call and there
  1258. is no procedure found, but the procedures
  1259. were defined with overload directive and at
  1260. least two procedures are defined then we ignore
  1261. this inherited by inserting a nothingn. Only
  1262. do this ugly hack in Delphi mode as it looks more
  1263. like a bug. It's also not documented }
  1264. if (m_delphi in aktmodeswitches) and
  1265. (nf_anon_inherited in flags) and
  1266. (symtableprocentry.owner.symtabletype=objectsymtable) and
  1267. (po_overload in symtableprocentry.first_procdef.procoptions) and
  1268. (symtableprocentry.procdef_count>=2) then
  1269. result:=cnothingnode.create
  1270. else
  1271. begin
  1272. { in tp mode we can try to convert to procvar if
  1273. there are no parameters specified. Only try it
  1274. when there is only one proc definition, else the
  1275. loadnode will give a strange error }
  1276. if not(assigned(left)) and
  1277. not(nf_inherited in flags) and
  1278. (m_tp_procvar in aktmodeswitches) and
  1279. (symtableprocentry.procdef_count=1) then
  1280. begin
  1281. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  1282. if assigned(methodpointer) then
  1283. tloadnode(hpt).set_mp(methodpointer.getcopy);
  1284. resulttypepass(hpt);
  1285. result:=hpt;
  1286. end
  1287. else
  1288. begin
  1289. if assigned(left) then
  1290. aktfilepos:=left.fileinfo;
  1291. CGMessage(parser_e_wrong_parameter_size);
  1292. symtableprocentry.write_parameter_lists(nil);
  1293. end;
  1294. end;
  1295. goto errorexit;
  1296. end;
  1297. { Retrieve information about the candidates }
  1298. candidates.get_information;
  1299. {$ifdef EXTDEBUG}
  1300. { Display info when multiple candidates are found }
  1301. if candidates.count>1 then
  1302. candidates.dump_info(V_Debug);
  1303. {$endif EXTDEBUG}
  1304. { Choose the best candidate and count the number of
  1305. candidates left }
  1306. cand_cnt:=candidates.choose_best(procdefinition);
  1307. { All parameters are checked, check if there are any
  1308. procedures left }
  1309. if cand_cnt>0 then
  1310. begin
  1311. { Multiple candidates left? }
  1312. if cand_cnt>1 then
  1313. begin
  1314. CGMessage(cg_e_cant_choose_overload_function);
  1315. {$ifdef EXTDEBUG}
  1316. candidates.dump_info(V_Hint);
  1317. {$else EXTDEBUG}
  1318. candidates.list(false);
  1319. {$endif EXTDEBUG}
  1320. { we'll just use the first candidate to make the
  1321. call }
  1322. end;
  1323. { assign procdefinition }
  1324. if symtableproc=nil then
  1325. symtableproc:=procdefinition.owner;
  1326. { update browser information }
  1327. if make_ref then
  1328. begin
  1329. tprocdef(procdefinition).lastref:=tref.create(tprocdef(procdefinition).lastref,@fileinfo);
  1330. inc(tprocdef(procdefinition).refcount);
  1331. if tprocdef(procdefinition).defref=nil then
  1332. tprocdef(procdefinition).defref:=tprocdef(procdefinition).lastref;
  1333. end;
  1334. end
  1335. else
  1336. begin
  1337. { No candidates left, this must be a type error,
  1338. because wrong size is already checked. procdefinition
  1339. is filled with the first (random) definition that is
  1340. found. We use this definition to display a nice error
  1341. message that the wrong type is passed }
  1342. candidates.find_wrong_para;
  1343. candidates.list(true);
  1344. {$ifdef EXTDEBUG}
  1345. candidates.dump_info(V_Hint);
  1346. {$endif EXTDEBUG}
  1347. { We can not proceed, release all procs and exit }
  1348. candidates.free;
  1349. goto errorexit;
  1350. end;
  1351. candidates.free;
  1352. end; { end of procedure to call determination }
  1353. end;
  1354. { add needed default parameters }
  1355. if assigned(procdefinition) and
  1356. (paralength<procdefinition.maxparacount) then
  1357. begin
  1358. currpara:=tparaitem(procdefinition.Para.first);
  1359. i:=0;
  1360. while (i<paralength) do
  1361. begin
  1362. if not assigned(currpara) then
  1363. internalerror(200306181);
  1364. if not currpara.is_hidden then
  1365. inc(i);
  1366. currpara:=tparaitem(currpara.next);
  1367. end;
  1368. while assigned(currpara) and currpara.is_hidden do
  1369. currpara:=tparaitem(currpara.next);
  1370. while assigned(currpara) do
  1371. begin
  1372. if not assigned(currpara.defaultvalue) then
  1373. internalerror(200212142);
  1374. left:=ccallparanode.create(genconstsymtree(tconstsym(currpara.defaultvalue)),left);
  1375. { Ignore vs_hidden parameters }
  1376. repeat
  1377. currpara:=tparaitem(currpara.next);
  1378. until (not assigned(currpara)) or (not currpara.is_hidden);
  1379. end;
  1380. end;
  1381. { handle predefined procedures }
  1382. is_const:=(po_internconst in procdefinition.procoptions) and
  1383. ((block_type in [bt_const,bt_type]) or
  1384. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  1385. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  1386. begin
  1387. if assigned(left) then
  1388. begin
  1389. { ptr and settextbuf needs two args }
  1390. if assigned(tcallparanode(left).right) then
  1391. begin
  1392. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  1393. left:=nil;
  1394. end
  1395. else
  1396. begin
  1397. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  1398. tcallparanode(left).left:=nil;
  1399. end;
  1400. end
  1401. else
  1402. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  1403. result:=hpt;
  1404. goto errorexit;
  1405. end;
  1406. { ensure that the result type is set }
  1407. if not(cnf_restypeset in callnodeflags) then
  1408. begin
  1409. { constructors return their current class type, not the type where the
  1410. constructor is declared, this can be different because of inheritance }
  1411. if (procdefinition.proctypeoption=potype_constructor) and
  1412. assigned(methodpointer) and
  1413. assigned(methodpointer.resulttype.def) and
  1414. (methodpointer.resulttype.def.deftype=classrefdef) then
  1415. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype
  1416. else
  1417. resulttype:=procdefinition.rettype;
  1418. end
  1419. else
  1420. resulttype:=restype;
  1421. if resulttype.def.needs_inittable then
  1422. include(current_procinfo.flags,pi_needs_implicit_finally);
  1423. if assigned(methodpointer) then
  1424. begin
  1425. resulttypepass(methodpointer);
  1426. { direct call to inherited abstract method, then we
  1427. can already give a error in the compiler instead
  1428. of a runtime error }
  1429. if (nf_inherited in flags) and
  1430. (po_abstractmethod in procdefinition.procoptions) then
  1431. CGMessage(cg_e_cant_call_abstract_method);
  1432. { if an inherited con- or destructor should be }
  1433. { called in a con- or destructor then a warning }
  1434. { will be made }
  1435. { con- and destructors need a pointer to the vmt }
  1436. if (nf_inherited in flags) and
  1437. (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  1438. is_object(methodpointer.resulttype.def) and
  1439. not(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) then
  1440. CGMessage(cg_w_member_cd_call_from_method);
  1441. if methodpointer.nodetype<>typen then
  1442. begin
  1443. hpt:=methodpointer;
  1444. while assigned(hpt) and (hpt.nodetype in [subscriptn,vecn]) do
  1445. hpt:=tunarynode(hpt).left;
  1446. if (procdefinition.proctypeoption=potype_constructor) and
  1447. assigned(symtableproc) and
  1448. (symtableproc.symtabletype=withsymtable) and
  1449. (tnode(twithsymtable(symtableproc).withrefnode).nodetype=temprefn) then
  1450. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  1451. { R.Init then R will be initialized by the constructor,
  1452. Also allow it for simple loads }
  1453. if (procdefinition.proctypeoption=potype_constructor) or
  1454. ((hpt.nodetype=loadn) and
  1455. (
  1456. (methodpointer.resulttype.def.deftype=classrefdef) or
  1457. (
  1458. (methodpointer.resulttype.def.deftype=objectdef) and
  1459. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  1460. )
  1461. )
  1462. ) then
  1463. method_must_be_valid:=false
  1464. else
  1465. method_must_be_valid:=true;
  1466. set_varstate(methodpointer,vs_used,method_must_be_valid);
  1467. { The object is already used if it is called once }
  1468. if (hpt.nodetype=loadn) and
  1469. (tloadnode(hpt).symtableentry.typ=varsym) then
  1470. tvarsym(tloadnode(hpt).symtableentry).varstate:=vs_used;
  1471. end;
  1472. { if we are calling the constructor check for abstract
  1473. methods. Ignore inherited and member calls, because the
  1474. class is then already created }
  1475. if (procdefinition.proctypeoption=potype_constructor) and
  1476. not(nf_inherited in flags) and
  1477. not(nf_member_call in flags) then
  1478. verifyabstractcalls;
  1479. end
  1480. else
  1481. begin
  1482. { When this is method the methodpointer must be available }
  1483. if (right=nil) and
  1484. (procdefinition.owner.symtabletype=objectsymtable) then
  1485. internalerror(200305061);
  1486. end;
  1487. { Change loading of array of const to varargs }
  1488. if assigned(left) and
  1489. is_array_of_const(tparaitem(procdefinition.para.last).paratype.def) and
  1490. (procdefinition.proccalloption in [pocall_cppdecl,pocall_cdecl]) then
  1491. convert_carg_array_of_const;
  1492. { bind paraitems to the callparanodes and insert hidden parameters }
  1493. aktcallnode:=self;
  1494. bind_paraitem;
  1495. { methodpointer is only needed for virtual calls, and
  1496. it should then be loaded with the VMT }
  1497. if (po_virtualmethod in procdefinition.procoptions) and
  1498. not(assigned(methodpointer) and
  1499. (methodpointer.nodetype=typen)) then
  1500. begin
  1501. if not assigned(methodpointer) then
  1502. internalerror(200305063);
  1503. if (methodpointer.resulttype.def.deftype<>classrefdef) then
  1504. begin
  1505. methodpointer:=cloadvmtaddrnode.create(methodpointer);
  1506. resulttypepass(methodpointer);
  1507. end;
  1508. end
  1509. else
  1510. begin
  1511. { not needed anymore }
  1512. methodpointer.free;
  1513. methodpointer:=nil;
  1514. end;
  1515. { insert type conversions for parameters }
  1516. if assigned(left) then
  1517. tcallparanode(left).insert_typeconv(true);
  1518. errorexit:
  1519. aktcallnode:=oldcallnode;
  1520. end;
  1521. procedure tcallnode.order_parameters;
  1522. var
  1523. hp,hpcurr,hpnext,hpfirst,hpprev : tcallparanode;
  1524. currloc : tcgloc;
  1525. begin
  1526. hpfirst:=nil;
  1527. hpcurr:=tcallparanode(left);
  1528. while assigned(hpcurr) do
  1529. begin
  1530. { pull out }
  1531. hpnext:=tcallparanode(hpcurr.right);
  1532. { pull in at the correct place.
  1533. Used order:
  1534. 1. LOC_REFERENCE with smallest offset (x86 only)
  1535. 2. LOC_REFERENCE with most registers
  1536. 3. LOC_REGISTER with most registers }
  1537. currloc:=hpcurr.paraitem.paraloc[callerside].loc;
  1538. hpprev:=nil;
  1539. hp:=hpfirst;
  1540. while assigned(hp) do
  1541. begin
  1542. case currloc of
  1543. LOC_REFERENCE :
  1544. begin
  1545. case hp.paraitem.paraloc[callerside].loc of
  1546. LOC_REFERENCE :
  1547. begin
  1548. { Offset is calculated like:
  1549. sub esp,12
  1550. mov [esp+8],para3
  1551. mov [esp+4],para2
  1552. mov [esp],para1
  1553. call function
  1554. That means the for pushes the para with the
  1555. highest offset (see para3) needs to be pushed first
  1556. }
  1557. if (hpcurr.registersint>hp.registersint)
  1558. {$ifdef x86}
  1559. or (hpcurr.paraitem.paraloc[callerside].reference.offset>hp.paraitem.paraloc[callerside].reference.offset)
  1560. {$endif x86}
  1561. then
  1562. break;
  1563. end;
  1564. LOC_REGISTER,
  1565. LOC_FPUREGISTER :
  1566. break;
  1567. end;
  1568. end;
  1569. LOC_FPUREGISTER,
  1570. LOC_REGISTER :
  1571. begin
  1572. if (hp.paraitem.paraloc[callerside].loc=currloc) and
  1573. (hpcurr.registersint>hp.registersint) then
  1574. break;
  1575. end;
  1576. end;
  1577. hpprev:=hp;
  1578. hp:=tcallparanode(hp.right);
  1579. end;
  1580. hpcurr.right:=hp;
  1581. if assigned(hpprev) then
  1582. hpprev.right:=hpcurr
  1583. else
  1584. hpfirst:=hpcurr;
  1585. { next }
  1586. hpcurr:=hpnext;
  1587. end;
  1588. left:=hpfirst;
  1589. end;
  1590. function tcallnode.pass_1 : tnode;
  1591. {$ifdef m68k}
  1592. var
  1593. regi : tregister;
  1594. {$endif}
  1595. label
  1596. errorexit;
  1597. begin
  1598. result:=nil;
  1599. { calculate the parameter info for the procdef }
  1600. if not procdefinition.has_paraloc_info then
  1601. begin
  1602. procdefinition.requiredargarea:=paramanager.create_paraloc_info(procdefinition,callerside);
  1603. procdefinition.has_paraloc_info:=true;
  1604. end;
  1605. current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,procdefinition.requiredargarea);
  1606. { calculate the parameter info for varargs }
  1607. if assigned(varargsparas) then
  1608. current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,
  1609. paramanager.create_varargs_paraloc_info(procdefinition,varargsparas));
  1610. { work trough all parameters to get the register requirements }
  1611. if assigned(left) then
  1612. tcallparanode(left).det_registers;
  1613. { order parameters }
  1614. order_parameters;
  1615. { function result node }
  1616. if assigned(_funcretnode) then
  1617. firstpass(_funcretnode);
  1618. { procedure variable ? }
  1619. if assigned(right) then
  1620. begin
  1621. firstpass(right);
  1622. { procedure does a call }
  1623. if not (block_type in [bt_const,bt_type]) then
  1624. include(current_procinfo.flags,pi_do_call);
  1625. end
  1626. else
  1627. { not a procedure variable }
  1628. begin
  1629. { calc the correture value for the register }
  1630. { handle predefined procedures }
  1631. if (procdefinition.proccalloption=pocall_inline) then
  1632. begin
  1633. { inherit flags }
  1634. current_procinfo.flags:=current_procinfo.flags+((procdefinition as tprocdef).inlininginfo^.flags*inherited_inlining_flags);
  1635. if assigned(methodpointer) then
  1636. CGMessage(cg_e_unable_inline_object_methods);
  1637. if assigned(right) then
  1638. CGMessage(cg_e_unable_inline_procvar);
  1639. if not assigned(inlinecode) then
  1640. begin
  1641. if assigned(tprocdef(procdefinition).inlininginfo^.code) then
  1642. inlinecode:=tprocdef(procdefinition).inlininginfo^.code.getcopy
  1643. else
  1644. CGMessage(cg_e_no_code_for_inline_stored);
  1645. if assigned(inlinecode) then
  1646. begin
  1647. { consider it has not inlined if called
  1648. again inside the args }
  1649. procdefinition.proccalloption:=pocall_default;
  1650. firstpass(inlinecode);
  1651. end;
  1652. end;
  1653. end
  1654. else
  1655. begin
  1656. if not (block_type in [bt_const,bt_type]) then
  1657. include(current_procinfo.flags,pi_do_call);
  1658. end;
  1659. end;
  1660. { get a register for the return value }
  1661. if (not is_void(resulttype.def)) then
  1662. begin
  1663. if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
  1664. begin
  1665. expectloc:=LOC_REFERENCE;
  1666. end
  1667. else
  1668. { for win32 records returned in EDX:EAX, we
  1669. move them to memory after ... }
  1670. if (resulttype.def.deftype=recorddef) then
  1671. begin
  1672. expectloc:=LOC_CREFERENCE;
  1673. end
  1674. else
  1675. { ansi/widestrings must be registered, so we can dispose them }
  1676. if is_ansistring(resulttype.def) or
  1677. is_widestring(resulttype.def) then
  1678. begin
  1679. expectloc:=LOC_CREFERENCE;
  1680. registersint:=1;
  1681. end
  1682. else
  1683. { we have only to handle the result if it is used }
  1684. if (nf_return_value_used in flags) then
  1685. begin
  1686. case resulttype.def.deftype of
  1687. enumdef,
  1688. orddef :
  1689. begin
  1690. if (procdefinition.proctypeoption=potype_constructor) then
  1691. begin
  1692. expectloc:=LOC_REGISTER;
  1693. registersint:=1;
  1694. end
  1695. else
  1696. begin
  1697. expectloc:=LOC_REGISTER;
  1698. if is_64bit(resulttype.def) then
  1699. registersint:=2
  1700. else
  1701. registersint:=1;
  1702. end;
  1703. end;
  1704. floatdef :
  1705. begin
  1706. expectloc:=LOC_FPUREGISTER;
  1707. {$ifdef cpufpemu}
  1708. if (cs_fp_emulation in aktmoduleswitches) then
  1709. registersint:=1
  1710. else
  1711. {$endif cpufpemu}
  1712. {$ifdef m68k}
  1713. if (tfloatdef(resulttype.def).typ=s32real) then
  1714. registersint:=1
  1715. else
  1716. {$endif m68k}
  1717. registersfpu:=1;
  1718. end;
  1719. else
  1720. begin
  1721. expectloc:=LOC_REGISTER;
  1722. registersint:=1;
  1723. end;
  1724. end;
  1725. end
  1726. else
  1727. expectloc:=LOC_VOID;
  1728. end
  1729. else
  1730. expectloc:=LOC_VOID;
  1731. {$ifdef m68k}
  1732. { we need one more address register for virtual calls on m68k }
  1733. if (po_virtualmethod in procdefinition.procoptions) then
  1734. inc(registersint);
  1735. {$endif m68k}
  1736. { a fpu can be used in any procedure !! }
  1737. {$ifdef i386}
  1738. registersfpu:=procdefinition.fpu_used;
  1739. {$endif i386}
  1740. { if this is a call to a method calc the registers }
  1741. if (methodpointer<>nil) then
  1742. begin
  1743. if methodpointer.nodetype<>typen then
  1744. begin
  1745. firstpass(methodpointer);
  1746. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  1747. registersint:=max(methodpointer.registersint,registersint);
  1748. {$ifdef SUPPORT_MMX }
  1749. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  1750. {$endif SUPPORT_MMX}
  1751. end;
  1752. end;
  1753. { determine the registers of the procedure variable }
  1754. { is this OK for inlined procs also ?? (PM) }
  1755. if assigned(inlinecode) then
  1756. begin
  1757. registersfpu:=max(inlinecode.registersfpu,registersfpu);
  1758. registersint:=max(inlinecode.registersint,registersint);
  1759. {$ifdef SUPPORT_MMX}
  1760. registersmmx:=max(inlinecode.registersmmx,registersmmx);
  1761. {$endif SUPPORT_MMX}
  1762. end;
  1763. { determine the registers of the procedure variable }
  1764. { is this OK for inlined procs also ?? (PM) }
  1765. if assigned(right) then
  1766. begin
  1767. registersfpu:=max(right.registersfpu,registersfpu);
  1768. registersint:=max(right.registersint,registersint);
  1769. {$ifdef SUPPORT_MMX}
  1770. registersmmx:=max(right.registersmmx,registersmmx);
  1771. {$endif SUPPORT_MMX}
  1772. end;
  1773. { determine the registers of the procedure }
  1774. if assigned(left) then
  1775. begin
  1776. registersfpu:=max(left.registersfpu,registersfpu);
  1777. registersint:=max(left.registersint,registersint);
  1778. {$ifdef SUPPORT_MMX}
  1779. registersmmx:=max(left.registersmmx,registersmmx);
  1780. {$endif SUPPORT_MMX}
  1781. end;
  1782. errorexit:
  1783. if assigned(inlinecode) then
  1784. procdefinition.proccalloption:=pocall_inline;
  1785. end;
  1786. {$ifdef state_tracking}
  1787. function Tcallnode.track_state_pass(exec_known:boolean):boolean;
  1788. var hp:Tcallparanode;
  1789. value:Tnode;
  1790. begin
  1791. track_state_pass:=false;
  1792. hp:=Tcallparanode(left);
  1793. while assigned(hp) do
  1794. begin
  1795. if left.track_state_pass(exec_known) then
  1796. begin
  1797. left.resulttype.def:=nil;
  1798. do_resulttypepass(left);
  1799. end;
  1800. value:=aktstate.find_fact(hp.left);
  1801. if value<>nil then
  1802. begin
  1803. track_state_pass:=true;
  1804. hp.left.destroy;
  1805. hp.left:=value.getcopy;
  1806. do_resulttypepass(hp.left);
  1807. end;
  1808. hp:=Tcallparanode(hp.right);
  1809. end;
  1810. end;
  1811. {$endif}
  1812. function tcallnode.para_count:longint;
  1813. var
  1814. ppn : tcallparanode;
  1815. begin
  1816. result:=0;
  1817. ppn:=tcallparanode(left);
  1818. while assigned(ppn) do
  1819. begin
  1820. if not(assigned(ppn.paraitem) and
  1821. ppn.paraitem.is_hidden) then
  1822. inc(result);
  1823. ppn:=tcallparanode(ppn.right);
  1824. end;
  1825. end;
  1826. function tcallnode.docompare(p: tnode): boolean;
  1827. begin
  1828. docompare :=
  1829. inherited docompare(p) and
  1830. (symtableprocentry = tcallnode(p).symtableprocentry) and
  1831. (procdefinition = tcallnode(p).procdefinition) and
  1832. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  1833. (((cnf_restypeset in callnodeflags) and (cnf_restypeset in tcallnode(p).callnodeflags) and
  1834. (equal_defs(restype.def,tcallnode(p).restype.def))) or
  1835. (not(cnf_restypeset in callnodeflags) and not(cnf_restypeset in tcallnode(p).callnodeflags)));
  1836. end;
  1837. procedure tcallnode.printnodedata(var t:text);
  1838. begin
  1839. if assigned(procdefinition) and
  1840. (procdefinition.deftype=procdef) then
  1841. writeln(t,printnodeindention,'proc = ',tprocdef(procdefinition).fullprocname(true))
  1842. else
  1843. begin
  1844. if assigned(symtableprocentry) then
  1845. writeln(t,printnodeindention,'proc = ',symtableprocentry.name)
  1846. else
  1847. writeln(t,printnodeindention,'proc = <nil>');
  1848. end;
  1849. printnode(t,methodpointer);
  1850. printnode(t,right);
  1851. printnode(t,left);
  1852. end;
  1853. begin
  1854. ccallnode:=tcallnode;
  1855. ccallparanode:=tcallparanode;
  1856. end.
  1857. {
  1858. $Log$
  1859. Revision 1.233 2004-05-12 13:21:09 karoly
  1860. * few small changes to add syscall support to M68k/Amiga target
  1861. Revision 1.232 2004/05/01 22:05:01 florian
  1862. + added lib support for Amiga/MorphOS syscalls
  1863. Revision 1.231 2004/03/14 20:07:13 peter
  1864. * removed unused paravisible
  1865. Revision 1.230 2004/03/04 17:25:16 peter
  1866. * fix check for parameter length when calling procvar, broken by the
  1867. previous default parameter for procvar fix
  1868. Revision 1.229 2004/02/26 16:09:49 peter
  1869. * fix procvars with default paras
  1870. Revision 1.228 2004/02/24 16:12:39 peter
  1871. * operator overload chooses rewrite
  1872. * overload choosing is now generic and moved to htypechk
  1873. Revision 1.227 2004/02/20 21:55:59 peter
  1874. * procvar cleanup
  1875. Revision 1.226 2004/02/19 17:07:42 florian
  1876. * fixed arg. area calculation
  1877. Revision 1.225 2004/02/13 15:42:21 peter
  1878. * compare_defs_ext has now a options argument
  1879. * fixes for variants
  1880. Revision 1.224 2004/02/12 15:54:03 peter
  1881. * make extcycle is working again
  1882. Revision 1.223 2004/02/05 01:24:08 florian
  1883. * several fixes to compile x86-64 system
  1884. Revision 1.222 2004/02/03 22:32:54 peter
  1885. * renamed xNNbittype to xNNinttype
  1886. * renamed registers32 to registersint
  1887. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  1888. Revision 1.221 2004/01/26 16:12:27 daniel
  1889. * reginfo now also only allocated during register allocation
  1890. * third round of gdb cleanups: kick out most of concatstabto
  1891. Revision 1.220 2004/01/15 15:16:18 daniel
  1892. * Some minor stuff
  1893. * Managed to eliminate speed effects of string compression
  1894. Revision 1.219 2004/01/14 17:53:58 peter
  1895. * ignore hidden parameters when default parameters are used
  1896. Revision 1.218 2004/01/11 23:56:19 daniel
  1897. * Experiment: Compress strings to save memory
  1898. Did not save a single byte of mem; clearly the core size is boosted by
  1899. temporary memory usage...
  1900. Revision 1.217 2003/12/28 22:09:12 florian
  1901. + setting of bit 6 of cr for c var args on ppc implemented
  1902. Revision 1.216 2003/12/21 19:42:42 florian
  1903. * fixed ppc inlining stuff
  1904. * fixed wrong unit writing
  1905. + added some sse stuff
  1906. Revision 1.215 2003/12/20 12:38:51 florian
  1907. * some x86-64 compilation fixe
  1908. Revision 1.214 2003/12/16 22:09:31 florian
  1909. * better inheritence of procinfo flags of inlined procedures
  1910. Revision 1.213 2003/12/16 21:29:24 florian
  1911. + inlined procedures inherit procinfo flags
  1912. Revision 1.212 2003/12/08 22:37:28 peter
  1913. * paralength is private again
  1914. Revision 1.211 2003/12/08 16:34:23 peter
  1915. * varargspara is left-right, so adding paraitems needs insert
  1916. instead of concat
  1917. Revision 1.210 2003/12/01 18:44:15 peter
  1918. * fixed some crashes
  1919. * fixed varargs and register calling probs
  1920. Revision 1.209 2003/11/28 17:24:22 peter
  1921. * reversed offset calculation for caller side so it works
  1922. correctly for interfaces
  1923. Revision 1.208 2003/11/23 17:05:15 peter
  1924. * register calling is left-right
  1925. * parameter ordering
  1926. * left-right calling inserts result parameter last
  1927. Revision 1.207 2003/11/10 22:02:52 peter
  1928. * cross unit inlining fixed
  1929. Revision 1.206 2003/11/10 19:09:29 peter
  1930. * procvar default value support
  1931. Revision 1.205 2003/11/06 15:54:32 peter
  1932. * fixed calling classmethod for other object from classmethod
  1933. Revision 1.204 2003/11/01 16:17:48 peter
  1934. * use explicit typecast when generating the high value
  1935. Revision 1.203 2003/10/31 15:52:58 peter
  1936. * support creating classes using <class of tobject>.create
  1937. Revision 1.202 2003/10/30 16:23:13 peter
  1938. * don't search for overloads in parents for constructors
  1939. Revision 1.201 2003/10/29 22:01:20 florian
  1940. * fixed passing of dyn. arrays to open array parameters
  1941. Revision 1.200 2003/10/23 14:44:07 peter
  1942. * splitted buildderef and buildderefimpl to fix interface crc
  1943. calculation
  1944. Revision 1.199 2003/10/22 20:40:00 peter
  1945. * write derefdata in a separate ppu entry
  1946. Revision 1.198 2003/10/21 18:17:02 peter
  1947. * only search for overloaded constructors in classes
  1948. Revision 1.197 2003/10/21 15:14:55 peter
  1949. * also search in parents for overloads when calling a constructor
  1950. Revision 1.196 2003/10/13 14:05:12 peter
  1951. * removed is_visible_for_proc
  1952. * search also for class overloads when finding interface
  1953. implementations
  1954. Revision 1.195 2003/10/09 21:31:37 daniel
  1955. * Register allocator splitted, ans abstract now
  1956. Revision 1.194 2003/10/09 15:00:13 florian
  1957. * fixed constructor call in class methods
  1958. Revision 1.193 2003/10/08 19:19:45 peter
  1959. * set_varstate cleanup
  1960. Revision 1.192 2003/10/07 21:14:32 peter
  1961. * compare_paras() has a parameter to ignore hidden parameters
  1962. * cross unit overload searching ignores hidden parameters when
  1963. comparing parameter lists. Now function(string):string is
  1964. not overriden with procedure(string) which has the same visible
  1965. parameter list
  1966. Revision 1.191 2003/10/05 21:21:52 peter
  1967. * c style array of const generates callparanodes
  1968. * varargs paraloc fixes
  1969. Revision 1.190 2003/10/05 12:54:17 peter
  1970. * don't check for abstract methods when the constructor is called
  1971. by inherited
  1972. * fix private member error instead of wrong number of parameters
  1973. Revision 1.189 2003/10/04 19:00:52 florian
  1974. * fixed TP 6.0 styled inherited call; fixes IDE with 1.1
  1975. Revision 1.188 2003/10/03 22:00:33 peter
  1976. * parameter alignment fixes
  1977. Revision 1.187 2003/10/03 14:44:38 peter
  1978. * fix IE when callnode was firstpassed twice
  1979. Revision 1.186 2003/10/02 21:13:46 peter
  1980. * protected visibility fixes
  1981. Revision 1.185 2003/10/01 20:34:48 peter
  1982. * procinfo unit contains tprocinfo
  1983. * cginfo renamed to cgbase
  1984. * moved cgmessage to verbose
  1985. * fixed ppc and sparc compiles
  1986. Revision 1.184 2003/09/28 21:44:55 peter
  1987. * fix check that filedef needs var para
  1988. Revision 1.183 2003/09/28 17:55:03 peter
  1989. * parent framepointer changed to hidden parameter
  1990. * tloadparentfpnode added
  1991. Revision 1.182 2003/09/25 21:28:00 peter
  1992. * parameter fixes
  1993. Revision 1.181 2003/09/23 17:56:05 peter
  1994. * locals and paras are allocated in the code generation
  1995. * tvarsym.localloc contains the location of para/local when
  1996. generating code for the current procedure
  1997. Revision 1.180 2003/09/16 16:17:01 peter
  1998. * varspez in calls to push_addr_param
  1999. Revision 1.179 2003/09/07 22:09:35 peter
  2000. * preparations for different default calling conventions
  2001. * various RA fixes
  2002. Revision 1.178 2003/09/06 22:27:08 florian
  2003. * fixed web bug 2669
  2004. * cosmetic fix in printnode
  2005. * tobjectdef.gettypename implemented
  2006. Revision 1.177 2003/09/03 15:55:00 peter
  2007. * NEWRA branch merged
  2008. Revision 1.176.2.3 2003/08/31 21:07:44 daniel
  2009. * callparatemp ripped
  2010. Revision 1.176.2.2 2003/08/27 20:23:55 peter
  2011. * remove old ra code
  2012. Revision 1.176.2.1 2003/08/27 19:55:54 peter
  2013. * first tregister patch
  2014. Revision 1.176 2003/08/23 18:42:57 peter
  2015. * only check for size matches when parameter is enum,ord,float
  2016. Revision 1.175 2003/08/10 17:25:23 peter
  2017. * fixed some reported bugs
  2018. Revision 1.174 2003/07/25 09:54:57 jonas
  2019. * fixed bogus abstract method warnings
  2020. Revision 1.173 2003/06/25 18:31:23 peter
  2021. * sym,def resolving partly rewritten to support also parent objects
  2022. not directly available through the uses clause
  2023. Revision 1.172 2003/06/17 16:34:44 jonas
  2024. * lots of newra fixes (need getfuncretparaloc implementation for i386)!
  2025. * renamed all_intregisters to volatile_intregisters and made it
  2026. processor dependent
  2027. Revision 1.171 2003/06/15 16:47:33 jonas
  2028. * fixed revious commit
  2029. Revision 1.170 2003/06/15 15:10:57 jonas
  2030. * callparatemp fix: if a threadvar is a parameter, that paramter also
  2031. does a call
  2032. Revision 1.169 2003/06/13 21:19:30 peter
  2033. * current_procdef removed, use current_procinfo.procdef instead
  2034. Revision 1.168 2003/06/08 20:01:53 jonas
  2035. * optimized assignments with on the right side a function that returns
  2036. an ansi- or widestring
  2037. Revision 1.167 2003/06/08 18:27:15 jonas
  2038. + ability to change the location of a ttempref node with changelocation()
  2039. method. Useful to use instead of copying the contents from one temp to
  2040. another
  2041. + some shortstring optimizations in tassignmentnode that avoid some
  2042. copying (required some shortstring optimizations to be moved from
  2043. resulttype to firstpass, because they work on callnodes and string
  2044. addnodes are only changed to callnodes in the firstpass)
  2045. * allow setting/changing the funcretnode of callnodes after the
  2046. resulttypepass has been done, funcretnode is now a property
  2047. (all of the above should have a quite big effect on callparatemp)
  2048. Revision 1.166 2003/06/08 11:42:33 peter
  2049. * creating class with abstract call checking fixed
  2050. * there will be only one warning for each class, the methods
  2051. are listed as hint
  2052. Revision 1.165 2003/06/07 20:26:32 peter
  2053. * re-resolving added instead of reloading from ppu
  2054. * tderef object added to store deref info for resolving
  2055. Revision 1.164 2003/06/03 21:05:48 peter
  2056. * fix check for procedure without parameters
  2057. * calling constructor as member will not allocate memory
  2058. Revision 1.163 2003/06/03 13:01:59 daniel
  2059. * Register allocator finished
  2060. Revision 1.162 2003/05/26 21:17:17 peter
  2061. * procinlinenode removed
  2062. * aktexit2label removed, fast exit removed
  2063. + tcallnode.inlined_pass_2 added
  2064. Revision 1.161 2003/05/25 11:34:17 peter
  2065. * methodpointer self pushing fixed
  2066. Revision 1.160 2003/05/25 08:59:16 peter
  2067. * inline fixes
  2068. Revision 1.159 2003/05/24 17:16:37 jonas
  2069. * added missing firstpass for callparatemp code
  2070. Revision 1.158 2003/05/23 14:27:35 peter
  2071. * remove some unit dependencies
  2072. * current_procinfo changes to store more info
  2073. Revision 1.157 2003/05/17 14:05:58 jonas
  2074. * fixed callparatemp for ansi/widestring and interfacecoms
  2075. Revision 1.156 2003/05/17 13:30:08 jonas
  2076. * changed tt_persistant to tt_persistent :)
  2077. * tempcreatenode now doesn't accept a boolean anymore for persistent
  2078. temps, but a ttemptype, so you can also create ansistring temps etc
  2079. Revision 1.155 2003/05/16 14:33:31 peter
  2080. * regvar fixes
  2081. Revision 1.154 2003/05/14 19:35:50 jonas
  2082. * fixed callparatemp so it works with vs_var, vs_out and formal const
  2083. parameters
  2084. Revision 1.153 2003/05/13 20:53:41 peter
  2085. * constructors return in register
  2086. Revision 1.152 2003/05/13 15:18:49 peter
  2087. * fixed various crashes
  2088. Revision 1.151 2003/05/11 21:37:03 peter
  2089. * moved implicit exception frame from ncgutil to psub
  2090. * constructor/destructor helpers moved from cobj/ncgutil to psub
  2091. Revision 1.150 2003/05/11 14:45:12 peter
  2092. * tloadnode does not support objectsymtable,withsymtable anymore
  2093. * withnode cleanup
  2094. * direct with rewritten to use temprefnode
  2095. Revision 1.149 2003/05/09 17:47:02 peter
  2096. * self moved to hidden parameter
  2097. * removed hdisposen,hnewn,selfn
  2098. Revision 1.148 2003/05/05 14:53:16 peter
  2099. * vs_hidden replaced by is_hidden boolean
  2100. Revision 1.147 2003/04/27 11:21:33 peter
  2101. * aktprocdef renamed to current_procinfo.procdef
  2102. * procinfo renamed to current_procinfo
  2103. * procinfo will now be stored in current_module so it can be
  2104. cleaned up properly
  2105. * gen_main_procsym changed to create_main_proc and release_main_proc
  2106. to also generate a tprocinfo structure
  2107. * fixed unit implicit initfinal
  2108. Revision 1.146 2003/04/27 09:08:44 jonas
  2109. * do callparatemp stuff only after the parameters have been firstpassed,
  2110. because some nodes are turned into calls during the firstpass
  2111. Revision 1.145 2003/04/27 07:29:50 peter
  2112. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2113. a new procdef declaration
  2114. * aktprocsym removed
  2115. * lexlevel removed, use symtable.symtablelevel instead
  2116. * implicit init/final code uses the normal genentry/genexit
  2117. * funcret state checking updated for new funcret handling
  2118. Revision 1.144 2003/04/25 20:59:33 peter
  2119. * removed funcretn,funcretsym, function result is now in varsym
  2120. and aliases for result and function name are added using absolutesym
  2121. * vs_hidden parameter for funcret passed in parameter
  2122. * vs_hidden fixes
  2123. * writenode changed to printnode and released from extdebug
  2124. * -vp option added to generate a tree.log with the nodetree
  2125. * nicer printnode for statements, callnode
  2126. Revision 1.143 2002/04/25 20:15:39 florian
  2127. * block nodes within expressions shouldn't release the used registers,
  2128. fixed using a flag till the new rg is ready
  2129. Revision 1.142 2003/04/23 20:16:04 peter
  2130. + added currency support based on int64
  2131. + is_64bit for use in cg units instead of is_64bitint
  2132. * removed cgmessage from n386add, replace with internalerrors
  2133. Revision 1.141 2003/04/23 13:21:06 peter
  2134. * fix warning for calling constructor inside constructor
  2135. Revision 1.140 2003/04/23 12:35:34 florian
  2136. * fixed several issues with powerpc
  2137. + applied a patch from Jonas for nested function calls (PowerPC only)
  2138. * ...
  2139. Revision 1.139 2003/04/22 23:50:22 peter
  2140. * firstpass uses expectloc
  2141. * checks if there are differences between the expectloc and
  2142. location.loc from secondpass in EXTDEBUG
  2143. Revision 1.138 2003/04/22 09:53:33 peter
  2144. * fix insert_typeconv to handle new varargs which don't have a
  2145. paraitem set
  2146. Revision 1.137 2003/04/11 16:02:05 peter
  2147. * don't firstpass typen
  2148. Revision 1.136 2003/04/11 15:51:04 peter
  2149. * support subscript,vec for setting methodpointer varstate
  2150. Revision 1.135 2003/04/10 17:57:52 peter
  2151. * vs_hidden released
  2152. Revision 1.134 2003/04/07 11:58:22 jonas
  2153. * more vs_invisible fixes
  2154. Revision 1.133 2003/04/07 10:40:21 jonas
  2155. * fixed VS_HIDDEN for high parameter so it works again
  2156. Revision 1.132 2003/04/04 15:38:56 peter
  2157. * moved generic code from n386cal to ncgcal, i386 now also
  2158. uses the generic ncgcal
  2159. Revision 1.131 2003/03/17 18:54:23 peter
  2160. * fix missing self setting for method to procvar conversion in
  2161. tp_procvar mode
  2162. Revision 1.130 2003/03/17 16:54:41 peter
  2163. * support DefaultHandler and anonymous inheritance fixed
  2164. for message methods
  2165. Revision 1.129 2003/03/17 15:54:22 peter
  2166. * store symoptions also for procdef
  2167. * check symoptions (private,public) when calculating possible
  2168. overload candidates
  2169. Revision 1.128 2003/02/19 22:00:14 daniel
  2170. * Code generator converted to new register notation
  2171. - Horribily outdated todo.txt removed
  2172. Revision 1.127 2003/01/16 22:13:52 peter
  2173. * convert_l3 convertlevel added. This level is used for conversions
  2174. where information can be lost like converting widestring->ansistring
  2175. or dword->byte
  2176. Revision 1.126 2003/01/15 01:44:32 peter
  2177. * merged methodpointer fixes from 1.0.x
  2178. Revision 1.125 2003/01/12 17:52:07 peter
  2179. * only check for auto inherited in objectsymtable
  2180. Revision 1.124 2003/01/09 21:45:46 peter
  2181. * extended information about overloaded candidates when compiled
  2182. with EXTDEBUG
  2183. Revision 1.123 2002/12/26 18:24:33 jonas
  2184. * fixed check for whether or not a high parameter was already generated
  2185. * no type checking/conversions for invisible parameters
  2186. Revision 1.122 2002/12/15 22:50:00 florian
  2187. + some stuff for the new hidden parameter handling added
  2188. Revision 1.121 2002/12/15 21:34:15 peter
  2189. * give sign difference between ordinals a small penalty. This is
  2190. needed to get word->[longword|longint] working
  2191. Revision 1.120 2002/12/15 21:30:12 florian
  2192. * tcallnode.paraitem introduced, all references to defcoll removed
  2193. Revision 1.119 2002/12/15 20:59:58 peter
  2194. * fix crash with default parameters
  2195. Revision 1.118 2002/12/15 11:26:02 peter
  2196. * ignore vs_hidden parameters when choosing overloaded proc
  2197. Revision 1.117 2002/12/11 22:42:28 peter
  2198. * tcallnode.det_resulttype rewrite, merged code from nice_ncal and
  2199. the old code. The new code collects the information about possible
  2200. candidates only once resultting in much less calls to type compare
  2201. routines
  2202. Revision 1.116 2002/12/07 14:27:07 carl
  2203. * 3% memory optimization
  2204. * changed some types
  2205. + added type checking with different size for call node and for
  2206. parameters
  2207. Revision 1.115 2002/12/06 17:51:10 peter
  2208. * merged cdecl and array fixes
  2209. Revision 1.114 2002/12/06 16:56:58 peter
  2210. * only compile cs_fp_emulation support when cpufpuemu is defined
  2211. * define cpufpuemu for m68k only
  2212. Revision 1.113 2002/11/27 20:04:38 peter
  2213. * cdecl array of const fixes
  2214. Revision 1.112 2002/11/27 15:33:46 peter
  2215. * the never ending story of tp procvar hacks
  2216. Revision 1.111 2002/11/27 02:31:17 peter
  2217. * fixed inlinetree parsing in det_resulttype
  2218. Revision 1.110 2002/11/25 18:43:32 carl
  2219. - removed the invalid if <> checking (Delphi is strange on this)
  2220. + implemented abstract warning on instance creation of class with
  2221. abstract methods.
  2222. * some error message cleanups
  2223. Revision 1.109 2002/11/25 17:43:17 peter
  2224. * splitted defbase in defutil,symutil,defcmp
  2225. * merged isconvertable and is_equal into compare_defs(_ext)
  2226. * made operator search faster by walking the list only once
  2227. Revision 1.108 2002/11/18 17:31:54 peter
  2228. * pass proccalloption to ret_in_xxx and push_xxx functions
  2229. Revision 1.107 2002/11/15 01:58:50 peter
  2230. * merged changes from 1.0.7 up to 04-11
  2231. - -V option for generating bug report tracing
  2232. - more tracing for option parsing
  2233. - errors for cdecl and high()
  2234. - win32 import stabs
  2235. - win32 records<=8 are returned in eax:edx (turned off by default)
  2236. - heaptrc update
  2237. - more info for temp management in .s file with EXTDEBUG
  2238. Revision 1.106 2002/10/14 18:20:30 carl
  2239. * var parameter checking for classes and interfaces in Delphi mode
  2240. Revision 1.105 2002/10/06 21:02:17 peter
  2241. * fixed limit checking for qword
  2242. Revision 1.104 2002/10/05 15:15:45 peter
  2243. * Write unknwon compiler proc using Comment and only in Extdebug
  2244. Revision 1.103 2002/10/05 12:43:25 carl
  2245. * fixes for Delphi 6 compilation
  2246. (warning : Some features do not work under Delphi)
  2247. Revision 1.102 2002/10/05 00:48:57 peter
  2248. * support inherited; support for overload as it is handled by
  2249. delphi. This is only for delphi mode as it is working is
  2250. undocumented and hard to predict what is done
  2251. Revision 1.101 2002/09/16 14:11:12 peter
  2252. * add argument to equal_paras() to support default values or not
  2253. Revision 1.100 2002/09/15 17:49:59 peter
  2254. * don't have strict var parameter checking for procedures in the
  2255. system unit
  2256. Revision 1.99 2002/09/09 19:30:34 peter
  2257. * don't allow convertable parameters for var and out parameters in
  2258. delphi and tp mode
  2259. Revision 1.98 2002/09/07 15:25:02 peter
  2260. * old logs removed and tabs fixed
  2261. Revision 1.97 2002/09/07 12:16:05 carl
  2262. * second part bug report 1996 fix, testrange in cordconstnode
  2263. only called if option is set (also make parsing a tiny faster)
  2264. Revision 1.96 2002/09/05 14:53:41 peter
  2265. * fixed old callnode.det_resulttype code
  2266. * old ncal code is default again
  2267. Revision 1.95 2002/09/03 21:32:49 daniel
  2268. * Small bugfix for procdef selection
  2269. Revision 1.94 2002/09/03 19:27:22 daniel
  2270. * Activated new ncal code
  2271. Revision 1.93 2002/09/03 16:26:26 daniel
  2272. * Make Tprocdef.defs protected
  2273. Revision 1.92 2002/09/01 13:28:37 daniel
  2274. - write_access fields removed in favor of a flag
  2275. Revision 1.91 2002/09/01 12:14:15 peter
  2276. * remove debug line
  2277. * containself methods can be called directly
  2278. Revision 1.90 2002/09/01 08:01:16 daniel
  2279. * Removed sets from Tcallnode.det_resulttype
  2280. + Added read/write notifications of variables. These will be usefull
  2281. for providing information for several optimizations. For example
  2282. the value of the loop variable of a for loop does matter is the
  2283. variable is read after the for loop, but if it's no longer used
  2284. or written, it doesn't matter and this can be used to optimize
  2285. the loop code generation.
  2286. Revision 1.89 2002/08/23 16:13:16 peter
  2287. * also firstpass funcretrefnode if available. This was breaking the
  2288. asnode compilerproc code
  2289. Revision 1.88 2002/08/20 10:31:26 daniel
  2290. * Tcallnode.det_resulttype rewritten
  2291. Revision 1.87 2002/08/19 19:36:42 peter
  2292. * More fixes for cross unit inlining, all tnodes are now implemented
  2293. * Moved pocall_internconst to po_internconst because it is not a
  2294. calling type at all and it conflicted when inlining of these small
  2295. functions was requested
  2296. Revision 1.86 2002/08/17 22:09:44 florian
  2297. * result type handling in tcgcal.pass_2 overhauled
  2298. * better tnode.dowrite
  2299. * some ppc stuff fixed
  2300. Revision 1.85 2002/08/17 09:23:34 florian
  2301. * first part of current_procinfo rewrite
  2302. Revision 1.84 2002/08/16 14:24:57 carl
  2303. * issameref() to test if two references are the same (then emit no opcodes)
  2304. + ret_in_reg to replace ret_in_acc
  2305. (fix some register allocation bugs at the same time)
  2306. + save_std_register now has an extra parameter which is the
  2307. usedinproc registers
  2308. Revision 1.83 2002/07/20 11:57:53 florian
  2309. * types.pas renamed to defbase.pas because D6 contains a types
  2310. unit so this would conflicts if D6 programms are compiled
  2311. + Willamette/SSE2 instructions to assembler added
  2312. Revision 1.82 2002/07/19 11:41:35 daniel
  2313. * State tracker work
  2314. * The whilen and repeatn are now completely unified into whilerepeatn. This
  2315. allows the state tracker to change while nodes automatically into
  2316. repeat nodes.
  2317. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  2318. 'not(a>b)' is optimized into 'a<=b'.
  2319. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  2320. by removing the notn and later switchting the true and falselabels. The
  2321. same is done with 'repeat until not a'.
  2322. Revision 1.81 2002/07/15 18:03:14 florian
  2323. * readded removed changes
  2324. Revision 1.79 2002/07/11 14:41:27 florian
  2325. * start of the new generic parameter handling
  2326. Revision 1.80 2002/07/14 18:00:43 daniel
  2327. + Added the beginning of a state tracker. This will track the values of
  2328. variables through procedures and optimize things away.
  2329. Revision 1.78 2002/07/04 20:43:00 florian
  2330. * first x86-64 patches
  2331. }