pexpr.pas 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131
  1. {
  2. $Id$
  3. Copyright (c) 1998 by Florian Klaempfl
  4. Does parsing of expression for Free Pascal
  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 pexpr;
  19. interface
  20. uses symtable,tree;
  21. { reads a whole expression }
  22. function expr : ptree;
  23. { reads an expression without assignements and .. }
  24. function comp_expr(accept_equal : boolean):Ptree;
  25. { reads a single factor }
  26. function factor(getaddr : boolean) : ptree;
  27. { the ID token has to be consumed before calling this function }
  28. procedure do_member_read(getaddr : boolean;const sym : psym;var p1 : ptree;
  29. var pd : pdef;var again : boolean);
  30. function get_intconst:longint;
  31. function get_stringconst:string;
  32. implementation
  33. uses
  34. cobjects,globals,scanner,aasm,pass_1,systems,
  35. hcodegen,types,verbose,strings
  36. { parser specific stuff }
  37. ,pbase,pdecl
  38. { processor specific stuff }
  39. {$ifdef i386}
  40. ,i386
  41. {$endif}
  42. {$ifdef m68k}
  43. ,m68k
  44. {$endif}
  45. ;
  46. function parse_paras(_colon,in_prop_paras : boolean) : ptree;
  47. var
  48. p1,p2 : ptree;
  49. end_of_paras : ttoken;
  50. begin
  51. if in_prop_paras then
  52. end_of_paras:=RECKKLAMMER
  53. else
  54. end_of_paras:=RKLAMMER;
  55. if token=end_of_paras then
  56. begin
  57. parse_paras:=nil;
  58. exit;
  59. end;
  60. p2:=nil;
  61. inc(parsing_para_level);
  62. while true do
  63. begin
  64. p1:=comp_expr(true);
  65. p2:=gencallparanode(p1,p2);
  66. { it's for the str(l:5,s); }
  67. if _colon and (token=COLON) then
  68. begin
  69. consume(COLON);
  70. p1:=comp_expr(true);
  71. p2:=gencallparanode(p1,p2);
  72. p2^.is_colon_para:=true;
  73. if token=COLON then
  74. begin
  75. consume(COLON);
  76. p1:=comp_expr(true);
  77. p2:=gencallparanode(p1,p2);
  78. p2^.is_colon_para:=true;
  79. end
  80. end;
  81. if token=COMMA then
  82. consume(COMMA)
  83. else
  84. break;
  85. end;
  86. dec(parsing_para_level);
  87. parse_paras:=p2;
  88. end;
  89. function statement_syssym(l : longint;var pd : pdef) : ptree;
  90. var
  91. p1,p2,paras : ptree;
  92. prev_in_args : boolean;
  93. Store_valid : boolean;
  94. begin
  95. prev_in_args:=in_args;
  96. Store_valid:=Must_be_valid;
  97. case l of
  98. in_ord_x :
  99. begin
  100. consume(LKLAMMER);
  101. in_args:=true;
  102. Must_be_valid:=true;
  103. p1:=comp_expr(true);
  104. consume(RKLAMMER);
  105. do_firstpass(p1);
  106. p1:=geninlinenode(in_ord_x,false,p1);
  107. do_firstpass(p1);
  108. statement_syssym := p1;
  109. pd:=p1^.resulttype;
  110. end;
  111. in_break :
  112. begin
  113. statement_syssym:=genzeronode(breakn);
  114. pd:=voiddef;
  115. end;
  116. in_continue :
  117. begin
  118. statement_syssym:=genzeronode(continuen);
  119. pd:=voiddef;
  120. end;
  121. in_typeof_x :
  122. begin
  123. consume(LKLAMMER);
  124. in_args:=true;
  125. p1:=comp_expr(true);
  126. consume(RKLAMMER);
  127. pd:=voidpointerdef;
  128. if p1^.treetype=typen then
  129. begin
  130. if (p1^.resulttype=nil) then
  131. begin
  132. Message(type_e_mismatch);
  133. statement_syssym:=genzeronode(errorn);
  134. end
  135. else
  136. if p1^.resulttype^.deftype=objectdef then
  137. statement_syssym:=geninlinenode(in_typeof_x,false,p1)
  138. else
  139. begin
  140. Message(type_e_mismatch);
  141. statement_syssym:=genzeronode(errorn);
  142. end;
  143. end
  144. else
  145. begin
  146. Must_be_valid:=false;
  147. do_firstpass(p1);
  148. if (p1^.resulttype=nil) then
  149. begin
  150. Message(type_e_mismatch);
  151. statement_syssym:=genzeronode(errorn)
  152. end
  153. else
  154. if p1^.resulttype^.deftype=objectdef then
  155. statement_syssym:=geninlinenode(in_typeof_x,false,p1)
  156. else
  157. begin
  158. Message(type_e_mismatch);
  159. statement_syssym:=genzeronode(errorn)
  160. end;
  161. end;
  162. end;
  163. in_sizeof_x :
  164. begin
  165. consume(LKLAMMER);
  166. in_args:=true;
  167. p1:=comp_expr(true);
  168. consume(RKLAMMER);
  169. pd:=s32bitdef;
  170. if p1^.treetype=typen then
  171. begin
  172. statement_syssym:=genordinalconstnode(p1^.resulttype^.size,pd);
  173. { p1 not needed !}
  174. disposetree(p1);
  175. end
  176. else
  177. begin
  178. Must_be_valid:=false;
  179. do_firstpass(p1);
  180. if ((p1^.resulttype^.deftype=objectdef) and
  181. ((pobjectdef(p1^.resulttype)^.options and oo_hasvirtual)<>0))
  182. or is_open_array(p1^.resulttype) then
  183. statement_syssym:=geninlinenode(in_sizeof_x,false,p1)
  184. else
  185. begin
  186. statement_syssym:=genordinalconstnode(p1^.resulttype^.size,pd);
  187. { p1 not needed !}
  188. disposetree(p1);
  189. end;
  190. end;
  191. end;
  192. in_assigned_x :
  193. begin
  194. consume(LKLAMMER);
  195. in_args:=true;
  196. p1:=comp_expr(true);
  197. Must_be_valid:=true;
  198. do_firstpass(p1);
  199. case p1^.resulttype^.deftype of
  200. pointerdef,
  201. procvardef,
  202. classrefdef : ;
  203. objectdef : if not(pobjectdef(p1^.resulttype)^.isclass) then
  204. Message(parser_e_illegal_parameter_list);
  205. else
  206. Message(parser_e_illegal_parameter_list);
  207. end;
  208. p2:=gencallparanode(p1,nil);
  209. p2:=geninlinenode(in_assigned_x,false,p2);
  210. consume(RKLAMMER);
  211. pd:=booldef;
  212. statement_syssym:=p2;
  213. end;
  214. in_ofs_x :
  215. begin
  216. consume(LKLAMMER);
  217. in_args:=true;
  218. p1:=comp_expr(true);
  219. p1:=gensinglenode(addrn,p1);
  220. Must_be_valid:=false;
  221. do_firstpass(p1);
  222. { Ofs() returns a longint, not a pointer }
  223. p1^.resulttype:=u32bitdef;
  224. pd:=p1^.resulttype;
  225. consume(RKLAMMER);
  226. statement_syssym:=p1;
  227. end;
  228. in_seg_x :
  229. begin
  230. consume(LKLAMMER);
  231. in_args:=true;
  232. p1:=comp_expr(true);
  233. do_firstpass(p1);
  234. if p1^.location.loc<>LOC_REFERENCE then
  235. Message(cg_e_illegal_expression);
  236. p1:=genordinalconstnode(0,s32bitdef);
  237. Must_be_valid:=false;
  238. pd:=s32bitdef;
  239. consume(RKLAMMER);
  240. statement_syssym:=p1;
  241. end;
  242. in_high_x,
  243. in_low_x :
  244. begin
  245. consume(LKLAMMER);
  246. in_args:=true;
  247. p1:=comp_expr(true);
  248. do_firstpass(p1);
  249. Must_be_valid:=false;
  250. p2:=geninlinenode(l,false,p1);
  251. consume(RKLAMMER);
  252. pd:=s32bitdef;
  253. statement_syssym:=p2;
  254. end;
  255. in_succ_x,
  256. in_pred_x :
  257. begin
  258. consume(LKLAMMER);
  259. in_args:=true;
  260. p1:=comp_expr(true);
  261. do_firstpass(p1);
  262. Must_be_valid:=false;
  263. p2:=geninlinenode(l,false,p1);
  264. consume(RKLAMMER);
  265. pd:=p1^.resulttype;
  266. statement_syssym:=p2;
  267. end;
  268. in_inc_x,
  269. in_dec_x :
  270. begin
  271. consume(LKLAMMER);
  272. in_args:=true;
  273. p1:=comp_expr(true);
  274. Must_be_valid:=false;
  275. if token=COMMA then
  276. begin
  277. consume(COMMA);
  278. p2:=gencallparanode(comp_expr(true),nil);
  279. end
  280. else
  281. p2:=nil;
  282. p2:=gencallparanode(p1,p2);
  283. statement_syssym:=geninlinenode(l,false,p2);
  284. consume(RKLAMMER);
  285. pd:=voiddef;
  286. end;
  287. in_concat_x :
  288. begin
  289. consume(LKLAMMER);
  290. in_args:=true;
  291. p2:=nil;
  292. while true do
  293. begin
  294. p1:=comp_expr(true);
  295. Must_be_valid:=true;
  296. do_firstpass(p1);
  297. if not((p1^.resulttype^.deftype=stringdef) or
  298. ((p1^.resulttype^.deftype=orddef) and
  299. (porddef(p1^.resulttype)^.typ=uchar))) then
  300. Message(parser_e_illegal_parameter_list);
  301. if p2<>nil then
  302. p2:=gennode(addn,p2,p1)
  303. else
  304. p2:=p1;
  305. if token=COMMA then
  306. consume(COMMA)
  307. else
  308. break;
  309. end;
  310. consume(RKLAMMER);
  311. pd:=cstringdef;
  312. statement_syssym:=p2;
  313. end;
  314. in_read_x,
  315. in_readln_x :
  316. begin
  317. if token=LKLAMMER then
  318. begin
  319. consume(LKLAMMER);
  320. in_args:=true;
  321. Must_be_valid:=false;
  322. paras:=parse_paras(false,false);
  323. consume(RKLAMMER);
  324. end
  325. else
  326. paras:=nil;
  327. pd:=voiddef;
  328. p1:=geninlinenode(l,false,paras);
  329. do_firstpass(p1);
  330. statement_syssym := p1;
  331. end;
  332. in_write_x,
  333. in_writeln_x :
  334. begin
  335. if token=LKLAMMER then
  336. begin
  337. consume(LKLAMMER);
  338. in_args:=true;
  339. Must_be_valid:=true;
  340. paras:=parse_paras(true,false);
  341. consume(RKLAMMER);
  342. end
  343. else
  344. paras:=nil;
  345. pd:=voiddef;
  346. p1 := geninlinenode(l,false,paras);
  347. do_firstpass(p1);
  348. statement_syssym := p1;
  349. end;
  350. in_str_x_string :
  351. begin
  352. consume(LKLAMMER);
  353. in_args:=true;
  354. paras:=parse_paras(true,false);
  355. consume(RKLAMMER);
  356. p1 := geninlinenode(l,false,paras);
  357. do_firstpass(p1);
  358. statement_syssym := p1;
  359. pd:=voiddef;
  360. end;
  361. in_include_x_y,
  362. in_exclude_x_y :
  363. begin
  364. consume(LKLAMMER);
  365. in_args:=true;
  366. p1:=comp_expr(true);
  367. Must_be_valid:=false;
  368. consume(COMMA);
  369. p2:=comp_expr(true);
  370. statement_syssym:=geninlinenode(l,false,gencallparanode(p1,gencallparanode(p2,nil)));
  371. consume(RKLAMMER);
  372. pd:=voiddef;
  373. end;
  374. in_assert_x_y :
  375. begin
  376. consume(LKLAMMER);
  377. in_args:=true;
  378. p1:=comp_expr(true);
  379. if token=COMMA then
  380. begin
  381. consume(COMMA);
  382. p2:=comp_expr(true);
  383. end
  384. else
  385. begin
  386. { then insert an empty string }
  387. p2:=genstringconstnode('');
  388. end;
  389. statement_syssym:=geninlinenode(l,false,gencallparanode(p1,gencallparanode(p2,nil)));
  390. consume(RKLAMMER);
  391. pd:=voiddef;
  392. end;
  393. else
  394. internalerror(15);
  395. end;
  396. in_args:=prev_in_args;
  397. Must_be_valid:=Store_valid;
  398. end;
  399. { reads the parameter for a subroutine call }
  400. procedure do_proc_call(getaddr : boolean;var again : boolean;var p1:Ptree;var pd:Pdef);
  401. var
  402. prev_in_args : boolean;
  403. prevafterassn : boolean;
  404. begin
  405. prev_in_args:=in_args;
  406. prevafterassn:=afterassignment;
  407. afterassignment:=false;
  408. { want we only determine the address of }
  409. { a subroutine ? }
  410. if not(getaddr) then
  411. begin
  412. if token=LKLAMMER then
  413. begin
  414. consume(LKLAMMER);
  415. in_args:=true;
  416. p1^.left:=parse_paras(false,false);
  417. consume(RKLAMMER);
  418. end
  419. else p1^.left:=nil;
  420. { do firstpass because we need the }
  421. { result type }
  422. do_firstpass(p1);
  423. end
  424. else
  425. begin
  426. { address operator @: }
  427. p1^.left:=nil;
  428. { forget pd }
  429. pd:=nil;
  430. { no postfix operators }
  431. again:=false;
  432. end;
  433. pd:=p1^.resulttype;
  434. in_args:=prev_in_args;
  435. afterassignment:=prevafterassn;
  436. end;
  437. { the following procedure handles the access to a property symbol }
  438. procedure handle_propertysym(sym : psym;st : psymtable;var p1 : ptree;
  439. var pd : pdef);
  440. var
  441. paras : ptree;
  442. p2 : ptree;
  443. begin
  444. paras:=nil;
  445. { property parameters? }
  446. if token=LECKKLAMMER then
  447. begin
  448. consume(LECKKLAMMER);
  449. paras:=parse_paras(false,true);
  450. consume(RECKKLAMMER);
  451. end;
  452. { indexed property }
  453. if (ppropertysym(sym)^.options and ppo_indexed)<>0 then
  454. begin
  455. p2:=genordinalconstnode(ppropertysym(sym)^.index,s32bitdef);
  456. paras:=gencallparanode(p2,paras);
  457. end;
  458. if not(afterassignment) and not(in_args) then
  459. begin
  460. { write property: }
  461. { no result }
  462. pd:=voiddef;
  463. if assigned(ppropertysym(sym)^.writeaccesssym) then
  464. begin
  465. if ppropertysym(sym)^.writeaccesssym^.typ=procsym then
  466. begin
  467. { generate the method call }
  468. p1:=genmethodcallnode(pprocsym(
  469. ppropertysym(sym)^.writeaccesssym),st,p1);
  470. { we know the procedure to call, so
  471. force the usage of that procedure }
  472. p1^.procdefinition:=pprocdef(ppropertysym(sym)^.writeaccessdef);
  473. p1^.left:=paras;
  474. consume(ASSIGNMENT);
  475. { read the expression }
  476. p2:=comp_expr(true);
  477. p1^.left:=gencallparanode(p2,p1^.left);
  478. end
  479. else if ppropertysym(sym)^.writeaccesssym^.typ=varsym then
  480. begin
  481. if assigned(paras) then
  482. message(parser_e_no_paras_allowed);
  483. { subscribed access? }
  484. if p1=nil then
  485. begin
  486. p1:=genloadnode(pvarsym(ppropertysym(sym)^.readaccesssym),st);
  487. end
  488. else
  489. p1:=gensubscriptnode(pvarsym(
  490. ppropertysym(sym)^.readaccesssym),p1);
  491. consume(ASSIGNMENT);
  492. { read the expression }
  493. p2:=comp_expr(true);
  494. p1:=gennode(assignn,p1,p2);
  495. end
  496. else
  497. begin
  498. p1:=genzeronode(errorn);
  499. Message(parser_e_no_procedure_to_access_property);
  500. end;
  501. end
  502. else
  503. begin
  504. p1:=genzeronode(errorn);
  505. Message(parser_e_no_procedure_to_access_property);
  506. end;
  507. end
  508. else
  509. begin
  510. { read property: }
  511. pd:=ppropertysym(sym)^.proptype;
  512. if assigned(ppropertysym(sym)^.readaccesssym) then
  513. begin
  514. if ppropertysym(sym)^.readaccesssym^.typ=varsym then
  515. begin
  516. if assigned(paras) then
  517. message(parser_e_no_paras_allowed);
  518. { subscribed access? }
  519. if p1=nil then
  520. begin
  521. p1:=genloadnode(pvarsym(
  522. ppropertysym(sym)^.readaccesssym),st);
  523. end
  524. else
  525. p1:=gensubscriptnode(pvarsym(
  526. ppropertysym(sym)^.readaccesssym),p1);
  527. end
  528. else if ppropertysym(sym)^.readaccesssym^.typ=procsym then
  529. begin
  530. { generate the method call }
  531. p1:=genmethodcallnode(pprocsym(
  532. ppropertysym(sym)^.readaccesssym),st,p1);
  533. { we know the procedure to call, so
  534. force the usage of that procedure }
  535. p1^.procdefinition:=pprocdef(ppropertysym(sym)^.readaccessdef);
  536. { insert paras }
  537. p1^.left:=paras;
  538. { if we should be delphi compatible }
  539. { then force type conversion }
  540. { }
  541. { isn't neccessary, the result types }
  542. { have to match excatly }
  543. {if cs_delphi2_compatible in aktswitches then
  544. p1:=gentypeconvnode(p1,pd);
  545. }
  546. end
  547. else
  548. begin
  549. p1:=genzeronode(errorn);
  550. Message(type_e_mismatch);
  551. end;
  552. end
  553. else
  554. begin
  555. { error, no function to read property }
  556. p1:=genzeronode(errorn);
  557. Message(parser_e_no_procedure_to_access_property);
  558. end;
  559. end;
  560. end;
  561. { the ID token has to be consumed before calling this function }
  562. procedure do_member_read(getaddr : boolean;const sym : psym;var p1 : ptree;
  563. var pd : pdef;var again : boolean);
  564. var
  565. static_name : string;
  566. isclassref : boolean;
  567. begin
  568. if sym=nil then
  569. begin
  570. { pattern is still valid unless
  571. there is another ID just after the ID of sym }
  572. Message1(sym_e_id_no_member,pattern);
  573. disposetree(p1);
  574. p1:=genzeronode(errorn);
  575. { try to clean up }
  576. pd:=generrordef;
  577. again:=false;
  578. end
  579. else
  580. begin
  581. isclassref:=pd^.deftype=classrefdef;
  582. { check protected and private members }
  583. if ((sym^.properties and sp_private)<>0) and
  584. (pobjectdef(sym^.owner^.defowner)^.owner^.symtabletype=unitsymtable) then
  585. Message(parser_e_cant_access_private_member);
  586. { this is wrong protected should not be overwritten but
  587. can be called !! PM
  588. if ((sym^.properties and sp_protected)<>0) and
  589. (pobjectdef(pd)^.owner^.symtabletype=unitsymtable) then
  590. Message(parser_e_cant_access_protected_member); }
  591. { we assume, that only procsyms and varsyms are in an object }
  592. { symbol table, for classes, properties are allowed }
  593. case sym^.typ of
  594. procsym:
  595. begin
  596. p1:=genmethodcallnode(pprocsym(sym),srsymtable,p1);
  597. do_proc_call(getaddr or
  598. (getprocvar and
  599. proc_to_procvar_equal(getprocvardef,pprocsym(sym)^.definition))
  600. ,again,p1,pd);
  601. { now we know the real method e.g. we can check for }
  602. { a class method }
  603. if isclassref and ((p1^.procdefinition^.options and (poclassmethod or poconstructor))=0) then
  604. Message(parser_e_only_class_methods_via_class_ref);
  605. end;
  606. varsym:
  607. begin
  608. if ((sym^.properties and sp_protected)<>0) and
  609. (pobjectdef(pd)^.owner^.symtabletype=unitsymtable) and
  610. not(afterassignment) and
  611. not(in_args) then
  612. Message(parser_e_cant_access_protected_member);
  613. if isclassref then
  614. Message(parser_e_only_class_methods_via_class_ref);
  615. if (sym^.properties and sp_static)<>0 then
  616. begin
  617. static_name:=lower(srsymtable^.name^)+'_'+sym^.name;
  618. getsym(static_name,true);
  619. disposetree(p1);
  620. p1:=genloadnode(pvarsym(srsym),srsymtable);
  621. end
  622. else
  623. p1:=gensubscriptnode(pvarsym(sym),p1);
  624. pd:=pvarsym(sym)^.definition;
  625. end;
  626. propertysym:
  627. begin
  628. if isclassref then
  629. Message(parser_e_only_class_methods_via_class_ref);
  630. handle_propertysym(sym,srsymtable,p1,pd);
  631. end;
  632. else internalerror(16);
  633. end;
  634. end;
  635. end;
  636. {****************************************************************************
  637. Factor
  638. ****************************************************************************}
  639. function factor(getaddr : boolean) : ptree;
  640. var
  641. l : longint;
  642. oldp1,
  643. p1,p2,p3 : ptree;
  644. code : integer;
  645. pd,pd2 : pdef;
  646. possible_error,
  647. unit_specific,
  648. again : boolean;
  649. sym : pvarsym;
  650. classh : pobjectdef;
  651. d : bestreal;
  652. static_name : string;
  653. propsym : ppropertysym;
  654. filepos : tfileposinfo;
  655. {---------------------------------------------
  656. Is_func_ret
  657. ---------------------------------------------}
  658. function is_func_ret(sym : psym) : boolean;
  659. var
  660. p : pprocinfo;
  661. storesymtablestack : psymtable;
  662. begin
  663. is_func_ret:=false;
  664. if (sym^.typ<>funcretsym) and ((procinfo.flags and pi_operator)=0) then
  665. exit;
  666. p:=@procinfo;
  667. while system.assigned(p) do
  668. begin
  669. { is this an access to a function result ? }
  670. if assigned(p^.funcretsym) and
  671. ((pfuncretsym(sym)=p^.funcretsym) or
  672. ((pvarsym(sym)=opsym) and
  673. ((p^.flags and pi_operator)<>0))) and
  674. (p^.retdef<>pdef(voiddef)) and
  675. (token<>LKLAMMER) and
  676. (not ((m_tp in aktmodeswitches) and
  677. (afterassignment or in_args))) then
  678. begin
  679. p1:=genzeronode(funcretn);
  680. pd:=p^.retdef;
  681. p1^.funcretprocinfo:=p;
  682. p1^.retdef:=pd;
  683. is_func_ret:=true;
  684. exit;
  685. end;
  686. p:=p^.parent;
  687. end;
  688. { we must use the function call }
  689. if(sym^.typ=funcretsym) then
  690. begin
  691. storesymtablestack:=symtablestack;
  692. symtablestack:=srsymtable^.next;
  693. getsym(sym^.name,true);
  694. if srsym^.typ<>procsym then
  695. Message(cg_e_illegal_expression);
  696. symtablestack:=storesymtablestack;
  697. end;
  698. end;
  699. {---------------------------------------------
  700. Factor_read_id
  701. ---------------------------------------------}
  702. procedure factor_read_id;
  703. begin
  704. { allow post fix operators }
  705. again:=true;
  706. if (m_result in aktmodeswitches) and
  707. (pattern='RESULT') and
  708. assigned(aktprocsym) and
  709. (procinfo.retdef<>pdef(voiddef)) then
  710. begin
  711. consume(ID);
  712. p1:=genzeronode(funcretn);
  713. pd:=procinfo.retdef;
  714. p1^.funcretprocinfo:=pointer(@procinfo);
  715. p1^.retdef:=pd;
  716. end
  717. else
  718. begin
  719. if lastsymknown then
  720. begin
  721. srsym:=lastsrsym;
  722. srsymtable:=lastsrsymtable;
  723. lastsymknown:=false;
  724. end
  725. else
  726. getsym(pattern,true);
  727. consume(ID);
  728. if not is_func_ret(srsym) then
  729. { else it's a normal symbol }
  730. begin
  731. { is it defined like UNIT.SYMBOL ? }
  732. if srsym^.typ=unitsym then
  733. begin
  734. consume(POINT);
  735. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  736. unit_specific:=true;
  737. consume(ID);
  738. end
  739. else
  740. unit_specific:=false;
  741. if not assigned(srsym) then
  742. Begin
  743. p1:=genzeronode(errorn);
  744. { try to clean up }
  745. pd:=generrordef;
  746. end
  747. else
  748. Begin
  749. { check semantics of private }
  750. if (srsym^.typ in [propertysym,procsym,varsym]) and
  751. (srsymtable^.symtabletype=objectsymtable) then
  752. begin
  753. if ((srsym^.properties and sp_private)<>0) and
  754. (pobjectdef(srsym^.owner^.defowner)^.owner^.symtabletype=unitsymtable) then
  755. Message(parser_e_cant_access_private_member);
  756. end;
  757. case srsym^.typ of
  758. absolutesym : begin
  759. p1:=genloadnode(pvarsym(srsym),srsymtable);
  760. pd:=pabsolutesym(srsym)^.definition;
  761. end;
  762. varsym : begin
  763. { are we in a class method ? }
  764. if (srsymtable^.symtabletype=objectsymtable) and
  765. assigned(aktprocsym) and
  766. ((aktprocsym^.definition^.options and poclassmethod)<>0) then
  767. Message(parser_e_only_class_methods);
  768. if (srsym^.properties and sp_static)<>0 then
  769. begin
  770. static_name:=lower(srsymtable^.name^)+'_'+srsym^.name;
  771. getsym(static_name,true);
  772. end;
  773. p1:=genloadnode(pvarsym(srsym),srsymtable);
  774. if pvarsym(srsym)^.is_valid=0 then
  775. begin
  776. p1^.is_first := true;
  777. { set special between first loaded until checked in firstpass }
  778. pvarsym(srsym)^.is_valid:=2;
  779. end;
  780. pd:=pvarsym(srsym)^.definition;
  781. end;
  782. typedconstsym : begin
  783. p1:=gentypedconstloadnode(ptypedconstsym(srsym),srsymtable);
  784. pd:=ptypedconstsym(srsym)^.definition;
  785. end;
  786. syssym : p1:=statement_syssym(psyssym(srsym)^.number,pd);
  787. typesym : begin
  788. pd:=ptypesym(srsym)^.definition;
  789. if not assigned(pd) then
  790. begin
  791. pd:=generrordef;
  792. again:=false;
  793. end
  794. else
  795. { if we read a type declaration }
  796. { we have to return the type and }
  797. { nothing else }
  798. if block_type=bt_type then
  799. begin
  800. p1:=genzeronode(typen);
  801. p1^.resulttype:=pd;
  802. pd:=voiddef;
  803. end
  804. else
  805. begin
  806. if token=LKLAMMER then
  807. begin
  808. consume(LKLAMMER);
  809. p1:=comp_expr(true);
  810. consume(RKLAMMER);
  811. p1:=gentypeconvnode(p1,pd);
  812. p1^.explizit:=true;
  813. end
  814. else
  815. if (token=POINT) and
  816. (pd^.deftype=objectdef) and
  817. ((pobjectdef(pd)^.options and oois_class)=0) then
  818. begin
  819. consume(POINT);
  820. if assigned(procinfo._class) then
  821. begin
  822. if procinfo._class^.isrelated(pobjectdef(pd)) then
  823. begin
  824. p1:=genzeronode(typen);
  825. p1^.resulttype:=pd;
  826. srsymtable:=pobjectdef(pd)^.publicsyms;
  827. sym:=pvarsym(srsymtable^.search(pattern));
  828. { search also in inherited methods }
  829. while sym=nil do
  830. begin
  831. pd:=pobjectdef(pd)^.childof;
  832. srsymtable:=pobjectdef(pd)^.publicsyms;
  833. sym:=pvarsym(srsymtable^.search(pattern));
  834. end;
  835. consume(ID);
  836. do_member_read(false,sym,p1,pd,again);
  837. end
  838. else
  839. begin
  840. Message(parser_e_no_super_class);
  841. pd:=generrordef;
  842. again:=false;
  843. end;
  844. end
  845. else
  846. begin
  847. { allows @TObject.Load }
  848. { also allows static methods and variables }
  849. p1:=genzeronode(typen);
  850. p1^.resulttype:=pd;
  851. { srsymtable:=pobjectdef(pd)^.publicsyms;
  852. sym:=pvarsym(srsymtable^.search(pattern)); }
  853. { TP allows also @TMenu.Load if Load is only }
  854. { defined in an anchestor class }
  855. sym:=pvarsym(search_class_member(pobjectdef(pd),pattern));
  856. if not(getaddr) and ((sym^.properties and sp_static)=0) then
  857. Message(sym_e_only_static_in_static)
  858. else
  859. begin
  860. consume(ID);
  861. do_member_read(getaddr,sym,p1,pd,again);
  862. end;
  863. end;
  864. end
  865. else
  866. begin
  867. { class reference ? }
  868. if (pd^.deftype=objectdef)
  869. and ((pobjectdef(pd)^.options and oois_class)<>0) then
  870. begin
  871. p1:=genzeronode(typen);
  872. p1^.resulttype:=pd;
  873. pd:=new(pclassrefdef,init(pd));
  874. p1:=gensinglenode(loadvmtn,p1);
  875. p1^.resulttype:=pd;
  876. end
  877. else
  878. begin
  879. { generate a type node }
  880. { (for typeof etc) }
  881. p1:=genzeronode(typen);
  882. p1^.resulttype:=pd;
  883. pd:=voiddef;
  884. end;
  885. end;
  886. end;
  887. end;
  888. enumsym : begin
  889. p1:=genenumnode(penumsym(srsym));
  890. pd:=p1^.resulttype;
  891. end;
  892. constsym : begin
  893. case pconstsym(srsym)^.consttype of
  894. constint : p1:=genordinalconstnode(pconstsym(srsym)^.value,s32bitdef);
  895. conststring : p1:=genstringconstnode(pstring(pconstsym(srsym)^.value)^);
  896. constchar : p1:=genordinalconstnode(pconstsym(srsym)^.value,cchardef);
  897. constreal : p1:=genrealconstnode(pbestreal(pconstsym(srsym)^.value)^);
  898. constbool : p1:=genordinalconstnode(pconstsym(srsym)^.value,booldef);
  899. constset : p1:=gensetconstnode(pconstset(pconstsym(srsym)^.value),
  900. psetdef(pconstsym(srsym)^.definition));
  901. constord : p1:=genordinalconstnode(pconstsym(srsym)^.value,
  902. pconstsym(srsym)^.definition);
  903. end;
  904. pd:=p1^.resulttype;
  905. end;
  906. procsym : begin
  907. { are we in a class method ? }
  908. possible_error:=(srsymtable^.symtabletype=objectsymtable) and
  909. assigned(aktprocsym) and
  910. ((aktprocsym^.definition^.options and poclassmethod)<>0);
  911. p1:=gencallnode(pprocsym(srsym),srsymtable);
  912. p1^.unit_specific:=unit_specific;
  913. do_proc_call(getaddr or
  914. (getprocvar and
  915. proc_to_procvar_equal(getprocvardef,pprocsym(srsym)^.definition)),
  916. again,p1,pd);
  917. if possible_error and
  918. ((p1^.procdefinition^.options and poclassmethod)=0) then
  919. Message(parser_e_only_class_methods);
  920. end;
  921. propertysym : begin
  922. { access to property in a method }
  923. { are we in a class method ? }
  924. if (srsymtable^.symtabletype=objectsymtable) and
  925. assigned(aktprocsym) and
  926. ((aktprocsym^.definition^.options and poclassmethod)<>0) then
  927. Message(parser_e_only_class_methods);
  928. { no method pointer }
  929. p1:=nil;
  930. handle_propertysym(srsym,srsymtable,p1,pd);
  931. end;
  932. errorsym : begin
  933. p1:=genzeronode(errorn);
  934. pd:=generrordef;
  935. if token=LKLAMMER then
  936. begin
  937. consume(LKLAMMER);
  938. parse_paras(false,false);
  939. consume(RKLAMMER);
  940. end;
  941. end;
  942. else
  943. begin
  944. p1:=genzeronode(errorn);
  945. pd:=generrordef;
  946. Message(cg_e_illegal_expression);
  947. end;
  948. end; { end case }
  949. end;
  950. end;
  951. end;
  952. end;
  953. {---------------------------------------------
  954. Factor_Read_Set
  955. ---------------------------------------------}
  956. { Read a set between [] }
  957. function factor_read_set:ptree;
  958. var
  959. p1,
  960. lastp,
  961. buildp : ptree;
  962. begin
  963. buildp:=nil;
  964. { be sure that a least one arrayconstructn is used, also for an
  965. empty [] }
  966. if token=RECKKLAMMER then
  967. buildp:=gennode(arrayconstructn,nil,buildp)
  968. else
  969. begin
  970. while true do
  971. begin
  972. p1:=comp_expr(true);
  973. if token=POINTPOINT then
  974. begin
  975. consume(POINTPOINT);
  976. p2:=comp_expr(true);
  977. p1:=gennode(arrayconstructrangen,p1,p2);
  978. end;
  979. { insert at the end of the tree, to get the correct order }
  980. if not assigned(buildp) then
  981. begin
  982. buildp:=gennode(arrayconstructn,p1,nil);
  983. lastp:=buildp;
  984. end
  985. else
  986. begin
  987. lastp^.right:=gennode(arrayconstructn,p1,nil);
  988. lastp:=lastp^.right;
  989. end;
  990. { there could be more elements }
  991. if token=COMMA then
  992. consume(COMMA)
  993. else
  994. break;
  995. end;
  996. end;
  997. factor_read_set:=buildp;
  998. end;
  999. {---------------------------------------------
  1000. Helpers
  1001. ---------------------------------------------}
  1002. procedure check_tokenpos;
  1003. begin
  1004. if (p1<>oldp1) then
  1005. begin
  1006. if assigned(p1) then
  1007. set_tree_filepos(p1,filepos);
  1008. oldp1:=p1;
  1009. filepos:=tokenpos;
  1010. end;
  1011. end;
  1012. {---------------------------------------------
  1013. PostFixOperators
  1014. ---------------------------------------------}
  1015. procedure postfixoperators;
  1016. { p1 and p2 must contain valid value_str }
  1017. begin
  1018. check_tokenpos;
  1019. while again do
  1020. begin
  1021. { prevent crashes with unknown types }
  1022. if not assigned(pd) then
  1023. begin
  1024. { try to recover }
  1025. repeat
  1026. case token of
  1027. CARET:
  1028. consume(CARET);
  1029. POINT:
  1030. begin
  1031. consume(POINT);
  1032. consume(ID);
  1033. end;
  1034. LECKKLAMMER:
  1035. begin
  1036. repeat
  1037. consume(token);
  1038. until token in [RECKKLAMMER,SEMICOLON];
  1039. end;
  1040. else
  1041. break;
  1042. end;
  1043. until false;
  1044. exit;
  1045. end;
  1046. { handle token }
  1047. case token of
  1048. CARET:
  1049. begin
  1050. consume(CARET);
  1051. if pd^.deftype<>pointerdef then
  1052. begin
  1053. { ^ as binary operator is a problem!!!! (FK) }
  1054. again:=false;
  1055. Message(cg_e_invalid_qualifier);
  1056. disposetree(p1);
  1057. p1:=genzeronode(errorn);
  1058. end
  1059. else
  1060. begin
  1061. p1:=gensinglenode(derefn,p1);
  1062. pd:=ppointerdef(pd)^.definition;
  1063. end;
  1064. end;
  1065. LECKKLAMMER:
  1066. begin
  1067. if (pd^.deftype=objectdef) and pobjectdef(pd)^.isclass then
  1068. begin
  1069. { default property }
  1070. propsym:=search_default_property(pobjectdef(pd));
  1071. if not(assigned(propsym)) then
  1072. begin
  1073. disposetree(p1);
  1074. p1:=genzeronode(errorn);
  1075. again:=false;
  1076. message(parser_e_no_default_property_available);
  1077. end
  1078. else
  1079. begin
  1080. p1:=nil;
  1081. handle_propertysym(propsym,propsym^.owner,p1,pd);
  1082. end;
  1083. end
  1084. else
  1085. begin
  1086. consume(LECKKLAMMER);
  1087. repeat
  1088. case pd^.deftype of
  1089. pointerdef:
  1090. begin
  1091. p2:=comp_expr(true);
  1092. p1:=gennode(vecn,p1,p2);
  1093. pd:=ppointerdef(pd)^.definition;
  1094. end;
  1095. stringdef : begin
  1096. p2:=comp_expr(true);
  1097. p1:=gennode(vecn,p1,p2);
  1098. pd:=cchardef
  1099. end;
  1100. arraydef : begin
  1101. p2:=comp_expr(true);
  1102. { support SEG:OFS for go32v2 Mem[] }
  1103. if (target_info.target=target_i386_go32v2) and
  1104. (p1^.treetype=loadn) and
  1105. assigned(p1^.symtableentry) and
  1106. assigned(p1^.symtableentry^.owner^.name) and
  1107. (p1^.symtableentry^.owner^.name^='SYSTEM') and
  1108. ((p1^.symtableentry^.name='MEM') or
  1109. (p1^.symtableentry^.name='MEMW') or
  1110. (p1^.symtableentry^.name='MEML')) then
  1111. begin
  1112. if (token=COLON) then
  1113. begin
  1114. consume(COLON);
  1115. p3:=gennode(muln,genordinalconstnode($10,s32bitdef),p2);
  1116. p2:=comp_expr(true);
  1117. p2:=gennode(addn,p2,p3);
  1118. p1:=gennode(vecn,p1,p2);
  1119. p1^.memseg:=true;
  1120. p1^.memindex:=true;
  1121. end
  1122. else
  1123. begin
  1124. p1:=gennode(vecn,p1,p2);
  1125. p1^.memindex:=true;
  1126. end;
  1127. end
  1128. else
  1129. p1:=gennode(vecn,p1,p2);
  1130. pd:=parraydef(pd)^.definition;
  1131. end;
  1132. else
  1133. begin
  1134. Message(cg_e_invalid_qualifier);
  1135. disposetree(p1);
  1136. p1:=genzeronode(errorn);
  1137. again:=false;
  1138. end;
  1139. end;
  1140. if token=COMMA then
  1141. consume(COMMA)
  1142. else
  1143. break;
  1144. until false;
  1145. consume(RECKKLAMMER);
  1146. end;
  1147. end;
  1148. POINT : begin
  1149. consume(POINT);
  1150. if (pd^.deftype=pointerdef) and
  1151. (m_autoderef in aktmodeswitches) then
  1152. begin
  1153. p1:=gensinglenode(derefn,p1);
  1154. pd:=ppointerdef(pd)^.definition;
  1155. end;
  1156. case pd^.deftype of
  1157. recorddef:
  1158. begin
  1159. sym:=pvarsym(precdef(pd)^.symtable^.search(pattern));
  1160. if sym=nil then
  1161. begin
  1162. Message1(sym_e_illegal_field,pattern);
  1163. disposetree(p1);
  1164. p1:=genzeronode(errorn);
  1165. end
  1166. else
  1167. begin
  1168. p1:=gensubscriptnode(sym,p1);
  1169. pd:=sym^.definition;
  1170. end;
  1171. consume(ID);
  1172. end;
  1173. classrefdef:
  1174. begin
  1175. classh:=pobjectdef(pclassrefdef(pd)^.definition);
  1176. sym:=nil;
  1177. while assigned(classh) do
  1178. begin
  1179. sym:=pvarsym(classh^.publicsyms^.search(pattern));
  1180. srsymtable:=classh^.publicsyms;
  1181. if assigned(sym) then
  1182. break;
  1183. classh:=classh^.childof;
  1184. end;
  1185. consume(ID);
  1186. do_member_read(false,sym,p1,pd,again);
  1187. end;
  1188. objectdef:
  1189. begin
  1190. classh:=pobjectdef(pd);
  1191. sym:=nil;
  1192. while assigned(classh) do
  1193. begin
  1194. sym:=pvarsym(classh^.publicsyms^.search(pattern));
  1195. srsymtable:=classh^.publicsyms;
  1196. if assigned(sym) then
  1197. break;
  1198. classh:=classh^.childof;
  1199. end;
  1200. consume(ID);
  1201. do_member_read(false,sym,p1,pd,again);
  1202. end;
  1203. pointerdef:
  1204. begin
  1205. Message(cg_e_invalid_qualifier);
  1206. if ppointerdef(pd)^.definition^.deftype in [recorddef,objectdef,classrefdef] then
  1207. Message(parser_h_maybe_deref_caret_missing);
  1208. end;
  1209. else
  1210. begin
  1211. Message(cg_e_invalid_qualifier);
  1212. disposetree(p1);
  1213. p1:=genzeronode(errorn);
  1214. end;
  1215. end;
  1216. end;
  1217. else
  1218. begin
  1219. { is this a procedure variable ? }
  1220. if assigned(pd) then
  1221. begin
  1222. if (pd^.deftype=procvardef) then
  1223. begin
  1224. if getprocvar and proc_to_procvar_equal(pprocvardef(pd),getprocvardef) then
  1225. again:=false
  1226. else
  1227. if (token=LKLAMMER) or
  1228. ((pprocvardef(pd)^.para1=nil) and
  1229. (not((token in [ASSIGNMENT,UNEQUAL,EQUAL]))) and
  1230. (not afterassignment) and
  1231. (not in_args)) then
  1232. begin
  1233. { do this in a strange way }
  1234. { it's not a clean solution }
  1235. p2:=p1;
  1236. p1:=gencallnode(nil,nil);
  1237. p1^.right:=p2;
  1238. p1^.unit_specific:=unit_specific;
  1239. p1^.symtableprocentry:=sym;
  1240. if token=LKLAMMER then
  1241. begin
  1242. consume(LKLAMMER);
  1243. p1^.left:=parse_paras(false,false);
  1244. consume(RKLAMMER);
  1245. end;
  1246. pd:=pprocvardef(pd)^.retdef;
  1247. { proc():= is never possible }
  1248. if token=ASSIGNMENT then
  1249. begin
  1250. Message(cg_e_illegal_expression);
  1251. p1:=genzeronode(errorn);
  1252. again:=false;
  1253. end;
  1254. p1^.resulttype:=pd;
  1255. end
  1256. else
  1257. again:=false;
  1258. p1^.resulttype:=pd;
  1259. end
  1260. else
  1261. again:=false;
  1262. end
  1263. else
  1264. again:=false;
  1265. end;
  1266. end;
  1267. check_tokenpos;
  1268. end; { while again }
  1269. end;
  1270. {---------------------------------------------
  1271. Factor (Main)
  1272. ---------------------------------------------}
  1273. begin
  1274. oldp1:=nil;
  1275. p1:=nil;
  1276. filepos:=tokenpos;
  1277. if token=ID then
  1278. begin
  1279. factor_read_id;
  1280. { handle post fix operators }
  1281. postfixoperators;
  1282. end
  1283. else
  1284. case token of
  1285. _NEW : begin
  1286. consume(_NEW);
  1287. consume(LKLAMMER);
  1288. p1:=factor(false);
  1289. if p1^.treetype<>typen then
  1290. begin
  1291. Message(type_e_type_id_expected);
  1292. pd:=generrordef;
  1293. end
  1294. else
  1295. pd:=p1^.resulttype;
  1296. pd2:=pd;
  1297. if (pd^.deftype<>pointerdef) or
  1298. (ppointerdef(pd)^.definition^.deftype<>objectdef) then
  1299. begin
  1300. Message(parser_e_pointer_to_class_expected);
  1301. { if an error occurs, read til the end of
  1302. the new statement }
  1303. p1:=genzeronode(errorn);
  1304. l:=1;
  1305. while true do
  1306. begin
  1307. case token of
  1308. LKLAMMER : inc(l);
  1309. RKLAMMER : dec(l);
  1310. end;
  1311. consume(token);
  1312. if l=0 then
  1313. break;
  1314. end;
  1315. end
  1316. else
  1317. begin
  1318. disposetree(p1);
  1319. p1:=genzeronode(hnewn);
  1320. p1^.resulttype:=ppointerdef(pd)^.definition;
  1321. consume(COMMA);
  1322. afterassignment:=false;
  1323. { determines the current object defintion }
  1324. classh:=pobjectdef(ppointerdef(pd)^.definition);
  1325. { check for an abstract class }
  1326. if (classh^.options and oois_abstract)<>0 then
  1327. Message(sym_e_no_instance_of_abstract_object);
  1328. { search the constructor also in the symbol tables of
  1329. the parents }
  1330. { no constructor found }
  1331. sym:=nil;
  1332. while assigned(classh) do
  1333. begin
  1334. sym:=pvarsym(classh^.publicsyms^.search(pattern));
  1335. srsymtable:=classh^.publicsyms;
  1336. if assigned(sym) then
  1337. break;
  1338. classh:=classh^.childof;
  1339. end;
  1340. consume(ID);
  1341. do_member_read(false,sym,p1,pd,again);
  1342. if (p1^.treetype<>calln) or
  1343. (assigned(p1^.procdefinition) and
  1344. ((p1^.procdefinition^.options and poconstructor)=0)) then
  1345. Message(parser_e_expr_have_to_be_constructor_call);
  1346. p1:=gensinglenode(newn,p1);
  1347. { set the resulttype }
  1348. p1^.resulttype:=pd2;
  1349. consume(RKLAMMER);
  1350. end;
  1351. end;
  1352. _SELF : begin
  1353. again:=true;
  1354. consume(_SELF);
  1355. if not assigned(procinfo._class) then
  1356. begin
  1357. p1:=genzeronode(errorn);
  1358. pd:=generrordef;
  1359. again:=false;
  1360. Message(parser_e_self_not_in_method);
  1361. end
  1362. else
  1363. begin
  1364. if (aktprocsym^.definition^.options and poclassmethod)<>0 then
  1365. begin
  1366. { self in class methods is a class reference type }
  1367. pd:=new(pclassrefdef,init(procinfo._class));
  1368. p1:=genselfnode(pd);
  1369. p1^.resulttype:=pd;
  1370. end
  1371. else
  1372. begin
  1373. p1:=genselfnode(procinfo._class);
  1374. p1^.resulttype:=procinfo._class;
  1375. end;
  1376. pd:=p1^.resulttype;
  1377. postfixoperators;
  1378. end;
  1379. end;
  1380. _INHERITED : begin
  1381. again:=true;
  1382. consume(_INHERITED);
  1383. if assigned(procinfo._class) then
  1384. begin
  1385. classh:=procinfo._class^.childof;
  1386. while assigned(classh) do
  1387. begin
  1388. srsymtable:=pobjectdef(classh)^.publicsyms;
  1389. sym:=pvarsym(srsymtable^.search(pattern));
  1390. if assigned(sym) then
  1391. begin
  1392. p1:=genzeronode(typen);
  1393. p1^.resulttype:=classh;
  1394. pd:=p1^.resulttype;
  1395. consume(ID);
  1396. do_member_read(false,sym,p1,pd,again);
  1397. break;
  1398. end;
  1399. classh:=classh^.childof;
  1400. end;
  1401. if classh=nil then
  1402. begin
  1403. Message1(sym_e_id_no_member,pattern);
  1404. again:=false;
  1405. pd:=generrordef;
  1406. p1:=genzeronode(errorn);
  1407. end;
  1408. end
  1409. else
  1410. begin
  1411. Message(parser_e_generic_methods_only_in_methods);
  1412. again:=false;
  1413. pd:=generrordef;
  1414. p1:=genzeronode(errorn);
  1415. end;
  1416. postfixoperators;
  1417. end;
  1418. INTCONST : begin
  1419. valint(pattern,l,code);
  1420. if code<>0 then
  1421. begin
  1422. val(pattern,d,code);
  1423. if code<>0 then
  1424. begin
  1425. Message(cg_e_invalid_integer);
  1426. consume(INTCONST);
  1427. l:=1;
  1428. p1:=genordinalconstnode(l,s32bitdef);
  1429. end
  1430. else
  1431. begin
  1432. consume(INTCONST);
  1433. p1:=genrealconstnode(d);
  1434. end;
  1435. end
  1436. else
  1437. begin
  1438. consume(INTCONST);
  1439. p1:=genordinalconstnode(l,s32bitdef);
  1440. end;
  1441. end;
  1442. REALNUMBER : begin
  1443. val(pattern,d,code);
  1444. if code<>0 then
  1445. begin
  1446. Message(parser_e_error_in_real);
  1447. d:=1.0;
  1448. end;
  1449. consume(REALNUMBER);
  1450. p1:=genrealconstnode(d);
  1451. end;
  1452. _STRING : begin
  1453. { STRING can be also a type cast }
  1454. pd:=stringtype;
  1455. consume(LKLAMMER);
  1456. p1:=comp_expr(true);
  1457. consume(RKLAMMER);
  1458. p1:=gentypeconvnode(p1,pd);
  1459. p1^.explizit:=true;
  1460. { handle postfix operators here e.g. string(a)[10] }
  1461. again:=true;
  1462. postfixoperators;
  1463. end;
  1464. _FILE : begin
  1465. { FILE can be also a type cast }
  1466. pd:=cfiledef;
  1467. consume(_FILE);
  1468. if token=LKLAMMER then
  1469. begin
  1470. consume(LKLAMMER);
  1471. p1:=comp_expr(true);
  1472. consume(RKLAMMER);
  1473. p1:=gentypeconvnode(p1,pd);
  1474. end
  1475. else
  1476. begin
  1477. p1:=genzeronode(typen);
  1478. p1^.resulttype:=pd;
  1479. end;
  1480. p1^.explizit:=true;
  1481. { handle postfix operators here e.g. string(a)[10] }
  1482. again:=true;
  1483. postfixoperators;
  1484. end;
  1485. CSTRING : begin
  1486. p1:=genstringconstnode(pattern);
  1487. consume(CSTRING);
  1488. end;
  1489. CCHAR : begin
  1490. p1:=genordinalconstnode(ord(pattern[1]),cchardef);
  1491. consume(CCHAR);
  1492. end;
  1493. KLAMMERAFFE : begin
  1494. consume(KLAMMERAFFE);
  1495. p1:=factor(true);
  1496. p1:=gensinglenode(addrn,p1);
  1497. end;
  1498. LKLAMMER : begin
  1499. consume(LKLAMMER);
  1500. p1:=comp_expr(true);
  1501. consume(RKLAMMER);
  1502. { it's not a good solution }
  1503. { but (a+b)^ makes some problems }
  1504. if token in [CARET,POINT,LECKKLAMMER] then
  1505. begin
  1506. { we need the resulttype }
  1507. { of the expression in pd }
  1508. do_firstpass(p1);
  1509. pd:=p1^.resulttype;
  1510. again:=true;
  1511. postfixoperators;
  1512. end;
  1513. end;
  1514. LECKKLAMMER : begin
  1515. consume(LECKKLAMMER);
  1516. p1:=factor_read_set;
  1517. consume(RECKKLAMMER);
  1518. end;
  1519. PLUS : begin
  1520. consume(PLUS);
  1521. p1:=factor(false);
  1522. end;
  1523. MINUS : begin
  1524. consume(MINUS);
  1525. p1:=factor(false);
  1526. p1:=gensinglenode(umminusn,p1);
  1527. end;
  1528. _NOT : begin
  1529. consume(_NOT);
  1530. p1:=factor(false);
  1531. p1:=gensinglenode(notn,p1);
  1532. end;
  1533. _TRUE : begin
  1534. consume(_TRUE);
  1535. p1:=genordinalconstnode(1,booldef);
  1536. end;
  1537. _FALSE : begin
  1538. consume(_FALSE);
  1539. p1:=genordinalconstnode(0,booldef);
  1540. end;
  1541. _NIL : begin
  1542. consume(_NIL);
  1543. p1:=genzeronode(niln);
  1544. end;
  1545. else
  1546. begin
  1547. p1:=genzeronode(errorn);
  1548. consume(token);
  1549. Message(cg_e_illegal_expression);
  1550. end;
  1551. end;
  1552. { generate error node if no node is created }
  1553. if not assigned(p1) then
  1554. p1:=genzeronode(errorn);
  1555. factor:=p1;
  1556. check_tokenpos;
  1557. end;
  1558. {****************************************************************************
  1559. Sub_Expr
  1560. ****************************************************************************}
  1561. type
  1562. Toperator_precedence=(opcompare,opaddition,opmultiply);
  1563. Ttok2nodeRec=record
  1564. tok : ttoken;
  1565. nod : ttreetyp;
  1566. end;
  1567. const
  1568. tok2nodes=23;
  1569. tok2node:array[1..tok2nodes] of ttok2noderec=(
  1570. (tok:PLUS ;nod:addn),
  1571. (tok:MINUS ;nod:subn),
  1572. (tok:STAR ;nod:muln),
  1573. (tok:SLASH ;nod:slashn),
  1574. (tok:EQUAL ;nod:equaln),
  1575. (tok:GT ;nod:gtn),
  1576. (tok:LT ;nod:ltn),
  1577. (tok:GTE ;nod:gten),
  1578. (tok:LTE ;nod:lten),
  1579. (tok:SYMDIF ;nod:symdifn),
  1580. (tok:STARSTAR;nod:starstarn),
  1581. (tok:CARET ;nod:caretn),
  1582. (tok:UNEQUAL ;nod:unequaln),
  1583. (tok:_AS ;nod:asn),
  1584. (tok:_IN ;nod:inn),
  1585. (tok:_IS ;nod:isn),
  1586. (tok:_OR ;nod:orn),
  1587. (tok:_AND ;nod:andn),
  1588. (tok:_DIV ;nod:divn),
  1589. (tok:_MOD ;nod:modn),
  1590. (tok:_SHL ;nod:shln),
  1591. (tok:_SHR ;nod:shrn),
  1592. (tok:_XOR ;nod:xorn)
  1593. );
  1594. operator_levels:array[Toperator_precedence] of set of Ttoken=
  1595. ([LT,LTE,GT,GTE,EQUAL,UNEQUAL,_IN,_IS],
  1596. [PLUS,MINUS,_OR,_XOR],
  1597. [CARET,SYMDIF,STARSTAR,STAR,SLASH,_DIV,_MOD,_AND,_SHL,_SHR,_AS]);
  1598. function sub_expr(pred_level:Toperator_precedence;accept_equal : boolean):Ptree;
  1599. {Reads a subexpression while the operators are of the current precedence
  1600. level, or any higher level. Replaces the old term, simpl_expr and
  1601. simpl2_expr.}
  1602. var
  1603. low,high,mid : longint;
  1604. p1,p2 : Ptree;
  1605. oldt : Ttoken;
  1606. filepos : tfileposinfo;
  1607. begin
  1608. if pred_level=opmultiply then
  1609. p1:=factor(false)
  1610. else
  1611. p1:=sub_expr(succ(pred_level),true);
  1612. repeat
  1613. if (token in operator_levels[pred_level]) and
  1614. ((token<>EQUAL) or accept_equal) then
  1615. begin
  1616. oldt:=token;
  1617. filepos:=tokenpos;
  1618. consume(token);
  1619. if pred_level=opmultiply then
  1620. p2:=factor(false)
  1621. else
  1622. p2:=sub_expr(succ(pred_level),true);
  1623. low:=1;
  1624. high:=tok2nodes;
  1625. while (low<high) do
  1626. begin
  1627. mid:=(low+high+1) shr 1;
  1628. if oldt<tok2node[mid].tok then
  1629. high:=mid-1
  1630. else
  1631. low:=mid;
  1632. end;
  1633. if tok2node[high].tok=oldt then
  1634. p1:=gennode(tok2node[high].nod,p1,p2)
  1635. else
  1636. p1:=gennode(nothingn,p1,p2);
  1637. set_tree_filepos(p1,filepos);
  1638. end
  1639. else
  1640. break;
  1641. until false;
  1642. sub_expr:=p1;
  1643. end;
  1644. function comp_expr(accept_equal : boolean):Ptree;
  1645. var
  1646. oldafterassignment : boolean;
  1647. begin
  1648. oldafterassignment:=afterassignment;
  1649. afterassignment:=true;
  1650. comp_expr:=sub_expr(opcompare,accept_equal);
  1651. afterassignment:=oldafterassignment;
  1652. end;
  1653. function expr : ptree;
  1654. var
  1655. p1,p2 : ptree;
  1656. oldafterassignment : boolean;
  1657. oldp1 : ptree;
  1658. filepos : tfileposinfo;
  1659. begin
  1660. oldafterassignment:=afterassignment;
  1661. p1:=sub_expr(opcompare,true);
  1662. if token in [ASSIGNMENT,_PLUSASN,_MINUSASN,_STARASN,_SLASHASN] then
  1663. afterassignment:=true;
  1664. filepos:=tokenpos;
  1665. oldp1:=p1;
  1666. case token of
  1667. POINTPOINT : begin
  1668. consume(POINTPOINT);
  1669. p2:=sub_expr(opcompare,true);
  1670. p1:=gennode(rangen,p1,p2);
  1671. end;
  1672. ASSIGNMENT : begin
  1673. consume(ASSIGNMENT);
  1674. { avoid a firstpass of a procedure if
  1675. it must be assigned to a procvar }
  1676. { should be recursive for a:=b:=c !!! }
  1677. if (p1^.resulttype<>nil) and (p1^.resulttype^.deftype=procvardef) then
  1678. begin
  1679. getprocvar:=true;
  1680. getprocvardef:=pprocvardef(p1^.resulttype);
  1681. end;
  1682. p2:=sub_expr(opcompare,true);
  1683. if getprocvar and (p2^.treetype=calln) and
  1684. (proc_to_procvar_equal(getprocvardef,pprocsym(p2^.symtableentry)^.definition)) then
  1685. begin
  1686. p2^.treetype:=loadn;
  1687. p2^.resulttype:=pprocsym(p2^.symtableprocentry)^.definition;
  1688. p2^.symtableentry:=p2^.symtableprocentry;
  1689. end;
  1690. getprocvar:=false;
  1691. p1:=gennode(assignn,p1,p2);
  1692. end;
  1693. { this is the code for C like assignements }
  1694. { from an improvement of Peter Schaefer }
  1695. _PLUSASN : begin
  1696. consume(_PLUSASN );
  1697. p2:=sub_expr(opcompare,true);
  1698. p1:=gennode(assignn,p1,gennode(addn,getcopy(p1),p2));
  1699. { was first
  1700. p1:=gennode(assignn,p1,gennode(addn,p1,p2));
  1701. but disposetree assumes that we have a real
  1702. *** tree *** }
  1703. end;
  1704. _MINUSASN : begin
  1705. consume(_MINUSASN );
  1706. p2:=sub_expr(opcompare,true);
  1707. p1:=gennode(assignn,p1,gennode(subn,getcopy(p1),p2));
  1708. end;
  1709. _STARASN : begin
  1710. consume(_STARASN );
  1711. p2:=sub_expr(opcompare,true);
  1712. p1:=gennode(assignn,p1,gennode(muln,getcopy(p1),p2));
  1713. end;
  1714. _SLASHASN : begin
  1715. consume(_SLASHASN );
  1716. p2:=sub_expr(opcompare,true);
  1717. p1:=gennode(assignn,p1,gennode(slashn,getcopy(p1),p2));
  1718. end;
  1719. end;
  1720. afterassignment:=oldafterassignment;
  1721. if p1<>oldp1 then
  1722. set_tree_filepos(p1,filepos);
  1723. expr:=p1;
  1724. end;
  1725. function get_intconst:longint;
  1726. {Reads an expression, tries to evalute it and check if it is an integer
  1727. constant. Then the constant is returned.}
  1728. var
  1729. p:Ptree;
  1730. begin
  1731. p:=comp_expr(true);
  1732. do_firstpass(p);
  1733. if (p^.treetype<>ordconstn) and
  1734. (p^.resulttype^.deftype=orddef) and
  1735. not(Porddef(p^.resulttype)^.typ in [uvoid,uchar,bool8bit,bool16bit,bool32bit]) then
  1736. Message(cg_e_illegal_expression)
  1737. else
  1738. get_intconst:=p^.value;
  1739. disposetree(p);
  1740. end;
  1741. function get_stringconst:string;
  1742. {Reads an expression, tries to evaluate it and checks if it is a string
  1743. constant. Then the constant is returned.}
  1744. var
  1745. p:Ptree;
  1746. begin
  1747. get_stringconst:='';
  1748. p:=comp_expr(true);
  1749. do_firstpass(p);
  1750. if p^.treetype<>stringconstn then
  1751. begin
  1752. if (p^.treetype=ordconstn) and
  1753. (p^.resulttype^.deftype=orddef) and
  1754. (Porddef(p^.resulttype)^.typ=uchar) then
  1755. get_stringconst:=char(p^.value)
  1756. else
  1757. Message(cg_e_illegal_expression);
  1758. end
  1759. else
  1760. {$ifdef UseAnsiString}
  1761. get_stringconst:=strpas(p^.value_str);
  1762. {$else UseAnsiString}
  1763. get_stringconst:=p^.value_str^;
  1764. {$endif UseAnsiString}
  1765. disposetree(p);
  1766. end;
  1767. end.
  1768. {
  1769. $Log$
  1770. Revision 1.65 1998-10-13 13:10:24 peter
  1771. * new style for m68k/i386 infos and enums
  1772. Revision 1.64 1998/10/12 12:20:55 pierre
  1773. + added tai_const_symbol_offset
  1774. for r : pointer = @var.field;
  1775. * better message for different arg names on implementation
  1776. of function
  1777. Revision 1.63 1998/10/12 10:28:30 florian
  1778. + auto dereferencing of pointers to structured types in delphi mode
  1779. Revision 1.62 1998/10/12 10:05:41 peter
  1780. * fixed mem leak with arrayconstrutor
  1781. Revision 1.61 1998/10/05 13:57:15 peter
  1782. * crash preventions
  1783. Revision 1.60 1998/10/05 12:32:46 peter
  1784. + assert() support
  1785. Revision 1.59 1998/10/01 14:56:24 peter
  1786. * crash preventions
  1787. Revision 1.58 1998/09/30 07:40:35 florian
  1788. * better error recovering
  1789. Revision 1.57 1998/09/28 16:18:16 florian
  1790. * two fixes to get ansi strings work
  1791. Revision 1.56 1998/09/26 17:45:36 peter
  1792. + idtoken and only one token table
  1793. Revision 1.55 1998/09/24 23:49:10 peter
  1794. + aktmodeswitches
  1795. Revision 1.54 1998/09/23 15:46:39 florian
  1796. * problem with with and classes fixed
  1797. Revision 1.53 1998/09/23 09:58:54 peter
  1798. * first working array of const things
  1799. Revision 1.52 1998/09/20 09:38:45 florian
  1800. * hasharray for defs fixed
  1801. * ansistring code generation corrected (init/final, assignement)
  1802. Revision 1.51 1998/09/18 16:03:43 florian
  1803. * some changes to compile with Delphi
  1804. Revision 1.50 1998/09/17 13:41:18 pierre
  1805. sizeof(TPOINT) problem
  1806. Revision 1.49.2.1 1998/09/17 08:42:31 pierre
  1807. TPOINT sizeof fix
  1808. Revision 1.49 1998/09/09 11:50:53 pierre
  1809. * forward def are not put in record or objects
  1810. + added check for forwards also in record and objects
  1811. * dummy parasymtable for unit initialization removed from
  1812. symtable stack
  1813. Revision 1.48 1998/09/07 22:25:53 peter
  1814. * fixed str(boolean,string) which was allowed
  1815. * fixed write(' ':<int expression>) only constants where allowed :(
  1816. Revision 1.47 1998/09/07 18:46:10 peter
  1817. * update smartlinking, uses getdatalabel
  1818. * renamed ptree.value vars to value_str,value_real,value_set
  1819. Revision 1.46 1998/09/04 08:42:03 peter
  1820. * updated some error messages
  1821. Revision 1.45 1998/09/01 17:39:49 peter
  1822. + internal constant functions
  1823. Revision 1.44 1998/08/28 10:54:24 peter
  1824. * fixed smallset generation from elements, it has never worked before!
  1825. Revision 1.43 1998/08/23 16:07:24 florian
  1826. * internalerror with mod/div fixed
  1827. Revision 1.42 1998/08/21 14:08:50 pierre
  1828. + TEST_FUNCRET now default (old code removed)
  1829. works also for m68k (at least compiles)
  1830. Revision 1.41 1998/08/20 21:36:39 peter
  1831. * fixed 'with object do' bug
  1832. Revision 1.40 1998/08/20 09:26:41 pierre
  1833. + funcret setting in underproc testing
  1834. compile with _dTEST_FUNCRET
  1835. Revision 1.39 1998/08/18 16:48:48 pierre
  1836. * bug for -So proc assignment to p^rocvar fixed
  1837. Revision 1.38 1998/08/18 14:17:09 pierre
  1838. * bug about assigning the return value of a function to
  1839. a procvar fixed : warning
  1840. assigning a proc to a procvar need @ in FPC mode !!
  1841. * missing file/line info restored
  1842. Revision 1.37 1998/08/18 09:24:43 pierre
  1843. * small warning position bug fixed
  1844. * support_mmx switches splitting was missing
  1845. * rhide error and warning output corrected
  1846. Revision 1.36 1998/08/15 16:50:29 peter
  1847. * fixed proc()=expr which was not allowed anymore by my previous fix
  1848. Revision 1.35 1998/08/14 18:18:46 peter
  1849. + dynamic set contruction
  1850. * smallsets are now working (always longint size)
  1851. Revision 1.34 1998/08/13 11:00:12 peter
  1852. * fixed procedure<>procedure construct
  1853. Revision 1.33 1998/08/11 15:31:39 peter
  1854. * write extended to ppu file
  1855. * new version 0.99.7
  1856. Revision 1.32 1998/08/11 14:05:32 peter
  1857. * fixed sizeof(array of char)
  1858. Revision 1.31 1998/08/10 14:50:11 peter
  1859. + localswitches, moduleswitches, globalswitches splitting
  1860. Revision 1.30 1998/07/28 21:52:54 florian
  1861. + implementation of raise and try..finally
  1862. + some misc. exception stuff
  1863. Revision 1.29 1998/07/27 21:57:13 florian
  1864. * fix to allow tv like stream registration:
  1865. @tmenu.load doesn't work if load had parameters or if load was only
  1866. declared in an anchestor class of tmenu
  1867. Revision 1.28 1998/07/14 21:46:51 peter
  1868. * updated messages file
  1869. Revision 1.27 1998/06/25 14:04:23 peter
  1870. + internal inc/dec
  1871. Revision 1.26 1998/06/09 16:01:46 pierre
  1872. + added procedure directive parsing for procvars
  1873. (accepted are popstack cdecl and pascal)
  1874. + added C vars with the following syntax
  1875. var C calias 'true_c_name';(can be followed by external)
  1876. reason is that you must add the Cprefix
  1877. which is target dependent
  1878. Revision 1.25 1998/06/05 14:37:33 pierre
  1879. * fixes for inline for operators
  1880. * inline procedure more correctly restricted
  1881. Revision 1.24 1998/06/04 23:51:52 peter
  1882. * m68k compiles
  1883. + .def file creation moved to gendef.pas so it could also be used
  1884. for win32
  1885. Revision 1.23 1998/06/04 09:55:40 pierre
  1886. * demangled name of procsym reworked to become independant of the mangling scheme
  1887. Revision 1.22 1998/06/02 17:03:03 pierre
  1888. * with node corrected for objects
  1889. * small bugs for SUPPORT_MMX fixed
  1890. Revision 1.21 1998/05/27 19:45:05 peter
  1891. * symtable.pas splitted into includefiles
  1892. * symtable adapted for $ifdef NEWPPU
  1893. Revision 1.20 1998/05/26 07:53:59 pierre
  1894. * bug fix for empty sets (nil pd was dereferenced )
  1895. Revision 1.19 1998/05/25 17:11:43 pierre
  1896. * firstpasscount bug fixed
  1897. now all is already set correctly the first time
  1898. under EXTDEBUG try -gp to skip all other firstpasses
  1899. it works !!
  1900. * small bug fixes
  1901. - for smallsets with -dTESTSMALLSET
  1902. - some warnings removed (by correcting code !)
  1903. Revision 1.18 1998/05/23 01:21:20 peter
  1904. + aktasmmode, aktoptprocessor, aktoutputformat
  1905. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1906. + $LIBNAME to set the library name where the unit will be put in
  1907. * splitted cgi386 a bit (codeseg to large for bp7)
  1908. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1909. Revision 1.17 1998/05/22 12:37:03 carl
  1910. * crash bugfix (patched msanually to main branch)
  1911. Revision 1.16 1998/05/21 19:33:32 peter
  1912. + better procedure directive handling and only one table
  1913. Revision 1.15 1998/05/20 09:42:35 pierre
  1914. + UseTokenInfo now default
  1915. * unit in interface uses and implementation uses gives error now
  1916. * only one error for unknown symbol (uses lastsymknown boolean)
  1917. the problem came from the label code !
  1918. + first inlined procedures and function work
  1919. (warning there might be allowed cases were the result is still wrong !!)
  1920. * UseBrower updated gives a global list of all position of all used symbols
  1921. with switch -gb
  1922. Revision 1.14 1998/05/11 13:07:56 peter
  1923. + $ifdef NEWPPU for the new ppuformat
  1924. + $define GDB not longer required
  1925. * removed all warnings and stripped some log comments
  1926. * no findfirst/findnext anymore to remove smartlink *.o files
  1927. Revision 1.13 1998/05/06 08:38:45 pierre
  1928. * better position info with UseTokenInfo
  1929. UseTokenInfo greatly simplified
  1930. + added check for changed tree after first time firstpass
  1931. (if we could remove all the cases were it happen
  1932. we could skip all firstpass if firstpasscount > 1)
  1933. Only with ExtDebug
  1934. Revision 1.12 1998/05/05 12:05:42 florian
  1935. * problems with properties fixed
  1936. * crash fixed: i:=l when i and l are undefined, was a problem with
  1937. implementation of private/protected
  1938. Revision 1.11 1998/05/04 11:22:26 florian
  1939. * problem with DOM solved: it crashes when accessing a property in a method
  1940. Revision 1.10 1998/05/01 16:38:45 florian
  1941. * handling of private and protected fixed
  1942. + change_keywords_to_tp implemented to remove
  1943. keywords which aren't supported by tp
  1944. * break and continue are now symbols of the system unit
  1945. + widestring, longstring and ansistring type released
  1946. Revision 1.9 1998/04/29 10:33:58 pierre
  1947. + added some code for ansistring (not complete nor working yet)
  1948. * corrected operator overloading
  1949. * corrected nasm output
  1950. + started inline procedures
  1951. + added starstarn : use ** for exponentiation (^ gave problems)
  1952. + started UseTokenInfo cond to get accurate positions
  1953. Revision 1.8 1998/04/14 23:27:03 florian
  1954. + exclude/include with constant second parameter added
  1955. Revision 1.7 1998/04/09 23:02:15 florian
  1956. * small problems solved to get remake3 work
  1957. Revision 1.6 1998/04/09 22:16:35 florian
  1958. * problem with previous REGALLOC solved
  1959. * improved property support
  1960. Revision 1.5 1998/04/08 10:26:09 florian
  1961. * correct error handling of virtual constructors
  1962. * problem with new type declaration handling fixed
  1963. Revision 1.4 1998/04/07 22:45:05 florian
  1964. * bug0092, bug0115 and bug0121 fixed
  1965. + packed object/class/array
  1966. Revision 1.3 1998/04/07 13:19:46 pierre
  1967. * bugfixes for reset_gdb_info
  1968. in MEM parsing for go32v2
  1969. better external symbol creation
  1970. support for rhgdb.exe (lowercase file names)
  1971. }