tcadd.pas 48 KB

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