ncal.pas 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987
  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. node,
  23. symbase,symtype,symsym,symdef,symtable;
  24. type
  25. tcallnode = class(tbinarynode)
  26. { the symbol containing the definition of the procedure }
  27. { to call }
  28. symtableprocentry : tprocsym;
  29. { the symtable containing symtableprocentry }
  30. symtableproc : tsymtable;
  31. { the definition of the procedure to call }
  32. procdefinition : tabstractprocdef;
  33. methodpointer : tnode;
  34. { separately specified resulttype for some compilerprocs (e.g. }
  35. { you can't have a function with an "array of char" resulttype }
  36. { the RTL) (JM) }
  37. restype: ttype;
  38. restypeset: boolean;
  39. { function return reference node, this is used to pass an already
  40. allocated reference for a ret_in_param return value }
  41. funcretrefnode : tnode;
  42. { only the processor specific nodes need to override this }
  43. { constructor }
  44. constructor create(l:tnode; v : tprocsym;st : tsymtable; mp : tnode);virtual;
  45. constructor createintern(const name: string; params: tnode);
  46. constructor createinternres(const name: string; params: tnode; const res: ttype);
  47. constructor createinternreturn(const name: string; params: tnode; returnnode : tnode);
  48. destructor destroy;override;
  49. function getcopy : tnode;override;
  50. procedure insertintolist(l : tnodelist);override;
  51. function pass_1 : tnode;override;
  52. function det_resulttype:tnode;override;
  53. function docompare(p: tnode): boolean; override;
  54. procedure set_procvar(procvar:tnode);
  55. end;
  56. tcallnodeclass = class of tcallnode;
  57. tcallparaflags = (
  58. { flags used by tcallparanode }
  59. cpf_exact_match_found,
  60. cpf_convlevel1found,
  61. cpf_convlevel2found,
  62. cpf_is_colon_para
  63. );
  64. tcallparanode = class(tbinarynode)
  65. callparaflags : set of tcallparaflags;
  66. hightree : tnode;
  67. { only the processor specific nodes need to override this }
  68. { constructor }
  69. constructor create(expr,next : tnode);virtual;
  70. destructor destroy;override;
  71. function getcopy : tnode;override;
  72. procedure insertintolist(l : tnodelist);override;
  73. procedure gen_high_tree(openstring:boolean);
  74. procedure get_paratype;
  75. procedure insert_typeconv(defcoll : tparaitem;do_count : boolean);
  76. procedure det_registers;
  77. procedure firstcallparan(defcoll : tparaitem;do_count : boolean);
  78. procedure secondcallparan(defcoll : tparaitem;
  79. push_from_left_to_right,inlined,is_cdecl : boolean;
  80. para_alignment,para_offset : longint);virtual;abstract;
  81. function docompare(p: tnode): boolean; override;
  82. end;
  83. tcallparanodeclass = class of tcallparanode;
  84. tprocinlinenode = class(tnode)
  85. inlinetree : tnode;
  86. inlineprocdef : tprocdef;
  87. retoffset,para_offset,para_size : longint;
  88. constructor create(callp,code : tnode);virtual;
  89. destructor destroy;override;
  90. function getcopy : tnode;override;
  91. procedure insertintolist(l : tnodelist);override;
  92. function pass_1 : tnode;override;
  93. function docompare(p: tnode): boolean; override;
  94. end;
  95. tprocinlinenodeclass = class of tprocinlinenode;
  96. function reverseparameters(p: tcallparanode): tcallparanode;
  97. var
  98. ccallnode : tcallnodeclass;
  99. ccallparanode : tcallparanodeclass;
  100. cprocinlinenode : tprocinlinenodeclass;
  101. implementation
  102. uses
  103. cutils,globtype,systems,
  104. verbose,globals,
  105. symconst,types,
  106. htypechk,pass_1,cpuinfo,cpubase,
  107. ncnv,nld,ninl,nadd,ncon,
  108. rgobj,cgbase
  109. ;
  110. {****************************************************************************
  111. HELPERS
  112. ****************************************************************************}
  113. function reverseparameters(p: tcallparanode): tcallparanode;
  114. var
  115. hp1, hp2: tcallparanode;
  116. begin
  117. hp1:=nil;
  118. while assigned(p) do
  119. begin
  120. { pull out }
  121. hp2:=p;
  122. p:=tcallparanode(p.right);
  123. { pull in }
  124. hp2.right:=hp1;
  125. hp1:=hp2;
  126. end;
  127. reverseparameters:=hp1;
  128. end;
  129. procedure search_class_overloads(aprocsym : tprocsym);
  130. { searches n in symtable of pd and all anchestors }
  131. var
  132. speedvalue : cardinal;
  133. srsym : tprocsym;
  134. s : string;
  135. found : boolean;
  136. srpdl,pdl : pprocdeflist;
  137. objdef : tobjectdef;
  138. begin
  139. if aprocsym.overloadchecked then
  140. exit;
  141. aprocsym.overloadchecked:=true;
  142. if (aprocsym.owner.symtabletype<>objectsymtable) then
  143. internalerror(200111021);
  144. objdef:=tobjectdef(aprocsym.owner.defowner);
  145. { we start in the parent }
  146. if not assigned(objdef.childof) then
  147. exit;
  148. objdef:=objdef.childof;
  149. s:=aprocsym.name;
  150. speedvalue:=getspeedvalue(s);
  151. while assigned(objdef) do
  152. begin
  153. srsym:=tprocsym(objdef.symtable.speedsearch(s,speedvalue));
  154. if assigned(srsym) then
  155. begin
  156. if (srsym.typ<>procsym) then
  157. internalerror(200111022);
  158. if srsym.is_visible_for_proc(aktprocdef) then
  159. begin
  160. srpdl:=srsym.defs;
  161. while assigned(srpdl) do
  162. begin
  163. found:=false;
  164. pdl:=aprocsym.defs;
  165. while assigned(pdl) do
  166. begin
  167. if equal_paras(pdl^.def.para,srpdl^.def.para,cp_value_equal_const) then
  168. begin
  169. found:=true;
  170. break;
  171. end;
  172. pdl:=pdl^.next;
  173. end;
  174. if not found then
  175. aprocsym.addprocdef(srpdl^.def);
  176. srpdl:=srpdl^.next;
  177. end;
  178. { we can stop if the overloads were already added
  179. for the found symbol }
  180. if srsym.overloadchecked then
  181. break;
  182. end;
  183. end;
  184. { next parent }
  185. objdef:=objdef.childof;
  186. end;
  187. end;
  188. {****************************************************************************
  189. TCALLPARANODE
  190. ****************************************************************************}
  191. constructor tcallparanode.create(expr,next : tnode);
  192. begin
  193. inherited create(callparan,expr,next);
  194. hightree:=nil;
  195. if assigned(expr) then
  196. expr.set_file_line(self);
  197. callparaflags:=[];
  198. end;
  199. destructor tcallparanode.destroy;
  200. begin
  201. hightree.free;
  202. inherited destroy;
  203. end;
  204. function tcallparanode.getcopy : tnode;
  205. var
  206. n : tcallparanode;
  207. begin
  208. n:=tcallparanode(inherited getcopy);
  209. n.callparaflags:=callparaflags;
  210. if assigned(hightree) then
  211. n.hightree:=hightree.getcopy
  212. else
  213. n.hightree:=nil;
  214. result:=n;
  215. end;
  216. procedure tcallparanode.insertintolist(l : tnodelist);
  217. begin
  218. end;
  219. procedure tcallparanode.get_paratype;
  220. var
  221. old_get_para_resulttype : boolean;
  222. old_array_constructor : boolean;
  223. begin
  224. inc(parsing_para_level);
  225. if assigned(right) then
  226. tcallparanode(right).get_paratype;
  227. old_array_constructor:=allow_array_constructor;
  228. old_get_para_resulttype:=get_para_resulttype;
  229. get_para_resulttype:=true;
  230. allow_array_constructor:=true;
  231. resulttypepass(left);
  232. get_para_resulttype:=old_get_para_resulttype;
  233. allow_array_constructor:=old_array_constructor;
  234. if codegenerror then
  235. resulttype:=generrortype
  236. else
  237. resulttype:=left.resulttype;
  238. dec(parsing_para_level);
  239. end;
  240. procedure tcallparanode.insert_typeconv(defcoll : tparaitem;do_count : boolean);
  241. var
  242. oldtype : ttype;
  243. {$ifdef extdebug}
  244. store_count_ref : boolean;
  245. {$endif def extdebug}
  246. p1 : tnode;
  247. begin
  248. inc(parsing_para_level);
  249. if not assigned(defcoll) then
  250. internalerror(200104261);
  251. {$ifdef extdebug}
  252. if do_count then
  253. begin
  254. store_count_ref:=count_ref;
  255. count_ref:=true;
  256. end;
  257. {$endif def extdebug}
  258. if assigned(right) then
  259. begin
  260. { if we are a para that belongs to varargs then keep
  261. the current defcoll }
  262. if (nf_varargs_para in flags) then
  263. tcallparanode(right).insert_typeconv(defcoll,do_count)
  264. else
  265. tcallparanode(right).insert_typeconv(tparaitem(defcoll.next),do_count);
  266. end;
  267. { Be sure to have the resulttype }
  268. if not assigned(left.resulttype.def) then
  269. resulttypepass(left);
  270. { Handle varargs directly, no typeconvs or typechecking needed }
  271. if (nf_varargs_para in flags) then
  272. begin
  273. { convert pascal to C types }
  274. case left.resulttype.def.deftype of
  275. stringdef :
  276. inserttypeconv(left,charpointertype);
  277. floatdef :
  278. inserttypeconv(left,s64floattype);
  279. end;
  280. set_varstate(left,true);
  281. resulttype:=left.resulttype;
  282. dec(parsing_para_level);
  283. exit;
  284. end;
  285. { Do we need arrayconstructor -> set conversion, then insert
  286. it here before the arrayconstructor node breaks the tree
  287. with its conversions of enum->ord }
  288. if (left.nodetype=arrayconstructorn) and
  289. (defcoll.paratype.def.deftype=setdef) then
  290. inserttypeconv(left,defcoll.paratype);
  291. { set some settings needed for arrayconstructor }
  292. if is_array_constructor(left.resulttype.def) then
  293. begin
  294. if is_array_of_const(defcoll.paratype.def) then
  295. begin
  296. if assigned(aktcallprocdef) and
  297. (aktcallprocdef.proccalloption in [pocall_cppdecl,pocall_cdecl]) and
  298. (po_external in aktcallprocdef.procoptions) then
  299. include(left.flags,nf_cargs);
  300. { force variant array }
  301. include(left.flags,nf_forcevaria);
  302. end
  303. else
  304. begin
  305. include(left.flags,nf_novariaallowed);
  306. { now that the resultting type is know we can insert the required
  307. typeconvs for the array constructor }
  308. tarrayconstructornode(left).force_type(tarraydef(defcoll.paratype.def).elementtype);
  309. end;
  310. end;
  311. { check if local proc/func is assigned to procvar }
  312. if left.resulttype.def.deftype=procvardef then
  313. test_local_to_procvar(tprocvardef(left.resulttype.def),defcoll.paratype.def);
  314. { generate the high() value tree }
  315. if not(assigned(aktcallprocdef) and
  316. (aktcallprocdef.proccalloption in [pocall_cppdecl,pocall_cdecl]) and
  317. (po_external in aktcallprocdef.procoptions)) and
  318. push_high_param(defcoll.paratype.def) then
  319. gen_high_tree(is_open_string(defcoll.paratype.def));
  320. { test conversions }
  321. if not(is_shortstring(left.resulttype.def) and
  322. is_shortstring(defcoll.paratype.def)) and
  323. (defcoll.paratype.def.deftype<>formaldef) then
  324. begin
  325. if (defcoll.paratyp in [vs_var,vs_out]) and
  326. { allows conversion from word to integer and
  327. byte to shortint, but only for TP7 compatibility }
  328. (not(
  329. (m_tp7 in aktmodeswitches) and
  330. (left.resulttype.def.deftype=orddef) and
  331. (defcoll.paratype.def.deftype=orddef) and
  332. (left.resulttype.def.size=defcoll.paratype.def.size)
  333. ) and
  334. { an implicit pointer conversion is allowed }
  335. not(
  336. (left.resulttype.def.deftype=pointerdef) and
  337. (defcoll.paratype.def.deftype=pointerdef)
  338. ) and
  339. { child classes can be also passed }
  340. not(
  341. (left.resulttype.def.deftype=objectdef) and
  342. (defcoll.paratype.def.deftype=objectdef) and
  343. tobjectdef(left.resulttype.def).is_related(tobjectdef(defcoll.paratype.def))
  344. ) and
  345. { passing a single element to a openarray of the same type }
  346. not(
  347. (is_open_array(defcoll.paratype.def) and
  348. is_equal(tarraydef(defcoll.paratype.def).elementtype.def,left.resulttype.def))
  349. ) and
  350. { an implicit file conversion is also allowed }
  351. { from a typed file to an untyped one }
  352. not(
  353. (left.resulttype.def.deftype=filedef) and
  354. (defcoll.paratype.def.deftype=filedef) and
  355. (tfiledef(defcoll.paratype.def).filetyp = ft_untyped) and
  356. (tfiledef(left.resulttype.def).filetyp = ft_typed)
  357. ) and
  358. not(is_equal(left.resulttype.def,defcoll.paratype.def))) then
  359. begin
  360. CGMessagePos2(left.fileinfo,parser_e_call_by_ref_without_typeconv,
  361. left.resulttype.def.typename,defcoll.paratype.def.typename);
  362. end;
  363. { Process open parameters }
  364. if push_high_param(defcoll.paratype.def) then
  365. begin
  366. { insert type conv but hold the ranges of the array }
  367. oldtype:=left.resulttype;
  368. inserttypeconv(left,defcoll.paratype);
  369. left.resulttype:=oldtype;
  370. end
  371. else
  372. begin
  373. inserttypeconv(left,defcoll.paratype);
  374. end;
  375. if codegenerror then
  376. begin
  377. dec(parsing_para_level);
  378. exit;
  379. end;
  380. end;
  381. { check var strings }
  382. if (cs_strict_var_strings in aktlocalswitches) and
  383. is_shortstring(left.resulttype.def) and
  384. is_shortstring(defcoll.paratype.def) and
  385. (defcoll.paratyp in [vs_out,vs_var]) and
  386. not(is_open_string(defcoll.paratype.def)) and
  387. not(is_equal(left.resulttype.def,defcoll.paratype.def)) then
  388. begin
  389. aktfilepos:=left.fileinfo;
  390. CGMessage(type_e_strict_var_string_violation);
  391. end;
  392. { Handle formal parameters separate }
  393. if (defcoll.paratype.def.deftype=formaldef) then
  394. begin
  395. { load procvar if a procedure is passed }
  396. if (m_tp_procvar in aktmodeswitches) and
  397. (left.nodetype=calln) and
  398. (is_void(left.resulttype.def)) then
  399. begin
  400. p1:=cloadnode.create_procvar(tcallnode(left).symtableprocentry,
  401. tprocdef(tcallnode(left).procdefinition),tcallnode(left).symtableproc);
  402. if assigned(tcallnode(left).right) then
  403. tloadnode(p1).set_mp(tcallnode(left).right);
  404. left.free;
  405. left:=p1;
  406. resulttypepass(left);
  407. end;
  408. case defcoll.paratyp of
  409. vs_var,
  410. vs_out :
  411. begin
  412. if not valid_for_formal_var(left) then
  413. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  414. end;
  415. vs_const :
  416. begin
  417. if not valid_for_formal_const(left) then
  418. CGMessagePos(left.fileinfo,parser_e_illegal_parameter_list);
  419. end;
  420. end;
  421. end
  422. else
  423. begin
  424. { check if the argument is allowed }
  425. if (defcoll.paratyp in [vs_out,vs_var]) then
  426. valid_for_var(left);
  427. end;
  428. if defcoll.paratyp in [vs_var,vs_const] then
  429. begin
  430. { Causes problems with const ansistrings if also }
  431. { done for vs_const (JM) }
  432. if defcoll.paratyp = vs_var then
  433. set_unique(left);
  434. make_not_regable(left);
  435. end;
  436. { ansistrings out paramaters doesn't need to be }
  437. { unique, they are finalized }
  438. if defcoll.paratyp=vs_out then
  439. make_not_regable(left);
  440. if do_count then
  441. begin
  442. { not completly proper, but avoids some warnings }
  443. if (defcoll.paratyp in [vs_var,vs_out]) then
  444. set_funcret_is_valid(left);
  445. set_varstate(left,not(defcoll.paratyp in [vs_var,vs_out]));
  446. end;
  447. { must only be done after typeconv PM }
  448. resulttype:=defcoll.paratype;
  449. dec(parsing_para_level);
  450. {$ifdef extdebug}
  451. if do_count then
  452. count_ref:=store_count_ref;
  453. {$endif def extdebug}
  454. end;
  455. procedure tcallparanode.det_registers;
  456. var
  457. old_get_para_resulttype : boolean;
  458. old_array_constructor : boolean;
  459. begin
  460. if assigned(right) then
  461. begin
  462. tcallparanode(right).det_registers;
  463. registers32:=right.registers32;
  464. registersfpu:=right.registersfpu;
  465. {$ifdef SUPPORT_MMX}
  466. registersmmx:=right.registersmmx;
  467. {$endif}
  468. end;
  469. old_array_constructor:=allow_array_constructor;
  470. old_get_para_resulttype:=get_para_resulttype;
  471. get_para_resulttype:=true;
  472. allow_array_constructor:=true;
  473. firstpass(left);
  474. get_para_resulttype:=old_get_para_resulttype;
  475. allow_array_constructor:=old_array_constructor;
  476. if left.registers32>registers32 then
  477. registers32:=left.registers32;
  478. if left.registersfpu>registersfpu then
  479. registersfpu:=left.registersfpu;
  480. {$ifdef SUPPORT_MMX}
  481. if left.registersmmx>registersmmx then
  482. registersmmx:=left.registersmmx;
  483. {$endif SUPPORT_MMX}
  484. end;
  485. procedure tcallparanode.firstcallparan(defcoll : tparaitem;do_count : boolean);
  486. begin
  487. if not assigned(left.resulttype.def) then
  488. begin
  489. get_paratype;
  490. if assigned(defcoll) then
  491. insert_typeconv(defcoll,do_count);
  492. end;
  493. det_registers;
  494. end;
  495. procedure tcallparanode.gen_high_tree(openstring:boolean);
  496. var
  497. temp: tnode;
  498. len : integer;
  499. loadconst : boolean;
  500. begin
  501. if assigned(hightree) then
  502. exit;
  503. len:=-1;
  504. loadconst:=true;
  505. case left.resulttype.def.deftype of
  506. arraydef :
  507. begin
  508. { handle via a normal inline in_high_x node }
  509. loadconst := false;
  510. hightree := geninlinenode(in_high_x,false,left.getcopy);
  511. { only substract low(array) if it's <> 0 }
  512. temp := geninlinenode(in_low_x,false,left.getcopy);
  513. firstpass(temp);
  514. if (temp.nodetype <> ordconstn) or
  515. (tordconstnode(temp).value <> 0) then
  516. hightree := caddnode.create(subn,hightree,temp)
  517. else
  518. temp.free;
  519. end;
  520. stringdef :
  521. begin
  522. if openstring then
  523. begin
  524. { handle via a normal inline in_high_x node }
  525. loadconst := false;
  526. hightree := geninlinenode(in_high_x,false,left.getcopy);
  527. end
  528. else
  529. { passing a string to an array of char }
  530. begin
  531. if (left.nodetype=stringconstn) then
  532. begin
  533. len:=str_length(left);
  534. if len>0 then
  535. dec(len);
  536. end
  537. else
  538. begin
  539. hightree:=caddnode.create(subn,geninlinenode(in_length_x,false,left.getcopy),
  540. cordconstnode.create(1,s32bittype));
  541. loadconst:=false;
  542. end;
  543. end;
  544. end;
  545. else
  546. len:=0;
  547. end;
  548. if loadconst then
  549. hightree:=cordconstnode.create(len,s32bittype)
  550. else
  551. hightree:=ctypeconvnode.create(hightree,s32bittype);
  552. firstpass(hightree);
  553. end;
  554. function tcallparanode.docompare(p: tnode): boolean;
  555. begin
  556. docompare :=
  557. inherited docompare(p) and
  558. (callparaflags = tcallparanode(p).callparaflags) and
  559. hightree.isequal(tcallparanode(p).hightree);
  560. end;
  561. {****************************************************************************
  562. TCALLNODE
  563. ****************************************************************************}
  564. constructor tcallnode.create(l:tnode;v : tprocsym;st : tsymtable; mp : tnode);
  565. begin
  566. inherited create(calln,l,nil);
  567. symtableprocentry:=v;
  568. symtableproc:=st;
  569. include(flags,nf_return_value_used);
  570. methodpointer:=mp;
  571. procdefinition:=nil;
  572. restypeset := false;
  573. funcretrefnode:=nil;
  574. end;
  575. constructor tcallnode.createintern(const name: string; params: tnode);
  576. var
  577. srsym: tsym;
  578. symowner: tsymtable;
  579. begin
  580. if not (cs_compilesystem in aktmoduleswitches) then
  581. begin
  582. srsym := searchsymonlyin(systemunit,name);
  583. symowner := systemunit;
  584. end
  585. else
  586. begin
  587. searchsym(name,srsym,symowner);
  588. if not assigned(srsym) then
  589. searchsym(upper(name),srsym,symowner);
  590. end;
  591. if not assigned(srsym) or
  592. (srsym.typ <> procsym) then
  593. begin
  594. writeln('unknown compilerproc ',name);
  595. internalerror(200107271);
  596. end;
  597. self.create(params,tprocsym(srsym),symowner,nil);
  598. end;
  599. constructor tcallnode.createinternres(const name: string; params: tnode; const res: ttype);
  600. begin
  601. self.createintern(name,params);
  602. restype := res;
  603. restypeset := true;
  604. { both the normal and specified resulttype either have to be returned via a }
  605. { parameter or not, but no mixing (JM) }
  606. if ret_in_param(restype.def) xor ret_in_param(symtableprocentry.defs^.def.rettype.def) 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. funcretrefnode:=returnnode;
  613. if not ret_in_param(symtableprocentry.defs^.def.rettype.def) then
  614. internalerror(200204247);
  615. end;
  616. destructor tcallnode.destroy;
  617. begin
  618. methodpointer.free;
  619. funcretrefnode.free;
  620. inherited destroy;
  621. end;
  622. procedure tcallnode.set_procvar(procvar:tnode);
  623. begin
  624. right:=procvar;
  625. end;
  626. function tcallnode.getcopy : tnode;
  627. var
  628. n : tcallnode;
  629. begin
  630. n:=tcallnode(inherited getcopy);
  631. n.symtableprocentry:=symtableprocentry;
  632. n.symtableproc:=symtableproc;
  633. n.procdefinition:=procdefinition;
  634. n.restype := restype;
  635. n.restypeset := restypeset;
  636. if assigned(methodpointer) then
  637. n.methodpointer:=methodpointer.getcopy
  638. else
  639. n.methodpointer:=nil;
  640. if assigned(funcretrefnode) then
  641. n.funcretrefnode:=funcretrefnode.getcopy
  642. else
  643. n.funcretrefnode:=nil;
  644. result:=n;
  645. end;
  646. procedure tcallnode.insertintolist(l : tnodelist);
  647. begin
  648. end;
  649. function tcallnode.det_resulttype:tnode;
  650. type
  651. pprocdefcoll = ^tprocdefcoll;
  652. tprocdefcoll = record
  653. data : tprocdef;
  654. nextpara : tparaitem;
  655. firstpara : tparaitem;
  656. next : pprocdefcoll;
  657. end;
  658. var
  659. hp,procs,hp2 : pprocdefcoll;
  660. pd : pprocdeflist;
  661. oldcallprocdef : tabstractprocdef;
  662. def_from,def_to,conv_to : tdef;
  663. hpt : tnode;
  664. pt : tcallparanode;
  665. exactmatch : boolean;
  666. paralength,lastpara : longint;
  667. lastparatype : tdef;
  668. pdc : tparaitem;
  669. { only Dummy }
  670. hcvt : tconverttype;
  671. label
  672. errorexit;
  673. { check if the resulttype.def from tree p is equal with def, needed
  674. for stringconstn and formaldef }
  675. function is_equal(p:tcallparanode;def:tdef) : boolean;
  676. begin
  677. { safety check }
  678. if not (assigned(def) or assigned(p.resulttype.def)) then
  679. begin
  680. is_equal:=false;
  681. exit;
  682. end;
  683. { all types can be passed to a formaldef }
  684. is_equal:=(def.deftype=formaldef) or
  685. (types.is_equal(p.resulttype.def,def))
  686. { integer constants are compatible with all integer parameters if
  687. the specified value matches the range }
  688. or
  689. (
  690. (tbinarynode(p).left.nodetype=ordconstn) and
  691. is_integer(p.resulttype.def) and
  692. is_integer(def) and
  693. (tordconstnode(p.left).value>=torddef(def).low) and
  694. (tordconstnode(p.left).value<=torddef(def).high)
  695. )
  696. { to support ansi/long/wide strings in a proper way }
  697. { string and string[10] are assumed as equal }
  698. { when searching the correct overloaded procedure }
  699. or
  700. (
  701. (def.deftype=stringdef) and (p.resulttype.def.deftype=stringdef) and
  702. (tstringdef(def).string_typ=tstringdef(p.resulttype.def).string_typ)
  703. )
  704. or
  705. (
  706. (p.left.nodetype=stringconstn) and
  707. (is_ansistring(p.resulttype.def) and is_pchar(def))
  708. )
  709. or
  710. (
  711. (p.left.nodetype=ordconstn) and
  712. (is_char(p.resulttype.def) and (is_shortstring(def) or is_ansistring(def)))
  713. )
  714. { set can also be a not yet converted array constructor }
  715. or
  716. (
  717. (def.deftype=setdef) and (p.resulttype.def.deftype=arraydef) and
  718. (tarraydef(p.resulttype.def).IsConstructor) and not(tarraydef(p.resulttype.def).IsVariant)
  719. )
  720. { in tp7 mode proc -> procvar is allowed }
  721. or
  722. (
  723. (m_tp_procvar in aktmodeswitches) and
  724. (def.deftype=procvardef) and (p.left.nodetype=calln) and
  725. (proc_to_procvar_equal(tprocdef(tcallnode(p.left).procdefinition),tprocvardef(def),false))
  726. )
  727. ;
  728. end;
  729. var
  730. i : longint;
  731. found,
  732. is_const : boolean;
  733. bestord : torddef;
  734. srprocsym : tprocsym;
  735. srsymtable : tsymtable;
  736. begin
  737. result:=nil;
  738. procs:=nil;
  739. oldcallprocdef:=aktcallprocdef;
  740. aktcallprocdef:=nil;
  741. { determine length of parameter list }
  742. pt:=tcallparanode(left);
  743. paralength:=0;
  744. while assigned(pt) do
  745. begin
  746. inc(paralength);
  747. pt:=tcallparanode(pt.right);
  748. end;
  749. { determine the type of the parameters }
  750. if assigned(left) then
  751. begin
  752. tcallparanode(left).get_paratype;
  753. if codegenerror then
  754. goto errorexit;
  755. end;
  756. { procedure variable ? }
  757. if assigned(right) then
  758. begin
  759. set_varstate(right,true);
  760. resulttypepass(right);
  761. if codegenerror then
  762. exit;
  763. procdefinition:=tabstractprocdef(right.resulttype.def);
  764. { check the amount of parameters }
  765. pdc:=tparaitem(procdefinition.Para.first);
  766. pt:=tcallparanode(left);
  767. lastpara:=paralength;
  768. while assigned(pdc) and assigned(pt) do
  769. begin
  770. { only goto next para if we're out of the varargs }
  771. if not(po_varargs in procdefinition.procoptions) or
  772. (lastpara<=procdefinition.maxparacount) then
  773. pdc:=tparaitem(pdc.next);
  774. pt:=tcallparanode(pt.right);
  775. dec(lastpara);
  776. end;
  777. if assigned(pt) or assigned(pdc) then
  778. begin
  779. if assigned(pt) then
  780. aktfilepos:=pt.fileinfo;
  781. CGMessage(parser_e_wrong_parameter_size);
  782. end;
  783. end
  784. else
  785. { not a procedure variable }
  786. begin
  787. { do we know the procedure to call ? }
  788. if not(assigned(procdefinition)) then
  789. begin
  790. { when the definition has overload directive set, we search for
  791. overloaded definitions in the class, this only needs to be done once
  792. for class entries as the tree keeps always the same }
  793. if (not symtableprocentry.overloadchecked) and
  794. (po_overload in symtableprocentry.defs^.def.procoptions) and
  795. (symtableprocentry.owner.symtabletype=objectsymtable) then
  796. search_class_overloads(symtableprocentry);
  797. { link all procedures which have the same # of parameters }
  798. pd:=symtableprocentry.defs;
  799. while assigned(pd) do
  800. begin
  801. { only when the # of parameter are supported by the
  802. procedure }
  803. if (paralength>=pd^.def.minparacount) and
  804. ((po_varargs in pd^.def.procoptions) or { varargs }
  805. (paralength<=pd^.def.maxparacount)) then
  806. begin
  807. new(hp);
  808. hp^.data:=pd^.def;
  809. hp^.next:=procs;
  810. hp^.firstpara:=tparaitem(pd^.def.Para.first);
  811. if not(po_varargs in pd^.def.procoptions) then
  812. begin
  813. { if not all parameters are given, then skip the
  814. default parameters }
  815. for i:=1 to pd^.def.maxparacount-paralength do
  816. hp^.firstpara:=tparaitem(hp^.firstPara.next);
  817. end;
  818. hp^.nextpara:=hp^.firstpara;
  819. procs:=hp;
  820. end;
  821. pd:=pd^.next;
  822. end;
  823. { when the definition has overload directive set, we search for
  824. overloaded definitions in the symtablestack. The found
  825. entries are only added to the procs list and not the procsym, because
  826. the list can change in every situation }
  827. if (po_overload in symtableprocentry.defs^.def.procoptions) and
  828. (symtableprocentry.owner.symtabletype<>objectsymtable) then
  829. begin
  830. srsymtable:=symtableprocentry.owner.next;
  831. while assigned(srsymtable) do
  832. begin
  833. if srsymtable.symtabletype in [localsymtable,staticsymtable,globalsymtable] then
  834. begin
  835. srprocsym:=tprocsym(srsymtable.speedsearch(symtableprocentry.name,symtableprocentry.speedvalue));
  836. { process only visible procsyms }
  837. if assigned(srprocsym) and
  838. (srprocsym.typ=procsym) and
  839. srprocsym.is_visible_for_proc(aktprocdef) then
  840. begin
  841. { if this procedure doesn't have overload we can stop
  842. searching }
  843. if not(po_overload in srprocsym.defs^.def.procoptions) then
  844. break;
  845. { process all overloaded definitions }
  846. pd:=srprocsym.defs;
  847. while assigned(pd) do
  848. begin
  849. { only when the # of parameter are supported by the
  850. procedure }
  851. if (paralength>=pd^.def.minparacount) and
  852. ((po_varargs in pd^.def.procoptions) or { varargs }
  853. (paralength<=pd^.def.maxparacount)) then
  854. begin
  855. found:=false;
  856. hp:=procs;
  857. while assigned(hp) do
  858. begin
  859. if equal_paras(hp^.data.para,pd^.def.para,cp_value_equal_const) then
  860. begin
  861. found:=true;
  862. break;
  863. end;
  864. hp:=hp^.next;
  865. end;
  866. if not found then
  867. begin
  868. new(hp);
  869. hp^.data:=pd^.def;
  870. hp^.next:=procs;
  871. hp^.firstpara:=tparaitem(pd^.def.Para.first);
  872. if not(po_varargs in pd^.def.procoptions) then
  873. begin
  874. { if not all parameters are given, then skip the
  875. default parameters }
  876. for i:=1 to pd^.def.maxparacount-paralength do
  877. hp^.firstpara:=tparaitem(hp^.firstPara.next);
  878. end;
  879. hp^.nextpara:=hp^.firstpara;
  880. procs:=hp;
  881. end;
  882. end;
  883. pd:=pd^.next;
  884. end;
  885. end;
  886. end;
  887. srsymtable:=srsymtable.next;
  888. end;
  889. end;
  890. { no procedures found? then there is something wrong
  891. with the parameter size }
  892. if not assigned(procs) then
  893. begin
  894. { in tp mode we can try to convert to procvar if
  895. there are no parameters specified }
  896. if not(assigned(left)) and
  897. (m_tp_procvar in aktmodeswitches) then
  898. begin
  899. hpt:=cloadnode.create(tprocsym(symtableprocentry),symtableproc);
  900. if (symtableprocentry.owner.symtabletype=objectsymtable) and
  901. assigned(methodpointer) then
  902. tloadnode(hpt).set_mp(methodpointer.getcopy);
  903. resulttypepass(hpt);
  904. result:=hpt;
  905. end
  906. else
  907. begin
  908. if assigned(left) then
  909. aktfilepos:=left.fileinfo;
  910. CGMessage(parser_e_wrong_parameter_size);
  911. symtableprocentry.write_parameter_lists(nil);
  912. end;
  913. goto errorexit;
  914. end;
  915. { now we can compare parameter after parameter }
  916. pt:=tcallparanode(left);
  917. { we start with the last parameter }
  918. lastpara:=paralength+1;
  919. lastparatype:=nil;
  920. while assigned(pt) do
  921. begin
  922. dec(lastpara);
  923. { walk all procedures and determine how this parameter matches and set:
  924. 1. pt.exact_match_found if one parameter has an exact match
  925. 2. exactmatch if an equal or exact match is found
  926. 3. Para.argconvtyp to exact,equal or convertable
  927. (when convertable then also convertlevel is set)
  928. 4. pt.convlevel1found if there is a convertlevel=1
  929. 5. pt.convlevel2found if there is a convertlevel=2
  930. }
  931. exactmatch:=false;
  932. hp:=procs;
  933. while assigned(hp) do
  934. begin
  935. { varargs are always equal, but not exact }
  936. if (po_varargs in hp^.data.procoptions) and
  937. (lastpara>hp^.data.minparacount) then
  938. begin
  939. hp^.nextPara.argconvtyp:=act_equal;
  940. exactmatch:=true;
  941. end
  942. else
  943. begin
  944. if is_equal(pt,hp^.nextPara.paratype.def) then
  945. begin
  946. if hp^.nextPara.paratype.def=pt.resulttype.def then
  947. begin
  948. include(pt.callparaflags,cpf_exact_match_found);
  949. hp^.nextPara.argconvtyp:=act_exact;
  950. end
  951. else
  952. hp^.nextPara.argconvtyp:=act_equal;
  953. exactmatch:=true;
  954. end
  955. else
  956. begin
  957. hp^.nextPara.argconvtyp:=act_convertable;
  958. hp^.nextPara.convertlevel:=isconvertable(pt.resulttype.def,hp^.nextPara.paratype.def,
  959. hcvt,pt.left.nodetype,false);
  960. case hp^.nextPara.convertlevel of
  961. 1 : include(pt.callparaflags,cpf_convlevel1found);
  962. 2 : include(pt.callparaflags,cpf_convlevel2found);
  963. end;
  964. end;
  965. end;
  966. hp:=hp^.next;
  967. end;
  968. { If there was an exactmatch then delete all convertables }
  969. if exactmatch then
  970. begin
  971. hp:=procs;
  972. procs:=nil;
  973. while assigned(hp) do
  974. begin
  975. hp2:=hp^.next;
  976. { keep if not convertable }
  977. if (hp^.nextPara.argconvtyp<>act_convertable) then
  978. begin
  979. hp^.next:=procs;
  980. procs:=hp;
  981. end
  982. else
  983. dispose(hp);
  984. hp:=hp2;
  985. end;
  986. end
  987. else
  988. { No exact match was found, remove all procedures that are
  989. not convertable (convertlevel=0) }
  990. begin
  991. hp:=procs;
  992. procs:=nil;
  993. while assigned(hp) do
  994. begin
  995. hp2:=hp^.next;
  996. { keep if not convertable }
  997. if (hp^.nextPara.convertlevel<>0) then
  998. begin
  999. hp^.next:=procs;
  1000. procs:=hp;
  1001. end
  1002. else
  1003. begin
  1004. { save the type for nice error message }
  1005. lastparatype:=hp^.nextPara.paratype.def;
  1006. dispose(hp);
  1007. end;
  1008. hp:=hp2;
  1009. end;
  1010. end;
  1011. { update nextpara for all procedures }
  1012. hp:=procs;
  1013. while assigned(hp) do
  1014. begin
  1015. { only goto next para if we're out of the varargs }
  1016. if not(po_varargs in hp^.data.procoptions) or
  1017. (lastpara<=hp^.data.maxparacount) then
  1018. hp^.nextpara:=tparaitem(hp^.nextPara.next);
  1019. hp:=hp^.next;
  1020. end;
  1021. { load next parameter or quit loop if no procs left }
  1022. if assigned(procs) then
  1023. pt:=tcallparanode(pt.right)
  1024. else
  1025. break;
  1026. end;
  1027. { All parameters are checked, check if there are any
  1028. procedures left }
  1029. if not assigned(procs) then
  1030. begin
  1031. { there is an error, must be wrong type, because
  1032. wrong size is already checked (PFV) }
  1033. if (not assigned(lastparatype)) or
  1034. (not assigned(pt)) or
  1035. (not assigned(pt.resulttype.def)) then
  1036. internalerror(39393)
  1037. else
  1038. begin
  1039. aktfilepos:=pt.fileinfo;
  1040. CGMessage3(type_e_wrong_parameter_type,tostr(lastpara),
  1041. pt.resulttype.def.typename,lastparatype.typename);
  1042. end;
  1043. symtableprocentry.write_parameter_lists(nil);
  1044. goto errorexit;
  1045. end;
  1046. { if there are several choices left then for orddef }
  1047. { if a type is totally included in the other }
  1048. { we don't fear an overflow , }
  1049. { so we can do as if it is an exact match }
  1050. { this will convert integer to longint }
  1051. { rather than to words }
  1052. { conversion of byte to integer or longint }
  1053. { would still not be solved }
  1054. if assigned(procs) and assigned(procs^.next) then
  1055. begin
  1056. hp:=procs;
  1057. while assigned(hp) do
  1058. begin
  1059. hp^.nextpara:=hp^.firstpara;
  1060. hp:=hp^.next;
  1061. end;
  1062. pt:=tcallparanode(left);
  1063. while assigned(pt) do
  1064. begin
  1065. { matches a parameter of one procedure exact ? }
  1066. exactmatch:=false;
  1067. def_from:=pt.resulttype.def;
  1068. hp:=procs;
  1069. while assigned(hp) do
  1070. begin
  1071. if not is_equal(pt,hp^.nextPara.paratype.def) then
  1072. begin
  1073. def_to:=hp^.nextPara.paratype.def;
  1074. if ((def_from.deftype=orddef) and (def_to.deftype=orddef)) and
  1075. (is_in_limit(def_from,def_to) or
  1076. ((hp^.nextPara.paratyp in [vs_var,vs_out]) and
  1077. (def_from.size=def_to.size))) then
  1078. begin
  1079. exactmatch:=true;
  1080. conv_to:=def_to;
  1081. { there's no use in continuing the search, it will }
  1082. { only result in conv_to being overwritten }
  1083. break;
  1084. end;
  1085. end;
  1086. hp:=hp^.next;
  1087. end;
  1088. { .... if yes, del all the other procedures }
  1089. if exactmatch then
  1090. begin
  1091. { the first .... }
  1092. while (assigned(procs)) and not(is_in_limit(def_from,procs^.nextPara.paratype.def)) do
  1093. begin
  1094. hp:=procs^.next;
  1095. dispose(procs);
  1096. procs:=hp;
  1097. end;
  1098. { and the others }
  1099. hp:=procs;
  1100. while (assigned(hp)) and assigned(hp^.next) do
  1101. begin
  1102. def_to:=hp^.next^.nextPara.paratype.def;
  1103. if not(is_in_limit(def_from,def_to)) then
  1104. begin
  1105. hp2:=hp^.next^.next;
  1106. dispose(hp^.next);
  1107. hp^.next:=hp2;
  1108. end
  1109. else
  1110. begin
  1111. { did we possibly find a better match? }
  1112. if (conv_to.size>def_to.size) or
  1113. is_in_limit(def_to,conv_to) then
  1114. begin
  1115. { is it the same as the previous best? }
  1116. if not types.is_equal(def_to,conv_to) then
  1117. begin
  1118. { no -> remove all previous best matches }
  1119. hp := hp^.next;
  1120. while procs <> hp do
  1121. begin
  1122. hp2 := procs;
  1123. procs := procs^.next;
  1124. dispose(hp2);
  1125. end;
  1126. { set new match type }
  1127. conv_to:=def_to;
  1128. end
  1129. { the new one matches just as well as the }
  1130. { old one -> keep both }
  1131. else
  1132. hp := hp^.next;
  1133. end
  1134. { not a better match -> remove }
  1135. else
  1136. begin
  1137. hp2 := hp^.next^.next;
  1138. dispose(hp^.next);
  1139. hp^.next:=hp2;
  1140. end;
  1141. end;
  1142. end;
  1143. end;
  1144. { update nextpara for all procedures }
  1145. hp:=procs;
  1146. while assigned(hp) do
  1147. begin
  1148. hp^.nextpara:=tparaitem(hp^.nextPara.next);
  1149. hp:=hp^.next;
  1150. end;
  1151. pt:=tcallparanode(pt.right);
  1152. end;
  1153. end;
  1154. { let's try to eliminate equal if there is an exact match
  1155. is there }
  1156. if assigned(procs) and assigned(procs^.next) then
  1157. begin
  1158. { reset nextpara for all procs left }
  1159. hp:=procs;
  1160. while assigned(hp) do
  1161. begin
  1162. hp^.nextpara:=hp^.firstpara;
  1163. hp:=hp^.next;
  1164. end;
  1165. pt:=tcallparanode(left);
  1166. while assigned(pt) do
  1167. begin
  1168. if cpf_exact_match_found in pt.callparaflags then
  1169. begin
  1170. hp:=procs;
  1171. procs:=nil;
  1172. while assigned(hp) do
  1173. begin
  1174. hp2:=hp^.next;
  1175. { keep the exact matches, dispose the others }
  1176. if (hp^.nextPara.argconvtyp=act_exact) then
  1177. begin
  1178. hp^.next:=procs;
  1179. procs:=hp;
  1180. end
  1181. else
  1182. dispose(hp);
  1183. hp:=hp2;
  1184. end;
  1185. end;
  1186. { update nextpara for all procedures }
  1187. hp:=procs;
  1188. while assigned(hp) do
  1189. begin
  1190. hp^.nextpara:=tparaitem(hp^.nextPara.next);
  1191. hp:=hp^.next;
  1192. end;
  1193. pt:=tcallparanode(pt.right);
  1194. end;
  1195. end;
  1196. { Check if there are integer constant to integer
  1197. parameters then choose the best matching integer
  1198. parameter and remove the others, this is Delphi
  1199. compatible. 1 = byte, 256 = word, etc. }
  1200. if assigned(procs) and assigned(procs^.next) then
  1201. begin
  1202. { reset nextpara for all procs left }
  1203. hp:=procs;
  1204. while assigned(hp) do
  1205. begin
  1206. hp^.nextpara:=hp^.firstpara;
  1207. hp:=hp^.next;
  1208. end;
  1209. pt:=tcallparanode(left);
  1210. while assigned(pt) do
  1211. begin
  1212. bestord:=nil;
  1213. if (pt.left.nodetype=ordconstn) and
  1214. is_integer(pt.resulttype.def) then
  1215. begin
  1216. hp:=procs;
  1217. while assigned(hp) do
  1218. begin
  1219. def_to:=hp^.nextPara.paratype.def;
  1220. { to be sure, it couldn't be something else,
  1221. also the defs here are all in the range
  1222. so now find the closest range }
  1223. if not is_integer(def_to) then
  1224. internalerror(43297815);
  1225. if (not assigned(bestord)) or
  1226. ((torddef(def_to).low>bestord.low) or
  1227. (torddef(def_to).high<bestord.high)) then
  1228. bestord:=torddef(def_to);
  1229. hp:=hp^.next;
  1230. end;
  1231. end;
  1232. { if a bestmatch is found then remove the other
  1233. procs which don't match the bestord }
  1234. if assigned(bestord) then
  1235. begin
  1236. hp:=procs;
  1237. procs:=nil;
  1238. while assigned(hp) do
  1239. begin
  1240. hp2:=hp^.next;
  1241. { keep matching bestord, dispose the others }
  1242. if (torddef(hp^.nextPara.paratype.def)=bestord) then
  1243. begin
  1244. hp^.next:=procs;
  1245. procs:=hp;
  1246. end
  1247. else
  1248. dispose(hp);
  1249. hp:=hp2;
  1250. end;
  1251. end;
  1252. { update nextpara for all procedures }
  1253. hp:=procs;
  1254. while assigned(hp) do
  1255. begin
  1256. hp^.nextpara:=tparaitem(hp^.nextPara.next);
  1257. hp:=hp^.next;
  1258. end;
  1259. pt:=tcallparanode(pt.right);
  1260. end;
  1261. end;
  1262. { Check if there are convertlevel 1 and 2 differences
  1263. left for the parameters, then discard all convertlevel
  1264. 2 procedures. The value of convlevelXfound can still
  1265. be used, because all convertables are still here or
  1266. not }
  1267. if assigned(procs) and assigned(procs^.next) then
  1268. begin
  1269. { reset nextpara for all procs left }
  1270. hp:=procs;
  1271. while assigned(hp) do
  1272. begin
  1273. hp^.nextpara:=hp^.firstpara;
  1274. hp:=hp^.next;
  1275. end;
  1276. pt:=tcallparanode(left);
  1277. while assigned(pt) do
  1278. begin
  1279. if (cpf_convlevel1found in pt.callparaflags) and
  1280. (cpf_convlevel2found in pt.callparaflags) then
  1281. begin
  1282. hp:=procs;
  1283. procs:=nil;
  1284. while assigned(hp) do
  1285. begin
  1286. hp2:=hp^.next;
  1287. { keep all not act_convertable and all convertlevels=1 }
  1288. if (hp^.nextPara.argconvtyp<>act_convertable) or
  1289. (hp^.nextPara.convertlevel=1) then
  1290. begin
  1291. hp^.next:=procs;
  1292. procs:=hp;
  1293. end
  1294. else
  1295. dispose(hp);
  1296. hp:=hp2;
  1297. end;
  1298. end;
  1299. { update nextpara for all procedures }
  1300. hp:=procs;
  1301. while assigned(hp) do
  1302. begin
  1303. hp^.nextpara:=tparaitem(hp^.nextPara.next);
  1304. hp:=hp^.next;
  1305. end;
  1306. pt:=tcallparanode(pt.right);
  1307. end;
  1308. end;
  1309. if not(assigned(procs)) or assigned(procs^.next) then
  1310. begin
  1311. CGMessage(cg_e_cant_choose_overload_function);
  1312. symtableprocentry.write_parameter_lists(nil);
  1313. goto errorexit;
  1314. end;
  1315. if make_ref then
  1316. begin
  1317. procs^.data.lastref:=tref.create(procs^.data.lastref,@fileinfo);
  1318. inc(procs^.data.refcount);
  1319. if procs^.data.defref=nil then
  1320. procs^.data.defref:=procs^.data.lastref;
  1321. end;
  1322. procdefinition:=procs^.data;
  1323. { big error for with statements
  1324. symtableproc:=procdefinition.owner;
  1325. but neede for overloaded operators !! }
  1326. if symtableproc=nil then
  1327. symtableproc:=procdefinition.owner;
  1328. end; { end of procedure to call determination }
  1329. { add needed default parameters }
  1330. if assigned(procs) and
  1331. (paralength<procdefinition.maxparacount) then
  1332. begin
  1333. { add default parameters, just read back the skipped
  1334. paras starting from firstPara.previous, when not available
  1335. (all parameters are default) then start with the last
  1336. parameter and read backward (PFV) }
  1337. if not assigned(procs^.firstpara) then
  1338. pdc:=tparaitem(procs^.data.Para.last)
  1339. else
  1340. pdc:=tparaitem(procs^.firstPara.previous);
  1341. while assigned(pdc) do
  1342. begin
  1343. if not assigned(pdc.defaultvalue) then
  1344. internalerror(751349858);
  1345. left:=ccallparanode.create(genconstsymtree(tconstsym(pdc.defaultvalue)),left);
  1346. pdc:=tparaitem(pdc.previous);
  1347. end;
  1348. end;
  1349. end;
  1350. { handle predefined procedures }
  1351. is_const:=(procdefinition.proccalloption=pocall_internconst) and
  1352. ((block_type in [bt_const,bt_type]) or
  1353. (assigned(left) and (tcallparanode(left).left.nodetype in [realconstn,ordconstn])));
  1354. if (procdefinition.proccalloption=pocall_internproc) or is_const then
  1355. begin
  1356. if assigned(left) then
  1357. begin
  1358. { ptr and settextbuf needs two args }
  1359. if assigned(tcallparanode(left).right) then
  1360. begin
  1361. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);
  1362. left:=nil;
  1363. end
  1364. else
  1365. begin
  1366. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,tcallparanode(left).left);
  1367. tcallparanode(left).left:=nil;
  1368. end;
  1369. end
  1370. else
  1371. hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,nil);
  1372. result:=hpt;
  1373. goto errorexit;
  1374. end;
  1375. { Calling a message method directly ? }
  1376. if assigned(procdefinition) and
  1377. (po_containsself in procdefinition.procoptions) then
  1378. message(cg_e_cannot_call_message_direct);
  1379. { ensure that the result type is set }
  1380. if not restypeset then
  1381. resulttype:=procdefinition.rettype
  1382. else
  1383. resulttype:=restype;
  1384. { get a register for the return value }
  1385. if (not is_void(resulttype.def)) then
  1386. begin
  1387. if ret_in_acc(resulttype.def) then
  1388. begin
  1389. { wide- and ansistrings are returned in EAX }
  1390. { but they are imm. moved to a memory location }
  1391. if is_widestring(resulttype.def) or
  1392. is_ansistring(resulttype.def) then
  1393. begin
  1394. { we use ansistrings so no fast exit here }
  1395. if assigned(procinfo) then
  1396. procinfo^.no_fast_exit:=true;
  1397. end;
  1398. end;
  1399. end;
  1400. { constructors return their current class type, not the type where the
  1401. constructor is declared, this can be different because of inheritance }
  1402. if (procdefinition.proctypeoption=potype_constructor) then
  1403. begin
  1404. if assigned(methodpointer) and
  1405. assigned(methodpointer.resulttype.def) and
  1406. (methodpointer.resulttype.def.deftype=classrefdef) then
  1407. resulttype:=tclassrefdef(methodpointer.resulttype.def).pointertype;
  1408. end;
  1409. { flag all callparanodes that belong to the varargs }
  1410. if (po_varargs in procdefinition.procoptions) then
  1411. begin
  1412. pt:=tcallparanode(left);
  1413. i:=paralength;
  1414. while (i>procdefinition.maxparacount) do
  1415. begin
  1416. include(tcallparanode(pt).flags,nf_varargs_para);
  1417. pt:=tcallparanode(pt.right);
  1418. dec(i);
  1419. end;
  1420. end;
  1421. { insert type conversions }
  1422. if assigned(left) then
  1423. begin
  1424. aktcallprocdef:=procdefinition;
  1425. tcallparanode(left).insert_typeconv(tparaitem(procdefinition.Para.first),true);
  1426. end;
  1427. errorexit:
  1428. { Reset some settings back }
  1429. if assigned(procs) then
  1430. dispose(procs);
  1431. aktcallprocdef:=oldcallprocdef;
  1432. end;
  1433. function tcallnode.pass_1 : tnode;
  1434. var
  1435. inlinecode : tnode;
  1436. inlined : boolean;
  1437. {$ifdef m68k}
  1438. regi : tregister;
  1439. {$endif}
  1440. method_must_be_valid : boolean;
  1441. label
  1442. errorexit;
  1443. begin
  1444. { the default is nothing to return }
  1445. location.loc:=LOC_INVALID;
  1446. result:=nil;
  1447. inlined:=false;
  1448. inlinecode := nil;
  1449. { work trough all parameters to get the register requirements }
  1450. if assigned(left) then
  1451. tcallparanode(left).det_registers;
  1452. if assigned(procdefinition) and
  1453. (procdefinition.proccalloption=pocall_inline) then
  1454. begin
  1455. inlinecode:=right;
  1456. if assigned(inlinecode) then
  1457. inlined:=true;
  1458. right:=nil;
  1459. end;
  1460. { procedure variable ? }
  1461. if assigned(right) then
  1462. begin
  1463. firstpass(right);
  1464. { procedure does a call }
  1465. if not (block_type in [bt_const,bt_type]) then
  1466. procinfo^.flags:=procinfo^.flags or pi_do_call;
  1467. rg.incrementregisterpushed(all_registers);
  1468. end
  1469. else
  1470. { not a procedure variable }
  1471. begin
  1472. { calc the correture value for the register }
  1473. { handle predefined procedures }
  1474. if (procdefinition.proccalloption=pocall_inline) then
  1475. begin
  1476. if assigned(methodpointer) then
  1477. CGMessage(cg_e_unable_inline_object_methods);
  1478. if assigned(right) and (right.nodetype<>procinlinen) then
  1479. CGMessage(cg_e_unable_inline_procvar);
  1480. { nodetype:=procinlinen; }
  1481. if not assigned(right) then
  1482. begin
  1483. if assigned(tprocdef(procdefinition).code) then
  1484. inlinecode:=cprocinlinenode.create(self,tnode(tprocdef(procdefinition).code))
  1485. else
  1486. CGMessage(cg_e_no_code_for_inline_stored);
  1487. if assigned(inlinecode) then
  1488. begin
  1489. { consider it has not inlined if called
  1490. again inside the args }
  1491. procdefinition.proccalloption:=pocall_fpccall;
  1492. firstpass(inlinecode);
  1493. inlined:=true;
  1494. end;
  1495. end;
  1496. end
  1497. else
  1498. begin
  1499. if not (block_type in [bt_const,bt_type]) then
  1500. procinfo^.flags:=procinfo^.flags or pi_do_call;
  1501. end;
  1502. { It doesn't hurt to calculate it already though :) (JM) }
  1503. rg.incrementregisterpushed(tprocdef(procdefinition).usedregisters);
  1504. end;
  1505. { get a register for the return value }
  1506. if (not is_void(resulttype.def)) then
  1507. begin
  1508. if ret_in_param(resulttype.def) then
  1509. begin
  1510. location.loc:=LOC_CREFERENCE;
  1511. end
  1512. else
  1513. { ansi/widestrings must be registered, so we can dispose them }
  1514. if is_ansistring(resulttype.def) or
  1515. is_widestring(resulttype.def) then
  1516. begin
  1517. location.loc:=LOC_CREFERENCE;
  1518. registers32:=1;
  1519. end
  1520. else
  1521. { we have only to handle the result if it is used }
  1522. if (nf_return_value_used in flags) then
  1523. begin
  1524. case resulttype.def.deftype of
  1525. enumdef,
  1526. orddef :
  1527. begin
  1528. if (procdefinition.proctypeoption=potype_constructor) then
  1529. begin
  1530. if assigned(methodpointer) and
  1531. (methodpointer.resulttype.def.deftype=classrefdef) then
  1532. begin
  1533. location.loc:=LOC_REGISTER;
  1534. registers32:=1;
  1535. end
  1536. else
  1537. location.loc:=LOC_FLAGS;
  1538. end
  1539. else
  1540. begin
  1541. location.loc:=LOC_REGISTER;
  1542. if is_64bitint(resulttype.def) then
  1543. registers32:=2
  1544. else
  1545. registers32:=1;
  1546. end;
  1547. end;
  1548. floatdef :
  1549. begin
  1550. location.loc:=LOC_FPUREGISTER;
  1551. {$ifdef m68k}
  1552. if (cs_fp_emulation in aktmoduleswitches) or
  1553. (tfloatdef(resulttype.def).typ=s32real) then
  1554. registers32:=1
  1555. else
  1556. registersfpu:=1;
  1557. {$else not m68k}
  1558. registersfpu:=1;
  1559. {$endif not m68k}
  1560. end;
  1561. else
  1562. begin
  1563. location.loc:=LOC_REGISTER;
  1564. registers32:=1;
  1565. end;
  1566. end;
  1567. end;
  1568. end;
  1569. { a fpu can be used in any procedure !! }
  1570. registersfpu:=procdefinition.fpu_used;
  1571. { if this is a call to a method calc the registers }
  1572. if (methodpointer<>nil) then
  1573. begin
  1574. case methodpointer.nodetype of
  1575. { but only, if this is not a supporting node }
  1576. typen: ;
  1577. { we need one register for new return value PM }
  1578. hnewn : if registers32=0 then
  1579. registers32:=1;
  1580. else
  1581. begin
  1582. if (procdefinition.proctypeoption in [potype_constructor,potype_destructor]) and
  1583. assigned(symtableproc) and (symtableproc.symtabletype=withsymtable) and
  1584. not twithsymtable(symtableproc).direct_with then
  1585. begin
  1586. CGmessage(cg_e_cannot_call_cons_dest_inside_with);
  1587. end; { Is accepted by Delphi !! }
  1588. { this is not a good reason to accept it in FPC if we produce
  1589. wrong code for it !!! (PM) }
  1590. { R.Assign is not a constructor !!! }
  1591. { but for R^.Assign, R must be valid !! }
  1592. if (procdefinition.proctypeoption=potype_constructor) or
  1593. ((methodpointer.nodetype=loadn) and
  1594. ((methodpointer.resulttype.def.deftype=classrefdef) or
  1595. ((methodpointer.resulttype.def.deftype=objectdef) and
  1596. not(oo_has_virtual in tobjectdef(methodpointer.resulttype.def).objectoptions)
  1597. )
  1598. )
  1599. ) then
  1600. method_must_be_valid:=false
  1601. else
  1602. method_must_be_valid:=true;
  1603. firstpass(methodpointer);
  1604. set_varstate(methodpointer,method_must_be_valid);
  1605. { The object is already used ven if it is called once }
  1606. if (methodpointer.nodetype=loadn) and
  1607. (tloadnode(methodpointer).symtableentry.typ=varsym) then
  1608. tvarsym(tloadnode(methodpointer).symtableentry).varstate:=vs_used;
  1609. registersfpu:=max(methodpointer.registersfpu,registersfpu);
  1610. registers32:=max(methodpointer.registers32,registers32);
  1611. {$ifdef SUPPORT_MMX }
  1612. registersmmx:=max(methodpointer.registersmmx,registersmmx);
  1613. {$endif SUPPORT_MMX}
  1614. end;
  1615. end;
  1616. end;
  1617. if inlined then
  1618. right:=inlinecode;
  1619. { determine the registers of the procedure variable }
  1620. { is this OK for inlined procs also ?? (PM) }
  1621. if assigned(right) then
  1622. begin
  1623. registersfpu:=max(right.registersfpu,registersfpu);
  1624. registers32:=max(right.registers32,registers32);
  1625. {$ifdef SUPPORT_MMX}
  1626. registersmmx:=max(right.registersmmx,registersmmx);
  1627. {$endif SUPPORT_MMX}
  1628. end;
  1629. { determine the registers of the procedure }
  1630. if assigned(left) then
  1631. begin
  1632. registersfpu:=max(left.registersfpu,registersfpu);
  1633. registers32:=max(left.registers32,registers32);
  1634. {$ifdef SUPPORT_MMX}
  1635. registersmmx:=max(left.registersmmx,registersmmx);
  1636. {$endif SUPPORT_MMX}
  1637. end;
  1638. errorexit:
  1639. if inlined then
  1640. procdefinition.proccalloption:=pocall_inline;
  1641. end;
  1642. function tcallnode.docompare(p: tnode): boolean;
  1643. begin
  1644. docompare :=
  1645. inherited docompare(p) and
  1646. (symtableprocentry = tcallnode(p).symtableprocentry) and
  1647. (symtableproc = tcallnode(p).symtableproc) and
  1648. (procdefinition = tcallnode(p).procdefinition) and
  1649. (methodpointer.isequal(tcallnode(p).methodpointer)) and
  1650. ((restypeset and tcallnode(p).restypeset and
  1651. (is_equal(restype.def,tcallnode(p).restype.def))) or
  1652. (not restypeset and not tcallnode(p).restypeset));
  1653. end;
  1654. {****************************************************************************
  1655. TPROCINLINENODE
  1656. ****************************************************************************}
  1657. constructor tprocinlinenode.create(callp,code : tnode);
  1658. begin
  1659. inherited create(procinlinen);
  1660. inlineprocdef:=tcallnode(callp).symtableprocentry.defs^.def;
  1661. retoffset:=-POINTER_SIZE; { less dangerous as zero (PM) }
  1662. para_offset:=0;
  1663. para_size:=inlineprocdef.para_size(target_info.alignment.paraalign);
  1664. if ret_in_param(inlineprocdef.rettype.def) then
  1665. inc(para_size,POINTER_SIZE);
  1666. { copy args }
  1667. if assigned(code) then
  1668. inlinetree:=code.getcopy
  1669. else inlinetree := nil;
  1670. registers32:=code.registers32;
  1671. registersfpu:=code.registersfpu;
  1672. {$ifdef SUPPORT_MMX}
  1673. registersmmx:=code.registersmmx;
  1674. {$endif SUPPORT_MMX}
  1675. resulttype:=inlineprocdef.rettype;
  1676. end;
  1677. destructor tprocinlinenode.destroy;
  1678. begin
  1679. if assigned(inlinetree) then
  1680. inlinetree.free;
  1681. inherited destroy;
  1682. end;
  1683. function tprocinlinenode.getcopy : tnode;
  1684. var
  1685. n : tprocinlinenode;
  1686. begin
  1687. n:=tprocinlinenode(inherited getcopy);
  1688. if assigned(inlinetree) then
  1689. n.inlinetree:=inlinetree.getcopy
  1690. else
  1691. n.inlinetree:=nil;
  1692. n.inlineprocdef:=inlineprocdef;
  1693. n.retoffset:=retoffset;
  1694. n.para_offset:=para_offset;
  1695. n.para_size:=para_size;
  1696. getcopy:=n;
  1697. end;
  1698. procedure tprocinlinenode.insertintolist(l : tnodelist);
  1699. begin
  1700. end;
  1701. function tprocinlinenode.pass_1 : tnode;
  1702. begin
  1703. result:=nil;
  1704. { left contains the code in tree form }
  1705. { but it has already been firstpassed }
  1706. { so firstpass(left); does not seem required }
  1707. { might be required later if we change the arg handling !! }
  1708. end;
  1709. function tprocinlinenode.docompare(p: tnode): boolean;
  1710. begin
  1711. docompare :=
  1712. inherited docompare(p) and
  1713. inlinetree.isequal(tprocinlinenode(p).inlinetree) and
  1714. (inlineprocdef = tprocinlinenode(p).inlineprocdef);
  1715. end;
  1716. begin
  1717. ccallnode:=tcallnode;
  1718. ccallparanode:=tcallparanode;
  1719. cprocinlinenode:=tprocinlinenode;
  1720. end.
  1721. {
  1722. $Log$
  1723. Revision 1.78 2002-07-04 20:43:00 florian
  1724. * first x86-64 patches
  1725. Revision 1.77 2002/07/01 16:23:52 peter
  1726. * cg64 patch
  1727. * basics for currency
  1728. * asnode updates for class and interface (not finished)
  1729. Revision 1.76 2002/05/18 13:34:09 peter
  1730. * readded missing revisions
  1731. Revision 1.75 2002/05/16 19:46:37 carl
  1732. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1733. + try to fix temp allocation (still in ifdef)
  1734. + generic constructor calls
  1735. + start of tassembler / tmodulebase class cleanup
  1736. Revision 1.73 2002/05/12 16:53:06 peter
  1737. * moved entry and exitcode to ncgutil and cgobj
  1738. * foreach gets extra argument for passing local data to the
  1739. iterator function
  1740. * -CR checks also class typecasts at runtime by changing them
  1741. into as
  1742. * fixed compiler to cycle with the -CR option
  1743. * fixed stabs with elf writer, finally the global variables can
  1744. be watched
  1745. * removed a lot of routines from cga unit and replaced them by
  1746. calls to cgobj
  1747. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1748. u32bit then the other is typecasted also to u32bit without giving
  1749. a rangecheck warning/error.
  1750. * fixed pascal calling method with reversing also the high tree in
  1751. the parast, detected by tcalcst3 test
  1752. Revision 1.72 2002/04/25 20:16:38 peter
  1753. * moved more routines from cga/n386util
  1754. Revision 1.71 2002/04/20 21:32:23 carl
  1755. + generic FPC_CHECKPOINTER
  1756. + first parameter offset in stack now portable
  1757. * rename some constants
  1758. + move some cpu stuff to other units
  1759. - remove unused constents
  1760. * fix stacksize for some targets
  1761. * fix generic size problems which depend now on EXTEND_SIZE constant
  1762. Revision 1.70 2002/04/16 16:09:08 peter
  1763. * allow passing the address of a procedure to a formal parameter
  1764. in delphi mode
  1765. Revision 1.69 2002/04/15 19:44:19 peter
  1766. * fixed stackcheck that would be called recursively when a stack
  1767. error was found
  1768. * generic changeregsize(reg,size) for i386 register resizing
  1769. * removed some more routines from cga unit
  1770. * fixed returnvalue handling
  1771. * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
  1772. Revision 1.68 2002/04/15 18:57:22 carl
  1773. + target_info.size_of_pointer -> POINTER_SIZE
  1774. Revision 1.67 2002/04/02 17:11:28 peter
  1775. * tlocation,treference update
  1776. * LOC_CONSTANT added for better constant handling
  1777. * secondadd splitted in multiple routines
  1778. * location_force_reg added for loading a location to a register
  1779. of a specified size
  1780. * secondassignment parses now first the right and then the left node
  1781. (this is compatible with Kylix). This saves a lot of push/pop especially
  1782. with string operations
  1783. * adapted some routines to use the new cg methods
  1784. Revision 1.66 2002/03/31 20:26:33 jonas
  1785. + a_loadfpu_* and a_loadmm_* methods in tcg
  1786. * register allocation is now handled by a class and is mostly processor
  1787. independent (+rgobj.pas and i386/rgcpu.pas)
  1788. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  1789. * some small improvements and fixes to the optimizer
  1790. * some register allocation fixes
  1791. * some fpuvaroffset fixes in the unary minus node
  1792. * push/popusedregisters is now called rg.save/restoreusedregisters and
  1793. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  1794. also better optimizable)
  1795. * fixed and optimized register saving/restoring for new/dispose nodes
  1796. * LOC_FPU locations now also require their "register" field to be set to
  1797. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  1798. - list field removed of the tnode class because it's not used currently
  1799. and can cause hard-to-find bugs
  1800. Revision 1.65 2002/03/30 23:02:42 carl
  1801. * avoid crash with inline routines
  1802. Revision 1.64 2002/01/24 18:25:48 peter
  1803. * implicit result variable generation for assembler routines
  1804. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1805. Revision 1.63 2002/01/24 12:33:52 jonas
  1806. * adapted ranges of native types to int64 (e.g. high cardinal is no
  1807. longer longint($ffffffff), but just $fffffff in psystem)
  1808. * small additional fix in 64bit rangecheck code generation for 32 bit
  1809. processors
  1810. * adaption of ranges required the matching talgorithm used for selecting
  1811. which overloaded procedure to call to be adapted. It should now always
  1812. select the closest match for ordinal parameters.
  1813. + inttostr(qword) in sysstr.inc/sysstrh.inc
  1814. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  1815. fixes were required to be able to add them)
  1816. * is_in_limit() moved from ncal to types unit, should always be used
  1817. instead of direct comparisons of low/high values of orddefs because
  1818. qword is a special case
  1819. Revision 1.62 2002/01/19 11:57:05 peter
  1820. * fixed path appending for lib
  1821. }