ncnv.pas 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954
  1. {
  2. $Id$
  3. Copyright (c) 2000-2001 by Florian Klaempfl
  4. Type checking and register allocation for type converting nodes
  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 ncnv;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. node,
  23. symtype,types,
  24. nld;
  25. type
  26. ttypeconvnode = class(tunarynode)
  27. totype : ttype;
  28. convtype : tconverttype;
  29. constructor create(node : tnode;const t : ttype);virtual;
  30. constructor create_explicit(node : tnode;const t : ttype);
  31. function getcopy : tnode;override;
  32. function pass_1 : tnode;override;
  33. function det_resulttype:tnode;override;
  34. function docompare(p: tnode) : boolean; override;
  35. private
  36. function resulttype_cord_to_pointer : tnode;
  37. function resulttype_chararray_to_string : tnode;
  38. function resulttype_string_to_chararray : tnode;
  39. function resulttype_string_to_string : tnode;
  40. function resulttype_char_to_string : tnode;
  41. function resulttype_char_to_chararray : tnode;
  42. function resulttype_int_to_real : tnode;
  43. function resulttype_real_to_real : tnode;
  44. function resulttype_cchar_to_pchar : tnode;
  45. function resulttype_cstring_to_pchar : tnode;
  46. function resulttype_char_to_char : tnode;
  47. function resulttype_arrayconstructor_to_set : tnode;
  48. function resulttype_pchar_to_string : tnode;
  49. function resulttype_interface_to_guid : tnode;
  50. function resulttype_dynarray_to_openarray : tnode;
  51. function resulttype_call_helper(c : tconverttype) : tnode;
  52. protected
  53. function first_int_to_int : tnode;virtual;
  54. function first_cstring_to_pchar : tnode;virtual;
  55. function first_string_to_chararray : tnode;virtual;
  56. function first_char_to_string : tnode;virtual;
  57. function first_nothing : tnode;virtual;
  58. function first_array_to_pointer : tnode;virtual;
  59. function first_int_to_real : tnode;virtual;
  60. function first_real_to_real : tnode;virtual;
  61. function first_pointer_to_array : tnode;virtual;
  62. function first_cchar_to_pchar : tnode;virtual;
  63. function first_bool_to_int : tnode;virtual;
  64. function first_int_to_bool : tnode;virtual;
  65. function first_bool_to_bool : tnode;virtual;
  66. function first_proc_to_procvar : tnode;virtual;
  67. function first_load_smallset : tnode;virtual;
  68. function first_cord_to_pointer : tnode;virtual;
  69. function first_ansistring_to_pchar : tnode;virtual;
  70. function first_arrayconstructor_to_set : tnode;virtual;
  71. function first_class_to_intf : tnode;virtual;
  72. function first_char_to_char : tnode;virtual;
  73. function first_call_helper(c : tconverttype) : tnode;
  74. procedure second_int_to_int;virtual;abstract;
  75. procedure second_string_to_string;virtual;abstract;
  76. procedure second_cstring_to_pchar;virtual;abstract;
  77. procedure second_string_to_chararray;virtual;abstract;
  78. procedure second_array_to_pointer;virtual;abstract;
  79. procedure second_pointer_to_array;virtual;abstract;
  80. procedure second_chararray_to_string;virtual;abstract;
  81. procedure second_char_to_string;virtual;abstract;
  82. procedure second_int_to_real;virtual;abstract;
  83. procedure second_real_to_real;virtual;abstract;
  84. procedure second_cord_to_pointer;virtual;abstract;
  85. procedure second_proc_to_procvar;virtual;abstract;
  86. procedure second_bool_to_int;virtual;abstract;
  87. procedure second_int_to_bool;virtual;abstract;
  88. procedure second_bool_to_bool;virtual;abstract;
  89. procedure second_load_smallset;virtual;abstract;
  90. procedure second_ansistring_to_pchar;virtual;abstract;
  91. procedure second_pchar_to_string;virtual;abstract;
  92. procedure second_class_to_intf;virtual;abstract;
  93. procedure second_char_to_char;virtual;abstract;
  94. procedure second_nothing; virtual;abstract;
  95. end;
  96. ttypeconvnodeclass = class of ttypeconvnode;
  97. tasnode = class(tbinarynode)
  98. constructor create(l,r : tnode);virtual;
  99. function pass_1 : tnode;override;
  100. function det_resulttype:tnode;override;
  101. procedure pass_2;override;
  102. end;
  103. tasnodeclass = class of tasnode;
  104. tisnode = class(tbinarynode)
  105. constructor create(l,r : tnode);virtual;
  106. function pass_1 : tnode;override;
  107. function det_resulttype:tnode;override;
  108. procedure pass_2;override;
  109. end;
  110. tisnodeclass = class of tisnode;
  111. var
  112. ctypeconvnode : ttypeconvnodeclass;
  113. casnode : tasnodeclass;
  114. cisnode : tisnodeclass;
  115. procedure inserttypeconv(var p:tnode;const t:ttype);
  116. procedure arrayconstructor_to_set(var p : tarrayconstructornode);
  117. implementation
  118. uses
  119. globtype,systems,tokens,
  120. cutils,verbose,globals,widestr,
  121. symconst,symdef,symsym,symtable,
  122. ncon,ncal,nset,nadd,ninl,nmem,nmat,
  123. cgbase,
  124. htypechk,pass_1,cpubase,cpuinfo;
  125. {*****************************************************************************
  126. Helpers
  127. *****************************************************************************}
  128. procedure inserttypeconv(var p:tnode;const t:ttype);
  129. begin
  130. if not assigned(p.resulttype.def) then
  131. begin
  132. resulttypepass(p);
  133. if codegenerror then
  134. exit;
  135. end;
  136. { don't insert obsolete type conversions }
  137. if is_equal(p.resulttype.def,t.def) and
  138. not ((p.resulttype.def.deftype=setdef) and
  139. (tsetdef(p.resulttype.def).settype <>
  140. tsetdef(t.def).settype)) then
  141. begin
  142. p.resulttype:=t;
  143. end
  144. else
  145. begin
  146. p:=ctypeconvnode.create(p,t);
  147. resulttypepass(p);
  148. end;
  149. end;
  150. {*****************************************************************************
  151. Array constructor to Set Conversion
  152. *****************************************************************************}
  153. procedure arrayconstructor_to_set(var p : tarrayconstructornode);
  154. var
  155. constp : tsetconstnode;
  156. buildp,
  157. p2,p3,p4 : tnode;
  158. htype : ttype;
  159. constset : pconstset;
  160. constsetlo,
  161. constsethi : longint;
  162. procedure update_constsethi(t:ttype);
  163. begin
  164. if ((t.def.deftype=orddef) and
  165. (torddef(t.def).high>=constsethi)) then
  166. begin
  167. constsethi:=torddef(t.def).high;
  168. if htype.def=nil then
  169. begin
  170. if (constsethi>255) or
  171. (torddef(t.def).low<0) then
  172. htype:=u8bittype
  173. else
  174. htype:=t;
  175. end;
  176. if constsethi>255 then
  177. constsethi:=255;
  178. end
  179. else if ((t.def.deftype=enumdef) and
  180. (tenumdef(t.def).max>=constsethi)) then
  181. begin
  182. if htype.def=nil then
  183. htype:=t;
  184. constsethi:=tenumdef(t.def).max;
  185. end;
  186. end;
  187. procedure do_set(pos : longint);
  188. var
  189. mask,l : longint;
  190. begin
  191. if (pos>255) or (pos<0) then
  192. Message(parser_e_illegal_set_expr);
  193. if pos>constsethi then
  194. constsethi:=pos;
  195. if pos<constsetlo then
  196. constsetlo:=pos;
  197. { to do this correctly we use the 32bit array }
  198. l:=pos shr 5;
  199. mask:=1 shl (pos mod 32);
  200. { do we allow the same twice }
  201. if (pconst32bitset(constset)^[l] and mask)<>0 then
  202. Message(parser_e_illegal_set_expr);
  203. pconst32bitset(constset)^[l]:=pconst32bitset(constset)^[l] or mask;
  204. end;
  205. var
  206. l : Longint;
  207. lr,hr : TConstExprInt;
  208. begin
  209. new(constset);
  210. FillChar(constset^,sizeof(constset^),0);
  211. htype.reset;
  212. constsetlo:=0;
  213. constsethi:=0;
  214. constp:=csetconstnode.create(nil,htype);
  215. constp.value_set:=constset;
  216. buildp:=constp;
  217. if assigned(p.left) then
  218. begin
  219. while assigned(p) do
  220. begin
  221. p4:=nil; { will contain the tree to create the set }
  222. {split a range into p2 and p3 }
  223. if p.left.nodetype=arrayconstructorrangen then
  224. begin
  225. p2:=tarrayconstructorrangenode(p.left).left;
  226. p3:=tarrayconstructorrangenode(p.left).right;
  227. tarrayconstructorrangenode(p.left).left:=nil;
  228. tarrayconstructorrangenode(p.left).right:=nil;
  229. end
  230. else
  231. begin
  232. p2:=p.left;
  233. p.left:=nil;
  234. p3:=nil;
  235. end;
  236. resulttypepass(p2);
  237. if assigned(p3) then
  238. resulttypepass(p3);
  239. if codegenerror then
  240. break;
  241. case p2.resulttype.def.deftype of
  242. enumdef,
  243. orddef:
  244. begin
  245. getrange(p2.resulttype.def,lr,hr);
  246. if assigned(p3) then
  247. begin
  248. { this isn't good, you'll get problems with
  249. type t010 = 0..10;
  250. ts = set of t010;
  251. var s : ts;b : t010
  252. begin s:=[1,2,b]; end.
  253. if is_integer(p3^.resulttype.def) then
  254. begin
  255. inserttypeconv(p3,u8bitdef);
  256. end;
  257. }
  258. if assigned(htype.def) and not(is_equal(htype.def,p3.resulttype.def)) then
  259. begin
  260. aktfilepos:=p3.fileinfo;
  261. CGMessage(type_e_typeconflict_in_set);
  262. end
  263. else
  264. begin
  265. if (p2.nodetype=ordconstn) and (p3.nodetype=ordconstn) then
  266. begin
  267. if not(is_integer(p3.resulttype.def)) then
  268. htype:=p3.resulttype
  269. else
  270. begin
  271. inserttypeconv(p3,u8bittype);
  272. inserttypeconv(p2,u8bittype);
  273. end;
  274. for l:=tordconstnode(p2).value to tordconstnode(p3).value do
  275. do_set(l);
  276. p2.free;
  277. p3.free;
  278. end
  279. else
  280. begin
  281. update_constsethi(p2.resulttype);
  282. inserttypeconv(p2,htype);
  283. update_constsethi(p3.resulttype);
  284. inserttypeconv(p3,htype);
  285. if assigned(htype.def) then
  286. inserttypeconv(p3,htype)
  287. else
  288. inserttypeconv(p3,u8bittype);
  289. p4:=csetelementnode.create(p2,p3);
  290. end;
  291. end;
  292. end
  293. else
  294. begin
  295. { Single value }
  296. if p2.nodetype=ordconstn then
  297. begin
  298. if not(is_integer(p2.resulttype.def)) then
  299. update_constsethi(p2.resulttype)
  300. else
  301. inserttypeconv(p2,u8bittype);
  302. do_set(tordconstnode(p2).value);
  303. p2.free;
  304. end
  305. else
  306. begin
  307. update_constsethi(p2.resulttype);
  308. if assigned(htype.def) then
  309. inserttypeconv(p2,htype)
  310. else
  311. inserttypeconv(p2,u8bittype);
  312. p4:=csetelementnode.create(p2,nil);
  313. end;
  314. end;
  315. end;
  316. stringdef :
  317. begin
  318. { if we've already set elements which are constants }
  319. { throw an error }
  320. if ((htype.def=nil) and assigned(buildp)) or
  321. not(is_char(htype.def)) then
  322. CGMessage(type_e_typeconflict_in_set)
  323. else
  324. for l:=1 to length(pstring(tstringconstnode(p2).value_str)^) do
  325. do_set(ord(pstring(tstringconstnode(p2).value_str)^[l]));
  326. if htype.def=nil then
  327. htype:=cchartype;
  328. p2.free;
  329. end;
  330. else
  331. CGMessage(type_e_ordinal_expr_expected);
  332. end;
  333. { insert the set creation tree }
  334. if assigned(p4) then
  335. buildp:=caddnode.create(addn,buildp,p4);
  336. { load next and dispose current node }
  337. p2:=p;
  338. p:=tarrayconstructornode(tarrayconstructornode(p2).right);
  339. tarrayconstructornode(p2).right:=nil;
  340. p2.free;
  341. end;
  342. if (htype.def=nil) then
  343. htype:=u8bittype;
  344. end
  345. else
  346. begin
  347. { empty set [], only remove node }
  348. p.free;
  349. end;
  350. { set the initial set type }
  351. constp.resulttype.setdef(tsetdef.create(htype,constsethi));
  352. { determine the resulttype for the tree }
  353. resulttypepass(buildp);
  354. { set the new tree }
  355. p:=tarrayconstructornode(buildp);
  356. end;
  357. {*****************************************************************************
  358. TTYPECONVNODE
  359. *****************************************************************************}
  360. constructor ttypeconvnode.create(node : tnode;const t:ttype);
  361. begin
  362. inherited create(typeconvn,node);
  363. convtype:=tc_not_possible;
  364. totype:=t;
  365. if t.def=nil then
  366. internalerror(200103281);
  367. set_file_line(node);
  368. end;
  369. constructor ttypeconvnode.create_explicit(node : tnode;const t:ttype);
  370. begin
  371. self.create(node,t);
  372. toggleflag(nf_explizit);
  373. end;
  374. function ttypeconvnode.getcopy : tnode;
  375. var
  376. n : ttypeconvnode;
  377. begin
  378. n:=ttypeconvnode(inherited getcopy);
  379. n.convtype:=convtype;
  380. getcopy:=n;
  381. end;
  382. function ttypeconvnode.resulttype_cord_to_pointer : tnode;
  383. var
  384. t : tnode;
  385. begin
  386. result:=nil;
  387. if left.nodetype=ordconstn then
  388. begin
  389. { check if we have a valid pointer constant (JM) }
  390. if (sizeof(pointer) > sizeof(TConstPtrUInt)) then
  391. if (sizeof(TConstPtrUInt) = 4) then
  392. begin
  393. if (tordconstnode(left).value < low(longint)) or
  394. (tordconstnode(left).value > high(cardinal)) then
  395. CGMessage(parser_e_range_check_error);
  396. end
  397. else if (sizeof(TConstPtrUInt) = 8) then
  398. begin
  399. if (tordconstnode(left).value < low(int64)) or
  400. (tordconstnode(left).value > high(qword)) then
  401. CGMessage(parser_e_range_check_error);
  402. end
  403. else
  404. internalerror(2001020801);
  405. t:=cpointerconstnode.create(TConstPtrUInt(tordconstnode(left).value),resulttype);
  406. result:=t;
  407. end
  408. else
  409. internalerror(200104023);
  410. end;
  411. function ttypeconvnode.resulttype_chararray_to_string : tnode;
  412. begin
  413. result := ccallnode.createinternres(
  414. 'fpc_chararray_to_'+tstringdef(resulttype.def).stringtypname,
  415. ccallparanode.create(left,nil),resulttype);
  416. left := nil;
  417. end;
  418. function ttypeconvnode.resulttype_string_to_chararray : tnode;
  419. var
  420. arrsize: longint;
  421. begin
  422. with tarraydef(resulttype.def) do
  423. begin
  424. if highrange<lowrange then
  425. internalerror(75432653);
  426. arrsize := highrange-lowrange+1;
  427. end;
  428. if (left.nodetype = stringconstn) and
  429. { left.length+1 since there's always a terminating #0 character (JM) }
  430. (tstringconstnode(left).len+1 >= arrsize) and
  431. (tstringdef(left.resulttype.def).string_typ=st_shortstring) then
  432. begin
  433. { handled separately }
  434. result := nil;
  435. exit;
  436. end;
  437. result := ccallnode.createinternres(
  438. 'fpc_'+tstringdef(left.resulttype.def).stringtypname+
  439. '_to_chararray',ccallparanode.create(left,ccallparanode.create(
  440. cordconstnode.create(arrsize,s32bittype),nil)),resulttype);
  441. left := nil;
  442. end;
  443. function ttypeconvnode.resulttype_string_to_string : tnode;
  444. var
  445. procname: string[31];
  446. stringpara : tcallparanode;
  447. pw : pcompilerwidestring;
  448. pc : pchar;
  449. begin
  450. result:=nil;
  451. if left.nodetype=stringconstn then
  452. begin
  453. { convert ascii 2 unicode }
  454. if (tstringdef(resulttype.def).string_typ=st_widestring) and
  455. (tstringconstnode(left).st_type in [st_ansistring,st_shortstring,st_longstring]) then
  456. begin
  457. initwidestring(pw);
  458. ascii2unicode(tstringconstnode(left).value_str,tstringconstnode(left).len,pw);
  459. ansistringdispose(tstringconstnode(left).value_str,tstringconstnode(left).len);
  460. pcompilerwidestring(tstringconstnode(left).value_str):=pw;
  461. end
  462. else
  463. { convert unicode 2 ascii }
  464. if (tstringconstnode(left).st_type=st_widestring) and
  465. (tstringdef(resulttype.def).string_typ in [st_ansistring,st_shortstring,st_longstring]) then
  466. begin
  467. pw:=pcompilerwidestring(tstringconstnode(left).value_str);
  468. getmem(pc,getlengthwidestring(pw)+1);
  469. unicode2ascii(pw,pc);
  470. donewidestring(pw);
  471. tstringconstnode(left).value_str:=pc;
  472. end;
  473. tstringconstnode(left).st_type:=tstringdef(resulttype.def).string_typ;
  474. tstringconstnode(left).resulttype:=resulttype;
  475. result:=left;
  476. left:=nil;
  477. end
  478. else
  479. begin
  480. { get the correct procedure name }
  481. procname := 'fpc_'+tstringdef(left.resulttype.def).stringtypname+
  482. '_to_'+tstringdef(resulttype.def).stringtypname;
  483. { create parameter (and remove left node from typeconvnode }
  484. { since it's reused as parameter) }
  485. stringpara := ccallparanode.create(left,nil);
  486. left := nil;
  487. { when converting to shortstrings, we have to pass high(destination) too }
  488. if (tstringdef(resulttype.def).string_typ = st_shortstring) then
  489. stringpara.right := ccallparanode.create(cinlinenode.create(
  490. in_high_x,false,self.getcopy),nil);
  491. { and create the callnode }
  492. result := ccallnode.createinternres(procname,stringpara,resulttype);
  493. end;
  494. end;
  495. function ttypeconvnode.resulttype_char_to_string : tnode;
  496. var
  497. procname: string[31];
  498. para : tcallparanode;
  499. hp : tstringconstnode;
  500. ws : pcompilerwidestring;
  501. begin
  502. result:=nil;
  503. if left.nodetype=ordconstn then
  504. begin
  505. if tstringdef(resulttype.def).string_typ=st_widestring then
  506. begin
  507. initwidestring(ws);
  508. concatwidestringchar(ws,tcompilerwidechar(chr(tordconstnode(left).value)));
  509. hp:=cstringconstnode.createwstr(ws);
  510. donewidestring(ws);
  511. end
  512. else
  513. hp:=cstringconstnode.createstr(chr(tordconstnode(left).value),tstringdef(resulttype.def).string_typ);
  514. result:=hp;
  515. end
  516. else
  517. { shortstrings are handled 'inline' }
  518. if tstringdef(resulttype.def).string_typ <> st_shortstring then
  519. begin
  520. { create the parameter }
  521. para := ccallparanode.create(left,nil);
  522. left := nil;
  523. { and the procname }
  524. procname := 'fpc_char_to_' +tstringdef(resulttype.def).stringtypname;
  525. { and finally the call }
  526. result := ccallnode.createinternres(procname,para,resulttype);
  527. end
  528. else
  529. begin
  530. { create word(byte(char) shl 8 or 1) for litte endian machines }
  531. { and word(byte(char) or 256) for big endian machines }
  532. left := ctypeconvnode.create(left,u8bittype);
  533. left.toggleflag(nf_explizit);
  534. if (target_info.endian = endian_little) then
  535. left := caddnode.create(orn,
  536. cshlshrnode.create(shln,left,cordconstnode.create(8,s32bittype)),
  537. cordconstnode.create(1,s32bittype))
  538. else
  539. left := caddnode.create(orn,left,
  540. cordconstnode.create(1 shl 8,s32bittype));
  541. left := ctypeconvnode.create(left,u16bittype);
  542. left.toggleflag(nf_explizit);
  543. resulttypepass(left);
  544. end;
  545. end;
  546. function ttypeconvnode.resulttype_char_to_chararray : tnode;
  547. begin
  548. if resulttype.def.size <> 1 then
  549. begin
  550. { convert first to string, then to chararray }
  551. inserttypeconv(left,cshortstringtype);
  552. inserttypeconv(left,resulttype);
  553. result:=left;
  554. left := nil;
  555. exit;
  556. end;
  557. result := nil;
  558. end;
  559. function ttypeconvnode.resulttype_char_to_char : tnode;
  560. var
  561. hp : tordconstnode;
  562. begin
  563. result:=nil;
  564. if left.nodetype=ordconstn then
  565. begin
  566. if (torddef(resulttype.def).typ=uchar) and
  567. (torddef(left.resulttype.def).typ=uwidechar) then
  568. begin
  569. hp:=cordconstnode.create(
  570. ord(unicode2asciichar(tcompilerwidechar(tordconstnode(left).value))),cchartype);
  571. result:=hp;
  572. end
  573. else if (torddef(resulttype.def).typ=uwidechar) and
  574. (torddef(left.resulttype.def).typ=uchar) then
  575. begin
  576. hp:=cordconstnode.create(
  577. asciichar2unicode(chr(tordconstnode(left).value)),cwidechartype);
  578. result:=hp;
  579. end
  580. else
  581. internalerror(200105131);
  582. exit;
  583. end;
  584. end;
  585. function ttypeconvnode.resulttype_int_to_real : tnode;
  586. var
  587. t : trealconstnode;
  588. begin
  589. result:=nil;
  590. if left.nodetype=ordconstn then
  591. begin
  592. t:=crealconstnode.create(tordconstnode(left).value,resulttype);
  593. result:=t;
  594. exit;
  595. end;
  596. end;
  597. function ttypeconvnode.resulttype_real_to_real : tnode;
  598. var
  599. t : tnode;
  600. begin
  601. result:=nil;
  602. if left.nodetype=realconstn then
  603. begin
  604. t:=crealconstnode.create(trealconstnode(left).value_real,resulttype);
  605. result:=t;
  606. end;
  607. end;
  608. function ttypeconvnode.resulttype_cchar_to_pchar : tnode;
  609. begin
  610. result:=nil;
  611. if is_pwidechar(resulttype.def) then
  612. inserttypeconv(left,cwidestringtype)
  613. else
  614. inserttypeconv(left,cshortstringtype);
  615. { evaluate again, reset resulttype so the convert_typ
  616. will be calculated again and cstring_to_pchar will
  617. be used for futher conversion }
  618. result:=det_resulttype;
  619. end;
  620. function ttypeconvnode.resulttype_cstring_to_pchar : tnode;
  621. begin
  622. result:=nil;
  623. if is_pwidechar(resulttype.def) then
  624. inserttypeconv(left,cwidestringtype);
  625. end;
  626. function ttypeconvnode.resulttype_arrayconstructor_to_set : tnode;
  627. var
  628. hp : tnode;
  629. begin
  630. result:=nil;
  631. if left.nodetype<>arrayconstructorn then
  632. internalerror(5546);
  633. { remove typeconv node }
  634. hp:=left;
  635. left:=nil;
  636. { create a set constructor tree }
  637. arrayconstructor_to_set(tarrayconstructornode(hp));
  638. result:=hp;
  639. end;
  640. function ttypeconvnode.resulttype_pchar_to_string : tnode;
  641. begin
  642. result := ccallnode.createinternres(
  643. 'fpc_pchar_to_'+tstringdef(resulttype.def).stringtypname,
  644. ccallparanode.create(left,nil),resulttype);
  645. left := nil;
  646. end;
  647. function ttypeconvnode.resulttype_interface_to_guid : tnode;
  648. begin
  649. if tobjectdef(left.resulttype.def).isiidguidvalid then
  650. result:=cguidconstnode.create(tobjectdef(left.resulttype.def).iidguid);
  651. end;
  652. function ttypeconvnode.resulttype_dynarray_to_openarray : tnode;
  653. begin
  654. { a dynamic array is a pointer to an array, so to convert it to }
  655. { an open array, we have to dereference it (JM) }
  656. result := ctypeconvnode.create(left,voidpointertype);
  657. { left is reused }
  658. left := nil;
  659. result.toggleflag(nf_explizit);
  660. result := cderefnode.create(result);
  661. result.resulttype := resulttype;
  662. end;
  663. function ttypeconvnode.resulttype_call_helper(c : tconverttype) : tnode;
  664. const
  665. resulttypeconvert : array[tconverttype] of pointer = (
  666. {equal} nil,
  667. {not_possible} nil,
  668. { string_2_string } @ttypeconvnode.resulttype_string_to_string,
  669. { char_2_string } @ttypeconvnode.resulttype_char_to_string,
  670. { char_2_chararray } @ttypeconvnode.resulttype_char_to_chararray,
  671. { pchar_2_string } @ttypeconvnode.resulttype_pchar_to_string,
  672. { cchar_2_pchar } @ttypeconvnode.resulttype_cchar_to_pchar,
  673. { cstring_2_pchar } @ttypeconvnode.resulttype_cstring_to_pchar,
  674. { ansistring_2_pchar } nil,
  675. { string_2_chararray } @ttypeconvnode.resulttype_string_to_chararray,
  676. { chararray_2_string } @ttypeconvnode.resulttype_chararray_to_string,
  677. { array_2_pointer } nil,
  678. { pointer_2_array } nil,
  679. { int_2_int } nil,
  680. { int_2_bool } nil,
  681. { bool_2_bool } nil,
  682. { bool_2_int } nil,
  683. { real_2_real } @ttypeconvnode.resulttype_real_to_real,
  684. { int_2_real } @ttypeconvnode.resulttype_int_to_real,
  685. { proc_2_procvar } nil,
  686. { arrayconstructor_2_set } @ttypeconvnode.resulttype_arrayconstructor_to_set,
  687. { load_smallset } nil,
  688. { cord_2_pointer } @ttypeconvnode.resulttype_cord_to_pointer,
  689. { intf_2_string } nil,
  690. { intf_2_guid } @ttypeconvnode.resulttype_interface_to_guid,
  691. { class_2_intf } nil,
  692. { char_2_char } @ttypeconvnode.resulttype_char_to_char,
  693. { normal_2_smallset} nil,
  694. { dynarray_2_openarray} @resulttype_dynarray_to_openarray
  695. );
  696. type
  697. tprocedureofobject = function : tnode of object;
  698. var
  699. r : packed record
  700. proc : pointer;
  701. obj : pointer;
  702. end;
  703. begin
  704. result:=nil;
  705. { this is a little bit dirty but it works }
  706. { and should be quite portable too }
  707. r.proc:=resulttypeconvert[c];
  708. r.obj:=self;
  709. if assigned(r.proc) then
  710. result:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  711. end;
  712. function ttypeconvnode.det_resulttype:tnode;
  713. var
  714. hp : tnode;
  715. currprocdef,
  716. aprocdef : tprocdef;
  717. begin
  718. result:=nil;
  719. resulttype:=totype;
  720. resulttypepass(left);
  721. if codegenerror then
  722. exit;
  723. { remove obsolete type conversions }
  724. if is_equal(left.resulttype.def,resulttype.def) then
  725. begin
  726. { becuase is_equal only checks the basetype for sets we need to
  727. check here if we are loading a smallset into a normalset }
  728. if (resulttype.def.deftype=setdef) and
  729. (left.resulttype.def.deftype=setdef) and
  730. ((tsetdef(resulttype.def).settype = smallset) xor
  731. (tsetdef(left.resulttype.def).settype = smallset)) then
  732. begin
  733. { constant sets can be converted by changing the type only }
  734. if (left.nodetype=setconstn) then
  735. begin
  736. tsetdef(left.resulttype.def).changesettype(tsetdef(resulttype.def).settype);
  737. result:=left;
  738. left:=nil;
  739. exit;
  740. end;
  741. if (tsetdef(resulttype.def).settype <> smallset) then
  742. convtype:=tc_load_smallset
  743. else
  744. convtype := tc_normal_2_smallset;
  745. exit;
  746. end
  747. else
  748. begin
  749. left.resulttype:=resulttype;
  750. result:=left;
  751. left:=nil;
  752. exit;
  753. end;
  754. end;
  755. aprocdef:=assignment_overloaded(left.resulttype.def,resulttype.def);
  756. if assigned(aprocdef) then
  757. begin
  758. procinfo^.flags:=procinfo^.flags or pi_do_call;
  759. hp:=ccallnode.create(ccallparanode.create(left,nil),
  760. overloaded_operators[_assignment],nil,nil);
  761. { tell explicitly which def we must use !! (PM) }
  762. tcallnode(hp).procdefinition:=aprocdef;
  763. left:=nil;
  764. result:=hp;
  765. exit;
  766. end;
  767. if isconvertable(left.resulttype.def,resulttype.def,convtype,left.nodetype,nf_explizit in flags)=0 then
  768. begin
  769. {Procedures have a resulttype.def of voiddef and functions of their
  770. own resulttype.def. They will therefore always be incompatible with
  771. a procvar. Because isconvertable cannot check for procedures we
  772. use an extra check for them.}
  773. if (m_tp_procvar in aktmodeswitches) then
  774. begin
  775. if (resulttype.def.deftype=procvardef) and
  776. (is_procsym_load(left) or is_procsym_call(left)) then
  777. begin
  778. if is_procsym_call(left) then
  779. begin
  780. currprocdef:=get_proc_2_procvar_def(tprocsym(tcallnode(left).symtableprocentry),tprocvardef(resulttype.def));
  781. hp:=cloadnode.create_procvar(tprocsym(tcallnode(left).symtableprocentry),
  782. currprocdef,tcallnode(left).symtableproc);
  783. if (tcallnode(left).symtableprocentry.owner.symtabletype=objectsymtable) and
  784. assigned(tcallnode(left).methodpointer) then
  785. tloadnode(hp).set_mp(tcallnode(left).methodpointer.getcopy);
  786. resulttypepass(hp);
  787. left.free;
  788. left:=hp;
  789. aprocdef:=tprocdef(left.resulttype.def);
  790. end
  791. else
  792. begin
  793. if (left.nodetype<>addrn) then
  794. aprocdef:=tprocsym(tloadnode(left).symtableentry).defs^.def;
  795. end;
  796. convtype:=tc_proc_2_procvar;
  797. { Now check if the procedure we are going to assign to
  798. the procvar, is compatible with the procvar's type }
  799. if assigned(aprocdef) then
  800. begin
  801. if not proc_to_procvar_equal(aprocdef,tprocvardef(resulttype.def),false) then
  802. CGMessage2(type_e_incompatible_types,aprocdef.typename,resulttype.def.typename);
  803. end
  804. else
  805. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  806. exit;
  807. end;
  808. end;
  809. if nf_explizit in flags then
  810. begin
  811. { check if the result could be in a register }
  812. if not(tstoreddef(resulttype.def).is_intregable) and
  813. not(tstoreddef(resulttype.def).is_fpuregable) then
  814. make_not_regable(left);
  815. { boolean to byte are special because the
  816. location can be different }
  817. if is_integer(resulttype.def) and
  818. is_boolean(left.resulttype.def) then
  819. begin
  820. convtype:=tc_bool_2_int;
  821. exit;
  822. end;
  823. { ansistring to pchar }
  824. if is_pchar(resulttype.def) and
  825. is_ansistring(left.resulttype.def) then
  826. begin
  827. convtype:=tc_ansistring_2_pchar;
  828. exit;
  829. end;
  830. { do common tc_equal cast }
  831. convtype:=tc_equal;
  832. { enum to ordinal will always be s32bit }
  833. if (left.resulttype.def.deftype=enumdef) and
  834. is_ordinal(resulttype.def) then
  835. begin
  836. if left.nodetype=ordconstn then
  837. begin
  838. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  839. result:=hp;
  840. exit;
  841. end
  842. else
  843. begin
  844. if isconvertable(s32bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  845. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  846. end;
  847. end
  848. { ordinal to enumeration }
  849. else
  850. if (resulttype.def.deftype=enumdef) and
  851. is_ordinal(left.resulttype.def) then
  852. begin
  853. if left.nodetype=ordconstn then
  854. begin
  855. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  856. result:=hp;
  857. exit;
  858. end
  859. else
  860. begin
  861. if IsConvertable(left.resulttype.def,s32bittype.def,convtype,ordconstn,false)=0 then
  862. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  863. end;
  864. end
  865. { nil to ordinal node }
  866. else if (left.nodetype=niln) and is_ordinal(resulttype.def) then
  867. begin
  868. hp:=cordconstnode.create(0,resulttype);
  869. result:=hp;
  870. exit;
  871. end
  872. { constant pointer to ordinal }
  873. else if is_ordinal(resulttype.def) and
  874. (left.nodetype=pointerconstn) then
  875. begin
  876. hp:=cordconstnode.create(tpointerconstnode(left).value,resulttype);
  877. result:=hp;
  878. exit;
  879. end
  880. {Are we typecasting an ordconst to a char?}
  881. else
  882. if is_char(resulttype.def) and
  883. is_ordinal(left.resulttype.def) then
  884. begin
  885. if left.nodetype=ordconstn then
  886. begin
  887. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  888. result:=hp;
  889. exit;
  890. end
  891. else
  892. begin
  893. if IsConvertable(left.resulttype.def,u8bittype.def,convtype,ordconstn,false)=0 then
  894. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  895. end;
  896. end
  897. {Are we typecasting an ordconst to a wchar?}
  898. else
  899. if is_widechar(resulttype.def) and
  900. is_ordinal(left.resulttype.def) then
  901. begin
  902. if left.nodetype=ordconstn then
  903. begin
  904. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  905. result:=hp;
  906. exit;
  907. end
  908. else
  909. begin
  910. if IsConvertable(left.resulttype.def,u16bittype.def,convtype,ordconstn,false)=0 then
  911. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  912. end;
  913. end
  914. { char to ordinal }
  915. else
  916. if is_char(left.resulttype.def) and
  917. is_ordinal(resulttype.def) then
  918. begin
  919. if left.nodetype=ordconstn then
  920. begin
  921. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  922. result:=hp;
  923. exit;
  924. end
  925. else
  926. begin
  927. if IsConvertable(u8bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  928. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  929. end;
  930. end
  931. { widechar to ordinal }
  932. else
  933. if is_widechar(left.resulttype.def) and
  934. is_ordinal(resulttype.def) then
  935. begin
  936. if left.nodetype=ordconstn then
  937. begin
  938. hp:=cordconstnode.create(tordconstnode(left).value,resulttype);
  939. result:=hp;
  940. exit;
  941. end
  942. else
  943. begin
  944. if IsConvertable(u16bittype.def,resulttype.def,convtype,ordconstn,false)=0 then
  945. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  946. end;
  947. end
  948. { only if the same size or formal def }
  949. { why do we allow typecasting of voiddef ?? (PM) }
  950. else
  951. begin
  952. if not(
  953. (left.resulttype.def.deftype=formaldef) or
  954. (left.resulttype.def.size=resulttype.def.size) or
  955. (is_void(left.resulttype.def) and
  956. (left.nodetype=derefn))
  957. ) then
  958. CGMessage(cg_e_illegal_type_conversion);
  959. if ((left.resulttype.def.deftype=orddef) and
  960. (resulttype.def.deftype=pointerdef)) or
  961. ((resulttype.def.deftype=orddef) and
  962. (left.resulttype.def.deftype=pointerdef)) then
  963. CGMessage(cg_d_pointer_to_longint_conv_not_portable);
  964. end;
  965. { the conversion into a strutured type is only }
  966. { possible, if the source is not a register }
  967. if ((resulttype.def.deftype in [recorddef,stringdef,arraydef]) or
  968. ((resulttype.def.deftype=objectdef) and not(is_class(resulttype.def)))
  969. ) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) { and
  970. it also works if the assignment is overloaded
  971. YES but this code is not executed if assignment is overloaded (PM)
  972. not assigned(assignment_overloaded(left.resulttype.def,resulttype.def))} then
  973. CGMessage(cg_e_illegal_type_conversion);
  974. end
  975. else
  976. CGMessage2(type_e_incompatible_types,left.resulttype.def.typename,resulttype.def.typename);
  977. end;
  978. { tp7 procvar support, when right is not a procvardef and we got a
  979. loadn of a procvar then convert to a calln, the check for the
  980. result is already done in is_convertible, also no conflict with
  981. @procvar is here because that has an extra addrn }
  982. if (m_tp_procvar in aktmodeswitches) and
  983. (resulttype.def.deftype<>procvardef) and
  984. (left.resulttype.def.deftype=procvardef) and
  985. (left.nodetype=loadn) then
  986. begin
  987. hp:=ccallnode.create(nil,nil,nil,nil);
  988. tcallnode(hp).set_procvar(left);
  989. resulttypepass(hp);
  990. left:=hp;
  991. end;
  992. { remove typeconv after niln, but not when the result is a
  993. methodpointer. The typeconv of the methodpointer will then
  994. take care of updateing size of niln to OS_64 }
  995. if (left.nodetype=niln) and
  996. not((resulttype.def.deftype=procvardef) and
  997. (po_methodpointer in tprocvardef(resulttype.def).procoptions)) then
  998. begin
  999. left.resulttype:=resulttype;
  1000. result:=left;
  1001. left:=nil;
  1002. exit;
  1003. end;
  1004. { ordinal contants can be directly converted }
  1005. if (left.nodetype=ordconstn) and is_ordinal(resulttype.def) then
  1006. begin
  1007. { replace the resulttype and recheck the range }
  1008. left.resulttype:=resulttype;
  1009. testrange(left.resulttype.def,tordconstnode(left).value,(nf_explizit in flags));
  1010. result:=left;
  1011. left:=nil;
  1012. exit;
  1013. end;
  1014. { fold nil to any pointer type }
  1015. if (left.nodetype=niln) and (resulttype.def.deftype=pointerdef) then
  1016. begin
  1017. hp:=cnilnode.create;
  1018. hp.resulttype:=resulttype;
  1019. result:=hp;
  1020. exit;
  1021. end;
  1022. { further, pointerconstn to any pointer is folded too }
  1023. if (left.nodetype=pointerconstn) and (resulttype.def.deftype=pointerdef) then
  1024. begin
  1025. left.resulttype:=resulttype;
  1026. result:=left;
  1027. left:=nil;
  1028. exit;
  1029. end;
  1030. { now call the resulttype helper to do constant folding }
  1031. result:=resulttype_call_helper(convtype);
  1032. end;
  1033. function ttypeconvnode.first_cord_to_pointer : tnode;
  1034. begin
  1035. result:=nil;
  1036. internalerror(200104043);
  1037. end;
  1038. function ttypeconvnode.first_int_to_int : tnode;
  1039. begin
  1040. first_int_to_int:=nil;
  1041. if (left.location.loc<>LOC_REGISTER) and
  1042. (resulttype.def.size>left.resulttype.def.size) then
  1043. location.loc:=LOC_REGISTER;
  1044. if is_64bitint(resulttype.def) then
  1045. registers32:=max(registers32,2)
  1046. else
  1047. registers32:=max(registers32,1);
  1048. end;
  1049. function ttypeconvnode.first_cstring_to_pchar : tnode;
  1050. begin
  1051. first_cstring_to_pchar:=nil;
  1052. registers32:=1;
  1053. location.loc:=LOC_REGISTER;
  1054. end;
  1055. function ttypeconvnode.first_string_to_chararray : tnode;
  1056. begin
  1057. first_string_to_chararray:=nil;
  1058. registers32:=1;
  1059. location.loc:=LOC_REGISTER;
  1060. end;
  1061. function ttypeconvnode.first_char_to_string : tnode;
  1062. begin
  1063. first_char_to_string:=nil;
  1064. location.loc:=LOC_CREFERENCE;
  1065. end;
  1066. function ttypeconvnode.first_nothing : tnode;
  1067. begin
  1068. first_nothing:=nil;
  1069. location.loc:=LOC_CREFERENCE;
  1070. end;
  1071. function ttypeconvnode.first_array_to_pointer : tnode;
  1072. begin
  1073. first_array_to_pointer:=nil;
  1074. if registers32<1 then
  1075. registers32:=1;
  1076. location.loc:=LOC_REGISTER;
  1077. end;
  1078. function ttypeconvnode.first_int_to_real : tnode;
  1079. begin
  1080. first_int_to_real:=nil;
  1081. {$ifdef m68k}
  1082. if (cs_fp_emulation in aktmoduleswitches) or
  1083. (tfloatdef(resulttype.def).typ=s32real) then
  1084. begin
  1085. if registers32<1 then
  1086. registers32:=1;
  1087. end
  1088. else
  1089. if registersfpu<1 then
  1090. registersfpu:=1;
  1091. {$else not m68k}
  1092. if registersfpu<1 then
  1093. registersfpu:=1;
  1094. {$endif not m68k}
  1095. location.loc:=LOC_FPUREGISTER;
  1096. end;
  1097. function ttypeconvnode.first_real_to_real : tnode;
  1098. begin
  1099. first_real_to_real:=nil;
  1100. { comp isn't a floating type }
  1101. {$ifdef i386}
  1102. if (tfloatdef(resulttype.def).typ=s64comp) and
  1103. (tfloatdef(left.resulttype.def).typ<>s64comp) and
  1104. not (nf_explizit in flags) then
  1105. CGMessage(type_w_convert_real_2_comp);
  1106. {$endif}
  1107. if registersfpu<1 then
  1108. registersfpu:=1;
  1109. location.loc:=LOC_FPUREGISTER;
  1110. end;
  1111. function ttypeconvnode.first_pointer_to_array : tnode;
  1112. begin
  1113. first_pointer_to_array:=nil;
  1114. if registers32<1 then
  1115. registers32:=1;
  1116. location.loc:=LOC_REFERENCE;
  1117. end;
  1118. function ttypeconvnode.first_cchar_to_pchar : tnode;
  1119. begin
  1120. first_cchar_to_pchar:=nil;
  1121. internalerror(200104021);
  1122. end;
  1123. function ttypeconvnode.first_bool_to_int : tnode;
  1124. begin
  1125. first_bool_to_int:=nil;
  1126. { byte(boolean) or word(wordbool) or longint(longbool) must
  1127. be accepted for var parameters }
  1128. if (nf_explizit in flags) and
  1129. (left.resulttype.def.size=resulttype.def.size) and
  1130. (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
  1131. exit;
  1132. { when converting to 64bit, first convert to a 32bit int and then }
  1133. { convert to a 64bit int (only necessary for 32bit processors) (JM) }
  1134. if resulttype.def.size > sizeof(aword) then
  1135. begin
  1136. result := ctypeconvnode.create(left,u32bittype);
  1137. result.toggleflag(nf_explizit);
  1138. result := ctypeconvnode.create(result,resulttype);
  1139. left := nil;
  1140. firstpass(result);
  1141. exit;
  1142. end;
  1143. location.loc:=LOC_REGISTER;
  1144. if registers32<1 then
  1145. registers32:=1;
  1146. end;
  1147. function ttypeconvnode.first_int_to_bool : tnode;
  1148. begin
  1149. first_int_to_bool:=nil;
  1150. { byte(boolean) or word(wordbool) or longint(longbool) must
  1151. be accepted for var parameters }
  1152. if (nf_explizit in flags) and
  1153. (left.resulttype.def.size=resulttype.def.size) and
  1154. (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
  1155. exit;
  1156. location.loc:=LOC_REGISTER;
  1157. { need if bool to bool !!
  1158. not very nice !!
  1159. insertypeconv(left,s32bittype);
  1160. left.explizit:=true;
  1161. firstpass(left); }
  1162. if registers32<1 then
  1163. registers32:=1;
  1164. end;
  1165. function ttypeconvnode.first_bool_to_bool : tnode;
  1166. begin
  1167. first_bool_to_bool:=nil;
  1168. location.loc:=LOC_REGISTER;
  1169. if registers32<1 then
  1170. registers32:=1;
  1171. end;
  1172. function ttypeconvnode.first_char_to_char : tnode;
  1173. begin
  1174. first_char_to_char:=nil;
  1175. location.loc:=LOC_REGISTER;
  1176. if registers32<1 then
  1177. registers32:=1;
  1178. end;
  1179. function ttypeconvnode.first_proc_to_procvar : tnode;
  1180. begin
  1181. first_proc_to_procvar:=nil;
  1182. if (left.location.loc<>LOC_REFERENCE) then
  1183. CGMessage(cg_e_illegal_expression);
  1184. registers32:=left.registers32;
  1185. if registers32<1 then
  1186. registers32:=1;
  1187. location.loc:=LOC_REGISTER;
  1188. end;
  1189. function ttypeconvnode.first_load_smallset : tnode;
  1190. var
  1191. srsym: ttypesym;
  1192. p: tcallparanode;
  1193. begin
  1194. if not searchsystype('FPC_SMALL_SET',srsym) then
  1195. internalerror(200108313);
  1196. p := ccallparanode.create(left,nil);
  1197. { reused }
  1198. left := nil;
  1199. { convert parameter explicitely to fpc_small_set }
  1200. p.left := ctypeconvnode.create(p.left,srsym.restype);
  1201. p.left.toggleflag(nf_explizit);
  1202. { create call, adjust resulttype }
  1203. result :=
  1204. ccallnode.createinternres('fpc_set_load_small',p,resulttype);
  1205. firstpass(result);
  1206. end;
  1207. function ttypeconvnode.first_ansistring_to_pchar : tnode;
  1208. begin
  1209. first_ansistring_to_pchar:=nil;
  1210. location.loc:=LOC_REGISTER;
  1211. if registers32<1 then
  1212. registers32:=1;
  1213. end;
  1214. function ttypeconvnode.first_arrayconstructor_to_set : tnode;
  1215. begin
  1216. first_arrayconstructor_to_set:=nil;
  1217. internalerror(200104022);
  1218. end;
  1219. function ttypeconvnode.first_class_to_intf : tnode;
  1220. begin
  1221. first_class_to_intf:=nil;
  1222. location.loc:=LOC_REFERENCE;
  1223. if registers32<1 then
  1224. registers32:=1;
  1225. end;
  1226. function ttypeconvnode.first_call_helper(c : tconverttype) : tnode;
  1227. const
  1228. firstconvert : array[tconverttype] of pointer = (
  1229. @ttypeconvnode.first_nothing, {equal}
  1230. @ttypeconvnode.first_nothing, {not_possible}
  1231. nil, { removed in resulttype_string_to_string }
  1232. @ttypeconvnode.first_char_to_string,
  1233. @ttypeconvnode.first_nothing, { char_2_chararray, needs nothing extra }
  1234. nil, { removed in resulttype_chararray_to_string }
  1235. @ttypeconvnode.first_cchar_to_pchar,
  1236. @ttypeconvnode.first_cstring_to_pchar,
  1237. @ttypeconvnode.first_ansistring_to_pchar,
  1238. @ttypeconvnode.first_string_to_chararray,
  1239. nil, { removed in resulttype_chararray_to_string }
  1240. @ttypeconvnode.first_array_to_pointer,
  1241. @ttypeconvnode.first_pointer_to_array,
  1242. @ttypeconvnode.first_int_to_int,
  1243. @ttypeconvnode.first_int_to_bool,
  1244. @ttypeconvnode.first_bool_to_bool,
  1245. @ttypeconvnode.first_bool_to_int,
  1246. @ttypeconvnode.first_real_to_real,
  1247. @ttypeconvnode.first_int_to_real,
  1248. @ttypeconvnode.first_proc_to_procvar,
  1249. @ttypeconvnode.first_arrayconstructor_to_set,
  1250. @ttypeconvnode.first_load_smallset,
  1251. @ttypeconvnode.first_cord_to_pointer,
  1252. @ttypeconvnode.first_nothing,
  1253. @ttypeconvnode.first_nothing,
  1254. @ttypeconvnode.first_class_to_intf,
  1255. @ttypeconvnode.first_char_to_char,
  1256. @ttypeconvnode.first_nothing,
  1257. @ttypeconvnode.first_nothing
  1258. );
  1259. type
  1260. tprocedureofobject = function : tnode of object;
  1261. var
  1262. r : packed record
  1263. proc : pointer;
  1264. obj : pointer;
  1265. end;
  1266. begin
  1267. { this is a little bit dirty but it works }
  1268. { and should be quite portable too }
  1269. r.proc:=firstconvert[c];
  1270. r.obj:=self;
  1271. first_call_helper:=tprocedureofobject(r){$ifdef FPC}();{$endif FPC}
  1272. end;
  1273. function ttypeconvnode.pass_1 : tnode;
  1274. begin
  1275. result:=nil;
  1276. firstpass(left);
  1277. if codegenerror then
  1278. exit;
  1279. { load the value_str from the left part }
  1280. registers32:=left.registers32;
  1281. registersfpu:=left.registersfpu;
  1282. {$ifdef SUPPORT_MMX}
  1283. registersmmx:=left.registersmmx;
  1284. {$endif}
  1285. location.loc:=left.location.loc;
  1286. if nf_explizit in flags then
  1287. begin
  1288. { check if the result could be in a register }
  1289. if not(tstoreddef(resulttype.def).is_intregable) and
  1290. not(tstoreddef(resulttype.def).is_fpuregable) then
  1291. make_not_regable(left);
  1292. end;
  1293. if convtype=tc_equal then
  1294. begin
  1295. { remove typeconv node if left is a const. For other nodes we can't
  1296. remove it because the secondpass can still depend on the old type (PFV)
  1297. Conversions to float should also be left in the tree, because a float
  1298. is not possible in LOC_CONSTANT. The second_nothing routine will take
  1299. care of the conversion to LOC_REFERENCE }
  1300. if is_constnode(left) and
  1301. (resulttype.def.deftype<>floatdef) then
  1302. begin
  1303. left.resulttype:=resulttype;
  1304. result:=left;
  1305. left:=nil;
  1306. end;
  1307. end
  1308. else
  1309. begin
  1310. result:=first_call_helper(convtype);
  1311. end;
  1312. end;
  1313. function ttypeconvnode.docompare(p: tnode) : boolean;
  1314. begin
  1315. docompare :=
  1316. inherited docompare(p) and
  1317. (convtype = ttypeconvnode(p).convtype);
  1318. end;
  1319. {*****************************************************************************
  1320. TISNODE
  1321. *****************************************************************************}
  1322. constructor tisnode.create(l,r : tnode);
  1323. begin
  1324. inherited create(isn,l,r);
  1325. end;
  1326. function tisnode.det_resulttype:tnode;
  1327. var
  1328. paras: tcallparanode;
  1329. begin
  1330. result:=nil;
  1331. resulttypepass(left);
  1332. resulttypepass(right);
  1333. set_varstate(left,true);
  1334. set_varstate(right,true);
  1335. if codegenerror then
  1336. exit;
  1337. if (right.resulttype.def.deftype=classrefdef) then
  1338. begin
  1339. { left must be a class }
  1340. if is_class(left.resulttype.def) then
  1341. begin
  1342. { the operands must be related }
  1343. if (not(tobjectdef(left.resulttype.def).is_related(
  1344. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1345. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1346. tobjectdef(left.resulttype.def)))) then
  1347. CGMessage(type_e_mismatch);
  1348. end
  1349. else
  1350. CGMessage(type_e_mismatch);
  1351. { call fpc_do_is helper }
  1352. paras := ccallparanode.create(
  1353. left,
  1354. ccallparanode.create(
  1355. right,nil));
  1356. result := ccallnode.createintern('fpc_do_is',paras);
  1357. left := nil;
  1358. right := nil;
  1359. end
  1360. else if is_interface(right.resulttype.def) then
  1361. begin
  1362. { left is a class }
  1363. if is_class(left.resulttype.def) then
  1364. begin
  1365. { the operands must be related }
  1366. if not(assigned(tobjectdef(left.resulttype.def).implementedinterfaces) and
  1367. (tobjectdef(left.resulttype.def).implementedinterfaces.searchintf(right.resulttype.def)<>-1)) then
  1368. CGMessage(type_e_mismatch);
  1369. end
  1370. { left is an interface }
  1371. else if is_interface(left.resulttype.def) then
  1372. begin
  1373. { the operands must be related }
  1374. if (not(tobjectdef(left.resulttype.def).is_related(tobjectdef(right.resulttype.def)))) and
  1375. (not(tobjectdef(right.resulttype.def).is_related(tobjectdef(left.resulttype.def)))) then
  1376. CGMessage(type_e_mismatch);
  1377. end
  1378. else
  1379. CGMessage(type_e_mismatch);
  1380. { call fpc_do_is helper }
  1381. paras := ccallparanode.create(
  1382. left,
  1383. ccallparanode.create(
  1384. right,nil));
  1385. result := ccallnode.createintern('fpc_do_is',paras);
  1386. left := nil;
  1387. right := nil;
  1388. end
  1389. else
  1390. CGMessage(type_e_mismatch);
  1391. resulttype:=booltype;
  1392. end;
  1393. function tisnode.pass_1 : tnode;
  1394. begin
  1395. internalerror(200204254);
  1396. result:=nil;
  1397. end;
  1398. { dummy pass_2, it will never be called, but we need one since }
  1399. { you can't instantiate an abstract class }
  1400. procedure tisnode.pass_2;
  1401. begin
  1402. end;
  1403. {*****************************************************************************
  1404. TASNODE
  1405. *****************************************************************************}
  1406. constructor tasnode.create(l,r : tnode);
  1407. begin
  1408. inherited create(asn,l,r);
  1409. end;
  1410. function tasnode.det_resulttype:tnode;
  1411. var
  1412. paras : tcallparanode;
  1413. begin
  1414. result:=nil;
  1415. resulttypepass(right);
  1416. resulttypepass(left);
  1417. set_varstate(right,true);
  1418. set_varstate(left,true);
  1419. if codegenerror then
  1420. exit;
  1421. if (right.resulttype.def.deftype=classrefdef) then
  1422. begin
  1423. { left must be a class }
  1424. if is_class(left.resulttype.def) then
  1425. begin
  1426. { the operands must be related }
  1427. if (not(tobjectdef(left.resulttype.def).is_related(
  1428. tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def)))) and
  1429. (not(tobjectdef(tclassrefdef(right.resulttype.def).pointertype.def).is_related(
  1430. tobjectdef(left.resulttype.def)))) then
  1431. CGMessage(type_e_mismatch);
  1432. end
  1433. else
  1434. CGMessage(type_e_mismatch);
  1435. { call fpc_do_as helper }
  1436. paras := ccallparanode.create(
  1437. left,
  1438. ccallparanode.create(
  1439. right,nil));
  1440. result := ccallnode.createinternres('fpc_do_as',paras,tclassrefdef(right.resulttype.def).pointertype);
  1441. left := nil;
  1442. right := nil;
  1443. end
  1444. else if is_interface(right.resulttype.def) then
  1445. begin
  1446. { left is a class }
  1447. if is_class(left.resulttype.def) then
  1448. begin
  1449. { the operands must be related }
  1450. if not(assigned(tobjectdef(left.resulttype.def).implementedinterfaces) and
  1451. (tobjectdef(left.resulttype.def).implementedinterfaces.searchintf(right.resulttype.def)<>-1)) then
  1452. CGMessage(type_e_mismatch);
  1453. end
  1454. { left is an interface }
  1455. else if is_interface(left.resulttype.def) then
  1456. begin
  1457. { the operands must be related }
  1458. if (not(tobjectdef(left.resulttype.def).is_related(tobjectdef(right.resulttype.def)))) and
  1459. (not(tobjectdef(right.resulttype.def).is_related(tobjectdef(left.resulttype.def)))) then
  1460. CGMessage(type_e_mismatch);
  1461. end
  1462. else
  1463. CGMessage(type_e_mismatch);
  1464. { call fpc_do_as helper }
  1465. paras := ccallparanode.create(
  1466. left,
  1467. ccallparanode.create(
  1468. right,nil));
  1469. result := ccallnode.createinternres('fpc_do_as',paras,right.resulttype);
  1470. left := nil;
  1471. right := nil;
  1472. end
  1473. else
  1474. CGMessage(type_e_mismatch);
  1475. end;
  1476. function tasnode.pass_1 : tnode;
  1477. begin
  1478. internalerror(200204252);
  1479. result:=nil;
  1480. end;
  1481. { dummy pass_2, it will never be called, but we need one since }
  1482. { you can't instantiate an abstract class }
  1483. procedure tasnode.pass_2;
  1484. begin
  1485. end;
  1486. begin
  1487. ctypeconvnode:=ttypeconvnode;
  1488. casnode:=tasnode;
  1489. cisnode:=tisnode;
  1490. end.
  1491. {
  1492. $Log$
  1493. Revision 1.54 2002-04-25 20:16:38 peter
  1494. * moved more routines from cga/n386util
  1495. Revision 1.53 2002/04/23 19:16:34 peter
  1496. * add pinline unit that inserts compiler supported functions using
  1497. one or more statements
  1498. * moved finalize and setlength from ninl to pinline
  1499. Revision 1.52 2002/04/21 19:02:03 peter
  1500. * removed newn and disposen nodes, the code is now directly
  1501. inlined from pexpr
  1502. * -an option that will write the secondpass nodes to the .s file, this
  1503. requires EXTDEBUG define to actually write the info
  1504. * fixed various internal errors and crashes due recent code changes
  1505. Revision 1.51 2002/04/06 18:10:42 jonas
  1506. * several powerpc-related additions and fixes
  1507. Revision 1.50 2002/04/04 19:05:58 peter
  1508. * removed unused units
  1509. * use tlocation.size in cg.a_*loc*() routines
  1510. Revision 1.49 2002/04/02 17:11:28 peter
  1511. * tlocation,treference update
  1512. * LOC_CONSTANT added for better constant handling
  1513. * secondadd splitted in multiple routines
  1514. * location_force_reg added for loading a location to a register
  1515. of a specified size
  1516. * secondassignment parses now first the right and then the left node
  1517. (this is compatible with Kylix). This saves a lot of push/pop especially
  1518. with string operations
  1519. * adapted some routines to use the new cg methods
  1520. Revision 1.48 2002/02/03 09:30:03 peter
  1521. * more fixes for protected handling
  1522. Revision 1.47 2001/12/10 14:34:04 jonas
  1523. * fixed type conversions from dynamic arrays to open arrays
  1524. Revision 1.46 2001/12/06 17:57:34 florian
  1525. + parasym to tparaitem added
  1526. Revision 1.45 2001/12/03 21:48:41 peter
  1527. * freemem change to value parameter
  1528. * torddef low/high range changed to int64
  1529. Revision 1.44 2001/11/02 23:24:11 jonas
  1530. * fixed web bug 1665 (allow char to chararray type conversion) ("merged")
  1531. Revision 1.43 2001/11/02 22:58:02 peter
  1532. * procsym definition rewrite
  1533. Revision 1.42 2001/10/28 17:22:25 peter
  1534. * allow assignment of overloaded procedures to procvars when we know
  1535. which procedure to take
  1536. Revision 1.41 2001/10/20 19:28:37 peter
  1537. * interface 2 guid support
  1538. * guid constants support
  1539. Revision 1.40 2001/10/20 17:21:54 peter
  1540. * fixed size of constset when change from small to normalset
  1541. Revision 1.39 2001/09/30 16:12:46 jonas
  1542. - removed unnecessary i386 pass_2 of as- and isnode and added dummy generic ones
  1543. Revision 1.38 2001/09/29 21:32:46 jonas
  1544. * almost all second pass typeconvnode helpers are now processor independent
  1545. * fixed converting boolean to int64/qword
  1546. * fixed register allocation bugs which could cause internalerror 10
  1547. * isnode and asnode are completely processor indepent now as well
  1548. * fpc_do_as now returns its class argument (necessary to be able to use it
  1549. properly with compilerproc)
  1550. Revision 1.37 2001/09/03 13:27:42 jonas
  1551. * compilerproc implementation of set addition/substraction/...
  1552. * changed the declaration of some set helpers somewhat to accomodate the
  1553. above change
  1554. * i386 still uses the old code for comparisons of sets, because its
  1555. helpers return the results in the flags
  1556. * dummy tc_normal_2_small_set type conversion because I need the original
  1557. resulttype of the set add nodes
  1558. NOTE: you have to start a cycle with 1.0.5!
  1559. Revision 1.36 2001/09/02 21:12:06 peter
  1560. * move class of definitions into type section for delphi
  1561. Revision 1.35 2001/08/29 19:49:03 jonas
  1562. * some fixes in compilerprocs for chararray to string conversions
  1563. * conversion from string to chararray is now also done via compilerprocs
  1564. Revision 1.34 2001/08/29 12:18:07 jonas
  1565. + new createinternres() constructor for tcallnode to support setting a
  1566. custom resulttype
  1567. * compilerproc typeconversions now set the resulttype from the type
  1568. conversion for the generated call node, because the resulttype of
  1569. of the compilerproc helper isn't always exact (e.g. the ones that
  1570. return shortstrings, actually return a shortstring[x], where x is
  1571. specified by the typeconversion node)
  1572. * ti386callnode.pass_2 now always uses resulttype instead of
  1573. procsym.definition.rettype (so the custom resulttype, if any, is
  1574. always used). Note that this "rettype" stuff is only for use with
  1575. compilerprocs.
  1576. Revision 1.33 2001/08/28 13:24:46 jonas
  1577. + compilerproc implementation of most string-related type conversions
  1578. - removed all code from the compiler which has been replaced by
  1579. compilerproc implementations (using (ifdef hascompilerproc) is not
  1580. necessary in the compiler)
  1581. Revision 1.32 2001/08/26 13:36:40 florian
  1582. * some cg reorganisation
  1583. * some PPC updates
  1584. Revision 1.31 2001/08/05 13:19:51 peter
  1585. * partly fix for proc of obj=nil
  1586. Revision 1.30 2001/07/30 20:59:27 peter
  1587. * m68k updates from v10 merged
  1588. Revision 1.29 2001/07/08 21:00:15 peter
  1589. * various widestring updates, it works now mostly without charset
  1590. mapping supported
  1591. Revision 1.28 2001/05/13 15:43:46 florian
  1592. * made resultype_char_to_char a little bit robuster
  1593. Revision 1.27 2001/05/08 21:06:30 florian
  1594. * some more support for widechars commited especially
  1595. regarding type casting and constants
  1596. Revision 1.26 2001/05/04 15:52:03 florian
  1597. * some Delphi incompatibilities fixed:
  1598. - out, dispose and new can be used as idenfiers now
  1599. - const p = apointerype(nil); is supported now
  1600. + support for const p = apointertype(pointer(1234)); added
  1601. Revision 1.25 2001/04/13 22:20:58 peter
  1602. * remove wrongly placed first_call_helper
  1603. Revision 1.24 2001/04/13 01:22:08 peter
  1604. * symtable change to classes
  1605. * range check generation and errors fixed, make cycle DEBUG=1 works
  1606. * memory leaks fixed
  1607. Revision 1.23 2001/04/04 22:42:39 peter
  1608. * move constant folding into det_resulttype
  1609. Revision 1.22 2001/04/02 21:20:30 peter
  1610. * resulttype rewrite
  1611. Revision 1.21 2001/03/08 17:44:47 jonas
  1612. * fixed web bug 1430
  1613. Revision 1.20 2001/02/21 11:49:50 jonas
  1614. * evaluate typecasts of const pointers to ordinals inline ('merged')
  1615. Revision 1.19 2001/02/20 18:37:10 peter
  1616. * removed unused code
  1617. Revision 1.18 2001/02/20 13:14:18 marco
  1618. * Fix from Peter for passing a procedure of method to a other method in a method
  1619. Revision 1.17 2001/02/08 13:09:03 jonas
  1620. * fixed web bug 1396: tpointerord is now a cardinal instead of a longint,
  1621. but added a hack in ncnv so that pointer(-1) still works
  1622. Revision 1.16 2000/12/31 11:14:10 jonas
  1623. + implemented/fixed docompare() mathods for all nodes (not tested)
  1624. + nopt.pas, nadd.pas, i386/n386opt.pas: optimized nodes for adding strings
  1625. and constant strings/chars together
  1626. * n386add.pas: don't copy temp strings (of size 256) to another temp string
  1627. when adding
  1628. Revision 1.15 2000/12/08 12:41:01 jonas
  1629. * fixed bug in sign extension patch
  1630. Revision 1.14 2000/12/07 17:19:42 jonas
  1631. * new constant handling: from now on, hex constants >$7fffffff are
  1632. parsed as unsigned constants (otherwise, $80000000 got sign extended
  1633. and became $ffffffff80000000), all constants in the longint range
  1634. become longints, all constants >$7fffffff and <=cardinal($ffffffff)
  1635. are cardinals and the rest are int64's.
  1636. * added lots of longint typecast to prevent range check errors in the
  1637. compiler and rtl
  1638. * type casts of symbolic ordinal constants are now preserved
  1639. * fixed bug where the original resulttype.def wasn't restored correctly
  1640. after doing a 64bit rangecheck
  1641. Revision 1.13 2000/11/29 00:30:32 florian
  1642. * unused units removed from uses clause
  1643. * some changes for widestrings
  1644. Revision 1.12 2000/11/20 16:06:04 jonas
  1645. + allow evaluation of 64bit constant expressions at compile time
  1646. * disable range checking for explicit typecasts of constant expressions
  1647. Revision 1.11 2000/11/12 23:24:11 florian
  1648. * interfaces are basically running
  1649. Revision 1.10 2000/11/04 14:25:20 florian
  1650. + merged Attila's changes for interfaces, not tested yet
  1651. Revision 1.9 2000/10/31 22:02:48 peter
  1652. * symtable splitted, no real code changes
  1653. Revision 1.8 2000/10/14 21:52:55 peter
  1654. * fixed memory leaks
  1655. Revision 1.7 2000/10/14 10:14:50 peter
  1656. * moehrendorf oct 2000 rewrite
  1657. Revision 1.6 2000/10/01 19:48:24 peter
  1658. * lot of compile updates for cg11
  1659. Revision 1.5 2000/09/28 19:49:52 florian
  1660. *** empty log message ***
  1661. Revision 1.4 2000/09/27 18:14:31 florian
  1662. * fixed a lot of syntax errors in the n*.pas stuff
  1663. Revision 1.3 2000/09/26 20:06:13 florian
  1664. * hmm, still a lot of work to get things compilable
  1665. Revision 1.2 2000/09/26 14:59:34 florian
  1666. * more conversion work done
  1667. Revision 1.1 2000/09/25 15:37:14 florian
  1668. * more fixes
  1669. }