tcinl.pas 58 KB

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