ninl.pas 61 KB

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