pexpr.pas 84 KB

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