ninl.pas 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Type checking and register allocation for inline 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 ninl;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. node,htypechk;
  23. {$i innr.inc}
  24. type
  25. tinlinenode = class(tunarynode)
  26. inlinenumber : byte;
  27. constructor create(number : byte;is_const:boolean;l : tnode);virtual;
  28. function getcopy : tnode;override;
  29. function pass_1 : tnode;override;
  30. end;
  31. var
  32. cinlinenode : class of tinlinenode;
  33. function geninlinenode(number : byte;is_const:boolean;l : tnode) : tinlinenode;
  34. implementation
  35. uses
  36. cobjects,verbose,globals,systems,
  37. globtype,
  38. symconst,symtable,aasm,types,
  39. pass_1,
  40. ncal,ncon,ncnv,nadd,nld,
  41. cpubase
  42. {$ifdef newcg}
  43. ,cgbase
  44. ,tgobj
  45. ,tgcpu
  46. {$else newcg}
  47. ,hcodegen
  48. {$ifdef i386}
  49. ,tgeni386
  50. {$endif}
  51. {$endif newcg}
  52. ;
  53. function geninlinenode(number : byte;is_const:boolean;l : tnode) : tinlinenode;
  54. begin
  55. geninlinenode:=cinlinenode.create(number,is_const,l);
  56. end;
  57. {*****************************************************************************
  58. TINLINENODE
  59. *****************************************************************************}
  60. constructor tinlinenode.create(number : byte;is_const:boolean;l : tnode);
  61. begin
  62. inherited create(inlinen,l);
  63. if is_const then
  64. include(flags,nf_inlineconst);
  65. inlinenumber:=number;
  66. end;
  67. function tinlinenode.getcopy : tnode;
  68. var
  69. n : tinlinenode;
  70. begin
  71. n:=tinlinenode(inherited getcopy);
  72. n.inlinenumber:=inlinenumber;
  73. end;
  74. {$ifdef fpc}
  75. {$maxfpuregisters 0}
  76. {$endif fpc}
  77. function tinlinenode.pass_1 : tnode;
  78. var
  79. vl,vl2 : longint;
  80. vr : bestreal;
  81. p1,hp,hpp : tnode;
  82. {$ifndef NOCOLONCHECK}
  83. frac_para,length_para : tnode;
  84. {$endif ndef NOCOLONCHECK}
  85. extra_register,
  86. isreal,
  87. dowrite,
  88. file_is_typed : boolean;
  89. function do_lowhigh(adef : pdef) : tnode;
  90. var
  91. v : longint;
  92. enum : penumsym;
  93. begin
  94. case Adef^.deftype of
  95. orddef:
  96. begin
  97. if inlinenumber=in_low_x then
  98. v:=porddef(adef)^.low
  99. else
  100. v:=porddef(adef)^.high;
  101. hp:=genordinalconstnode(v,adef);
  102. firstpass(hp);
  103. do_lowhigh:=hp;
  104. end;
  105. enumdef:
  106. begin
  107. enum:=Penumdef(Adef)^.firstenum;
  108. if inlinenumber=in_high_x then
  109. while enum^.nextenum<>nil do
  110. enum:=enum^.nextenum;
  111. hp:=genenumnode(enum);
  112. do_lowhigh:=hp;
  113. end;
  114. else
  115. internalerror(87);
  116. end;
  117. end;
  118. function getconstrealvalue : bestreal;
  119. begin
  120. case left.nodetype of
  121. ordconstn:
  122. getconstrealvalue:=tordconstnode(left).value;
  123. realconstn:
  124. getconstrealvalue:=trealconstnode(left).value_real;
  125. else
  126. internalerror(309992);
  127. end;
  128. end;
  129. procedure setconstrealvalue(r : bestreal);
  130. var
  131. hp : tnode;
  132. begin
  133. hp:=genrealconstnode(r,bestrealdef^);
  134. firstpass(hp);
  135. end;
  136. procedure handleextendedfunction;
  137. begin
  138. location.loc:=LOC_FPU;
  139. resulttype:=s80floatdef;
  140. { redo firstpass for varstate status PM }
  141. set_varstate(left,true);
  142. if (left.resulttype^.deftype<>floatdef) or
  143. (pfloatdef(left.resulttype)^.typ<>s80real) then
  144. begin
  145. left:=gentypeconvnode(left,s80floatdef);
  146. firstpass(left);
  147. end;
  148. registers32:=left.registers32;
  149. registersfpu:=left.registersfpu;
  150. {$ifdef SUPPORT_MMX}
  151. registersmmx:=left.registersmmx;
  152. {$endif SUPPORT_MMX}
  153. end;
  154. begin
  155. { if we handle writeln; left contains no valid address }
  156. if assigned(left) then
  157. begin
  158. if left.nodetype=callparan then
  159. tcallparanode(left).firstcallparan(nil,false)
  160. else
  161. firstpass(left);
  162. left_max;
  163. set_location(location,left.location);
  164. end;
  165. inc(parsing_para_level);
  166. { handle intern constant functions in separate case }
  167. if nf_inlineconst in flags then
  168. begin
  169. hp:=nil;
  170. { no parameters? }
  171. if not assigned(left) then
  172. begin
  173. case inlinenumber of
  174. in_const_pi :
  175. hp:=genrealconstnode(pi,bestrealdef^);
  176. else
  177. internalerror(89);
  178. end;
  179. end
  180. else
  181. { process constant expression with parameter }
  182. begin
  183. vl:=0;
  184. vl2:=0; { second parameter Ex: ptr(vl,vl2) }
  185. vr:=0;
  186. isreal:=false;
  187. case left.nodetype of
  188. realconstn :
  189. begin
  190. isreal:=true;
  191. vr:=trealconstnode(left).value_real;
  192. end;
  193. ordconstn :
  194. vl:=tordconstnode(left).value;
  195. callparan :
  196. begin
  197. { both exists, else it was not generated }
  198. vl:=tordconstnode(tcallparanode(left).left).value;
  199. vl2:=tordconstnode(tcallparanode(tcallparanode(left).right).left).value;
  200. end;
  201. else
  202. CGMessage(cg_e_illegal_expression);
  203. end;
  204. case inlinenumber of
  205. in_const_trunc :
  206. begin
  207. if isreal then
  208. begin
  209. if (vr>=2147483648.0) or (vr<=-2147483649.0) then
  210. begin
  211. CGMessage(parser_e_range_check_error);
  212. hp:=genordinalconstnode(1,s32bitdef)
  213. end
  214. else
  215. hp:=genordinalconstnode(trunc(vr),s32bitdef)
  216. end
  217. else
  218. hp:=genordinalconstnode(trunc(vl),s32bitdef);
  219. end;
  220. in_const_round :
  221. begin
  222. if isreal then
  223. begin
  224. if (vr>=2147483647.5) or (vr<=-2147483648.5) then
  225. begin
  226. CGMessage(parser_e_range_check_error);
  227. hp:=genordinalconstnode(1,s32bitdef)
  228. end
  229. else
  230. hp:=genordinalconstnode(round(vr),s32bitdef)
  231. end
  232. else
  233. hp:=genordinalconstnode(round(vl),s32bitdef);
  234. end;
  235. in_const_frac :
  236. begin
  237. if isreal then
  238. hp:=genrealconstnode(frac(vr),bestrealdef^)
  239. else
  240. hp:=genrealconstnode(frac(vl),bestrealdef^);
  241. end;
  242. in_const_int :
  243. begin
  244. if isreal then
  245. hp:=genrealconstnode(int(vr),bestrealdef^)
  246. else
  247. hp:=genrealconstnode(int(vl),bestrealdef^);
  248. end;
  249. in_const_abs :
  250. begin
  251. if isreal then
  252. hp:=genrealconstnode(abs(vr),bestrealdef^)
  253. else
  254. hp:=genordinalconstnode(abs(vl),left.resulttype);
  255. end;
  256. in_const_sqr :
  257. begin
  258. if isreal then
  259. hp:=genrealconstnode(sqr(vr),bestrealdef^)
  260. else
  261. hp:=genordinalconstnode(sqr(vl),left.resulttype);
  262. end;
  263. in_const_odd :
  264. begin
  265. if isreal then
  266. CGMessage1(type_e_integer_expr_expected,left.resulttype^.typename)
  267. else
  268. hp:=genordinalconstnode(byte(odd(vl)),booldef);
  269. end;
  270. in_const_swap_word :
  271. begin
  272. if isreal then
  273. CGMessage1(type_e_integer_expr_expected,left.resulttype^.typename)
  274. else
  275. hp:=genordinalconstnode((vl and $ff) shl 8+(vl shr 8),left.resulttype);
  276. end;
  277. in_const_swap_long :
  278. begin
  279. if isreal then
  280. CGMessage(type_e_mismatch)
  281. else
  282. hp:=genordinalconstnode((vl and $ffff) shl 16+(vl shr 16),left.resulttype);
  283. end;
  284. in_const_ptr :
  285. begin
  286. if isreal then
  287. CGMessage(type_e_mismatch)
  288. else
  289. hp:=genordinalconstnode((vl2 shl 16) or vl,voidpointerdef);
  290. end;
  291. in_const_sqrt :
  292. begin
  293. if isreal then
  294. begin
  295. if vr<0.0 then
  296. CGMessage(type_e_wrong_math_argument)
  297. else
  298. hp:=genrealconstnode(sqrt(vr),bestrealdef^)
  299. end
  300. else
  301. begin
  302. if vl<0 then
  303. CGMessage(type_e_wrong_math_argument)
  304. else
  305. hp:=genrealconstnode(sqrt(vl),bestrealdef^);
  306. end;
  307. end;
  308. in_const_arctan :
  309. begin
  310. if isreal then
  311. hp:=genrealconstnode(arctan(vr),bestrealdef^)
  312. else
  313. hp:=genrealconstnode(arctan(vl),bestrealdef^);
  314. end;
  315. in_const_cos :
  316. begin
  317. if isreal then
  318. hp:=genrealconstnode(cos(vr),bestrealdef^)
  319. else
  320. hp:=genrealconstnode(cos(vl),bestrealdef^);
  321. end;
  322. in_const_sin :
  323. begin
  324. if isreal then
  325. hp:=genrealconstnode(sin(vr),bestrealdef^)
  326. else
  327. hp:=genrealconstnode(sin(vl),bestrealdef^);
  328. end;
  329. in_const_exp :
  330. begin
  331. if isreal then
  332. hp:=genrealconstnode(exp(vr),bestrealdef^)
  333. else
  334. hp:=genrealconstnode(exp(vl),bestrealdef^);
  335. end;
  336. in_const_ln :
  337. begin
  338. if isreal then
  339. begin
  340. if vr<=0.0 then
  341. CGMessage(type_e_wrong_math_argument)
  342. else
  343. hp:=genrealconstnode(ln(vr),bestrealdef^)
  344. end
  345. else
  346. begin
  347. if vl<=0 then
  348. CGMessage(type_e_wrong_math_argument)
  349. else
  350. hp:=genrealconstnode(ln(vl),bestrealdef^);
  351. end;
  352. end;
  353. else
  354. internalerror(88);
  355. end;
  356. end;
  357. if hp=nil then
  358. hp:=tnode.create(errorn);
  359. firstpass(hp);
  360. pass_1:=hp;
  361. end
  362. else
  363. begin
  364. case inlinenumber of
  365. in_lo_qword,
  366. in_hi_qword,
  367. in_lo_long,
  368. in_hi_long,
  369. in_lo_word,
  370. in_hi_word:
  371. begin
  372. set_varstate(left,true);
  373. if registers32<1 then
  374. registers32:=1;
  375. if inlinenumber in [in_lo_word,in_hi_word] then
  376. resulttype:=u8bitdef
  377. else if inlinenumber in [in_lo_qword,in_hi_qword] then
  378. begin
  379. resulttype:=u32bitdef;
  380. if (m_tp in aktmodeswitches) or
  381. (m_delphi in aktmodeswitches) then
  382. CGMessage(type_w_maybe_wrong_hi_lo);
  383. end
  384. else
  385. begin
  386. resulttype:=u16bitdef;
  387. if (m_tp in aktmodeswitches) or
  388. (m_delphi in aktmodeswitches) then
  389. CGMessage(type_w_maybe_wrong_hi_lo);
  390. end;
  391. location.loc:=LOC_REGISTER;
  392. if not is_integer(left.resulttype) then
  393. CGMessage(type_e_mismatch)
  394. else
  395. begin
  396. if left.nodetype=ordconstn then
  397. begin
  398. case inlinenumber of
  399. in_lo_word : hp:=genordinalconstnode(tordconstnode(left).value and $ff,left.resulttype);
  400. in_hi_word : hp:=genordinalconstnode(tordconstnode(left).value shr 8,left.resulttype);
  401. in_lo_long : hp:=genordinalconstnode(tordconstnode(left).value and $ffff,left.resulttype);
  402. in_hi_long : hp:=genordinalconstnode(tordconstnode(left).value shr 16,left.resulttype);
  403. in_lo_qword : hp:=genordinalconstnode(tordconstnode(left).value and $ffffffff,left.resulttype);
  404. in_hi_qword : hp:=genordinalconstnode(tordconstnode(left).value shr 32,left.resulttype);
  405. end;
  406. firstpass(hp);
  407. pass_1:=hp;
  408. end;
  409. end;
  410. end;
  411. in_sizeof_x:
  412. begin
  413. set_varstate(left,false);
  414. if push_high_param(left.resulttype) then
  415. begin
  416. getsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
  417. hp:=caddnode.create(addn,genloadnode(pvarsym(srsym),tloadnode(left).symtable),
  418. genordinalconstnode(1,s32bitdef));
  419. if (left.resulttype^.deftype=arraydef) and
  420. (parraydef(left.resulttype)^.elesize<>1) then
  421. hp:=caddnode.create(muln,hp,genordinalconstnode(parraydef(left.resulttype)^.elesize,s32bitdef));
  422. firstpass(hp);
  423. end;
  424. if hp.registers32<1 then
  425. hp.registers32:=1;
  426. hp.resulttype:=s32bitdef;
  427. hp.location.loc:=LOC_REGISTER;
  428. pass_1:=hp;
  429. end;
  430. in_typeof_x:
  431. begin
  432. set_varstate(left,false);
  433. if registers32<1 then
  434. registers32:=1;
  435. location.loc:=LOC_REGISTER;
  436. resulttype:=voidpointerdef;
  437. end;
  438. in_ord_x:
  439. begin
  440. set_varstate(left,true);
  441. if (left.nodetype=ordconstn) then
  442. begin
  443. hp:=genordinalconstnode(tordconstnode(left).value,s32bitdef);
  444. firstpass(hp);
  445. pass_1:=hp;
  446. end
  447. else
  448. begin
  449. { otherwise you get a crash if you try ord on an expression containing }
  450. { an undeclared variable (JM) }
  451. if not assigned(left.resulttype) then
  452. exit;
  453. if (left.resulttype^.deftype=orddef) then
  454. if (porddef(left.resulttype)^.typ in [uchar,uwidechar,bool8bit]) then
  455. case porddef(left.resulttype)^.typ of
  456. uchar:
  457. begin
  458. hp:=gentypeconvnode(left,u8bitdef);
  459. left:=nil;
  460. include(hp.flags,nf_explizit);
  461. firstpass(hp);
  462. pass_1:=hp;
  463. end;
  464. uwidechar:
  465. begin
  466. hp:=gentypeconvnode(left,u16bitdef);
  467. left:=nil;
  468. include(hp.flags,nf_explizit);
  469. firstpass(hp);
  470. pass_1:=hp;
  471. end;
  472. bool8bit:
  473. begin
  474. hp:=gentypeconvnode(left,u8bitdef);
  475. left:=nil;
  476. ttypeconvnode(hp).convtype:=tc_bool_2_int;
  477. include(hp.flags,nf_explizit);
  478. firstpass(hp);
  479. pass_1:=hp;
  480. end
  481. end
  482. { can this happen ? }
  483. else if (porddef(left.resulttype)^.typ=uvoid) then
  484. CGMessage(type_e_mismatch)
  485. else
  486. { all other orddef need no transformation }
  487. begin
  488. hp:=left;
  489. left:=nil;
  490. pass_1:=hp;
  491. end
  492. else if (left.resulttype^.deftype=enumdef) then
  493. begin
  494. hp:=gentypeconvnode(left,s32bitdef);
  495. left:=nil;
  496. include(hp.flags,nf_explizit);
  497. firstpass(hp);
  498. pass_1:=hp;
  499. end
  500. else
  501. begin
  502. { can anything else be ord() ?}
  503. CGMessage(type_e_mismatch);
  504. end;
  505. end;
  506. end;
  507. in_chr_byte:
  508. begin
  509. set_varstate(left,true);
  510. hp:=gentypeconvnode(left,cchardef);
  511. left:=nil;
  512. include(hp.flags,nf_explizit);
  513. firstpass(hp);
  514. pass_1:=hp;
  515. end;
  516. in_length_string:
  517. begin
  518. set_varstate(left,true);
  519. if is_ansistring(left.resulttype) then
  520. resulttype:=s32bitdef
  521. else
  522. resulttype:=u8bitdef;
  523. { we don't need string conversations here }
  524. if (left.nodetype=typeconvn) and
  525. (ttypeconvnode(left).left.resulttype^.deftype=stringdef) then
  526. begin
  527. hp:=ttypeconvnode(left).left;
  528. ttypeconvnode(left).left:=nil;
  529. left.free;
  530. left:=hp;
  531. end;
  532. { check the type, must be string or char }
  533. if (left.resulttype^.deftype<>stringdef) and
  534. (not is_char(left.resulttype)) then
  535. CGMessage(type_e_mismatch);
  536. { evaluates length of constant strings direct }
  537. if (left.nodetype=stringconstn) then
  538. begin
  539. hp:=genordinalconstnode(tstringconstnode(left).len,s32bitdef);
  540. firstpass(hp);
  541. pass_1:=hp;
  542. end
  543. { length of char is one allways }
  544. else if is_constcharnode(left) then
  545. begin
  546. hp:=genordinalconstnode(1,s32bitdef);
  547. firstpass(hp);
  548. pass_1:=hp;
  549. end;
  550. end;
  551. in_typeinfo_x:
  552. begin
  553. resulttype:=voidpointerdef;
  554. location.loc:=LOC_REGISTER;
  555. registers32:=1;
  556. end;
  557. in_assigned_x:
  558. begin
  559. set_varstate(left,true);
  560. resulttype:=booldef;
  561. location.loc:=LOC_FLAGS;
  562. end;
  563. in_ofs_x,
  564. in_seg_x :
  565. set_varstate(left,false);
  566. in_pred_x,
  567. in_succ_x:
  568. begin
  569. resulttype:=left.resulttype;
  570. if is_64bitint(resulttype) then
  571. begin
  572. if (registers32<2) then
  573. registers32:=2
  574. end
  575. else
  576. begin
  577. if (registers32<1) then
  578. registers32:=1;
  579. end;
  580. location.loc:=LOC_REGISTER;
  581. set_varstate(left,true);
  582. if not is_ordinal(resulttype) then
  583. CGMessage(type_e_ordinal_expr_expected)
  584. else
  585. begin
  586. if (resulttype^.deftype=enumdef) and
  587. (penumdef(resulttype)^.has_jumps) then
  588. CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible)
  589. else
  590. if left.nodetype=ordconstn then
  591. begin
  592. if inlinenumber=in_succ_x then
  593. hp:=genordinalconstnode(tordconstnode(left).value+1,left.resulttype)
  594. else
  595. hp:=genordinalconstnode(tordconstnode(left).value-1,left.resulttype);
  596. firstpass(hp);
  597. pass_1:=hp;
  598. end;
  599. end;
  600. end;
  601. in_inc_x,
  602. in_dec_x:
  603. begin
  604. resulttype:=voiddef;
  605. if assigned(left) then
  606. begin
  607. tcallparanode(left).firstcallparan(nil,true);
  608. set_varstate(left,true);
  609. if codegenerror then
  610. exit;
  611. { first param must be var }
  612. valid_for_assign(tcallparanode(left).left,false);
  613. { check type }
  614. if (left.resulttype^.deftype in [enumdef,pointerdef]) or
  615. is_ordinal(left.resulttype) then
  616. begin
  617. { two paras ? }
  618. if assigned(tcallparanode(left).right) then
  619. begin
  620. { insert a type conversion }
  621. { the second param is always longint }
  622. tcallparanode(tcallparanode(left).right).left:=
  623. gentypeconvnode(tcallparanode(tcallparanode(left).right).left,s32bitdef);
  624. { check the type conversion }
  625. firstpass(tcallparanode(tcallparanode(left).right).left);
  626. { need we an additional register ? }
  627. if not(is_constintnode(tcallparanode(tcallparanode(left).right).left)) and
  628. (tcallparanode(tcallparanode(left).right).left.location.loc in [LOC_MEM,LOC_REFERENCE]) and
  629. (tcallparanode(tcallparanode(left).right).left.registers32<=1) then
  630. inc(registers32);
  631. { do we need an additional register to restore the first parameter? }
  632. if tcallparanode(tcallparanode(left).right).left.registers32>=registers32 then
  633. inc(registers32);
  634. if assigned(tcallparanode(tcallparanode(left).right).right) then
  635. CGMessage(cg_e_illegal_expression);
  636. end;
  637. end
  638. else
  639. CGMessage(type_e_ordinal_expr_expected);
  640. end
  641. else
  642. CGMessage(type_e_mismatch);
  643. end;
  644. in_read_x,
  645. in_readln_x,
  646. in_write_x,
  647. in_writeln_x :
  648. begin
  649. { needs a call }
  650. procinfo^.flags:=procinfo^.flags or pi_do_call;
  651. resulttype:=voiddef;
  652. { true, if readln needs an extra register }
  653. extra_register:=false;
  654. { we must know if it is a typed file or not }
  655. { but we must first do the firstpass for it }
  656. file_is_typed:=false;
  657. if assigned(left) then
  658. begin
  659. dowrite:=(inlinenumber in [in_write_x,in_writeln_x]);
  660. tcallparanode(left).firstcallparan(nil,true);
  661. set_varstate(left,dowrite);
  662. { now we can check }
  663. hp:=left;
  664. while assigned(tcallparanode(hp).right) do
  665. hp:=tcallparanode(hp).right;
  666. { if resulttype is not assigned, then automatically }
  667. { file is not typed. }
  668. if assigned(hp) and assigned(hp.resulttype) then
  669. Begin
  670. if (hp.resulttype^.deftype=filedef) then
  671. if (pfiledef(hp.resulttype)^.filetyp=ft_untyped) then
  672. begin
  673. if (inlinenumber in [in_readln_x,in_writeln_x]) then
  674. CGMessage(type_e_no_readln_writeln_for_typed_file)
  675. else
  676. CGMessage(type_e_no_read_write_for_untyped_file);
  677. end
  678. else if (pfiledef(hp.resulttype)^.filetyp=ft_typed) then
  679. begin
  680. file_is_typed:=true;
  681. { test the type }
  682. if (inlinenumber in [in_readln_x,in_writeln_x]) then
  683. CGMessage(type_e_no_readln_writeln_for_typed_file);
  684. hpp:=left;
  685. while (hpp<>hp) do
  686. begin
  687. if (tcallparanode(hpp).left.nodetype=typen) then
  688. CGMessage(type_e_cant_read_write_type);
  689. if not is_equal(hpp.resulttype,pfiledef(hp.resulttype)^.typedfiletype.def) then
  690. CGMessage(type_e_mismatch);
  691. { generate the high() value for the shortstring }
  692. if ((not dowrite) and is_shortstring(tcallparanode(hpp).left.resulttype)) or
  693. (is_chararray(tcallparanode(hpp).left.resulttype)) then
  694. tcallparanode(hpp).gen_high_tree(true);
  695. { read(ln) is call by reference (JM) }
  696. if not dowrite then
  697. make_not_regable(tcallparanode(hpp).left);
  698. hpp:=tcallparanode(hpp).right;
  699. end;
  700. end;
  701. end; { endif assigned(hp) }
  702. { insert type conversions for write(ln) }
  703. if (not file_is_typed) then
  704. begin
  705. hp:=left;
  706. while assigned(hp) do
  707. begin
  708. incrementregisterpushed($ff);
  709. if (tcallparanode(hp).left.nodetype=typen) then
  710. CGMessage(type_e_cant_read_write_type);
  711. if assigned(tcallparanode(hp).left.resulttype) then
  712. begin
  713. isreal:=false;
  714. { support writeln(procvar) }
  715. if (tcallparanode(hp).left.resulttype^.deftype=procvardef) then
  716. begin
  717. p1:=gencallnode(nil,nil);
  718. tcallnode(p1).right:=tcallparanode(hp).left;
  719. p1.resulttype:=pprocvardef(tcallparanode(hp).left.resulttype)^.rettype.def;
  720. firstpass(p1);
  721. tcallparanode(hp).left:=p1;
  722. end;
  723. case tcallparanode(hp).left.resulttype^.deftype of
  724. filedef :
  725. begin
  726. { only allowed as first parameter }
  727. if assigned(tcallparanode(hp).right) then
  728. CGMessage(type_e_cant_read_write_type);
  729. end;
  730. stringdef :
  731. begin
  732. { generate the high() value for the shortstring }
  733. if (not dowrite) and
  734. is_shortstring(tcallparanode(hp).left.resulttype) then
  735. tcallparanode(hp).gen_high_tree(true);
  736. end;
  737. pointerdef :
  738. begin
  739. if not is_pchar(tcallparanode(hp).left.resulttype) then
  740. CGMessage(type_e_cant_read_write_type);
  741. end;
  742. floatdef :
  743. begin
  744. isreal:=true;
  745. end;
  746. orddef :
  747. begin
  748. case porddef(tcallparanode(hp).left.resulttype)^.typ of
  749. uchar,
  750. u32bit,s32bit,
  751. u64bit,s64bit:
  752. ;
  753. u8bit,s8bit,
  754. u16bit,s16bit :
  755. if dowrite then
  756. tcallparanode(hp).left:=gentypeconvnode(tcallparanode(hp).left,s32bitdef);
  757. bool8bit,
  758. bool16bit,
  759. bool32bit :
  760. if dowrite then
  761. tcallparanode(hp).left:=gentypeconvnode(tcallparanode(hp).left,booldef)
  762. else
  763. CGMessage(type_e_cant_read_write_type);
  764. else
  765. CGMessage(type_e_cant_read_write_type);
  766. end;
  767. if not(dowrite) and
  768. not(is_64bitint(tcallparanode(hp).left.resulttype)) then
  769. extra_register:=true;
  770. end;
  771. arraydef :
  772. begin
  773. if is_chararray(tcallparanode(hp).left.resulttype) then
  774. tcallparanode(hp).gen_high_tree(true)
  775. else
  776. CGMessage(type_e_cant_read_write_type);
  777. end;
  778. else
  779. CGMessage(type_e_cant_read_write_type);
  780. end;
  781. { some format options ? }
  782. if nf_is_colon_para in hp.flags then
  783. begin
  784. if nf_is_colon_para in tcallparanode(hp).right.flags then
  785. begin
  786. frac_para:=hp;
  787. length_para:=tcallparanode(hp).right;
  788. hp:=tcallparanode(hp).right;
  789. hpp:=tcallparanode(hp).right;
  790. end
  791. else
  792. begin
  793. length_para:=hp;
  794. frac_para:=nil;
  795. hpp:=tcallparanode(hp).right;
  796. end;
  797. { can be nil if you use "write(e:0:6)" while e is undeclared (JM) }
  798. if assigned(tcallparanode(hpp).left.resulttype) then
  799. isreal:=(tcallparanode(hpp).left.resulttype^.deftype=floatdef)
  800. else exit;
  801. if (not is_integer(tcallparanode(length_para).left.resulttype)) then
  802. CGMessage1(type_e_integer_expr_expected,tcallparanode(length_para).left.resulttype^.typename)
  803. else
  804. tcallparanode(length_para).left:=gentypeconvnode(tcallparanode(length_para).left,s32bitdef);
  805. if assigned(frac_para) then
  806. begin
  807. if isreal then
  808. begin
  809. if (not is_integer(tcallparanode(frac_para).left.resulttype)) then
  810. CGMessage1(type_e_integer_expr_expected,tcallparanode(frac_para).left.resulttype^.typename)
  811. else
  812. tcallparanode(frac_para).left:=gentypeconvnode(tcallparanode(frac_para).left,s32bitdef);
  813. end
  814. else
  815. CGMessage(parser_e_illegal_colon_qualifier);
  816. end;
  817. { do the checking for the colon'd arg }
  818. hp:=length_para;
  819. end;
  820. end;
  821. hp:=tcallparanode(hp).right;
  822. end;
  823. end;
  824. { pass all parameters again for the typeconversions }
  825. if codegenerror then
  826. exit;
  827. tcallparanode(left).firstcallparan(nil,true);
  828. set_varstate(left,true);
  829. { calc registers }
  830. left_max;
  831. if extra_register then
  832. inc(registers32);
  833. end;
  834. end;
  835. in_settextbuf_file_x :
  836. begin
  837. { warning here left is the callparannode
  838. not the argument directly }
  839. { left.left is text var }
  840. { left.right.left is the buffer var }
  841. { firstcallparan(left,nil);
  842. already done in firstcalln }
  843. { now we know the type of buffer }
  844. getsymonlyin(systemunit,'SETTEXTBUF');
  845. hp:=gencallnode(pprocsym(srsym),systemunit);
  846. tcallnode(hp).left:=gencallparanode(
  847. genordinalconstnode(tcallparanode(left).left.resulttype^.size,s32bitdef),left);
  848. left:=nil;
  849. firstpass(hp);
  850. pass_1:=hp;
  851. end;
  852. { the firstpass of the arg has been done in firstcalln ? }
  853. in_reset_typedfile,
  854. in_rewrite_typedfile :
  855. begin
  856. procinfo^.flags:=procinfo^.flags or pi_do_call;
  857. firstpass(left);
  858. set_varstate(left,true);
  859. resulttype:=voiddef;
  860. end;
  861. in_str_x_string :
  862. begin
  863. procinfo^.flags:=procinfo^.flags or pi_do_call;
  864. resulttype:=voiddef;
  865. { check the amount of parameters }
  866. if not(assigned(left)) or
  867. not(assigned(tcallparanode(left).right)) then
  868. begin
  869. CGMessage(parser_e_wrong_parameter_size);
  870. exit;
  871. end;
  872. { first pass just the string for first local use }
  873. hp:=tcallparanode(left).right;
  874. tcallparanode(left).right:=nil;
  875. tcallparanode(left).firstcallparan(nil,true);
  876. set_varstate(left,false);
  877. { remove warning when result is passed }
  878. set_funcret_is_valid(tcallparanode(left).left);
  879. tcallparanode(left).right:=hp;
  880. tcallparanode(tcallparanode(left).right).firstcallparan(nil,true);
  881. set_varstate(tcallparanode(left).right,true);
  882. hp:=left;
  883. { valid string ? }
  884. if not assigned(hp) or
  885. (tcallparanode(hp).left.resulttype^.deftype<>stringdef) or
  886. (tcallparanode(hp).right=nil) then
  887. CGMessage(cg_e_illegal_expression);
  888. { we need a var parameter }
  889. valid_for_assign(tcallparanode(hp).left,false);
  890. { generate the high() value for the shortstring }
  891. if is_shortstring(tcallparanode(hp).left.resulttype) then
  892. tcallparanode(hp).gen_high_tree(true);
  893. { !!!! check length of string }
  894. while assigned(tcallparanode(hp).right) do
  895. hp:=tcallparanode(hp).right;
  896. if not assigned(tcallparanode(hp).resulttype) then
  897. exit;
  898. { check and convert the first param }
  899. if (nf_is_colon_para in hp.flags) or
  900. not assigned(hp.resulttype) then
  901. CGMessage(cg_e_illegal_expression);
  902. isreal:=false;
  903. case hp.resulttype^.deftype of
  904. orddef :
  905. begin
  906. case porddef(tcallparanode(hp).left.resulttype)^.typ of
  907. u32bit,s32bit,
  908. s64bit,u64bit:
  909. ;
  910. u8bit,s8bit,
  911. u16bit,s16bit:
  912. tcallparanode(hp).left:=gentypeconvnode(tcallparanode(hp).left,s32bitdef);
  913. else
  914. CGMessage(type_e_integer_or_real_expr_expected);
  915. end;
  916. end;
  917. floatdef :
  918. begin
  919. isreal:=true;
  920. end;
  921. else
  922. CGMessage(type_e_integer_or_real_expr_expected);
  923. end;
  924. { some format options ? }
  925. hpp:=tcallparanode(left).right;
  926. if assigned(hpp) and (nf_is_colon_para in hpp.flags) then
  927. begin
  928. firstpass(tcallparanode(hpp).left);
  929. set_varstate(tcallparanode(hpp).left,true);
  930. if (not is_integer(tcallparanode(hpp).left.resulttype)) then
  931. CGMessage1(type_e_integer_expr_expected,tcallparanode(hpp).left.resulttype^.typename)
  932. else
  933. tcallparanode(hpp).left:=gentypeconvnode(tcallparanode(hpp).left,s32bitdef);
  934. hpp:=tcallparanode(hpp).right;
  935. if assigned(hpp) and (nf_is_colon_para in hpp.flags) then
  936. begin
  937. if isreal then
  938. begin
  939. if (not is_integer(tcallparanode(hpp).left.resulttype)) then
  940. CGMessage1(type_e_integer_expr_expected,tcallparanode(hpp).left.resulttype^.typename)
  941. else
  942. begin
  943. firstpass(tcallparanode(hpp).left);
  944. set_varstate(tcallparanode(hpp).left,true);
  945. tcallparanode(hpp).left:=gentypeconvnode(tcallparanode(hpp).left,s32bitdef);
  946. end;
  947. end
  948. else
  949. CGMessage(parser_e_illegal_colon_qualifier);
  950. end;
  951. end;
  952. { pass all parameters again for the typeconversions }
  953. if codegenerror then
  954. exit;
  955. tcallparanode(left).firstcallparan(nil,true);
  956. { calc registers }
  957. left_max;
  958. end;
  959. in_val_x :
  960. begin
  961. procinfo^.flags:=procinfo^.flags or pi_do_call;
  962. resulttype:=voiddef;
  963. { check the amount of parameters }
  964. if not(assigned(left)) or
  965. not(assigned(tcallparanode(left).right)) then
  966. begin
  967. CGMessage(parser_e_wrong_parameter_size);
  968. exit;
  969. end;
  970. If Assigned(tcallparanode(tcallparanode(left).right).right) Then
  971. {there is a "code" parameter}
  972. Begin
  973. { first pass just the code parameter for first local use}
  974. hp := tcallparanode(left).right;
  975. tcallparanode(left).right := nil;
  976. make_not_regable(tcallparanode(left).left);
  977. tcallparanode(left).firstcallparan(nil,true);
  978. set_varstate(left,false);
  979. if codegenerror then exit;
  980. tcallparanode(left).right := hp;
  981. {code has to be a var parameter}
  982. if valid_for_assign(tcallparanode(left).left,false) then
  983. begin
  984. if (tcallparanode(left).left.resulttype^.deftype <> orddef) or
  985. not(porddef(tcallparanode(left).left.resulttype)^.typ in
  986. [u16bit,s16bit,u32bit,s32bit]) then
  987. CGMessage(type_e_mismatch);
  988. end;
  989. hpp := tcallparanode(left).right
  990. End
  991. Else hpp := left;
  992. {now hpp = the destination value tree}
  993. { first pass just the destination parameter for first local use}
  994. hp:=tcallparanode(hpp).right;
  995. tcallparanode(hpp).right:=nil;
  996. {hpp = destination}
  997. make_not_regable(tcallparanode(hpp).left);
  998. tcallparanode(hpp).firstcallparan(nil,true);
  999. set_varstate(hpp,false);
  1000. if codegenerror then
  1001. exit;
  1002. { remove warning when result is passed }
  1003. set_funcret_is_valid(tcallparanode(hpp).left);
  1004. tcallparanode(hpp).right := hp;
  1005. if valid_for_assign(tcallparanode(hpp).left,false) then
  1006. begin
  1007. If Not((tcallparanode(hpp).left.resulttype^.deftype = floatdef) or
  1008. ((tcallparanode(hpp).left.resulttype^.deftype = orddef) And
  1009. (POrdDef(tcallparanode(hpp).left.resulttype)^.typ in
  1010. [u32bit,s32bit,
  1011. u8bit,s8bit,u16bit,s16bit,s64bit,u64bit]))) Then
  1012. CGMessage(type_e_mismatch);
  1013. end;
  1014. {hp = source (String)}
  1015. { count_ref := false; WHY ?? }
  1016. tcallparanode(hp).firstcallparan(nil,true);
  1017. set_varstate(hp,true);
  1018. if codegenerror then
  1019. exit;
  1020. { if not a stringdef then insert a type conv which
  1021. does the other type checking }
  1022. If (tcallparanode(hp).left.resulttype^.deftype<>stringdef) then
  1023. begin
  1024. tcallparanode(hp).left:=gentypeconvnode(tcallparanode(hp).left,cshortstringdef);
  1025. firstpass(hp);
  1026. end;
  1027. { calc registers }
  1028. left_max;
  1029. { val doesn't calculate the registers really }
  1030. { correct, we need one register extra (FK) }
  1031. if is_64bitint(tcallparanode(hpp).left.resulttype) then
  1032. inc(registers32,2)
  1033. else
  1034. inc(registers32,1);
  1035. end;
  1036. in_include_x_y,
  1037. in_exclude_x_y:
  1038. begin
  1039. resulttype:=voiddef;
  1040. if assigned(left) then
  1041. begin
  1042. tcallparanode(left).firstcallparan(nil,true);
  1043. set_varstate(left,true);
  1044. registers32:=left.registers32;
  1045. registersfpu:=left.registersfpu;
  1046. {$ifdef SUPPORT_MMX}
  1047. registersmmx:=left.registersmmx;
  1048. {$endif SUPPORT_MMX}
  1049. { remove warning when result is passed }
  1050. set_funcret_is_valid(tcallparanode(left).left);
  1051. { first param must be var }
  1052. valid_for_assign(tcallparanode(left).left,false);
  1053. { check type }
  1054. if assigned(left.resulttype) and
  1055. (left.resulttype^.deftype=setdef) then
  1056. begin
  1057. { two paras ? }
  1058. if assigned(tcallparanode(left).right) then
  1059. begin
  1060. { insert a type conversion }
  1061. { to the type of the set elements }
  1062. tcallparanode(tcallparanode(left).right).left:=gentypeconvnode(
  1063. tcallparanode(tcallparanode(left).right).left,
  1064. psetdef(left.resulttype)^.elementtype.def);
  1065. { check the type conversion }
  1066. firstpass(tcallparanode(tcallparanode(left).right).left);
  1067. { only three parameters are allowed }
  1068. if assigned(tcallparanode(tcallparanode(left).right).right) then
  1069. CGMessage(cg_e_illegal_expression);
  1070. end;
  1071. end
  1072. else
  1073. CGMessage(type_e_mismatch);
  1074. end
  1075. else
  1076. CGMessage(type_e_mismatch);
  1077. end;
  1078. in_low_x,
  1079. in_high_x:
  1080. begin
  1081. set_varstate(left,false);
  1082. { this fixes tests\webtbs\tbug879.pp (FK)
  1083. if left.nodetype in [typen,loadn,subscriptn] then
  1084. begin
  1085. }
  1086. case left.resulttype^.deftype of
  1087. orddef,enumdef:
  1088. begin
  1089. hp:=do_lowhigh(left.resulttype);
  1090. firstpass(hp);
  1091. pass_1:=hp;
  1092. end;
  1093. setdef:
  1094. begin
  1095. hp:=do_lowhigh(Psetdef(left.resulttype)^.elementtype.def);
  1096. firstpass(hp);
  1097. pass_1:=hp;
  1098. end;
  1099. arraydef:
  1100. begin
  1101. if inlinenumber=in_low_x then
  1102. begin
  1103. hp:=genordinalconstnode(Parraydef(left.resulttype)^.lowrange,
  1104. Parraydef(left.resulttype)^.rangetype.def);
  1105. firstpass(hp);
  1106. pass_1:=hp;
  1107. end
  1108. else
  1109. begin
  1110. if is_open_array(left.resulttype) or
  1111. is_array_of_const(left.resulttype) then
  1112. begin
  1113. getsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
  1114. hp:=genloadnode(pvarsym(srsym),tloadnode(left).symtable);
  1115. firstpass(hp);
  1116. pass_1:=hp;
  1117. end
  1118. else
  1119. begin
  1120. hp:=genordinalconstnode(Parraydef(left.resulttype)^.highrange,
  1121. Parraydef(left.resulttype)^.rangetype.def);
  1122. firstpass(hp);
  1123. pass_1:=hp;
  1124. end;
  1125. end;
  1126. end;
  1127. stringdef:
  1128. begin
  1129. if inlinenumber=in_low_x then
  1130. begin
  1131. hp:=genordinalconstnode(0,u8bitdef);
  1132. firstpass(hp);
  1133. pass_1:=hp;
  1134. end
  1135. else
  1136. begin
  1137. if is_open_string(left.resulttype) then
  1138. begin
  1139. getsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
  1140. hp:=genloadnode(pvarsym(srsym),tloadnode(left).symtable);
  1141. firstpass(hp);
  1142. pass_1:=hp;
  1143. end
  1144. else
  1145. begin
  1146. hp:=genordinalconstnode(Pstringdef(left.resulttype)^.len,u8bitdef);
  1147. firstpass(hp);
  1148. pass_1:=hp;
  1149. end;
  1150. end;
  1151. end;
  1152. else
  1153. CGMessage(type_e_mismatch);
  1154. end;
  1155. {
  1156. end
  1157. else
  1158. CGMessage(type_e_varid_or_typeid_expected);
  1159. }
  1160. end;
  1161. in_cos_extended:
  1162. begin
  1163. if left.nodetype in [ordconstn,realconstn] then
  1164. setconstrealvalue(cos(getconstrealvalue))
  1165. else
  1166. handleextendedfunction;
  1167. end;
  1168. in_sin_extended:
  1169. begin
  1170. if left.nodetype in [ordconstn,realconstn] then
  1171. setconstrealvalue(sin(getconstrealvalue))
  1172. else
  1173. handleextendedfunction;
  1174. end;
  1175. in_arctan_extended:
  1176. begin
  1177. if left.nodetype in [ordconstn,realconstn] then
  1178. setconstrealvalue(arctan(getconstrealvalue))
  1179. else
  1180. handleextendedfunction;
  1181. end;
  1182. in_pi:
  1183. if block_type=bt_const then
  1184. setconstrealvalue(pi)
  1185. else
  1186. begin
  1187. location.loc:=LOC_FPU;
  1188. resulttype:=s80floatdef;
  1189. end;
  1190. in_abs_extended:
  1191. begin
  1192. if left.nodetype in [ordconstn,realconstn] then
  1193. setconstrealvalue(abs(getconstrealvalue))
  1194. else
  1195. handleextendedfunction;
  1196. end;
  1197. in_sqr_extended:
  1198. begin
  1199. if left.nodetype in [ordconstn,realconstn] then
  1200. setconstrealvalue(sqr(getconstrealvalue))
  1201. else
  1202. handleextendedfunction;
  1203. end;
  1204. in_sqrt_extended:
  1205. begin
  1206. if left.nodetype in [ordconstn,realconstn] then
  1207. begin
  1208. vr:=getconstrealvalue;
  1209. if vr<0.0 then
  1210. begin
  1211. CGMessage(type_e_wrong_math_argument);
  1212. setconstrealvalue(0);
  1213. end
  1214. else
  1215. setconstrealvalue(sqrt(vr));
  1216. end
  1217. else
  1218. handleextendedfunction;
  1219. end;
  1220. in_ln_extended:
  1221. begin
  1222. if left.nodetype in [ordconstn,realconstn] then
  1223. begin
  1224. vr:=getconstrealvalue;
  1225. if vr<=0.0 then
  1226. begin
  1227. CGMessage(type_e_wrong_math_argument);
  1228. setconstrealvalue(0);
  1229. end
  1230. else
  1231. setconstrealvalue(ln(vr));
  1232. end
  1233. else
  1234. handleextendedfunction;
  1235. end;
  1236. {$ifdef SUPPORT_MMX}
  1237. in_mmx_pcmpeqb..in_mmx_pcmpgtw:
  1238. begin
  1239. end;
  1240. {$endif SUPPORT_MMX}
  1241. in_assert_x_y :
  1242. begin
  1243. resulttype:=voiddef;
  1244. if assigned(left) then
  1245. begin
  1246. tcallparanode(left).firstcallparan(nil,true);
  1247. set_varstate(left,true);
  1248. registers32:=left.registers32;
  1249. registersfpu:=left.registersfpu;
  1250. {$ifdef SUPPORT_MMX}
  1251. registersmmx:=left.registersmmx;
  1252. {$endif SUPPORT_MMX}
  1253. { check type }
  1254. if is_boolean(left.resulttype) then
  1255. begin
  1256. { must always be a string }
  1257. tcallparanode(tcallparanode(left).right).left:=
  1258. gentypeconvnode(tcallparanode(tcallparanode(left).right).left,cshortstringdef);
  1259. firstpass(tcallparanode(tcallparanode(left).right).left);
  1260. end
  1261. else
  1262. CGMessage(type_e_mismatch);
  1263. end
  1264. else
  1265. CGMessage(type_e_mismatch);
  1266. { We've checked the whole statement for correctness, now we
  1267. can remove it if assertions are off }
  1268. if not(cs_do_assertion in aktlocalswitches) then
  1269. { we need a valid node, so insert a nothingn }
  1270. pass_1:=cnothingnode.create;
  1271. end;
  1272. else
  1273. internalerror(8);
  1274. end;
  1275. end;
  1276. { generate an error if no resulttype is set }
  1277. if not assigned(resulttype) then
  1278. resulttype:=generrordef;
  1279. { ... also if the node will be replaced }
  1280. if not assigned(pass_1.resulttype) then
  1281. pass_1.resulttype:=generrordef;
  1282. dec(parsing_para_level);
  1283. end;
  1284. {$ifdef fpc}
  1285. {$maxfpuregisters default}
  1286. {$endif fpc}
  1287. begin
  1288. cinlinenode:=tinlinenode;
  1289. end.
  1290. {
  1291. $Log$
  1292. Revision 1.6 2000-10-01 19:48:24 peter
  1293. * lot of compile updates for cg11
  1294. Revision 1.5 2000/09/28 19:49:52 florian
  1295. *** empty log message ***
  1296. Revision 1.4 2000/09/28 16:34:47 florian
  1297. *** empty log message ***
  1298. Revision 1.3 2000/09/27 21:33:22 florian
  1299. * finally nadd.pas compiles
  1300. Revision 1.2 2000/09/27 20:25:44 florian
  1301. * more stuff fixed
  1302. Revision 1.1 2000/09/26 14:59:34 florian
  1303. * more conversion work done
  1304. }