pexpr.pas 85 KB

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