ninl.pas 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379
  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;
  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,htypechk,
  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. procedure do_lowhigh(adef : pdef);
  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. pass_1:=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. pass_1:=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. left.set_varstate(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_right_max(self);
  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. left.set_varstate(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. left.set_varstate(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. left.set_varstate(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. left.set_varstate(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).convtyp:=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. left.set_varstate(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. left.set_varstate(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. left.set_varstate(true);
  560. resulttype:=booldef;
  561. location.loc:=LOC_FLAGS;
  562. end;
  563. in_ofs_x,
  564. in_seg_x :
  565. left.set_varstate(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. left.set_varstate(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. left.set_varstate(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. left.set_varstate(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. left.set_varstate(true);
  829. { calc registers }
  830. left_right_max(self);
  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. left.set_varstate(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. left.set_varstate(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. tcallparanode(left).right.set_varstate(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. tcallparanode(hpp).left.set_varstate(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. tcallparanode(hpp).left.set_varstate(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_right_max(self);
  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. tcallparanode(left).set_varstate(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. hpp.set_varstate(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. hp.set_varstate(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_right_max(self);
  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. left.set_varstate(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. left.set_varstate(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. do_lowhigh(left.resulttype);
  1090. firstpass(p);
  1091. end;
  1092. setdef:
  1093. begin
  1094. do_lowhigh(Psetdef(left.resulttype)^.elementtype.def);
  1095. firstpass(p);
  1096. end;
  1097. arraydef:
  1098. begin
  1099. if inlinenumber=in_low_x then
  1100. begin
  1101. hp:=genordinalconstnode(Parraydef(left.resulttype)^.lowrange,
  1102. Parraydef(left.resulttype)^.rangetype.def);
  1103. firstpass(hp);
  1104. pass_1:=hp;
  1105. end
  1106. else
  1107. begin
  1108. if is_open_array(left.resulttype) or
  1109. is_array_of_const(left.resulttype) then
  1110. begin
  1111. getsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
  1112. hp:=genloadnode(pvarsym(srsym),tloadnode(left).symtable);
  1113. firstpass(hp);
  1114. pass_1:=hp;
  1115. end
  1116. else
  1117. begin
  1118. hp:=genordinalconstnode(Parraydef(left.resulttype)^.highrange,
  1119. Parraydef(left.resulttype)^.rangetype.def);
  1120. firstpass(hp);
  1121. pass_1:=hp;
  1122. end;
  1123. end;
  1124. end;
  1125. stringdef:
  1126. begin
  1127. if inlinenumber=in_low_x then
  1128. begin
  1129. hp:=genordinalconstnode(0,u8bitdef);
  1130. firstpass(hp);
  1131. pass_1:=hp;
  1132. end
  1133. else
  1134. begin
  1135. if is_open_string(left.resulttype) then
  1136. begin
  1137. getsymonlyin(tloadnode(left).symtable,'high'+pvarsym(tloadnode(left).symtableentry)^.name);
  1138. hp:=genloadnode(pvarsym(srsym),tloadnode(left).symtable);
  1139. firstpass(hp);
  1140. pass_1:=hp;
  1141. end
  1142. else
  1143. begin
  1144. hp:=genordinalconstnode(Pstringdef(left.resulttype)^.len,u8bitdef);
  1145. firstpass(hp);
  1146. pass_1:=hp;
  1147. end;
  1148. end;
  1149. end;
  1150. else
  1151. CGMessage(type_e_mismatch);
  1152. end;
  1153. {
  1154. end
  1155. else
  1156. CGMessage(type_e_varid_or_typeid_expected);
  1157. }
  1158. end;
  1159. in_cos_extended:
  1160. begin
  1161. if left.nodetype in [ordconstn,realconstn] then
  1162. setconstrealvalue(cos(getconstrealvalue))
  1163. else
  1164. handleextendedfunction;
  1165. end;
  1166. in_sin_extended:
  1167. begin
  1168. if left.nodetype in [ordconstn,realconstn] then
  1169. setconstrealvalue(sin(getconstrealvalue))
  1170. else
  1171. handleextendedfunction;
  1172. end;
  1173. in_arctan_extended:
  1174. begin
  1175. if left.nodetype in [ordconstn,realconstn] then
  1176. setconstrealvalue(arctan(getconstrealvalue))
  1177. else
  1178. handleextendedfunction;
  1179. end;
  1180. in_pi:
  1181. if block_type=bt_const then
  1182. setconstrealvalue(pi)
  1183. else
  1184. begin
  1185. location.loc:=LOC_FPU;
  1186. resulttype:=s80floatdef;
  1187. end;
  1188. in_abs_extended:
  1189. begin
  1190. if left.nodetype in [ordconstn,realconstn] then
  1191. setconstrealvalue(abs(getconstrealvalue))
  1192. else
  1193. handleextendedfunction;
  1194. end;
  1195. in_sqr_extended:
  1196. begin
  1197. if left.nodetype in [ordconstn,realconstn] then
  1198. setconstrealvalue(sqr(getconstrealvalue))
  1199. else
  1200. handleextendedfunction;
  1201. end;
  1202. in_sqrt_extended:
  1203. begin
  1204. if left.nodetype in [ordconstn,realconstn] then
  1205. begin
  1206. vr:=getconstrealvalue;
  1207. if vr<0.0 then
  1208. begin
  1209. CGMessage(type_e_wrong_math_argument);
  1210. setconstrealvalue(0);
  1211. end
  1212. else
  1213. setconstrealvalue(sqrt(vr));
  1214. end
  1215. else
  1216. handleextendedfunction;
  1217. end;
  1218. in_ln_extended:
  1219. begin
  1220. if left.nodetype in [ordconstn,realconstn] then
  1221. begin
  1222. vr:=getconstrealvalue;
  1223. if vr<=0.0 then
  1224. begin
  1225. CGMessage(type_e_wrong_math_argument);
  1226. setconstrealvalue(0);
  1227. end
  1228. else
  1229. setconstrealvalue(ln(vr));
  1230. end
  1231. else
  1232. handleextendedfunction;
  1233. end;
  1234. {$ifdef SUPPORT_MMX}
  1235. in_mmx_pcmpeqb..in_mmx_pcmpgtw:
  1236. begin
  1237. end;
  1238. {$endif SUPPORT_MMX}
  1239. in_assert_x_y :
  1240. begin
  1241. resulttype:=voiddef;
  1242. if assigned(left) then
  1243. begin
  1244. tcallparanode(left).firstcallparan(nil,true);
  1245. left.set_varstate(true);
  1246. registers32:=left.registers32;
  1247. registersfpu:=left.registersfpu;
  1248. {$ifdef SUPPORT_MMX}
  1249. registersmmx:=left.registersmmx;
  1250. {$endif SUPPORT_MMX}
  1251. { check type }
  1252. if is_boolean(left.resulttype) then
  1253. begin
  1254. { must always be a string }
  1255. tcallparanode(tcallparanode(left).right).left:=
  1256. gentypeconvnode(tcallparanode(tcallparanode(left).right).left,cshortstringdef);
  1257. firstpass(tcallparanode(tcallparanode(left).right).left);
  1258. end
  1259. else
  1260. CGMessage(type_e_mismatch);
  1261. end
  1262. else
  1263. CGMessage(type_e_mismatch);
  1264. { We've checked the whole statement for correctness, now we
  1265. can remove it if assertions are off }
  1266. if not(cs_do_assertion in aktlocalswitches) then
  1267. { we need a valid node, so insert a nothingn }
  1268. pass_1:=cnothingnode.create;
  1269. end;
  1270. else
  1271. internalerror(8);
  1272. end;
  1273. end;
  1274. { generate an error if no resulttype is set }
  1275. if not assigned(resulttype) then
  1276. resulttype:=generrordef;
  1277. { ... also if the node will be replaced }
  1278. if not assigned(pass_1.resulttype) then
  1279. pass_1.resulttype:=generrordef;
  1280. dec(parsing_para_level);
  1281. end;
  1282. {$ifdef fpc}
  1283. {$maxfpuregisters default}
  1284. {$endif fpc}
  1285. begin
  1286. cinlinenode:=tinlinenode;
  1287. end.
  1288. {
  1289. $Log$
  1290. Revision 1.4 2000-09-28 16:34:47 florian
  1291. *** empty log message ***
  1292. Revision 1.3 2000/09/27 21:33:22 florian
  1293. * finally nadd.pas compiles
  1294. Revision 1.2 2000/09/27 20:25:44 florian
  1295. * more stuff fixed
  1296. Revision 1.1 2000/09/26 14:59:34 florian
  1297. * more conversion work done
  1298. }