pexpr.pas 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205
  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:=cstringdef;
  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. pobj : pobjectdef;
  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. 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. { FILE can be also a type cast }
  1513. pd:=cfiledef;
  1514. consume(_FILE);
  1515. if token=LKLAMMER then
  1516. begin
  1517. consume(LKLAMMER);
  1518. p1:=comp_expr(true);
  1519. consume(RKLAMMER);
  1520. p1:=gentypeconvnode(p1,pd);
  1521. end
  1522. else
  1523. begin
  1524. p1:=genzeronode(typen);
  1525. p1^.resulttype:=pd;
  1526. end;
  1527. p1^.explizit:=true;
  1528. { handle postfix operators here e.g. string(a)[10] }
  1529. again:=true;
  1530. postfixoperators;
  1531. end;
  1532. CSTRING : begin
  1533. p1:=genstringconstnode(pattern);
  1534. consume(CSTRING);
  1535. end;
  1536. CCHAR : begin
  1537. p1:=genordinalconstnode(ord(pattern[1]),cchardef);
  1538. consume(CCHAR);
  1539. end;
  1540. KLAMMERAFFE : begin
  1541. consume(KLAMMERAFFE);
  1542. p1:=factor(true);
  1543. p1:=gensinglenode(addrn,p1);
  1544. end;
  1545. LKLAMMER : begin
  1546. consume(LKLAMMER);
  1547. p1:=comp_expr(true);
  1548. consume(RKLAMMER);
  1549. { it's not a good solution }
  1550. { but (a+b)^ makes some problems }
  1551. if token in [CARET,POINT,LECKKLAMMER] then
  1552. begin
  1553. { we need the resulttype }
  1554. { of the expression in pd }
  1555. do_firstpass(p1);
  1556. pd:=p1^.resulttype;
  1557. again:=true;
  1558. postfixoperators;
  1559. end;
  1560. end;
  1561. LECKKLAMMER : begin
  1562. consume(LECKKLAMMER);
  1563. p1:=factor_read_set;
  1564. consume(RECKKLAMMER);
  1565. end;
  1566. PLUS : begin
  1567. consume(PLUS);
  1568. p1:=factor(false);
  1569. end;
  1570. MINUS : begin
  1571. consume(MINUS);
  1572. p1:=factor(false);
  1573. p1:=gensinglenode(umminusn,p1);
  1574. end;
  1575. _NOT : begin
  1576. consume(_NOT);
  1577. p1:=factor(false);
  1578. p1:=gensinglenode(notn,p1);
  1579. end;
  1580. _TRUE : begin
  1581. consume(_TRUE);
  1582. p1:=genordinalconstnode(1,booldef);
  1583. end;
  1584. _FALSE : begin
  1585. consume(_FALSE);
  1586. p1:=genordinalconstnode(0,booldef);
  1587. end;
  1588. _NIL : begin
  1589. consume(_NIL);
  1590. p1:=genzeronode(niln);
  1591. end;
  1592. else
  1593. begin
  1594. p1:=genzeronode(errorn);
  1595. consume(token);
  1596. Message(cg_e_illegal_expression);
  1597. end;
  1598. end;
  1599. { generate error node if no node is created }
  1600. if not assigned(p1) then
  1601. p1:=genzeronode(errorn);
  1602. factor:=p1;
  1603. check_tokenpos;
  1604. end;
  1605. {****************************************************************************
  1606. Sub_Expr
  1607. ****************************************************************************}
  1608. type
  1609. Toperator_precedence=(opcompare,opaddition,opmultiply);
  1610. Ttok2nodeRec=record
  1611. tok : ttoken;
  1612. nod : ttreetyp;
  1613. end;
  1614. const
  1615. tok2nodes=23;
  1616. tok2node:array[1..tok2nodes] of ttok2noderec=(
  1617. (tok:PLUS ;nod:addn),
  1618. (tok:MINUS ;nod:subn),
  1619. (tok:STAR ;nod:muln),
  1620. (tok:SLASH ;nod:slashn),
  1621. (tok:EQUAL ;nod:equaln),
  1622. (tok:GT ;nod:gtn),
  1623. (tok:LT ;nod:ltn),
  1624. (tok:GTE ;nod:gten),
  1625. (tok:LTE ;nod:lten),
  1626. (tok:SYMDIF ;nod:symdifn),
  1627. (tok:STARSTAR;nod:starstarn),
  1628. (tok:CARET ;nod:caretn),
  1629. (tok:UNEQUAL ;nod:unequaln),
  1630. (tok:_AS ;nod:asn),
  1631. (tok:_IN ;nod:inn),
  1632. (tok:_IS ;nod:isn),
  1633. (tok:_OR ;nod:orn),
  1634. (tok:_AND ;nod:andn),
  1635. (tok:_DIV ;nod:divn),
  1636. (tok:_MOD ;nod:modn),
  1637. (tok:_SHL ;nod:shln),
  1638. (tok:_SHR ;nod:shrn),
  1639. (tok:_XOR ;nod:xorn)
  1640. );
  1641. operator_levels:array[Toperator_precedence] of set of Ttoken=
  1642. ([LT,LTE,GT,GTE,EQUAL,UNEQUAL,_IN,_IS],
  1643. [PLUS,MINUS,_OR,_XOR],
  1644. [CARET,SYMDIF,STARSTAR,STAR,SLASH,_DIV,_MOD,_AND,_SHL,_SHR,_AS]);
  1645. function sub_expr(pred_level:Toperator_precedence;accept_equal : boolean):Ptree;
  1646. {Reads a subexpression while the operators are of the current precedence
  1647. level, or any higher level. Replaces the old term, simpl_expr and
  1648. simpl2_expr.}
  1649. var
  1650. low,high,mid : longint;
  1651. p1,p2 : Ptree;
  1652. oldt : Ttoken;
  1653. filepos : tfileposinfo;
  1654. begin
  1655. if pred_level=opmultiply then
  1656. p1:=factor(false)
  1657. else
  1658. p1:=sub_expr(succ(pred_level),true);
  1659. repeat
  1660. if (token in operator_levels[pred_level]) and
  1661. ((token<>EQUAL) or accept_equal) then
  1662. begin
  1663. oldt:=token;
  1664. filepos:=tokenpos;
  1665. consume(token);
  1666. if pred_level=opmultiply then
  1667. p2:=factor(false)
  1668. else
  1669. p2:=sub_expr(succ(pred_level),true);
  1670. low:=1;
  1671. high:=tok2nodes;
  1672. while (low<high) do
  1673. begin
  1674. mid:=(low+high+1) shr 1;
  1675. if oldt<tok2node[mid].tok then
  1676. high:=mid-1
  1677. else
  1678. low:=mid;
  1679. end;
  1680. if tok2node[high].tok=oldt then
  1681. p1:=gennode(tok2node[high].nod,p1,p2)
  1682. else
  1683. p1:=gennode(nothingn,p1,p2);
  1684. set_tree_filepos(p1,filepos);
  1685. end
  1686. else
  1687. break;
  1688. until false;
  1689. sub_expr:=p1;
  1690. end;
  1691. function comp_expr(accept_equal : boolean):Ptree;
  1692. var
  1693. oldafterassignment : boolean;
  1694. begin
  1695. oldafterassignment:=afterassignment;
  1696. afterassignment:=true;
  1697. comp_expr:=sub_expr(opcompare,accept_equal);
  1698. afterassignment:=oldafterassignment;
  1699. end;
  1700. function expr : ptree;
  1701. var
  1702. p1,p2 : ptree;
  1703. oldafterassignment : boolean;
  1704. oldp1 : ptree;
  1705. filepos : tfileposinfo;
  1706. begin
  1707. oldafterassignment:=afterassignment;
  1708. p1:=sub_expr(opcompare,true);
  1709. if token in [ASSIGNMENT,_PLUSASN,_MINUSASN,_STARASN,_SLASHASN] then
  1710. afterassignment:=true;
  1711. filepos:=tokenpos;
  1712. oldp1:=p1;
  1713. case token of
  1714. POINTPOINT : begin
  1715. consume(POINTPOINT);
  1716. p2:=sub_expr(opcompare,true);
  1717. p1:=gennode(rangen,p1,p2);
  1718. end;
  1719. ASSIGNMENT : begin
  1720. consume(ASSIGNMENT);
  1721. { avoid a firstpass of a procedure if
  1722. it must be assigned to a procvar }
  1723. { should be recursive for a:=b:=c !!! }
  1724. if (p1^.resulttype<>nil) and (p1^.resulttype^.deftype=procvardef) then
  1725. begin
  1726. getprocvar:=true;
  1727. getprocvardef:=pprocvardef(p1^.resulttype);
  1728. end;
  1729. p2:=sub_expr(opcompare,true);
  1730. if getprocvar and (p2^.treetype=calln) and
  1731. (proc_to_procvar_equal(getprocvardef,pprocsym(p2^.symtableentry)^.definition)) then
  1732. begin
  1733. p2^.treetype:=loadn;
  1734. p2^.resulttype:=pprocsym(p2^.symtableprocentry)^.definition;
  1735. p2^.symtableentry:=p2^.symtableprocentry;
  1736. end;
  1737. getprocvar:=false;
  1738. p1:=gennode(assignn,p1,p2);
  1739. end;
  1740. { this is the code for C like assignements }
  1741. { from an improvement of Peter Schaefer }
  1742. _PLUSASN : begin
  1743. consume(_PLUSASN );
  1744. p2:=sub_expr(opcompare,true);
  1745. p1:=gennode(assignn,p1,gennode(addn,getcopy(p1),p2));
  1746. { was first
  1747. p1:=gennode(assignn,p1,gennode(addn,p1,p2));
  1748. but disposetree assumes that we have a real
  1749. *** tree *** }
  1750. end;
  1751. _MINUSASN : begin
  1752. consume(_MINUSASN );
  1753. p2:=sub_expr(opcompare,true);
  1754. p1:=gennode(assignn,p1,gennode(subn,getcopy(p1),p2));
  1755. end;
  1756. _STARASN : begin
  1757. consume(_STARASN );
  1758. p2:=sub_expr(opcompare,true);
  1759. p1:=gennode(assignn,p1,gennode(muln,getcopy(p1),p2));
  1760. end;
  1761. _SLASHASN : begin
  1762. consume(_SLASHASN );
  1763. p2:=sub_expr(opcompare,true);
  1764. p1:=gennode(assignn,p1,gennode(slashn,getcopy(p1),p2));
  1765. end;
  1766. end;
  1767. afterassignment:=oldafterassignment;
  1768. if p1<>oldp1 then
  1769. set_tree_filepos(p1,filepos);
  1770. expr:=p1;
  1771. end;
  1772. function get_intconst:longint;
  1773. {Reads an expression, tries to evalute it and check if it is an integer
  1774. constant. Then the constant is returned.}
  1775. var
  1776. p:Ptree;
  1777. begin
  1778. p:=comp_expr(true);
  1779. do_firstpass(p);
  1780. if (p^.treetype<>ordconstn) and
  1781. (p^.resulttype^.deftype=orddef) and
  1782. not(Porddef(p^.resulttype)^.typ in [uvoid,uchar,bool8bit,bool16bit,bool32bit]) then
  1783. Message(cg_e_illegal_expression)
  1784. else
  1785. get_intconst:=p^.value;
  1786. disposetree(p);
  1787. end;
  1788. function get_stringconst:string;
  1789. {Reads an expression, tries to evaluate it and checks if it is a string
  1790. constant. Then the constant is returned.}
  1791. var
  1792. p:Ptree;
  1793. begin
  1794. get_stringconst:='';
  1795. p:=comp_expr(true);
  1796. do_firstpass(p);
  1797. if p^.treetype<>stringconstn then
  1798. begin
  1799. if (p^.treetype=ordconstn) and
  1800. (p^.resulttype^.deftype=orddef) and
  1801. (Porddef(p^.resulttype)^.typ=uchar) then
  1802. get_stringconst:=char(p^.value)
  1803. else
  1804. Message(cg_e_illegal_expression);
  1805. end
  1806. else
  1807. {$ifdef UseAnsiString}
  1808. get_stringconst:=strpas(p^.value_str);
  1809. {$else UseAnsiString}
  1810. get_stringconst:=p^.value_str^;
  1811. {$endif UseAnsiString}
  1812. disposetree(p);
  1813. end;
  1814. end.
  1815. {
  1816. $Log$
  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. }