ncal.pas 87 KB

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