pexpr.pas 85 KB

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