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