tcadd.pas 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. Type checking and register allocation for add node
  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 tcadd;
  19. interface
  20. uses
  21. tree;
  22. procedure firstadd(var p : ptree);
  23. implementation
  24. uses
  25. globtype,systems,tokens,
  26. cobjects,verbose,globals,
  27. symconst,symtable,aasm,types,
  28. hcodegen,htypechk,pass_1,
  29. cpubase,tccnv
  30. ;
  31. {*****************************************************************************
  32. FirstAdd
  33. *****************************************************************************}
  34. procedure firstadd(var p : ptree);
  35. procedure make_bool_equal_size(var p:ptree);
  36. begin
  37. if porddef(p^.left^.resulttype)^.typ>porddef(p^.right^.resulttype)^.typ then
  38. begin
  39. p^.right:=gentypeconvnode(p^.right,porddef(p^.left^.resulttype));
  40. p^.right^.convtyp:=tc_bool_2_int;
  41. p^.right^.explizit:=true;
  42. firstpass(p^.right);
  43. end
  44. else
  45. if porddef(p^.left^.resulttype)^.typ<porddef(p^.right^.resulttype)^.typ then
  46. begin
  47. p^.left:=gentypeconvnode(p^.left,porddef(p^.right^.resulttype));
  48. p^.left^.convtyp:=tc_bool_2_int;
  49. p^.left^.explizit:=true;
  50. firstpass(p^.left);
  51. end;
  52. end;
  53. var
  54. t,hp : ptree;
  55. ot,
  56. lt,rt : ttreetyp;
  57. rv,lv : longint;
  58. rvd,lvd : bestreal;
  59. resdef,
  60. rd,ld : pdef;
  61. tempdef : pdef;
  62. optoken : ttoken;
  63. concatstrings : boolean;
  64. { to evalute const sets }
  65. resultset : pconstset;
  66. i : longint;
  67. b : boolean;
  68. convdone : boolean;
  69. s1,s2 : pchar;
  70. l1,l2 : longint;
  71. { this totally forgets to set the pi_do_call flag !! }
  72. label
  73. no_overload;
  74. begin
  75. { first do the two subtrees }
  76. firstpass(p^.left);
  77. firstpass(p^.right);
  78. if codegenerror then
  79. exit;
  80. { convert array constructors to sets, because there is no other operator
  81. possible for array constructors }
  82. if is_array_constructor(p^.left^.resulttype) then
  83. arrayconstructor_to_set(p^.left);
  84. if is_array_constructor(p^.right^.resulttype) then
  85. arrayconstructor_to_set(p^.right);
  86. { load easier access variables }
  87. lt:=p^.left^.treetype;
  88. rt:=p^.right^.treetype;
  89. rd:=p^.right^.resulttype;
  90. ld:=p^.left^.resulttype;
  91. convdone:=false;
  92. { overloaded operator ? }
  93. if (p^.treetype=starstarn) or
  94. (ld^.deftype=recorddef) or
  95. ((ld^.deftype=arraydef) and
  96. not((cs_mmx in aktlocalswitches) and
  97. is_mmx_able_array(ld)) and
  98. (not (rd^.deftype in [orddef])) and
  99. (not is_chararray(ld))
  100. ) or
  101. { <> and = are defined for classes }
  102. ((ld^.deftype=objectdef) and
  103. (not(pobjectdef(ld)^.is_class) or
  104. not(p^.treetype in [equaln,unequaln])
  105. )
  106. ) or
  107. (rd^.deftype=recorddef) or
  108. ((rd^.deftype=arraydef) and
  109. not((cs_mmx in aktlocalswitches) and
  110. is_mmx_able_array(rd)) and
  111. (not (ld^.deftype in [orddef])) and
  112. (not is_chararray(rd))
  113. ) or
  114. { <> and = are defined for classes }
  115. ((rd^.deftype=objectdef) and
  116. (not(pobjectdef(rd)^.is_class) or
  117. not(p^.treetype in [equaln,unequaln])
  118. )
  119. ) then
  120. begin
  121. {!!!!!!!!! handle paras }
  122. case p^.treetype of
  123. { the nil as symtable signs firstcalln that this is
  124. an overloaded operator }
  125. addn:
  126. token:=_PLUS;
  127. subn:
  128. token:=_MINUS;
  129. muln:
  130. token:=_STAR;
  131. starstarn:
  132. token:=_STARSTAR;
  133. slashn:
  134. token:=_SLASH;
  135. ltn:
  136. token:=tokens._lt;
  137. gtn:
  138. token:=tokens._gt;
  139. lten:
  140. token:=_lte;
  141. gten:
  142. token:=_gte;
  143. equaln,unequaln :
  144. token:=_EQUAL;
  145. symdifn :
  146. token:=_SYMDIF;
  147. modn :
  148. token:=_OP_MOD;
  149. orn :
  150. token:=_OP_OR;
  151. xorn :
  152. token:=_OP_XOR;
  153. andn :
  154. token:=_OP_AND;
  155. divn :
  156. token:=_OP_DIV;
  157. shln :
  158. token:=_OP_SHL;
  159. shrn :
  160. token:=_OP_SHR;
  161. else goto no_overload;
  162. end;
  163. t:=gencallnode(overloaded_operators[token],nil);
  164. { we have to convert p^.left and p^.right into
  165. callparanodes }
  166. if t^.symtableprocentry=nil then
  167. begin
  168. CGMessage(parser_e_operator_not_overloaded);
  169. putnode(t);
  170. end
  171. else
  172. begin
  173. t^.left:=gencallparanode(p^.left,nil);
  174. t^.left:=gencallparanode(p^.right,t^.left);
  175. if p^.treetype=unequaln then
  176. t:=gensinglenode(notn,t);
  177. firstpass(t);
  178. putnode(p);
  179. p:=t;
  180. exit;
  181. end;
  182. end;
  183. no_overload:
  184. { compact consts }
  185. { convert int consts to real consts, if the }
  186. { other operand is a real const }
  187. if (rt=realconstn) and is_constintnode(p^.left) then
  188. begin
  189. t:=genrealconstnode(p^.left^.value,p^.right^.resulttype);
  190. disposetree(p^.left);
  191. p^.left:=t;
  192. lt:=realconstn;
  193. end;
  194. if (lt=realconstn) and is_constintnode(p^.right) then
  195. begin
  196. t:=genrealconstnode(p^.right^.value,p^.left^.resulttype);
  197. disposetree(p^.right);
  198. p^.right:=t;
  199. rt:=realconstn;
  200. end;
  201. { both are int constants, also allow operations on two equal enums
  202. in fpc mode (Needed for conversion of C code) }
  203. if ((lt=ordconstn) and (rt=ordconstn)) and
  204. ((is_constintnode(p^.left) and is_constintnode(p^.right)) or
  205. (is_constboolnode(p^.left) and is_constboolnode(p^.right) and
  206. (p^.treetype in [ltn,lten,gtn,gten,equaln,unequaln]))) then
  207. begin
  208. resdef:=s32bitdef;
  209. lv:=p^.left^.value;
  210. rv:=p^.right^.value;
  211. case p^.treetype of
  212. addn : t:=genordinalconstnode(lv+rv,resdef);
  213. subn : t:=genordinalconstnode(lv-rv,resdef);
  214. muln : t:=genordinalconstnode(lv*rv,resdef);
  215. xorn : t:=genordinalconstnode(lv xor rv,resdef);
  216. orn : t:=genordinalconstnode(lv or rv,resdef);
  217. andn : t:=genordinalconstnode(lv and rv,resdef);
  218. ltn : t:=genordinalconstnode(ord(lv<rv),booldef);
  219. lten : t:=genordinalconstnode(ord(lv<=rv),booldef);
  220. gtn : t:=genordinalconstnode(ord(lv>rv),booldef);
  221. gten : t:=genordinalconstnode(ord(lv>=rv),booldef);
  222. equaln : t:=genordinalconstnode(ord(lv=rv),booldef);
  223. unequaln : t:=genordinalconstnode(ord(lv<>rv),booldef);
  224. slashn : begin
  225. { int/int becomes a real }
  226. if int(rv)=0 then
  227. begin
  228. Message(parser_e_invalid_float_operation);
  229. t:=genrealconstnode(0,bestrealdef^);
  230. end
  231. else
  232. t:=genrealconstnode(int(lv)/int(rv),bestrealdef^);
  233. firstpass(t);
  234. end;
  235. else
  236. CGMessage(type_e_mismatch);
  237. end;
  238. disposetree(p);
  239. firstpass(t);
  240. p:=t;
  241. exit;
  242. end;
  243. { both real constants ? }
  244. if (lt=realconstn) and (rt=realconstn) then
  245. begin
  246. lvd:=p^.left^.value_real;
  247. rvd:=p^.right^.value_real;
  248. case p^.treetype of
  249. addn : t:=genrealconstnode(lvd+rvd,bestrealdef^);
  250. subn : t:=genrealconstnode(lvd-rvd,bestrealdef^);
  251. muln : t:=genrealconstnode(lvd*rvd,bestrealdef^);
  252. caretn : t:=genrealconstnode(exp(ln(lvd)*rvd),bestrealdef^);
  253. slashn : begin
  254. if rvd=0 then
  255. begin
  256. Message(parser_e_invalid_float_operation);
  257. t:=genrealconstnode(0,bestrealdef^);
  258. end
  259. else
  260. t:=genrealconstnode(lvd/rvd,bestrealdef^);
  261. end;
  262. ltn : t:=genordinalconstnode(ord(lvd<rvd),booldef);
  263. lten : t:=genordinalconstnode(ord(lvd<=rvd),booldef);
  264. gtn : t:=genordinalconstnode(ord(lvd>rvd),booldef);
  265. gten : t:=genordinalconstnode(ord(lvd>=rvd),booldef);
  266. equaln : t:=genordinalconstnode(ord(lvd=rvd),booldef);
  267. unequaln : t:=genordinalconstnode(ord(lvd<>rvd),booldef);
  268. else
  269. CGMessage(type_e_mismatch);
  270. end;
  271. disposetree(p);
  272. p:=t;
  273. firstpass(p);
  274. exit;
  275. end;
  276. { concating strings ? }
  277. concatstrings:=false;
  278. s1:=nil;
  279. s2:=nil;
  280. if (lt=ordconstn) and (rt=ordconstn) and
  281. is_char(ld) and is_char(rd) then
  282. begin
  283. s1:=strpnew(char(byte(p^.left^.value)));
  284. s2:=strpnew(char(byte(p^.right^.value)));
  285. l1:=1;
  286. l2:=1;
  287. concatstrings:=true;
  288. end
  289. else
  290. if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
  291. begin
  292. s1:=getpcharcopy(p^.left);
  293. l1:=p^.left^.length;
  294. s2:=strpnew(char(byte(p^.right^.value)));
  295. l2:=1;
  296. concatstrings:=true;
  297. end
  298. else
  299. if (lt=ordconstn) and (rt=stringconstn) and is_char(ld) then
  300. begin
  301. s1:=strpnew(char(byte(p^.left^.value)));
  302. l1:=1;
  303. s2:=getpcharcopy(p^.right);
  304. l2:=p^.right^.length;
  305. concatstrings:=true;
  306. end
  307. else if (lt=stringconstn) and (rt=stringconstn) then
  308. begin
  309. s1:=getpcharcopy(p^.left);
  310. l1:=p^.left^.length;
  311. s2:=getpcharcopy(p^.right);
  312. l2:=p^.right^.length;
  313. concatstrings:=true;
  314. end;
  315. { I will need to translate all this to ansistrings !!! }
  316. if concatstrings then
  317. begin
  318. case p^.treetype of
  319. addn :
  320. t:=genpcharconstnode(concatansistrings(s1,s2,l1,l2),l1+l2);
  321. ltn :
  322. t:=genordinalconstnode(byte(compareansistrings(s1,s2,l1,l2)<0),booldef);
  323. lten :
  324. t:=genordinalconstnode(byte(compareansistrings(s1,s2,l1,l2)<=0),booldef);
  325. gtn :
  326. t:=genordinalconstnode(byte(compareansistrings(s1,s2,l1,l2)>0),booldef);
  327. gten :
  328. t:=genordinalconstnode(byte(compareansistrings(s1,s2,l1,l2)>=0),booldef);
  329. equaln :
  330. t:=genordinalconstnode(byte(compareansistrings(s1,s2,l1,l2)=0),booldef);
  331. unequaln :
  332. t:=genordinalconstnode(byte(compareansistrings(s1,s2,l1,l2)<>0),booldef);
  333. end;
  334. ansistringdispose(s1,l1);
  335. ansistringdispose(s2,l2);
  336. disposetree(p);
  337. firstpass(t);
  338. p:=t;
  339. exit;
  340. end;
  341. { if both are orddefs then check sub types }
  342. if (ld^.deftype=orddef) and (rd^.deftype=orddef) then
  343. begin
  344. { 2 booleans ? }
  345. if is_boolean(ld) and is_boolean(rd) then
  346. begin
  347. case p^.treetype of
  348. andn,
  349. orn:
  350. begin
  351. calcregisters(p,0,0,0);
  352. make_bool_equal_size(p);
  353. p^.location.loc:=LOC_JUMP;
  354. end;
  355. xorn,ltn,lten,gtn,gten :
  356. begin
  357. make_bool_equal_size(p);
  358. if (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) and
  359. (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) then
  360. calcregisters(p,2,0,0)
  361. else
  362. calcregisters(p,1,0,0);
  363. end;
  364. unequaln,
  365. equaln:
  366. begin
  367. make_bool_equal_size(p);
  368. { Remove any compares with constants }
  369. if (p^.left^.treetype=ordconstn) then
  370. begin
  371. hp:=p^.right;
  372. b:=(p^.left^.value<>0);
  373. ot:=p^.treetype;
  374. disposetree(p^.left);
  375. putnode(p);
  376. p:=hp;
  377. if (not(b) and (ot=equaln)) or
  378. (b and (ot=unequaln)) then
  379. begin
  380. p:=gensinglenode(notn,p);
  381. firstpass(p);
  382. end;
  383. exit;
  384. end;
  385. if (p^.right^.treetype=ordconstn) then
  386. begin
  387. hp:=p^.left;
  388. b:=(p^.right^.value<>0);
  389. ot:=p^.treetype;
  390. disposetree(p^.right);
  391. putnode(p);
  392. p:=hp;
  393. if (not(b) and (ot=equaln)) or
  394. (b and (ot=unequaln)) then
  395. begin
  396. p:=gensinglenode(notn,p);
  397. firstpass(p);
  398. end;
  399. exit;
  400. end;
  401. if (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) and
  402. (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) then
  403. calcregisters(p,2,0,0)
  404. else
  405. calcregisters(p,1,0,0);
  406. end;
  407. else
  408. CGMessage(type_e_mismatch);
  409. end;
  410. { these one can't be in flags! }
  411. if p^.treetype in [xorn,unequaln,equaln] then
  412. begin
  413. if p^.left^.location.loc=LOC_FLAGS then
  414. begin
  415. p^.left:=gentypeconvnode(p^.left,porddef(p^.left^.resulttype));
  416. p^.left^.convtyp:=tc_bool_2_int;
  417. p^.left^.explizit:=true;
  418. firstpass(p^.left);
  419. end;
  420. if p^.right^.location.loc=LOC_FLAGS then
  421. begin
  422. p^.right:=gentypeconvnode(p^.right,porddef(p^.right^.resulttype));
  423. p^.right^.convtyp:=tc_bool_2_int;
  424. p^.right^.explizit:=true;
  425. firstpass(p^.right);
  426. end;
  427. { readjust registers }
  428. calcregisters(p,1,0,0);
  429. end;
  430. convdone:=true;
  431. end
  432. else
  433. { Both are chars? only convert to shortstrings for addn }
  434. if is_char(rd) and is_char(ld) then
  435. begin
  436. if p^.treetype=addn then
  437. begin
  438. p^.left:=gentypeconvnode(p^.left,cshortstringdef);
  439. p^.right:=gentypeconvnode(p^.right,cshortstringdef);
  440. firstpass(p^.left);
  441. firstpass(p^.right);
  442. { here we call STRCOPY }
  443. procinfo^.flags:=procinfo^.flags or pi_do_call;
  444. calcregisters(p,0,0,0);
  445. p^.location.loc:=LOC_MEM;
  446. end
  447. else
  448. calcregisters(p,1,0,0);
  449. convdone:=true;
  450. end
  451. { is there a 64 bit type ? }
  452. else if (porddef(rd)^.typ=s64bit) or (porddef(ld)^.typ=s64bit) then
  453. begin
  454. if (porddef(ld)^.typ<>s64bit) then
  455. begin
  456. p^.left:=gentypeconvnode(p^.left,cs64bitdef);
  457. firstpass(p^.left);
  458. end;
  459. if (porddef(rd)^.typ<>s64bit) then
  460. begin
  461. p^.right:=gentypeconvnode(p^.right,cs64bitdef);
  462. firstpass(p^.right);
  463. end;
  464. calcregisters(p,2,0,0);
  465. convdone:=true;
  466. end
  467. else if (porddef(rd)^.typ=u64bit) or (porddef(ld)^.typ=u64bit) then
  468. begin
  469. if (porddef(ld)^.typ<>u64bit) then
  470. begin
  471. p^.left:=gentypeconvnode(p^.left,cu64bitdef);
  472. firstpass(p^.left);
  473. end;
  474. if (porddef(rd)^.typ<>u64bit) then
  475. begin
  476. p^.right:=gentypeconvnode(p^.right,cu64bitdef);
  477. firstpass(p^.right);
  478. end;
  479. calcregisters(p,2,0,0);
  480. convdone:=true;
  481. end
  482. else
  483. { is there a cardinal? }
  484. if (porddef(rd)^.typ=u32bit) or (porddef(ld)^.typ=u32bit) then
  485. begin
  486. { convert constants to u32bit }
  487. if (porddef(ld)^.typ<>u32bit) then
  488. begin
  489. { s32bit will be used for when the other is also s32bit }
  490. if (porddef(rd)^.typ=s32bit) and (lt<>ordconstn) then
  491. p^.left:=gentypeconvnode(p^.left,s32bitdef)
  492. else
  493. p^.left:=gentypeconvnode(p^.left,u32bitdef);
  494. firstpass(p^.left);
  495. end;
  496. if (porddef(rd)^.typ<>u32bit) then
  497. begin
  498. { s32bit will be used for when the other is also s32bit }
  499. if (porddef(ld)^.typ=s32bit) and (rt<>ordconstn) then
  500. p^.right:=gentypeconvnode(p^.right,s32bitdef)
  501. else
  502. p^.right:=gentypeconvnode(p^.right,u32bitdef);
  503. firstpass(p^.right);
  504. end;
  505. calcregisters(p,1,0,0);
  506. { for unsigned mul we need an extra register }
  507. { p^.registers32:=p^.left^.registers32+p^.right^.registers32; }
  508. if p^.treetype=muln then
  509. inc(p^.registers32);
  510. convdone:=true;
  511. end;
  512. end
  513. else
  514. { left side a setdef, must be before string processing,
  515. else array constructor can be seen as array of char (PFV) }
  516. if (ld^.deftype=setdef) {or is_array_constructor(ld)} then
  517. begin
  518. { trying to add a set element? }
  519. if (p^.treetype=addn) and (rd^.deftype<>setdef) then
  520. begin
  521. if (rt=setelementn) then
  522. begin
  523. if not(is_equal(psetdef(ld)^.setof,rd)) then
  524. CGMessage(type_e_set_element_are_not_comp);
  525. end
  526. else
  527. CGMessage(type_e_mismatch)
  528. end
  529. else
  530. begin
  531. if not(p^.treetype in [addn,subn,symdifn,muln,equaln,unequaln
  532. {$IfNDef NoSetInclusion}
  533. ,lten,gten
  534. {$EndIf NoSetInclusion}
  535. ]) then
  536. CGMessage(type_e_set_operation_unknown);
  537. { right def must be a also be set }
  538. if (rd^.deftype<>setdef) or not(is_equal(rd,ld)) then
  539. CGMessage(type_e_set_element_are_not_comp);
  540. end;
  541. { ranges require normsets }
  542. if (psetdef(ld)^.settype=smallset) and
  543. (rt=setelementn) and
  544. assigned(p^.right^.right) then
  545. begin
  546. { generate a temporary normset def }
  547. tempdef:=new(psetdef,init(psetdef(ld)^.setof,255));
  548. p^.left:=gentypeconvnode(p^.left,tempdef);
  549. firstpass(p^.left);
  550. dispose(tempdef,done);
  551. ld:=p^.left^.resulttype;
  552. end;
  553. { if the destination is not a smallset then insert a typeconv
  554. which loads a smallset into a normal set }
  555. if (psetdef(ld)^.settype<>smallset) and
  556. (psetdef(rd)^.settype=smallset) then
  557. begin
  558. if (p^.right^.treetype=setconstn) then
  559. begin
  560. t:=gensetconstnode(p^.right^.value_set,psetdef(p^.left^.resulttype));
  561. t^.left:=p^.right^.left;
  562. putnode(p^.right);
  563. p^.right:=t;
  564. end
  565. else
  566. p^.right:=gentypeconvnode(p^.right,psetdef(p^.left^.resulttype));
  567. firstpass(p^.right);
  568. end;
  569. { do constant evaluation }
  570. if (p^.right^.treetype=setconstn) and
  571. not assigned(p^.right^.left) and
  572. (p^.left^.treetype=setconstn) and
  573. not assigned(p^.left^.left) then
  574. begin
  575. new(resultset);
  576. case p^.treetype of
  577. addn : begin
  578. for i:=0 to 31 do
  579. resultset^[i]:=
  580. p^.right^.value_set^[i] or p^.left^.value_set^[i];
  581. t:=gensetconstnode(resultset,psetdef(ld));
  582. end;
  583. muln : begin
  584. for i:=0 to 31 do
  585. resultset^[i]:=
  586. p^.right^.value_set^[i] and p^.left^.value_set^[i];
  587. t:=gensetconstnode(resultset,psetdef(ld));
  588. end;
  589. subn : begin
  590. for i:=0 to 31 do
  591. resultset^[i]:=
  592. p^.left^.value_set^[i] and not(p^.right^.value_set^[i]);
  593. t:=gensetconstnode(resultset,psetdef(ld));
  594. end;
  595. symdifn : begin
  596. for i:=0 to 31 do
  597. resultset^[i]:=
  598. p^.left^.value_set^[i] xor p^.right^.value_set^[i];
  599. t:=gensetconstnode(resultset,psetdef(ld));
  600. end;
  601. unequaln : begin
  602. b:=true;
  603. for i:=0 to 31 do
  604. if p^.right^.value_set^[i]=p^.left^.value_set^[i] then
  605. begin
  606. b:=false;
  607. break;
  608. end;
  609. t:=genordinalconstnode(ord(b),booldef);
  610. end;
  611. equaln : begin
  612. b:=true;
  613. for i:=0 to 31 do
  614. if p^.right^.value_set^[i]<>p^.left^.value_set^[i] then
  615. begin
  616. b:=false;
  617. break;
  618. end;
  619. t:=genordinalconstnode(ord(b),booldef);
  620. end;
  621. {$IfNDef NoSetInclusion}
  622. lten : Begin
  623. b := true;
  624. For i := 0 to 31 Do
  625. If (p^.right^.value_set^[i] And p^.left^.value_set^[i]) <>
  626. p^.left^.value_set^[i] Then
  627. Begin
  628. b := false;
  629. Break
  630. End;
  631. t := genordinalconstnode(ord(b),booldef);
  632. End;
  633. gten : Begin
  634. b := true;
  635. For i := 0 to 31 Do
  636. If (p^.left^.value_set^[i] And p^.right^.value_set^[i]) <>
  637. p^.right^.value_set^[i] Then
  638. Begin
  639. b := false;
  640. Break
  641. End;
  642. t := genordinalconstnode(ord(b),booldef);
  643. End;
  644. {$EndIf NoSetInclusion}
  645. end;
  646. dispose(resultset);
  647. disposetree(p);
  648. p:=t;
  649. firstpass(p);
  650. exit;
  651. end
  652. else
  653. if psetdef(ld)^.settype=smallset then
  654. begin
  655. calcregisters(p,1,0,0);
  656. { are we adding set elements ? }
  657. if p^.right^.treetype=setelementn then
  658. begin
  659. { we need at least two registers PM }
  660. if p^.registers32<2 then
  661. p^.registers32:=2;
  662. end;
  663. p^.location.loc:=LOC_REGISTER;
  664. end
  665. else
  666. begin
  667. calcregisters(p,0,0,0);
  668. { here we call SET... }
  669. procinfo^.flags:=procinfo^.flags or pi_do_call;
  670. p^.location.loc:=LOC_MEM;
  671. end;
  672. convdone:=true;
  673. end
  674. else
  675. { is one of the operands a string?,
  676. chararrays are also handled as strings (after conversion) }
  677. if (rd^.deftype=stringdef) or (ld^.deftype=stringdef) or
  678. (is_chararray(rd) and is_chararray(ld)) then
  679. begin
  680. if is_widestring(rd) or is_widestring(ld) then
  681. begin
  682. if not(is_widestring(rd)) then
  683. p^.right:=gentypeconvnode(p^.right,cwidestringdef);
  684. if not(is_widestring(ld)) then
  685. p^.left:=gentypeconvnode(p^.left,cwidestringdef);
  686. p^.resulttype:=cwidestringdef;
  687. { this is only for add, the comparisaion is handled later }
  688. p^.location.loc:=LOC_REGISTER;
  689. end
  690. else if is_ansistring(rd) or is_ansistring(ld) then
  691. begin
  692. if not(is_ansistring(rd)) then
  693. p^.right:=gentypeconvnode(p^.right,cansistringdef);
  694. if not(is_ansistring(ld)) then
  695. p^.left:=gentypeconvnode(p^.left,cansistringdef);
  696. p^.resulttype:=cansistringdef;
  697. { this is only for add, the comparisaion is handled later }
  698. p^.location.loc:=LOC_REGISTER;
  699. end
  700. else if is_longstring(rd) or is_longstring(ld) then
  701. begin
  702. if not(is_longstring(rd)) then
  703. p^.right:=gentypeconvnode(p^.right,clongstringdef);
  704. if not(is_longstring(ld)) then
  705. p^.left:=gentypeconvnode(p^.left,clongstringdef);
  706. p^.resulttype:=clongstringdef;
  707. { this is only for add, the comparisaion is handled later }
  708. p^.location.loc:=LOC_MEM;
  709. end
  710. else
  711. begin
  712. if not(is_shortstring(rd)) then
  713. p^.right:=gentypeconvnode(p^.right,cshortstringdef);
  714. if not(is_shortstring(ld)) then
  715. p^.left:=gentypeconvnode(p^.left,cshortstringdef);
  716. p^.resulttype:=cshortstringdef;
  717. { this is only for add, the comparisaion is handled later }
  718. p^.location.loc:=LOC_MEM;
  719. end;
  720. { only if there is a type cast we need to do again }
  721. { the first pass }
  722. if p^.left^.treetype=typeconvn then
  723. firstpass(p^.left);
  724. if p^.right^.treetype=typeconvn then
  725. firstpass(p^.right);
  726. { here we call STRCONCAT or STRCMP or STRCOPY }
  727. procinfo^.flags:=procinfo^.flags or pi_do_call;
  728. if p^.location.loc=LOC_MEM then
  729. calcregisters(p,0,0,0)
  730. else
  731. calcregisters(p,1,0,0);
  732. convdone:=true;
  733. end
  734. else
  735. { is one a real float ? }
  736. if (rd^.deftype=floatdef) or (ld^.deftype=floatdef) then
  737. begin
  738. { if one is a fixed, then convert to f32bit }
  739. if ((rd^.deftype=floatdef) and (pfloatdef(rd)^.typ=f32bit)) or
  740. ((ld^.deftype=floatdef) and (pfloatdef(ld)^.typ=f32bit)) then
  741. begin
  742. if not is_integer(rd) or (p^.treetype<>muln) then
  743. p^.right:=gentypeconvnode(p^.right,s32fixeddef);
  744. if not is_integer(ld) or (p^.treetype<>muln) then
  745. p^.left:=gentypeconvnode(p^.left,s32fixeddef);
  746. firstpass(p^.left);
  747. firstpass(p^.right);
  748. calcregisters(p,1,0,0);
  749. p^.location.loc:=LOC_REGISTER;
  750. end
  751. else
  752. { convert both to bestreal }
  753. begin
  754. p^.right:=gentypeconvnode(p^.right,bestrealdef^);
  755. p^.left:=gentypeconvnode(p^.left,bestrealdef^);
  756. firstpass(p^.left);
  757. firstpass(p^.right);
  758. calcregisters(p,1,1,0);
  759. p^.location.loc:=LOC_FPU;
  760. end;
  761. convdone:=true;
  762. end
  763. else
  764. { pointer comperation and subtraction }
  765. if (rd^.deftype=pointerdef) and (ld^.deftype=pointerdef) then
  766. begin
  767. p^.location.loc:=LOC_REGISTER;
  768. { p^.right:=gentypeconvnode(p^.right,ld); }
  769. { firstpass(p^.right); }
  770. calcregisters(p,1,0,0);
  771. case p^.treetype of
  772. equaln,unequaln :
  773. begin
  774. if is_equal(p^.right^.resulttype,voidpointerdef) then
  775. begin
  776. p^.right:=gentypeconvnode(p^.right,ld);
  777. firstpass(p^.right);
  778. end
  779. else if is_equal(p^.left^.resulttype,voidpointerdef) then
  780. begin
  781. p^.left:=gentypeconvnode(p^.left,rd);
  782. firstpass(p^.left);
  783. end
  784. else if not(is_equal(ld,rd)) then
  785. CGMessage(type_e_mismatch);
  786. end;
  787. ltn,lten,gtn,gten:
  788. begin
  789. if is_equal(p^.right^.resulttype,voidpointerdef) then
  790. begin
  791. p^.right:=gentypeconvnode(p^.right,ld);
  792. firstpass(p^.right);
  793. end
  794. else if is_equal(p^.left^.resulttype,voidpointerdef) then
  795. begin
  796. p^.left:=gentypeconvnode(p^.left,rd);
  797. firstpass(p^.left);
  798. end
  799. else if not(is_equal(ld,rd)) then
  800. CGMessage(type_e_mismatch);
  801. if not(cs_extsyntax in aktmoduleswitches) then
  802. CGMessage(type_e_mismatch);
  803. end;
  804. subn:
  805. begin
  806. if not(is_equal(ld,rd)) then
  807. CGMessage(type_e_mismatch);
  808. if not(cs_extsyntax in aktmoduleswitches) then
  809. CGMessage(type_e_mismatch);
  810. p^.resulttype:=s32bitdef;
  811. exit;
  812. end;
  813. else CGMessage(type_e_mismatch);
  814. end;
  815. convdone:=true;
  816. end
  817. else
  818. if (rd^.deftype=objectdef) and (ld^.deftype=objectdef) and
  819. pobjectdef(rd)^.is_class and pobjectdef(ld)^.is_class then
  820. begin
  821. p^.location.loc:=LOC_REGISTER;
  822. if pobjectdef(rd)^.is_related(pobjectdef(ld)) then
  823. p^.right:=gentypeconvnode(p^.right,ld)
  824. else
  825. p^.left:=gentypeconvnode(p^.left,rd);
  826. firstpass(p^.right);
  827. firstpass(p^.left);
  828. calcregisters(p,1,0,0);
  829. case p^.treetype of
  830. equaln,unequaln : ;
  831. else CGMessage(type_e_mismatch);
  832. end;
  833. convdone:=true;
  834. end
  835. else
  836. if (rd^.deftype=classrefdef) and (ld^.deftype=classrefdef) then
  837. begin
  838. p^.location.loc:=LOC_REGISTER;
  839. if pobjectdef(pclassrefdef(rd)^.definition)^.is_related(pobjectdef(
  840. pclassrefdef(ld)^.definition)) then
  841. p^.right:=gentypeconvnode(p^.right,ld)
  842. else
  843. p^.left:=gentypeconvnode(p^.left,rd);
  844. firstpass(p^.right);
  845. firstpass(p^.left);
  846. calcregisters(p,1,0,0);
  847. case p^.treetype of
  848. equaln,unequaln : ;
  849. else CGMessage(type_e_mismatch);
  850. end;
  851. convdone:=true;
  852. end
  853. else
  854. { allows comperasion with nil pointer }
  855. if (rd^.deftype=objectdef) and
  856. pobjectdef(rd)^.is_class then
  857. begin
  858. p^.location.loc:=LOC_REGISTER;
  859. p^.left:=gentypeconvnode(p^.left,rd);
  860. firstpass(p^.left);
  861. calcregisters(p,1,0,0);
  862. case p^.treetype of
  863. equaln,unequaln : ;
  864. else CGMessage(type_e_mismatch);
  865. end;
  866. convdone:=true;
  867. end
  868. else
  869. if (ld^.deftype=objectdef) and
  870. pobjectdef(ld)^.is_class then
  871. begin
  872. p^.location.loc:=LOC_REGISTER;
  873. p^.right:=gentypeconvnode(p^.right,ld);
  874. firstpass(p^.right);
  875. calcregisters(p,1,0,0);
  876. case p^.treetype of
  877. equaln,unequaln : ;
  878. else CGMessage(type_e_mismatch);
  879. end;
  880. convdone:=true;
  881. end
  882. else
  883. if (rd^.deftype=classrefdef) then
  884. begin
  885. p^.left:=gentypeconvnode(p^.left,rd);
  886. firstpass(p^.left);
  887. calcregisters(p,1,0,0);
  888. case p^.treetype of
  889. equaln,unequaln : ;
  890. else CGMessage(type_e_mismatch);
  891. end;
  892. convdone:=true;
  893. end
  894. else
  895. if (ld^.deftype=classrefdef) then
  896. begin
  897. p^.right:=gentypeconvnode(p^.right,ld);
  898. firstpass(p^.right);
  899. calcregisters(p,1,0,0);
  900. case p^.treetype of
  901. equaln,unequaln : ;
  902. else
  903. CGMessage(type_e_mismatch);
  904. end;
  905. convdone:=true;
  906. end
  907. else
  908. { support procvar=nil,procvar<>nil }
  909. if ((ld^.deftype=procvardef) and (rt=niln)) or
  910. ((rd^.deftype=procvardef) and (lt=niln)) then
  911. begin
  912. calcregisters(p,1,0,0);
  913. p^.location.loc:=LOC_REGISTER;
  914. case p^.treetype of
  915. equaln,unequaln : ;
  916. else
  917. CGMessage(type_e_mismatch);
  918. end;
  919. convdone:=true;
  920. end
  921. else
  922. if (rd^.deftype=pointerdef) or
  923. is_zero_based_array(rd) then
  924. begin
  925. if is_zero_based_array(rd) then
  926. begin
  927. p^.resulttype:=new(ppointerdef,init(parraydef(rd)^.definition));
  928. p^.right:=gentypeconvnode(p^.right,p^.resulttype);
  929. firstpass(p^.right);
  930. end;
  931. p^.location.loc:=LOC_REGISTER;
  932. p^.left:=gentypeconvnode(p^.left,s32bitdef);
  933. firstpass(p^.left);
  934. calcregisters(p,1,0,0);
  935. if p^.treetype=addn then
  936. begin
  937. if not(cs_extsyntax in aktmoduleswitches) or
  938. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  939. CGMessage(type_e_mismatch);
  940. { Dirty hack, to support multiple firstpasses (PFV) }
  941. if (p^.resulttype=nil) and
  942. (rd^.deftype=pointerdef) and
  943. (ppointerdef(rd)^.definition^.size>1) then
  944. begin
  945. p^.left:=gennode(muln,p^.left,genordinalconstnode(ppointerdef(rd)^.definition^.size,s32bitdef));
  946. firstpass(p^.left);
  947. end;
  948. end
  949. else
  950. CGMessage(type_e_mismatch);
  951. convdone:=true;
  952. end
  953. else
  954. if (ld^.deftype=pointerdef) or
  955. is_zero_based_array(ld) then
  956. begin
  957. if is_zero_based_array(ld) then
  958. begin
  959. p^.resulttype:=new(ppointerdef,init(parraydef(ld)^.definition));
  960. p^.left:=gentypeconvnode(p^.left,p^.resulttype);
  961. firstpass(p^.left);
  962. end;
  963. p^.location.loc:=LOC_REGISTER;
  964. p^.right:=gentypeconvnode(p^.right,s32bitdef);
  965. firstpass(p^.right);
  966. calcregisters(p,1,0,0);
  967. case p^.treetype of
  968. addn,subn : begin
  969. if not(cs_extsyntax in aktmoduleswitches) or
  970. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  971. CGMessage(type_e_mismatch);
  972. { Dirty hack, to support multiple firstpasses (PFV) }
  973. if (p^.resulttype=nil) and
  974. (ld^.deftype=pointerdef) and
  975. (ppointerdef(ld)^.definition^.size>1) then
  976. begin
  977. p^.right:=gennode(muln,p^.right,
  978. genordinalconstnode(ppointerdef(ld)^.definition^.size,s32bitdef));
  979. firstpass(p^.right);
  980. end;
  981. end;
  982. else
  983. CGMessage(type_e_mismatch);
  984. end;
  985. convdone:=true;
  986. end
  987. else
  988. if (rd^.deftype=procvardef) and (ld^.deftype=procvardef) and is_equal(rd,ld) then
  989. begin
  990. calcregisters(p,1,0,0);
  991. p^.location.loc:=LOC_REGISTER;
  992. case p^.treetype of
  993. equaln,unequaln : ;
  994. else
  995. CGMessage(type_e_mismatch);
  996. end;
  997. convdone:=true;
  998. end
  999. else
  1000. {$ifdef SUPPORT_MMX}
  1001. if (cs_mmx in aktlocalswitches) and is_mmx_able_array(ld) and
  1002. is_mmx_able_array(rd) and is_equal(ld,rd) then
  1003. begin
  1004. firstpass(p^.right);
  1005. firstpass(p^.left);
  1006. case p^.treetype of
  1007. addn,subn,xorn,orn,andn:
  1008. ;
  1009. { mul is a little bit restricted }
  1010. muln:
  1011. if not(mmx_type(p^.left^.resulttype) in
  1012. [mmxu16bit,mmxs16bit,mmxfixed16]) then
  1013. CGMessage(type_e_mismatch);
  1014. else
  1015. CGMessage(type_e_mismatch);
  1016. end;
  1017. p^.location.loc:=LOC_MMXREGISTER;
  1018. calcregisters(p,0,0,1);
  1019. convdone:=true;
  1020. end
  1021. else
  1022. {$endif SUPPORT_MMX}
  1023. if (ld^.deftype=enumdef) and (rd^.deftype=enumdef) and (is_equal(ld,rd)) then
  1024. begin
  1025. calcregisters(p,1,0,0);
  1026. case p^.treetype of
  1027. equaln,unequaln,
  1028. ltn,lten,gtn,gten : ;
  1029. else CGMessage(type_e_mismatch);
  1030. end;
  1031. convdone:=true;
  1032. end;
  1033. { the general solution is to convert to 32 bit int }
  1034. if not convdone then
  1035. begin
  1036. { but an int/int gives real/real! }
  1037. if p^.treetype=slashn then
  1038. begin
  1039. CGMessage(type_h_use_div_for_int);
  1040. p^.right:=gentypeconvnode(p^.right,bestrealdef^);
  1041. p^.left:=gentypeconvnode(p^.left,bestrealdef^);
  1042. firstpass(p^.left);
  1043. firstpass(p^.right);
  1044. { maybe we need an integer register to save }
  1045. { a reference }
  1046. if ((p^.left^.location.loc<>LOC_FPU) or
  1047. (p^.right^.location.loc<>LOC_FPU)) and
  1048. (p^.left^.registers32=p^.right^.registers32) then
  1049. calcregisters(p,1,1,0)
  1050. else
  1051. calcregisters(p,0,1,0);
  1052. p^.location.loc:=LOC_FPU;
  1053. end
  1054. else
  1055. begin
  1056. p^.right:=gentypeconvnode(p^.right,s32bitdef);
  1057. p^.left:=gentypeconvnode(p^.left,s32bitdef);
  1058. firstpass(p^.left);
  1059. firstpass(p^.right);
  1060. calcregisters(p,1,0,0);
  1061. p^.location.loc:=LOC_REGISTER;
  1062. end;
  1063. end;
  1064. if codegenerror then
  1065. exit;
  1066. { determines result type for comparions }
  1067. { here the is a problem with multiple passes }
  1068. { example length(s)+1 gets internal 'longint' type first }
  1069. { if it is a arg it is converted to 'LONGINT' }
  1070. { but a second first pass will reset this to 'longint' }
  1071. case p^.treetype of
  1072. ltn,lten,gtn,gten,equaln,unequaln:
  1073. begin
  1074. if (not assigned(p^.resulttype)) or
  1075. (p^.resulttype^.deftype=stringdef) then
  1076. p^.resulttype:=booldef;
  1077. if is_64bitint(p^.left^.resulttype) then
  1078. p^.location.loc:=LOC_JUMP
  1079. else
  1080. p^.location.loc:=LOC_FLAGS;
  1081. end;
  1082. xorn:
  1083. begin
  1084. if not assigned(p^.resulttype) then
  1085. p^.resulttype:=p^.left^.resulttype;
  1086. p^.location.loc:=LOC_REGISTER;
  1087. end;
  1088. addn:
  1089. begin
  1090. if not assigned(p^.resulttype) then
  1091. begin
  1092. { for strings, return is always a 255 char string }
  1093. if is_shortstring(p^.left^.resulttype) then
  1094. p^.resulttype:=cshortstringdef
  1095. else
  1096. p^.resulttype:=p^.left^.resulttype;
  1097. end;
  1098. end;
  1099. else
  1100. p^.resulttype:=p^.left^.resulttype;
  1101. end;
  1102. end;
  1103. end.
  1104. {
  1105. $Log$
  1106. Revision 1.52 1999-11-15 17:53:00 pierre
  1107. + one field added for ttoken record for operator
  1108. linking the id to the corresponding operator token that
  1109. can now now all be overloaded
  1110. * overloaded operators are resetted to nil in InitSymtable
  1111. (bug when trying to compile a uint that overloads operators twice)
  1112. Revision 1.51 1999/11/06 14:34:29 peter
  1113. * truncated log to 20 revs
  1114. Revision 1.50 1999/09/27 23:45:00 peter
  1115. * procinfo is now a pointer
  1116. * support for result setting in sub procedure
  1117. Revision 1.49 1999/09/16 13:39:14 peter
  1118. * arrayconstructor 2 set conversion is now called always in the
  1119. beginning of firstadd
  1120. Revision 1.48 1999/09/15 20:35:45 florian
  1121. * small fix to operator overloading when in MMX mode
  1122. + the compiler uses now fldz and fld1 if possible
  1123. + some fixes to floating point registers
  1124. + some math. functions (arctan, ln, sin, cos, sqrt, sqr, pi) are now inlined
  1125. * .... ???
  1126. Revision 1.47 1999/09/13 16:28:05 peter
  1127. * typo in previous commit open_array -> chararray :(
  1128. Revision 1.46 1999/09/10 15:40:46 peter
  1129. * fixed array check for operators, becuase array can also be a set
  1130. Revision 1.45 1999/09/08 16:05:29 peter
  1131. * pointer add/sub is now as expected and the same results as inc/dec
  1132. Revision 1.44 1999/09/07 07:52:19 peter
  1133. * > < >= <= support for boolean
  1134. * boolean constants are now calculated like integer constants
  1135. Revision 1.43 1999/08/23 23:44:05 pierre
  1136. * setelementn registers32 corrected
  1137. Revision 1.42 1999/08/07 11:29:27 peter
  1138. * better fix for muln register allocation
  1139. Revision 1.41 1999/08/05 21:58:57 peter
  1140. * fixed register count ord*ord
  1141. Revision 1.40 1999/08/04 13:03:13 jonas
  1142. * all tokens now start with an underscore
  1143. * PowerPC compiles!!
  1144. Revision 1.39 1999/08/04 00:23:33 florian
  1145. * renamed i386asm and i386base to cpuasm and cpubase
  1146. Revision 1.38 1999/08/03 22:03:24 peter
  1147. * moved bitmask constants to sets
  1148. * some other type/const renamings
  1149. Revision 1.37 1999/07/16 10:04:37 peter
  1150. * merged
  1151. Revision 1.36 1999/06/17 15:32:48 pierre
  1152. * merged from 0-99-12 branch
  1153. Revision 1.34.2.3 1999/07/16 09:54:58 peter
  1154. * @procvar support in tp7 mode works again
  1155. Revision 1.34.2.2 1999/06/17 15:25:07 pierre
  1156. * for arrays of char operators can not be overloaded
  1157. Revision 1.35 1999/06/17 13:19:57 pierre
  1158. * merged from 0_99_12 branch
  1159. Revision 1.34.2.1 1999/06/17 12:35:23 pierre
  1160. * allow array binary operator overloading if not with orddef
  1161. Revision 1.34 1999/06/02 10:11:52 florian
  1162. * make cycle fixed i.e. compilation with 0.99.10
  1163. * some fixes for qword
  1164. * start of register calling conventions
  1165. }