pexpr.pas 82 KB

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