tcadd.pas 52 KB

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