nadd.pas 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Type checking and register allocation for add nodes
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit nadd;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. node;
  23. type
  24. taddnode = class(tbinopnode)
  25. constructor create(tt : tnodetype;l,r : tnode);override;
  26. function pass_1 : tnode;override;
  27. function det_resulttype:tnode;override;
  28. end;
  29. var
  30. { caddnode is used to create nodes of the add type }
  31. { the virtual constructor allows to assign }
  32. { another class type to caddnode => processor }
  33. { specific node types can be created }
  34. caddnode : class of taddnode;
  35. implementation
  36. uses
  37. globtype,systems,
  38. cutils,verbose,globals,widestr,
  39. symconst,symtype,symdef,types,
  40. cpuinfo,
  41. {$ifdef newcg}
  42. cgbase,
  43. {$else newcg}
  44. hcodegen,
  45. {$endif newcg}
  46. htypechk,pass_1,
  47. nmat,ncnv,nld,ncon,nset,nopt,
  48. cpubase;
  49. {*****************************************************************************
  50. TADDNODE
  51. *****************************************************************************}
  52. {$ifdef fpc}
  53. {$maxfpuregisters 0}
  54. {$endif fpc}
  55. constructor taddnode.create(tt : tnodetype;l,r : tnode);
  56. begin
  57. inherited create(tt,l,r);
  58. end;
  59. function taddnode.det_resulttype:tnode;
  60. var
  61. hp,t : tnode;
  62. lt,rt : tnodetype;
  63. rd,ld : tdef;
  64. htype : ttype;
  65. ot : tnodetype;
  66. concatstrings : boolean;
  67. resultset : pconstset;
  68. i : longint;
  69. b : boolean;
  70. s1,s2 : pchar;
  71. ws1,ws2,
  72. ws3 : tcompilerwidestring;
  73. l1,l2 : longint;
  74. rv,lv : tconstexprint;
  75. rvd,lvd : bestreal;
  76. begin
  77. result:=nil;
  78. { first do the two subtrees }
  79. resulttypepass(left);
  80. resulttypepass(right);
  81. { both left and right need to be valid }
  82. set_varstate(left,true);
  83. set_varstate(right,true);
  84. if codegenerror then
  85. exit;
  86. { convert array constructors to sets, because there is no other operator
  87. possible for array constructors }
  88. if is_array_constructor(left.resulttype.def) then
  89. begin
  90. arrayconstructor_to_set(tarrayconstructornode(left));
  91. resulttypepass(left);
  92. end;
  93. if is_array_constructor(right.resulttype.def) then
  94. begin
  95. arrayconstructor_to_set(tarrayconstructornode(right));
  96. resulttypepass(right);
  97. end;
  98. { allow operator overloading }
  99. hp:=self;
  100. if isbinaryoverloaded(hp) then
  101. begin
  102. resulttypepass(hp);
  103. result:=hp;
  104. exit;
  105. end;
  106. { is one a real float, then both need to be floats, this
  107. need to be done before the constant folding so constant
  108. operation on a float and int are also handled }
  109. if (right.resulttype.def.deftype=floatdef) or (left.resulttype.def.deftype=floatdef) then
  110. begin
  111. inserttypeconv(right,pbestrealtype^);
  112. inserttypeconv(left,pbestrealtype^);
  113. end;
  114. { if one operand is a widechar or a widestring, both operands }
  115. { are converted to widestring. This must be done before constant }
  116. { folding to allow char+widechar etc. }
  117. if is_widestring(right.resulttype.def) or
  118. is_widestring(left.resulttype.def) or
  119. is_widechar(right.resulttype.def) or
  120. is_widechar(left.resulttype.def) then
  121. begin
  122. inserttypeconv(right,cwidestringtype);
  123. inserttypeconv(left,cwidestringtype);
  124. end;
  125. { load easier access variables }
  126. rd:=right.resulttype.def;
  127. ld:=left.resulttype.def;
  128. rt:=right.nodetype;
  129. lt:=left.nodetype;
  130. { both are int constants }
  131. if (((is_constintnode(left) and is_constintnode(right)) or
  132. (is_constboolnode(left) and is_constboolnode(right) and
  133. (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,andn,xorn,orn])))) or
  134. { support pointer arithmetics on constants (JM) }
  135. ((lt = pointerconstn) and is_constintnode(right) and
  136. (nodetype in [addn,subn])) or
  137. ((lt = pointerconstn) and (rt = pointerconstn) and
  138. (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,subn])) then
  139. begin
  140. { when comparing/substracting pointers, make sure they are }
  141. { of the same type (JM) }
  142. if (lt = pointerconstn) and (rt = pointerconstn) then
  143. begin
  144. if not(cs_extsyntax in aktmoduleswitches) and
  145. not(nodetype in [equaln,unequaln]) then
  146. CGMessage(type_e_mismatch)
  147. else
  148. if (nodetype <> subn) and
  149. is_voidpointer(rd) then
  150. inserttypeconv(right,left.resulttype)
  151. else if (nodetype <> subn) and
  152. is_voidpointer(ld) then
  153. inserttypeconv(left,right.resulttype)
  154. else if not(is_equal(ld,rd)) then
  155. CGMessage(type_e_mismatch);
  156. end
  157. else if (lt=ordconstn) and (rt=ordconstn) then
  158. begin
  159. { make left const type the biggest, this type will be used
  160. for orn,andn,xorn }
  161. if rd.size>ld.size then
  162. inserttypeconv(left,right.resulttype);
  163. end;
  164. { load values }
  165. if (lt = ordconstn) then
  166. lv:=tordconstnode(left).value
  167. else
  168. lv:=tpointerconstnode(left).value;
  169. if (rt = ordconstn) then
  170. rv:=tordconstnode(right).value
  171. else
  172. rv:=tpointerconstnode(right).value;
  173. if (lt = pointerconstn) and
  174. (rt <> pointerconstn) then
  175. rv := rv * tpointerdef(left.resulttype.def).pointertype.def.size;
  176. if (rt = pointerconstn) and
  177. (lt <> pointerconstn) then
  178. lv := lv * tpointerdef(right.resulttype.def).pointertype.def.size;
  179. case nodetype of
  180. addn :
  181. if (lt <> pointerconstn) then
  182. t := genintconstnode(lv+rv)
  183. else
  184. t := cpointerconstnode.create(lv+rv,left.resulttype);
  185. subn :
  186. if (lt <> pointerconstn) or (rt = pointerconstn) then
  187. t := genintconstnode(lv-rv)
  188. else
  189. t := cpointerconstnode.create(lv-rv,left.resulttype);
  190. muln :
  191. t:=genintconstnode(lv*rv);
  192. xorn :
  193. t:=cordconstnode.create(lv xor rv,left.resulttype);
  194. orn :
  195. t:=cordconstnode.create(lv or rv,left.resulttype);
  196. andn :
  197. t:=cordconstnode.create(lv and rv,left.resulttype);
  198. ltn :
  199. t:=cordconstnode.create(ord(lv<rv),booltype);
  200. lten :
  201. t:=cordconstnode.create(ord(lv<=rv),booltype);
  202. gtn :
  203. t:=cordconstnode.create(ord(lv>rv),booltype);
  204. gten :
  205. t:=cordconstnode.create(ord(lv>=rv),booltype);
  206. equaln :
  207. t:=cordconstnode.create(ord(lv=rv),booltype);
  208. unequaln :
  209. t:=cordconstnode.create(ord(lv<>rv),booltype);
  210. slashn :
  211. begin
  212. { int/int becomes a real }
  213. if int(rv)=0 then
  214. begin
  215. Message(parser_e_invalid_float_operation);
  216. t:=crealconstnode.create(0,pbestrealtype^);
  217. end
  218. else
  219. t:=crealconstnode.create(int(lv)/int(rv),pbestrealtype^);
  220. end;
  221. else
  222. CGMessage(type_e_mismatch);
  223. end;
  224. resulttypepass(t);
  225. result:=t;
  226. exit;
  227. end;
  228. { both real constants ? }
  229. if (lt=realconstn) and (rt=realconstn) then
  230. begin
  231. lvd:=trealconstnode(left).value_real;
  232. rvd:=trealconstnode(right).value_real;
  233. case nodetype of
  234. addn :
  235. t:=crealconstnode.create(lvd+rvd,pbestrealtype^);
  236. subn :
  237. t:=crealconstnode.create(lvd-rvd,pbestrealtype^);
  238. muln :
  239. t:=crealconstnode.create(lvd*rvd,pbestrealtype^);
  240. starstarn,
  241. caretn :
  242. begin
  243. if lvd<0 then
  244. begin
  245. Message(parser_e_invalid_float_operation);
  246. t:=crealconstnode.create(0,pbestrealtype^);
  247. end
  248. else if lvd=0 then
  249. t:=crealconstnode.create(1.0,pbestrealtype^)
  250. else
  251. t:=crealconstnode.create(exp(ln(lvd)*rvd),pbestrealtype^);
  252. end;
  253. slashn :
  254. begin
  255. if rvd=0 then
  256. begin
  257. Message(parser_e_invalid_float_operation);
  258. t:=crealconstnode.create(0,pbestrealtype^);
  259. end
  260. else
  261. t:=crealconstnode.create(lvd/rvd,pbestrealtype^);
  262. end;
  263. ltn :
  264. t:=cordconstnode.create(ord(lvd<rvd),booltype);
  265. lten :
  266. t:=cordconstnode.create(ord(lvd<=rvd),booltype);
  267. gtn :
  268. t:=cordconstnode.create(ord(lvd>rvd),booltype);
  269. gten :
  270. t:=cordconstnode.create(ord(lvd>=rvd),booltype);
  271. equaln :
  272. t:=cordconstnode.create(ord(lvd=rvd),booltype);
  273. unequaln :
  274. t:=cordconstnode.create(ord(lvd<>rvd),booltype);
  275. else
  276. CGMessage(type_e_mismatch);
  277. end;
  278. resulttypepass(t);
  279. result:=t;
  280. exit;
  281. end;
  282. { first, we handle widestrings, so we can check later for }
  283. { stringconstn only }
  284. { widechars are converted above to widestrings too }
  285. { this isn't veryy efficient, but I don't think }
  286. { that it does matter that much (FK) }
  287. if (lt=stringconstn) and (rt=stringconstn) and
  288. (tstringconstnode(left).st_type=st_widestring) and
  289. (tstringconstnode(right).st_type=st_widestring) then
  290. begin
  291. initwidestring(ws1);
  292. initwidestring(ws2);
  293. copywidestring(pcompilerwidestring(tstringconstnode(left).value_str)^,ws1);
  294. copywidestring(pcompilerwidestring(tstringconstnode(right).value_str)^,ws2);
  295. case nodetype of
  296. addn :
  297. begin
  298. initwidestring(ws3);
  299. concatwidestrings(ws1,ws2,ws3);
  300. t:=cstringconstnode.createwstr(ws3);
  301. donewidestring(ws3);
  302. end;
  303. ltn :
  304. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<0),booltype);
  305. lten :
  306. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<=0),booltype);
  307. gtn :
  308. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>0),booltype);
  309. gten :
  310. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>=0),booltype);
  311. equaln :
  312. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)=0),booltype);
  313. unequaln :
  314. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<>0),booltype);
  315. end;
  316. donewidestring(ws1);
  317. donewidestring(ws2);
  318. resulttypepass(t);
  319. result:=t;
  320. exit;
  321. end;
  322. { concating strings ? }
  323. concatstrings:=false;
  324. s1:=nil;
  325. s2:=nil;
  326. if (lt=ordconstn) and (rt=ordconstn) and
  327. is_char(ld) and is_char(rd) then
  328. begin
  329. s1:=strpnew(char(byte(tordconstnode(left).value)));
  330. s2:=strpnew(char(byte(tordconstnode(right).value)));
  331. l1:=1;
  332. l2:=1;
  333. concatstrings:=true;
  334. end
  335. else
  336. if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
  337. begin
  338. s1:=tstringconstnode(left).getpcharcopy;
  339. l1:=tstringconstnode(left).len;
  340. s2:=strpnew(char(byte(tordconstnode(right).value)));
  341. l2:=1;
  342. concatstrings:=true;
  343. end
  344. else
  345. if (lt=ordconstn) and (rt=stringconstn) and is_char(ld) then
  346. begin
  347. s1:=strpnew(char(byte(tordconstnode(left).value)));
  348. l1:=1;
  349. s2:=tstringconstnode(right).getpcharcopy;
  350. l2:=tstringconstnode(right).len;
  351. concatstrings:=true;
  352. end
  353. else if (lt=stringconstn) and (rt=stringconstn) then
  354. begin
  355. s1:=tstringconstnode(left).getpcharcopy;
  356. l1:=tstringconstnode(left).len;
  357. s2:=tstringconstnode(right).getpcharcopy;
  358. l2:=tstringconstnode(right).len;
  359. concatstrings:=true;
  360. end;
  361. if concatstrings then
  362. begin
  363. case nodetype of
  364. addn :
  365. t:=cstringconstnode.createpchar(concatansistrings(s1,s2,l1,l2),l1+l2);
  366. ltn :
  367. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<0),booltype);
  368. lten :
  369. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<=0),booltype);
  370. gtn :
  371. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>0),booltype);
  372. gten :
  373. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>=0),booltype);
  374. equaln :
  375. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)=0),booltype);
  376. unequaln :
  377. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<>0),booltype);
  378. end;
  379. ansistringdispose(s1,l1);
  380. ansistringdispose(s2,l2);
  381. resulttypepass(t);
  382. result:=t;
  383. exit;
  384. end;
  385. { set constant evaluation }
  386. if (right.nodetype=setconstn) and
  387. not assigned(tsetconstnode(right).left) and
  388. (left.nodetype=setconstn) and
  389. not assigned(tsetconstnode(left).left) then
  390. begin
  391. { check types }
  392. inserttypeconv(left,right.resulttype);
  393. if codegenerror then
  394. begin
  395. { recover by only returning the left part }
  396. result:=left;
  397. left:=nil;
  398. exit;
  399. end;
  400. new(resultset);
  401. case nodetype of
  402. addn :
  403. begin
  404. for i:=0 to 31 do
  405. resultset^[i]:=tsetconstnode(right).value_set^[i] or tsetconstnode(left).value_set^[i];
  406. t:=csetconstnode.create(resultset,left.resulttype);
  407. end;
  408. muln :
  409. begin
  410. for i:=0 to 31 do
  411. resultset^[i]:=tsetconstnode(right).value_set^[i] and tsetconstnode(left).value_set^[i];
  412. t:=csetconstnode.create(resultset,left.resulttype);
  413. end;
  414. subn :
  415. begin
  416. for i:=0 to 31 do
  417. resultset^[i]:=tsetconstnode(left).value_set^[i] and not(tsetconstnode(right).value_set^[i]);
  418. t:=csetconstnode.create(resultset,left.resulttype);
  419. end;
  420. symdifn :
  421. begin
  422. for i:=0 to 31 do
  423. resultset^[i]:=tsetconstnode(left).value_set^[i] xor tsetconstnode(right).value_set^[i];
  424. t:=csetconstnode.create(resultset,left.resulttype);
  425. end;
  426. unequaln :
  427. begin
  428. b:=true;
  429. for i:=0 to 31 do
  430. if tsetconstnode(right).value_set^[i]=tsetconstnode(left).value_set^[i] then
  431. begin
  432. b:=false;
  433. break;
  434. end;
  435. t:=cordconstnode.create(ord(b),booltype);
  436. end;
  437. equaln :
  438. begin
  439. b:=true;
  440. for i:=0 to 31 do
  441. if tsetconstnode(right).value_set^[i]<>tsetconstnode(left).value_set^[i] then
  442. begin
  443. b:=false;
  444. break;
  445. end;
  446. t:=cordconstnode.create(ord(b),booltype);
  447. end;
  448. lten :
  449. begin
  450. b := true;
  451. For i := 0 to 31 Do
  452. If (tsetconstnode(right).value_set^[i] And tsetconstnode(left).value_set^[i]) <>
  453. tsetconstnode(left).value_set^[i] Then
  454. Begin
  455. b := false;
  456. Break
  457. End;
  458. t := cordconstnode.create(ord(b),booltype);
  459. End;
  460. gten :
  461. Begin
  462. b := true;
  463. For i := 0 to 31 Do
  464. If (tsetconstnode(left).value_set^[i] And tsetconstnode(right).value_set^[i]) <>
  465. tsetconstnode(right).value_set^[i] Then
  466. Begin
  467. b := false;
  468. Break
  469. End;
  470. t := cordconstnode.create(ord(b),booltype);
  471. End;
  472. end;
  473. dispose(resultset);
  474. resulttypepass(t);
  475. result:=t;
  476. exit;
  477. end;
  478. { but an int/int gives real/real! }
  479. if nodetype=slashn then
  480. begin
  481. CGMessage(type_h_use_div_for_int);
  482. inserttypeconv(right,pbestrealtype^);
  483. inserttypeconv(left,pbestrealtype^);
  484. end
  485. { if both are orddefs then check sub types }
  486. else if (ld.deftype=orddef) and (rd.deftype=orddef) then
  487. begin
  488. { 2 booleans? Make them equal to the largest boolean }
  489. if is_boolean(ld) and is_boolean(rd) then
  490. begin
  491. if torddef(left.resulttype.def).size>torddef(right.resulttype.def).size then
  492. begin
  493. inserttypeconv(right,left.resulttype);
  494. ttypeconvnode(right).convtype:=tc_bool_2_int;
  495. include(right.flags,nf_explizit);
  496. end
  497. else if torddef(left.resulttype.def).size<torddef(right.resulttype.def).size then
  498. begin
  499. inserttypeconv(left,right.resulttype);
  500. ttypeconvnode(left).convtype:=tc_bool_2_int;
  501. include(left.flags,nf_explizit);
  502. end;
  503. case nodetype of
  504. xorn,
  505. ltn,
  506. lten,
  507. gtn,
  508. gten,
  509. andn,
  510. orn:
  511. begin
  512. end;
  513. unequaln,
  514. equaln:
  515. begin
  516. if not(cs_full_boolean_eval in aktlocalswitches) then
  517. begin
  518. { Remove any compares with constants }
  519. if (left.nodetype=ordconstn) then
  520. begin
  521. hp:=right;
  522. b:=(tordconstnode(left).value<>0);
  523. ot:=nodetype;
  524. left.free;
  525. left:=nil;
  526. right:=nil;
  527. if (not(b) and (ot=equaln)) or
  528. (b and (ot=unequaln)) then
  529. begin
  530. hp:=cnotnode.create(hp);
  531. resulttypepass(hp);
  532. end;
  533. result:=hp;
  534. exit;
  535. end;
  536. if (right.nodetype=ordconstn) then
  537. begin
  538. hp:=left;
  539. b:=(tordconstnode(right).value<>0);
  540. ot:=nodetype;
  541. right.free;
  542. right:=nil;
  543. left:=nil;
  544. if (not(b) and (ot=equaln)) or
  545. (b and (ot=unequaln)) then
  546. begin
  547. hp:=cnotnode.create(hp);
  548. resulttypepass(hp);
  549. end;
  550. result:=hp;
  551. exit;
  552. end;
  553. end;
  554. end;
  555. else
  556. CGMessage(type_e_mismatch);
  557. end;
  558. end
  559. { Both are chars? }
  560. else if is_char(rd) and is_char(ld) then
  561. begin
  562. if nodetype=addn then
  563. begin
  564. resulttype:=cshortstringtype;
  565. if not(is_constcharnode(left) and is_constcharnode(right)) then
  566. begin
  567. inserttypeconv(left,cshortstringtype);
  568. hp := genaddsstringcharoptnode(self);
  569. resulttypepass(hp);
  570. result := hp;
  571. exit;
  572. end;
  573. end;
  574. end
  575. { is there a signed 64 bit type ? }
  576. else if ((torddef(rd).typ=s64bit) or (torddef(ld).typ=s64bit)) then
  577. begin
  578. if (torddef(ld).typ<>s64bit) then
  579. inserttypeconv(left,cs64bittype);
  580. if (torddef(rd).typ<>s64bit) then
  581. inserttypeconv(right,cs64bittype);
  582. end
  583. { is there a unsigned 64 bit type ? }
  584. else if ((torddef(rd).typ=u64bit) or (torddef(ld).typ=u64bit)) then
  585. begin
  586. if (torddef(ld).typ<>u64bit) then
  587. inserttypeconv(left,cu64bittype);
  588. if (torddef(rd).typ<>u64bit) then
  589. inserttypeconv(right,cu64bittype);
  590. end
  591. { is there a cardinal? }
  592. else if ((torddef(rd).typ=u32bit) or (torddef(ld).typ=u32bit)) then
  593. begin
  594. if is_signed(ld) and
  595. { then rd = u32bit }
  596. { convert positive constants to u32bit }
  597. not(is_constintnode(left) and
  598. (tordconstnode(left).value >= 0)) and
  599. { range/overflow checking on mixed signed/cardinal expressions }
  600. { is only possible if you convert everything to 64bit (JM) }
  601. ((aktlocalswitches * [cs_check_overflow,cs_check_range] <> []) and
  602. (nodetype in [addn,subn,muln])) then
  603. begin
  604. { perform the operation in 64bit }
  605. CGMessage(type_w_mixed_signed_unsigned);
  606. inserttypeconv(left,cs64bittype);
  607. inserttypeconv(right,cs64bittype);
  608. end
  609. else
  610. begin
  611. if is_signed(ld) and
  612. not(is_constintnode(left) and
  613. (tordconstnode(left).value >= 0)) and
  614. (cs_check_range in aktlocalswitches) then
  615. CGMessage(type_w_mixed_signed_unsigned2);
  616. inserttypeconv(left,u32bittype);
  617. if is_signed(rd) and
  618. { then ld = u32bit }
  619. { convert positive constants to u32bit }
  620. not(is_constintnode(right) and
  621. (tordconstnode(right).value >= 0)) and
  622. ((aktlocalswitches * [cs_check_overflow,cs_check_range] <> []) and
  623. (nodetype in [addn,subn,muln])) then
  624. begin
  625. { perform the operation in 64bit }
  626. CGMessage(type_w_mixed_signed_unsigned);
  627. inserttypeconv(left,cs64bittype);
  628. inserttypeconv(right,cs64bittype);
  629. end
  630. else
  631. begin
  632. if is_signed(rd) and
  633. not(is_constintnode(right) and
  634. (tordconstnode(right).value >= 0)) and
  635. (cs_check_range in aktlocalswitches) then
  636. CGMessage(type_w_mixed_signed_unsigned2);
  637. inserttypeconv(right,u32bittype);
  638. end;
  639. end;
  640. end
  641. { generic ord conversion is s32bit }
  642. else
  643. begin
  644. inserttypeconv(right,s32bittype);
  645. inserttypeconv(left,s32bittype);
  646. end;
  647. end
  648. { if both are floatdefs, conversion is already done before constant folding }
  649. else if (ld.deftype=floatdef) then
  650. begin
  651. { already converted }
  652. end
  653. else if (right.resulttype.def.deftype=floatdef) or (left.resulttype.def.deftype=floatdef) then
  654. begin
  655. inserttypeconv(right,pbestrealtype^);
  656. inserttypeconv(left,pbestrealtype^);
  657. end
  658. { left side a setdef, must be before string processing,
  659. else array constructor can be seen as array of char (PFV) }
  660. else if (ld.deftype=setdef) then
  661. begin
  662. { trying to add a set element? }
  663. if (nodetype=addn) and (rd.deftype<>setdef) then
  664. begin
  665. if (rt=setelementn) then
  666. begin
  667. if not(is_equal(tsetdef(ld).elementtype.def,rd)) then
  668. CGMessage(type_e_set_element_are_not_comp);
  669. end
  670. else
  671. CGMessage(type_e_mismatch)
  672. end
  673. else
  674. begin
  675. if not(nodetype in [addn,subn,symdifn,muln,equaln,unequaln,lten,gten]) then
  676. CGMessage(type_e_set_operation_unknown);
  677. { right def must be a also be set }
  678. if (rd.deftype<>setdef) or not(is_equal(rd,ld)) then
  679. CGMessage(type_e_set_element_are_not_comp);
  680. end;
  681. { ranges require normsets }
  682. if (tsetdef(ld).settype=smallset) and
  683. (rt=setelementn) and
  684. assigned(tsetelementnode(right).right) then
  685. begin
  686. { generate a temporary normset def, it'll be destroyed
  687. when the symtable is unloaded }
  688. htype.setdef(tsetdef.create(tsetdef(ld).elementtype,255));
  689. inserttypeconv(left,htype);
  690. end;
  691. end
  692. { compare pchar to char arrays by addresses like BP/Delphi }
  693. else if (is_pchar(ld) and is_chararray(rd)) or
  694. (is_pchar(rd) and is_chararray(ld)) then
  695. begin
  696. if is_chararray(rd) then
  697. inserttypeconv(right,left.resulttype)
  698. else
  699. inserttypeconv(left,right.resulttype);
  700. end
  701. { is one of the operands a string?,
  702. chararrays are also handled as strings (after conversion), also take
  703. care of chararray+chararray and chararray+char }
  704. else if (rd.deftype=stringdef) or (ld.deftype=stringdef) or
  705. ((is_chararray(rd) or is_char(rd)) and
  706. (is_chararray(ld) or is_char(ld))) then
  707. begin
  708. if is_widestring(rd) or is_widestring(ld) then
  709. begin
  710. if not(is_widestring(rd)) then
  711. inserttypeconv(right,cwidestringtype);
  712. if not(is_widestring(ld)) then
  713. inserttypeconv(left,cwidestringtype);
  714. end
  715. else if is_ansistring(rd) or is_ansistring(ld) then
  716. begin
  717. if not(is_ansistring(rd)) then
  718. inserttypeconv(right,cansistringtype);
  719. if not(is_ansistring(ld)) then
  720. inserttypeconv(left,cansistringtype);
  721. end
  722. else if is_longstring(rd) or is_longstring(ld) then
  723. begin
  724. if not(is_longstring(rd)) then
  725. inserttypeconv(right,clongstringtype);
  726. if not(is_longstring(ld)) then
  727. inserttypeconv(left,clongstringtype);
  728. location.loc:=LOC_MEM;
  729. end
  730. else
  731. begin
  732. if not(is_shortstring(ld)) then
  733. inserttypeconv(left,cshortstringtype);
  734. { don't convert char, that can be handled by the optimized node }
  735. if not(is_shortstring(rd) or is_char(rd)) then
  736. inserttypeconv(right,cshortstringtype);
  737. end;
  738. end
  739. { pointer comparision and subtraction }
  740. else if (rd.deftype=pointerdef) and (ld.deftype=pointerdef) then
  741. begin
  742. case nodetype of
  743. equaln,unequaln :
  744. begin
  745. if is_voidpointer(right.resulttype.def) then
  746. inserttypeconv(right,left.resulttype)
  747. else if is_voidpointer(left.resulttype.def) then
  748. inserttypeconv(left,right.resulttype)
  749. else if not(is_equal(ld,rd)) then
  750. CGMessage(type_e_mismatch);
  751. end;
  752. ltn,lten,gtn,gten:
  753. begin
  754. if (cs_extsyntax in aktmoduleswitches) then
  755. begin
  756. if is_voidpointer(right.resulttype.def) then
  757. inserttypeconv(right,left.resulttype)
  758. else if is_voidpointer(left.resulttype.def) then
  759. inserttypeconv(left,right.resulttype)
  760. else if not(is_equal(ld,rd)) then
  761. CGMessage(type_e_mismatch);
  762. end
  763. else
  764. CGMessage(type_e_mismatch);
  765. end;
  766. subn:
  767. begin
  768. if (cs_extsyntax in aktmoduleswitches) then
  769. begin
  770. if is_voidpointer(right.resulttype.def) then
  771. inserttypeconv(right,left.resulttype)
  772. else if is_voidpointer(left.resulttype.def) then
  773. inserttypeconv(left,right.resulttype)
  774. else if not(is_equal(ld,rd)) then
  775. CGMessage(type_e_mismatch);
  776. end
  777. else
  778. CGMessage(type_e_mismatch);
  779. resulttype:=s32bittype;
  780. exit;
  781. end;
  782. addn:
  783. begin
  784. if (cs_extsyntax in aktmoduleswitches) then
  785. begin
  786. if is_voidpointer(right.resulttype.def) then
  787. inserttypeconv(right,left.resulttype)
  788. else if is_voidpointer(left.resulttype.def) then
  789. inserttypeconv(left,right.resulttype)
  790. else if not(is_equal(ld,rd)) then
  791. CGMessage(type_e_mismatch);
  792. end
  793. else
  794. CGMessage(type_e_mismatch);
  795. resulttype:=s32bittype;
  796. exit;
  797. end;
  798. else
  799. CGMessage(type_e_mismatch);
  800. end;
  801. end
  802. { class or interface equation }
  803. else if is_class_or_interface(rd) or is_class_or_interface(ld) then
  804. begin
  805. if is_class_or_interface(rd) and is_class_or_interface(ld) then
  806. begin
  807. if tobjectdef(rd).is_related(tobjectdef(ld)) then
  808. inserttypeconv(right,left.resulttype)
  809. else
  810. inserttypeconv(left,right.resulttype);
  811. end
  812. else if is_class_or_interface(rd) then
  813. inserttypeconv(left,right.resulttype)
  814. else
  815. inserttypeconv(right,left.resulttype);
  816. if not(nodetype in [equaln,unequaln]) then
  817. CGMessage(type_e_mismatch);
  818. end
  819. else if (rd.deftype=classrefdef) and (ld.deftype=classrefdef) then
  820. begin
  821. if tobjectdef(tclassrefdef(rd).pointertype.def).is_related(
  822. tobjectdef(tclassrefdef(ld).pointertype.def)) then
  823. inserttypeconv(right,left.resulttype)
  824. else
  825. inserttypeconv(left,right.resulttype);
  826. if not(nodetype in [equaln,unequaln]) then
  827. CGMessage(type_e_mismatch);
  828. end
  829. { allows comperasion with nil pointer }
  830. else if is_class_or_interface(rd) or (rd.deftype=classrefdef) then
  831. begin
  832. inserttypeconv(left,right.resulttype);
  833. if not(nodetype in [equaln,unequaln]) then
  834. CGMessage(type_e_mismatch);
  835. end
  836. else if is_class_or_interface(ld) or (ld.deftype=classrefdef) then
  837. begin
  838. inserttypeconv(right,left.resulttype);
  839. if not(nodetype in [equaln,unequaln]) then
  840. CGMessage(type_e_mismatch);
  841. end
  842. { support procvar=nil,procvar<>nil }
  843. else if ((ld.deftype=procvardef) and (rt=niln)) or
  844. ((rd.deftype=procvardef) and (lt=niln)) then
  845. begin
  846. if not(nodetype in [equaln,unequaln]) then
  847. CGMessage(type_e_mismatch);
  848. end
  849. {$ifdef SUPPORT_MMX}
  850. { mmx support, this must be before the zero based array
  851. check }
  852. else if (cs_mmx in aktlocalswitches) and
  853. is_mmx_able_array(ld) and
  854. is_mmx_able_array(rd) and
  855. is_equal(ld,rd) then
  856. begin
  857. case nodetype of
  858. addn,subn,xorn,orn,andn:
  859. ;
  860. { mul is a little bit restricted }
  861. muln:
  862. if not(mmx_type(ld) in [mmxu16bit,mmxs16bit,mmxfixed16]) then
  863. CGMessage(type_e_mismatch);
  864. else
  865. CGMessage(type_e_mismatch);
  866. end;
  867. end
  868. {$endif SUPPORT_MMX}
  869. { this is a little bit dangerous, also the left type }
  870. { pointer to should be checked! This broke the mmx support }
  871. else if (rd.deftype=pointerdef) or is_zero_based_array(rd) then
  872. begin
  873. if is_zero_based_array(rd) then
  874. begin
  875. resulttype.setdef(tpointerdef.create(tarraydef(rd).elementtype));
  876. inserttypeconv(right,resulttype);
  877. end;
  878. inserttypeconv(left,s32bittype);
  879. if nodetype=addn then
  880. begin
  881. if not(cs_extsyntax in aktmoduleswitches) or
  882. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  883. CGMessage(type_e_mismatch);
  884. if (rd.deftype=pointerdef) and
  885. (tpointerdef(rd).pointertype.def.size>1) then
  886. left:=caddnode.create(muln,left,cordconstnode.create(tpointerdef(rd).pointertype.def.size,s32bittype));
  887. end
  888. else
  889. CGMessage(type_e_mismatch);
  890. end
  891. else if (ld.deftype=pointerdef) or is_zero_based_array(ld) then
  892. begin
  893. if is_zero_based_array(ld) then
  894. begin
  895. resulttype.setdef(tpointerdef.create(tarraydef(ld).elementtype));
  896. inserttypeconv(left,resulttype);
  897. end;
  898. inserttypeconv(right,s32bittype);
  899. if nodetype in [addn,subn] then
  900. begin
  901. if not(cs_extsyntax in aktmoduleswitches) or
  902. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  903. CGMessage(type_e_mismatch);
  904. if (ld.deftype=pointerdef) and
  905. (tpointerdef(ld).pointertype.def.size>1) then
  906. right:=caddnode.create(muln,right,cordconstnode.create(tpointerdef(ld).pointertype.def.size,s32bittype));
  907. end
  908. else
  909. CGMessage(type_e_mismatch);
  910. end
  911. else if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
  912. begin
  913. if not (nodetype in [equaln,unequaln]) then
  914. CGMessage(type_e_mismatch);
  915. end
  916. { enums }
  917. else if (ld.deftype=enumdef) and (rd.deftype=enumdef) then
  918. begin
  919. if not(is_equal(ld,rd)) then
  920. inserttypeconv(right,left.resulttype);
  921. if not(nodetype in [equaln,unequaln,ltn,lten,gtn,gten]) then
  922. CGMessage(type_e_mismatch);
  923. end
  924. { generic conversion }
  925. else
  926. begin
  927. {$ifdef EXTDEBUG}
  928. Comment(V_Warning,'Generic conversion to s32bit');
  929. {$endif}
  930. inserttypeconv(right,s32bittype);
  931. inserttypeconv(left,s32bittype);
  932. end;
  933. { set resulttype if not already done }
  934. if not assigned(resulttype.def) then
  935. begin
  936. case nodetype of
  937. ltn,lten,gtn,gten,equaln,unequaln :
  938. resulttype:=booltype;
  939. slashn :
  940. resulttype:=pbestrealtype^;
  941. addn:
  942. begin
  943. { for strings, return is always a 255 char string }
  944. if is_shortstring(left.resulttype.def) then
  945. resulttype:=cshortstringtype
  946. else
  947. resulttype:=left.resulttype;
  948. end;
  949. else
  950. resulttype:=left.resulttype;
  951. end;
  952. end;
  953. end;
  954. function taddnode.pass_1 : tnode;
  955. var
  956. hp : tnode;
  957. lt,rt : tnodetype;
  958. rd,ld : tdef;
  959. begin
  960. result:=nil;
  961. { first do the two subtrees }
  962. firstpass(left);
  963. firstpass(right);
  964. if codegenerror then
  965. exit;
  966. { load easier access variables }
  967. rd:=right.resulttype.def;
  968. ld:=left.resulttype.def;
  969. rt:=right.nodetype;
  970. lt:=left.nodetype;
  971. { int/int gives real/real! }
  972. if nodetype=slashn then
  973. begin
  974. { maybe we need an integer register to save }
  975. { a reference }
  976. if ((left.location.loc<>LOC_FPU) or
  977. (right.location.loc<>LOC_FPU)) and
  978. (left.registers32=right.registers32) then
  979. calcregisters(self,1,1,0)
  980. else
  981. calcregisters(self,0,1,0);
  982. location.loc:=LOC_FPU;
  983. end
  984. { if both are orddefs then check sub types }
  985. else if (ld.deftype=orddef) and (rd.deftype=orddef) then
  986. begin
  987. { 2 booleans ? }
  988. if is_boolean(ld) and is_boolean(rd) then
  989. begin
  990. if not(cs_full_boolean_eval in aktlocalswitches) and
  991. (nodetype in [andn,orn]) then
  992. begin
  993. calcregisters(self,0,0,0);
  994. location.loc:=LOC_JUMP;
  995. end
  996. else
  997. begin
  998. if (left.location.loc in [LOC_JUMP,LOC_FLAGS]) and
  999. (left.location.loc in [LOC_JUMP,LOC_FLAGS]) then
  1000. calcregisters(self,2,0,0)
  1001. else
  1002. calcregisters(self,1,0,0);
  1003. end;
  1004. end
  1005. else
  1006. { Both are chars? only convert to shortstrings for addn }
  1007. if is_char(ld) then
  1008. begin
  1009. if nodetype=addn then
  1010. internalerror(200103291);
  1011. calcregisters(self,1,0,0);
  1012. end
  1013. { is there a 64 bit type ? }
  1014. else if (torddef(ld).typ in [s64bit,u64bit]) then
  1015. calcregisters(self,2,0,0)
  1016. { is there a cardinal? }
  1017. else if (torddef(ld).typ=u32bit) then
  1018. begin
  1019. calcregisters(self,1,0,0);
  1020. { for unsigned mul we need an extra register }
  1021. if nodetype=muln then
  1022. inc(registers32);
  1023. end
  1024. { generic s32bit conversion }
  1025. else
  1026. calcregisters(self,1,0,0);
  1027. end
  1028. { left side a setdef, must be before string processing,
  1029. else array constructor can be seen as array of char (PFV) }
  1030. else if (ld.deftype=setdef) then
  1031. begin
  1032. if tsetdef(ld).settype=smallset then
  1033. begin
  1034. { are we adding set elements ? }
  1035. if right.nodetype=setelementn then
  1036. calcregisters(self,2,0,0)
  1037. else
  1038. calcregisters(self,1,0,0);
  1039. location.loc:=LOC_REGISTER;
  1040. end
  1041. else
  1042. begin
  1043. calcregisters(self,0,0,0);
  1044. { here we call SET... }
  1045. procinfo^.flags:=procinfo^.flags or pi_do_call;
  1046. location.loc:=LOC_MEM;
  1047. end;
  1048. end
  1049. { compare pchar by addresses like BP/Delphi }
  1050. else if is_pchar(ld) then
  1051. begin
  1052. location.loc:=LOC_REGISTER;
  1053. calcregisters(self,1,0,0);
  1054. end
  1055. { is one of the operands a string }
  1056. else if (ld.deftype=stringdef) then
  1057. begin
  1058. if is_widestring(ld) then
  1059. begin
  1060. { we use reference counted widestrings so no fast exit here }
  1061. procinfo^.no_fast_exit:=true;
  1062. { this is only for add, the comparisaion is handled later }
  1063. location.loc:=LOC_REGISTER;
  1064. end
  1065. else if is_ansistring(ld) then
  1066. begin
  1067. { we use ansistrings so no fast exit here }
  1068. procinfo^.no_fast_exit:=true;
  1069. { this is only for add, the comparisaion is handled later }
  1070. location.loc:=LOC_REGISTER;
  1071. end
  1072. else if is_longstring(ld) then
  1073. begin
  1074. { this is only for add, the comparisaion is handled later }
  1075. location.loc:=LOC_MEM;
  1076. end
  1077. else
  1078. begin
  1079. if canbeaddsstringcharoptnode(self) then
  1080. begin
  1081. hp := genaddsstringcharoptnode(self);
  1082. firstpass(hp);
  1083. pass_1 := hp;
  1084. exit;
  1085. end
  1086. else
  1087. begin
  1088. { Fix right to be shortstring }
  1089. if is_char(right.resulttype.def) then
  1090. begin
  1091. inserttypeconv(right,cshortstringtype);
  1092. firstpass(right);
  1093. end;
  1094. end;
  1095. if canbeaddsstringcsstringoptnode(self) then
  1096. begin
  1097. hp := genaddsstringcsstringoptnode(self);
  1098. firstpass(hp);
  1099. pass_1 := hp;
  1100. exit;
  1101. end;
  1102. { this is only for add, the comparisaion is handled later }
  1103. location.loc:=LOC_MEM;
  1104. end;
  1105. { here we call STRCONCAT or STRCMP or STRCOPY }
  1106. procinfo^.flags:=procinfo^.flags or pi_do_call;
  1107. if location.loc=LOC_MEM then
  1108. calcregisters(self,0,0,0)
  1109. else
  1110. calcregisters(self,1,0,0);
  1111. end
  1112. { is one a real float ? }
  1113. else if (rd.deftype=floatdef) or (ld.deftype=floatdef) then
  1114. begin
  1115. calcregisters(self,0,1,0);
  1116. location.loc:=LOC_FPU;
  1117. end
  1118. { pointer comperation and subtraction }
  1119. else if (ld.deftype=pointerdef) then
  1120. begin
  1121. location.loc:=LOC_REGISTER;
  1122. calcregisters(self,1,0,0);
  1123. end
  1124. else if is_class_or_interface(ld) then
  1125. begin
  1126. location.loc:=LOC_REGISTER;
  1127. calcregisters(self,1,0,0);
  1128. end
  1129. else if (ld.deftype=classrefdef) then
  1130. begin
  1131. location.loc:=LOC_REGISTER;
  1132. calcregisters(self,1,0,0);
  1133. end
  1134. { support procvar=nil,procvar<>nil }
  1135. else if ((ld.deftype=procvardef) and (rt=niln)) or
  1136. ((rd.deftype=procvardef) and (lt=niln)) then
  1137. begin
  1138. calcregisters(self,1,0,0);
  1139. location.loc:=LOC_REGISTER;
  1140. end
  1141. {$ifdef SUPPORT_MMX}
  1142. { mmx support, this must be before the zero based array
  1143. check }
  1144. else if (cs_mmx in aktlocalswitches) and is_mmx_able_array(ld) and
  1145. is_mmx_able_array(rd) then
  1146. begin
  1147. location.loc:=LOC_MMXREGISTER;
  1148. calcregisters(self,0,0,1);
  1149. end
  1150. {$endif SUPPORT_MMX}
  1151. else if (rd.deftype=pointerdef) or (ld.deftype=pointerdef) then
  1152. begin
  1153. location.loc:=LOC_REGISTER;
  1154. calcregisters(self,1,0,0);
  1155. end
  1156. else if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
  1157. begin
  1158. calcregisters(self,1,0,0);
  1159. location.loc:=LOC_REGISTER;
  1160. end
  1161. else if (ld.deftype=enumdef) then
  1162. begin
  1163. calcregisters(self,1,0,0);
  1164. end
  1165. {$ifdef SUPPORT_MMX}
  1166. else if (cs_mmx in aktlocalswitches) and
  1167. is_mmx_able_array(ld) and
  1168. is_mmx_able_array(rd) then
  1169. begin
  1170. location.loc:=LOC_MMXREGISTER;
  1171. calcregisters(self,0,0,1);
  1172. end
  1173. {$endif SUPPORT_MMX}
  1174. { the general solution is to convert to 32 bit int }
  1175. else
  1176. begin
  1177. calcregisters(self,1,0,0);
  1178. location.loc:=LOC_REGISTER;
  1179. end;
  1180. case nodetype of
  1181. ltn,lten,gtn,gten,equaln,unequaln:
  1182. begin
  1183. if is_64bitint(left.resulttype.def) then
  1184. location.loc:=LOC_JUMP
  1185. else
  1186. location.loc:=LOC_FLAGS;
  1187. end;
  1188. xorn:
  1189. begin
  1190. location.loc:=LOC_REGISTER;
  1191. end;
  1192. end;
  1193. end;
  1194. begin
  1195. caddnode:=taddnode;
  1196. end.
  1197. {
  1198. $Log$
  1199. Revision 1.28 2001-05-27 14:30:55 florian
  1200. + some widestring stuff added
  1201. Revision 1.27 2001/05/19 21:11:50 peter
  1202. * first check for overloaded operator before doing inserting any
  1203. typeconvs
  1204. Revision 1.26 2001/05/19 12:53:52 peter
  1205. * check set types when doing constant set evaluation
  1206. Revision 1.25 2001/04/13 01:22:08 peter
  1207. * symtable change to classes
  1208. * range check generation and errors fixed, make cycle DEBUG=1 works
  1209. * memory leaks fixed
  1210. Revision 1.24 2001/04/04 22:42:39 peter
  1211. * move constant folding into det_resulttype
  1212. Revision 1.23 2001/04/02 21:20:30 peter
  1213. * resulttype rewrite
  1214. Revision 1.22 2001/02/04 11:12:17 jonas
  1215. * fixed web bug 1377 & const pointer arithmtic
  1216. Revision 1.21 2001/01/14 22:13:13 peter
  1217. * constant calculation fixed. The type of the new constant is now
  1218. defined after the calculation is done. This should remove a lot
  1219. of wrong warnings (and errors with -Cr).
  1220. Revision 1.20 2000/12/31 11:14:10 jonas
  1221. + implemented/fixed docompare() mathods for all nodes (not tested)
  1222. + nopt.pas, nadd.pas, i386/n386opt.pas: optimized nodes for adding strings
  1223. and constant strings/chars together
  1224. * n386add.pas: don't copy temp strings (of size 256) to another temp string
  1225. when adding
  1226. Revision 1.19 2000/12/16 15:55:32 jonas
  1227. + warning when there is a chance to get a range check error because of
  1228. automatic type conversion to u32bit
  1229. * arithmetic operations with a cardinal and a signed operand are carried
  1230. out in 64bit when range checking is on ("merged" from fixes branch)
  1231. Revision 1.18 2000/11/29 00:30:31 florian
  1232. * unused units removed from uses clause
  1233. * some changes for widestrings
  1234. Revision 1.17 2000/11/20 15:30:42 jonas
  1235. * changed types of values used for constant expression evaluation to
  1236. tconstexprint
  1237. Revision 1.16 2000/11/13 11:30:55 florian
  1238. * some bugs with interfaces and NIL fixed
  1239. Revision 1.15 2000/11/04 14:25:20 florian
  1240. + merged Attila's changes for interfaces, not tested yet
  1241. Revision 1.14 2000/10/31 22:02:47 peter
  1242. * symtable splitted, no real code changes
  1243. Revision 1.13 2000/10/14 10:14:50 peter
  1244. * moehrendorf oct 2000 rewrite
  1245. Revision 1.12 2000/10/01 19:48:23 peter
  1246. * lot of compile updates for cg11
  1247. Revision 1.11 2000/09/30 16:08:45 peter
  1248. * more cg11 updates
  1249. Revision 1.10 2000/09/28 19:49:52 florian
  1250. *** empty log message ***
  1251. Revision 1.9 2000/09/27 21:33:22 florian
  1252. * finally nadd.pas compiles
  1253. Revision 1.8 2000/09/27 20:25:44 florian
  1254. * more stuff fixed
  1255. Revision 1.7 2000/09/27 18:14:31 florian
  1256. * fixed a lot of syntax errors in the n*.pas stuff
  1257. Revision 1.6 2000/09/24 15:06:19 peter
  1258. * use defines.inc
  1259. Revision 1.5 2000/09/22 22:42:52 florian
  1260. * more fixes
  1261. Revision 1.4 2000/09/21 12:22:42 jonas
  1262. * put piece of code between -dnewoptimizations2 since it wasn't
  1263. necessary otherwise
  1264. + support for full boolean evaluation (from tcadd)
  1265. Revision 1.3 2000/09/20 21:50:59 florian
  1266. * updated
  1267. Revision 1.2 2000/08/29 08:24:45 jonas
  1268. * some modifications to -dcardinalmulfix code
  1269. Revision 1.1 2000/08/26 12:24:20 florian
  1270. * initial release
  1271. }