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:=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. end;
  947. pd:=p1^.resulttype;
  948. end;
  949. procsym : begin
  950. { are we in a class method ? }
  951. possible_error:=(srsymtable^.symtabletype=objectsymtable) and
  952. assigned(aktprocsym) and
  953. ((aktprocsym^.definition^.options and poclassmethod)<>0);
  954. p1:=gencallnode(pprocsym(srsym),srsymtable);
  955. p1^.unit_specific:=unit_specific;
  956. do_proc_call(getaddr or
  957. (getprocvar and
  958. proc_to_procvar_equal(getprocvardef,pprocsym(srsym)^.definition)),
  959. again,p1,pd);
  960. if possible_error and
  961. ((p1^.procdefinition^.options and poclassmethod)=0) then
  962. Message(parser_e_only_class_methods);
  963. end;
  964. propertysym : begin
  965. { access to property in a method }
  966. { are we in a class method ? }
  967. if (srsymtable^.symtabletype=objectsymtable) and
  968. assigned(aktprocsym) and
  969. ((aktprocsym^.definition^.options and poclassmethod)<>0) then
  970. Message(parser_e_only_class_methods);
  971. { no method pointer }
  972. p1:=nil;
  973. handle_propertysym(srsym,srsymtable,p1,pd);
  974. end;
  975. errorsym : begin
  976. p1:=genzeronode(errorn);
  977. pd:=generrordef;
  978. if token=LKLAMMER then
  979. begin
  980. consume(LKLAMMER);
  981. parse_paras(false,false);
  982. consume(RKLAMMER);
  983. end;
  984. end;
  985. else
  986. begin
  987. p1:=genzeronode(errorn);
  988. pd:=generrordef;
  989. Message(cg_e_illegal_expression);
  990. end;
  991. end; { end case }
  992. end;
  993. end;
  994. end;
  995. end;
  996. {---------------------------------------------
  997. Factor_Read_Set
  998. ---------------------------------------------}
  999. { Read a set between [] }
  1000. function factor_read_set:ptree;
  1001. var
  1002. p1,
  1003. lastp,
  1004. buildp : ptree;
  1005. begin
  1006. buildp:=nil;
  1007. { be sure that a least one arrayconstructn is used, also for an
  1008. empty [] }
  1009. if token=RECKKLAMMER then
  1010. buildp:=gennode(arrayconstructn,nil,buildp)
  1011. else
  1012. begin
  1013. while true do
  1014. begin
  1015. p1:=comp_expr(true);
  1016. if token=POINTPOINT then
  1017. begin
  1018. consume(POINTPOINT);
  1019. p2:=comp_expr(true);
  1020. p1:=gennode(arrayconstructrangen,p1,p2);
  1021. end;
  1022. { insert at the end of the tree, to get the correct order }
  1023. if not assigned(buildp) then
  1024. begin
  1025. buildp:=gennode(arrayconstructn,p1,nil);
  1026. lastp:=buildp;
  1027. end
  1028. else
  1029. begin
  1030. lastp^.right:=gennode(arrayconstructn,p1,nil);
  1031. lastp:=lastp^.right;
  1032. end;
  1033. { there could be more elements }
  1034. if token=COMMA then
  1035. consume(COMMA)
  1036. else
  1037. break;
  1038. end;
  1039. end;
  1040. factor_read_set:=buildp;
  1041. end;
  1042. {---------------------------------------------
  1043. Helpers
  1044. ---------------------------------------------}
  1045. procedure check_tokenpos;
  1046. begin
  1047. if (p1<>oldp1) then
  1048. begin
  1049. if assigned(p1) then
  1050. set_tree_filepos(p1,filepos);
  1051. oldp1:=p1;
  1052. filepos:=tokenpos;
  1053. end;
  1054. end;
  1055. {---------------------------------------------
  1056. PostFixOperators
  1057. ---------------------------------------------}
  1058. procedure postfixoperators;
  1059. { p1 and p2 must contain valid value_str }
  1060. begin
  1061. check_tokenpos;
  1062. while again do
  1063. begin
  1064. { prevent crashes with unknown types }
  1065. if not assigned(pd) then
  1066. begin
  1067. { try to recover }
  1068. repeat
  1069. case token of
  1070. CARET:
  1071. consume(CARET);
  1072. POINT:
  1073. begin
  1074. consume(POINT);
  1075. consume(ID);
  1076. end;
  1077. LECKKLAMMER:
  1078. begin
  1079. repeat
  1080. consume(token);
  1081. until token in [RECKKLAMMER,SEMICOLON];
  1082. end;
  1083. else
  1084. break;
  1085. end;
  1086. until false;
  1087. exit;
  1088. end;
  1089. { handle token }
  1090. case token of
  1091. CARET:
  1092. begin
  1093. consume(CARET);
  1094. if pd^.deftype<>pointerdef then
  1095. begin
  1096. { ^ as binary operator is a problem!!!! (FK) }
  1097. again:=false;
  1098. Message(cg_e_invalid_qualifier);
  1099. disposetree(p1);
  1100. p1:=genzeronode(errorn);
  1101. end
  1102. else
  1103. begin
  1104. p1:=gensinglenode(derefn,p1);
  1105. pd:=ppointerdef(pd)^.definition;
  1106. end;
  1107. end;
  1108. LECKKLAMMER:
  1109. begin
  1110. if (pd^.deftype=objectdef) and pobjectdef(pd)^.isclass then
  1111. begin
  1112. { default property }
  1113. propsym:=search_default_property(pobjectdef(pd));
  1114. if not(assigned(propsym)) then
  1115. begin
  1116. disposetree(p1);
  1117. p1:=genzeronode(errorn);
  1118. again:=false;
  1119. message(parser_e_no_default_property_available);
  1120. end
  1121. else
  1122. begin
  1123. p1:=nil;
  1124. handle_propertysym(propsym,propsym^.owner,p1,pd);
  1125. end;
  1126. end
  1127. else
  1128. begin
  1129. consume(LECKKLAMMER);
  1130. repeat
  1131. case pd^.deftype of
  1132. pointerdef:
  1133. begin
  1134. p2:=comp_expr(true);
  1135. p1:=gennode(vecn,p1,p2);
  1136. pd:=ppointerdef(pd)^.definition;
  1137. end;
  1138. stringdef : begin
  1139. p2:=comp_expr(true);
  1140. p1:=gennode(vecn,p1,p2);
  1141. pd:=cchardef
  1142. end;
  1143. arraydef : begin
  1144. p2:=comp_expr(true);
  1145. { support SEG:OFS for go32v2 Mem[] }
  1146. if (target_info.target=target_i386_go32v2) and
  1147. (p1^.treetype=loadn) and
  1148. assigned(p1^.symtableentry) and
  1149. assigned(p1^.symtableentry^.owner^.name) and
  1150. (p1^.symtableentry^.owner^.name^='SYSTEM') and
  1151. ((p1^.symtableentry^.name='MEM') or
  1152. (p1^.symtableentry^.name='MEMW') or
  1153. (p1^.symtableentry^.name='MEML')) then
  1154. begin
  1155. if (token=COLON) then
  1156. begin
  1157. consume(COLON);
  1158. p3:=gennode(muln,genordinalconstnode($10,s32bitdef),p2);
  1159. p2:=comp_expr(true);
  1160. p2:=gennode(addn,p2,p3);
  1161. p1:=gennode(vecn,p1,p2);
  1162. p1^.memseg:=true;
  1163. p1^.memindex:=true;
  1164. end
  1165. else
  1166. begin
  1167. p1:=gennode(vecn,p1,p2);
  1168. p1^.memindex:=true;
  1169. end;
  1170. end
  1171. else
  1172. p1:=gennode(vecn,p1,p2);
  1173. pd:=parraydef(pd)^.definition;
  1174. end;
  1175. else
  1176. begin
  1177. Message(cg_e_invalid_qualifier);
  1178. disposetree(p1);
  1179. p1:=genzeronode(errorn);
  1180. again:=false;
  1181. end;
  1182. end;
  1183. if token=COMMA then
  1184. consume(COMMA)
  1185. else
  1186. break;
  1187. until false;
  1188. consume(RECKKLAMMER);
  1189. end;
  1190. end;
  1191. POINT : begin
  1192. consume(POINT);
  1193. if (pd^.deftype=pointerdef) and
  1194. (m_autoderef in aktmodeswitches) then
  1195. begin
  1196. p1:=gensinglenode(derefn,p1);
  1197. pd:=ppointerdef(pd)^.definition;
  1198. end;
  1199. case pd^.deftype of
  1200. recorddef:
  1201. begin
  1202. sym:=pvarsym(precdef(pd)^.symtable^.search(pattern));
  1203. if sym=nil then
  1204. begin
  1205. Message1(sym_e_illegal_field,pattern);
  1206. disposetree(p1);
  1207. p1:=genzeronode(errorn);
  1208. end
  1209. else
  1210. begin
  1211. p1:=gensubscriptnode(sym,p1);
  1212. pd:=sym^.definition;
  1213. end;
  1214. consume(ID);
  1215. end;
  1216. classrefdef:
  1217. begin
  1218. classh:=pobjectdef(pclassrefdef(pd)^.definition);
  1219. sym:=nil;
  1220. while assigned(classh) do
  1221. begin
  1222. sym:=pvarsym(classh^.publicsyms^.search(pattern));
  1223. srsymtable:=classh^.publicsyms;
  1224. if assigned(sym) then
  1225. break;
  1226. classh:=classh^.childof;
  1227. end;
  1228. consume(ID);
  1229. do_member_read(false,sym,p1,pd,again);
  1230. end;
  1231. objectdef:
  1232. begin
  1233. classh:=pobjectdef(pd);
  1234. sym:=nil;
  1235. while assigned(classh) do
  1236. begin
  1237. sym:=pvarsym(classh^.publicsyms^.search(pattern));
  1238. srsymtable:=classh^.publicsyms;
  1239. if assigned(sym) then
  1240. break;
  1241. classh:=classh^.childof;
  1242. end;
  1243. consume(ID);
  1244. do_member_read(false,sym,p1,pd,again);
  1245. end;
  1246. pointerdef:
  1247. begin
  1248. Message(cg_e_invalid_qualifier);
  1249. if ppointerdef(pd)^.definition^.deftype in [recorddef,objectdef,classrefdef] then
  1250. Message(parser_h_maybe_deref_caret_missing);
  1251. end;
  1252. else
  1253. begin
  1254. Message(cg_e_invalid_qualifier);
  1255. disposetree(p1);
  1256. p1:=genzeronode(errorn);
  1257. end;
  1258. end;
  1259. end;
  1260. else
  1261. begin
  1262. { is this a procedure variable ? }
  1263. if assigned(pd) then
  1264. begin
  1265. if (pd^.deftype=procvardef) then
  1266. begin
  1267. if getprocvar and proc_to_procvar_equal(pprocvardef(pd),getprocvardef) then
  1268. again:=false
  1269. else
  1270. if (token=LKLAMMER) or
  1271. ((pprocvardef(pd)^.para1=nil) and
  1272. (not((token in [ASSIGNMENT,UNEQUAL,EQUAL]))) and
  1273. (not afterassignment) and
  1274. (not in_args)) then
  1275. begin
  1276. { do this in a strange way }
  1277. { it's not a clean solution }
  1278. p2:=p1;
  1279. p1:=gencallnode(nil,nil);
  1280. p1^.right:=p2;
  1281. p1^.unit_specific:=unit_specific;
  1282. p1^.symtableprocentry:=sym;
  1283. if token=LKLAMMER then
  1284. begin
  1285. consume(LKLAMMER);
  1286. p1^.left:=parse_paras(false,false);
  1287. consume(RKLAMMER);
  1288. end;
  1289. pd:=pprocvardef(pd)^.retdef;
  1290. { proc():= is never possible }
  1291. if token=ASSIGNMENT then
  1292. begin
  1293. Message(cg_e_illegal_expression);
  1294. p1:=genzeronode(errorn);
  1295. again:=false;
  1296. end;
  1297. p1^.resulttype:=pd;
  1298. end
  1299. else
  1300. again:=false;
  1301. p1^.resulttype:=pd;
  1302. end
  1303. else
  1304. again:=false;
  1305. end
  1306. else
  1307. again:=false;
  1308. end;
  1309. end;
  1310. check_tokenpos;
  1311. end; { while again }
  1312. end;
  1313. {---------------------------------------------
  1314. Factor (Main)
  1315. ---------------------------------------------}
  1316. begin
  1317. oldp1:=nil;
  1318. p1:=nil;
  1319. filepos:=tokenpos;
  1320. if token=ID then
  1321. begin
  1322. factor_read_id;
  1323. { handle post fix operators }
  1324. postfixoperators;
  1325. end
  1326. else
  1327. case token of
  1328. _NEW : begin
  1329. consume(_NEW);
  1330. consume(LKLAMMER);
  1331. {allow_type:=true;}
  1332. p1:=factor(false);
  1333. {allow_type:=false;}
  1334. if p1^.treetype<>typen then
  1335. begin
  1336. Message(type_e_type_id_expected);
  1337. disposetree(p1);
  1338. pd:=generrordef;
  1339. end
  1340. else
  1341. pd:=p1^.typenodetype;
  1342. pd2:=pd;
  1343. if (pd^.deftype<>pointerdef) or
  1344. (ppointerdef(pd)^.definition^.deftype<>objectdef) then
  1345. begin
  1346. Message(parser_e_pointer_to_class_expected);
  1347. { if an error occurs, read til the end of
  1348. the new statement }
  1349. p1:=genzeronode(errorn);
  1350. l:=1;
  1351. while true do
  1352. begin
  1353. case token of
  1354. LKLAMMER : inc(l);
  1355. RKLAMMER : dec(l);
  1356. end;
  1357. consume(token);
  1358. if l=0 then
  1359. break;
  1360. end;
  1361. end
  1362. else
  1363. begin
  1364. disposetree(p1);
  1365. p1:=genzeronode(hnewn);
  1366. p1^.resulttype:=ppointerdef(pd)^.definition;
  1367. consume(COMMA);
  1368. afterassignment:=false;
  1369. { determines the current object defintion }
  1370. classh:=pobjectdef(ppointerdef(pd)^.definition);
  1371. { check for an abstract class }
  1372. if (classh^.options and oo_is_abstract)<>0 then
  1373. Message(sym_e_no_instance_of_abstract_object);
  1374. { search the constructor also in the symbol tables of
  1375. the parents }
  1376. { no constructor found }
  1377. sym:=nil;
  1378. while assigned(classh) do
  1379. begin
  1380. sym:=pvarsym(classh^.publicsyms^.search(pattern));
  1381. srsymtable:=classh^.publicsyms;
  1382. if assigned(sym) then
  1383. break;
  1384. classh:=classh^.childof;
  1385. end;
  1386. consume(ID);
  1387. do_member_read(false,sym,p1,pd,again);
  1388. if (p1^.treetype<>calln) or
  1389. (assigned(p1^.procdefinition) and
  1390. ((p1^.procdefinition^.options and poconstructor)=0)) then
  1391. Message(parser_e_expr_have_to_be_constructor_call);
  1392. p1:=gensinglenode(newn,p1);
  1393. { set the resulttype }
  1394. p1^.resulttype:=pd2;
  1395. consume(RKLAMMER);
  1396. end;
  1397. end;
  1398. _SELF : begin
  1399. again:=true;
  1400. consume(_SELF);
  1401. if not assigned(procinfo._class) then
  1402. begin
  1403. p1:=genzeronode(errorn);
  1404. pd:=generrordef;
  1405. again:=false;
  1406. Message(parser_e_self_not_in_method);
  1407. end
  1408. else
  1409. begin
  1410. if (aktprocsym^.definition^.options and poclassmethod)<>0 then
  1411. begin
  1412. { self in class methods is a class reference type }
  1413. pd:=new(pclassrefdef,init(procinfo._class));
  1414. p1:=genselfnode(pd);
  1415. p1^.resulttype:=pd;
  1416. end
  1417. else
  1418. begin
  1419. p1:=genselfnode(procinfo._class);
  1420. p1^.resulttype:=procinfo._class;
  1421. end;
  1422. pd:=p1^.resulttype;
  1423. postfixoperators;
  1424. end;
  1425. end;
  1426. _INHERITED : begin
  1427. again:=true;
  1428. consume(_INHERITED);
  1429. if assigned(procinfo._class) then
  1430. begin
  1431. classh:=procinfo._class^.childof;
  1432. while assigned(classh) do
  1433. begin
  1434. srsymtable:=pobjectdef(classh)^.publicsyms;
  1435. sym:=pvarsym(srsymtable^.search(pattern));
  1436. if assigned(sym) then
  1437. begin
  1438. p1:=genzeronode(typen);
  1439. p1^.resulttype:=classh;
  1440. pd:=p1^.resulttype;
  1441. consume(ID);
  1442. do_member_read(false,sym,p1,pd,again);
  1443. break;
  1444. end;
  1445. classh:=classh^.childof;
  1446. end;
  1447. if classh=nil then
  1448. begin
  1449. Message1(sym_e_id_no_member,pattern);
  1450. again:=false;
  1451. pd:=generrordef;
  1452. p1:=genzeronode(errorn);
  1453. end;
  1454. end
  1455. else
  1456. begin
  1457. Message(parser_e_generic_methods_only_in_methods);
  1458. again:=false;
  1459. pd:=generrordef;
  1460. p1:=genzeronode(errorn);
  1461. end;
  1462. postfixoperators;
  1463. end;
  1464. INTCONST : begin
  1465. valint(pattern,l,code);
  1466. if code<>0 then
  1467. begin
  1468. val(pattern,d,code);
  1469. if code<>0 then
  1470. begin
  1471. Message(cg_e_invalid_integer);
  1472. consume(INTCONST);
  1473. l:=1;
  1474. p1:=genordinalconstnode(l,s32bitdef);
  1475. end
  1476. else
  1477. begin
  1478. consume(INTCONST);
  1479. p1:=genrealconstnode(d);
  1480. end;
  1481. end
  1482. else
  1483. begin
  1484. consume(INTCONST);
  1485. p1:=genordinalconstnode(l,s32bitdef);
  1486. end;
  1487. end;
  1488. REALNUMBER : begin
  1489. val(pattern,d,code);
  1490. if code<>0 then
  1491. begin
  1492. Message(parser_e_error_in_real);
  1493. d:=1.0;
  1494. end;
  1495. consume(REALNUMBER);
  1496. p1:=genrealconstnode(d);
  1497. end;
  1498. _STRING : begin
  1499. { STRING can be also a type cast }
  1500. pd:=stringtype;
  1501. consume(LKLAMMER);
  1502. p1:=comp_expr(true);
  1503. consume(RKLAMMER);
  1504. p1:=gentypeconvnode(p1,pd);
  1505. p1^.explizit:=true;
  1506. { handle postfix operators here e.g. string(a)[10] }
  1507. again:=true;
  1508. postfixoperators;
  1509. end;
  1510. _FILE : begin
  1511. pd:=cfiledef;
  1512. consume(_FILE);
  1513. { FILE can be also a type cast }
  1514. if token=LKLAMMER then
  1515. begin
  1516. consume(LKLAMMER);
  1517. p1:=comp_expr(true);
  1518. consume(RKLAMMER);
  1519. p1:=gentypeconvnode(p1,pd);
  1520. p1^.explizit:=true;
  1521. { handle postfix operators here e.g. string(a)[10] }
  1522. again:=true;
  1523. postfixoperators;
  1524. end
  1525. else
  1526. p1:=gentypenode(pd);
  1527. end;
  1528. CSTRING : begin
  1529. p1:=genstringconstnode(pattern);
  1530. consume(CSTRING);
  1531. end;
  1532. CCHAR : begin
  1533. p1:=genordinalconstnode(ord(pattern[1]),cchardef);
  1534. consume(CCHAR);
  1535. end;
  1536. KLAMMERAFFE : begin
  1537. consume(KLAMMERAFFE);
  1538. p1:=factor(true);
  1539. p1:=gensinglenode(addrn,p1);
  1540. end;
  1541. LKLAMMER : begin
  1542. consume(LKLAMMER);
  1543. p1:=comp_expr(true);
  1544. consume(RKLAMMER);
  1545. { it's not a good solution }
  1546. { but (a+b)^ makes some problems }
  1547. if token in [CARET,POINT,LECKKLAMMER] then
  1548. begin
  1549. { we need the resulttype }
  1550. { of the expression in pd }
  1551. do_firstpass(p1);
  1552. pd:=p1^.resulttype;
  1553. again:=true;
  1554. postfixoperators;
  1555. end;
  1556. end;
  1557. LECKKLAMMER : begin
  1558. consume(LECKKLAMMER);
  1559. p1:=factor_read_set;
  1560. consume(RECKKLAMMER);
  1561. end;
  1562. PLUS : begin
  1563. consume(PLUS);
  1564. p1:=factor(false);
  1565. end;
  1566. MINUS : begin
  1567. consume(MINUS);
  1568. p1:=factor(false);
  1569. p1:=gensinglenode(umminusn,p1);
  1570. end;
  1571. _NOT : begin
  1572. consume(_NOT);
  1573. p1:=factor(false);
  1574. p1:=gensinglenode(notn,p1);
  1575. end;
  1576. _TRUE : begin
  1577. consume(_TRUE);
  1578. p1:=genordinalconstnode(1,booldef);
  1579. end;
  1580. _FALSE : begin
  1581. consume(_FALSE);
  1582. p1:=genordinalconstnode(0,booldef);
  1583. end;
  1584. _NIL : begin
  1585. consume(_NIL);
  1586. p1:=genzeronode(niln);
  1587. end;
  1588. else
  1589. begin
  1590. p1:=genzeronode(errorn);
  1591. consume(token);
  1592. Message(cg_e_illegal_expression);
  1593. end;
  1594. end;
  1595. { generate error node if no node is created }
  1596. if not assigned(p1) then
  1597. p1:=genzeronode(errorn);
  1598. factor:=p1;
  1599. check_tokenpos;
  1600. end;
  1601. {****************************************************************************
  1602. Sub_Expr
  1603. ****************************************************************************}
  1604. type
  1605. Toperator_precedence=(opcompare,opaddition,opmultiply);
  1606. Ttok2nodeRec=record
  1607. tok : ttoken;
  1608. nod : ttreetyp;
  1609. end;
  1610. const
  1611. tok2nodes=23;
  1612. tok2node:array[1..tok2nodes] of ttok2noderec=(
  1613. (tok:PLUS ;nod:addn),
  1614. (tok:MINUS ;nod:subn),
  1615. (tok:STAR ;nod:muln),
  1616. (tok:SLASH ;nod:slashn),
  1617. (tok:EQUAL ;nod:equaln),
  1618. (tok:GT ;nod:gtn),
  1619. (tok:LT ;nod:ltn),
  1620. (tok:GTE ;nod:gten),
  1621. (tok:LTE ;nod:lten),
  1622. (tok:SYMDIF ;nod:symdifn),
  1623. (tok:STARSTAR;nod:starstarn),
  1624. (tok:CARET ;nod:caretn),
  1625. (tok:UNEQUAL ;nod:unequaln),
  1626. (tok:_AS ;nod:asn),
  1627. (tok:_IN ;nod:inn),
  1628. (tok:_IS ;nod:isn),
  1629. (tok:_OR ;nod:orn),
  1630. (tok:_AND ;nod:andn),
  1631. (tok:_DIV ;nod:divn),
  1632. (tok:_MOD ;nod:modn),
  1633. (tok:_SHL ;nod:shln),
  1634. (tok:_SHR ;nod:shrn),
  1635. (tok:_XOR ;nod:xorn)
  1636. );
  1637. operator_levels:array[Toperator_precedence] of set of Ttoken=
  1638. ([LT,LTE,GT,GTE,EQUAL,UNEQUAL,_IN,_IS],
  1639. [PLUS,MINUS,_OR,_XOR],
  1640. [CARET,SYMDIF,STARSTAR,STAR,SLASH,_DIV,_MOD,_AND,_SHL,_SHR,_AS]);
  1641. function sub_expr(pred_level:Toperator_precedence;accept_equal : boolean):Ptree;
  1642. {Reads a subexpression while the operators are of the current precedence
  1643. level, or any higher level. Replaces the old term, simpl_expr and
  1644. simpl2_expr.}
  1645. var
  1646. low,high,mid : longint;
  1647. p1,p2 : Ptree;
  1648. oldt : Ttoken;
  1649. filepos : tfileposinfo;
  1650. begin
  1651. if pred_level=opmultiply then
  1652. p1:=factor(false)
  1653. else
  1654. p1:=sub_expr(succ(pred_level),true);
  1655. repeat
  1656. if (token in operator_levels[pred_level]) and
  1657. ((token<>EQUAL) or accept_equal) then
  1658. begin
  1659. oldt:=token;
  1660. filepos:=tokenpos;
  1661. consume(token);
  1662. if pred_level=opmultiply then
  1663. p2:=factor(false)
  1664. else
  1665. p2:=sub_expr(succ(pred_level),true);
  1666. low:=1;
  1667. high:=tok2nodes;
  1668. while (low<high) do
  1669. begin
  1670. mid:=(low+high+1) shr 1;
  1671. if oldt<tok2node[mid].tok then
  1672. high:=mid-1
  1673. else
  1674. low:=mid;
  1675. end;
  1676. if tok2node[high].tok=oldt then
  1677. p1:=gennode(tok2node[high].nod,p1,p2)
  1678. else
  1679. p1:=gennode(nothingn,p1,p2);
  1680. set_tree_filepos(p1,filepos);
  1681. end
  1682. else
  1683. break;
  1684. until false;
  1685. sub_expr:=p1;
  1686. end;
  1687. function comp_expr(accept_equal : boolean):Ptree;
  1688. var
  1689. oldafterassignment : boolean;
  1690. begin
  1691. oldafterassignment:=afterassignment;
  1692. afterassignment:=true;
  1693. comp_expr:=sub_expr(opcompare,accept_equal);
  1694. afterassignment:=oldafterassignment;
  1695. end;
  1696. function expr : ptree;
  1697. var
  1698. p1,p2 : ptree;
  1699. oldafterassignment : boolean;
  1700. oldp1 : ptree;
  1701. filepos : tfileposinfo;
  1702. begin
  1703. oldafterassignment:=afterassignment;
  1704. p1:=sub_expr(opcompare,true);
  1705. if token in [ASSIGNMENT,_PLUSASN,_MINUSASN,_STARASN,_SLASHASN] then
  1706. afterassignment:=true;
  1707. filepos:=tokenpos;
  1708. oldp1:=p1;
  1709. case token of
  1710. POINTPOINT : begin
  1711. consume(POINTPOINT);
  1712. p2:=sub_expr(opcompare,true);
  1713. p1:=gennode(rangen,p1,p2);
  1714. end;
  1715. ASSIGNMENT : begin
  1716. consume(ASSIGNMENT);
  1717. { avoid a firstpass of a procedure if
  1718. it must be assigned to a procvar }
  1719. { should be recursive for a:=b:=c !!! }
  1720. if (p1^.resulttype<>nil) and (p1^.resulttype^.deftype=procvardef) then
  1721. begin
  1722. getprocvar:=true;
  1723. getprocvardef:=pprocvardef(p1^.resulttype);
  1724. end;
  1725. p2:=sub_expr(opcompare,true);
  1726. if getprocvar and (p2^.treetype=calln) and
  1727. (proc_to_procvar_equal(getprocvardef,pprocsym(p2^.symtableentry)^.definition)) then
  1728. begin
  1729. p2^.treetype:=loadn;
  1730. p2^.resulttype:=pprocsym(p2^.symtableprocentry)^.definition;
  1731. p2^.symtableentry:=p2^.symtableprocentry;
  1732. end;
  1733. getprocvar:=false;
  1734. p1:=gennode(assignn,p1,p2);
  1735. end;
  1736. { this is the code for C like assignements }
  1737. { from an improvement of Peter Schaefer }
  1738. _PLUSASN : begin
  1739. consume(_PLUSASN );
  1740. p2:=sub_expr(opcompare,true);
  1741. p1:=gennode(assignn,p1,gennode(addn,getcopy(p1),p2));
  1742. { was first
  1743. p1:=gennode(assignn,p1,gennode(addn,p1,p2));
  1744. but disposetree assumes that we have a real
  1745. *** tree *** }
  1746. end;
  1747. _MINUSASN : begin
  1748. consume(_MINUSASN );
  1749. p2:=sub_expr(opcompare,true);
  1750. p1:=gennode(assignn,p1,gennode(subn,getcopy(p1),p2));
  1751. end;
  1752. _STARASN : begin
  1753. consume(_STARASN );
  1754. p2:=sub_expr(opcompare,true);
  1755. p1:=gennode(assignn,p1,gennode(muln,getcopy(p1),p2));
  1756. end;
  1757. _SLASHASN : begin
  1758. consume(_SLASHASN );
  1759. p2:=sub_expr(opcompare,true);
  1760. p1:=gennode(assignn,p1,gennode(slashn,getcopy(p1),p2));
  1761. end;
  1762. end;
  1763. afterassignment:=oldafterassignment;
  1764. if p1<>oldp1 then
  1765. set_tree_filepos(p1,filepos);
  1766. expr:=p1;
  1767. end;
  1768. function get_intconst:longint;
  1769. {Reads an expression, tries to evalute it and check if it is an integer
  1770. constant. Then the constant is returned.}
  1771. var
  1772. p:Ptree;
  1773. begin
  1774. p:=comp_expr(true);
  1775. do_firstpass(p);
  1776. if (p^.treetype<>ordconstn) and
  1777. (p^.resulttype^.deftype=orddef) and
  1778. not(Porddef(p^.resulttype)^.typ in [uvoid,uchar,bool8bit,bool16bit,bool32bit]) then
  1779. Message(cg_e_illegal_expression)
  1780. else
  1781. get_intconst:=p^.value;
  1782. disposetree(p);
  1783. end;
  1784. function get_stringconst:string;
  1785. {Reads an expression, tries to evaluate it and checks if it is a string
  1786. constant. Then the constant is returned.}
  1787. var
  1788. p:Ptree;
  1789. begin
  1790. get_stringconst:='';
  1791. p:=comp_expr(true);
  1792. do_firstpass(p);
  1793. if p^.treetype<>stringconstn then
  1794. begin
  1795. if (p^.treetype=ordconstn) and is_char(p^.resulttype) then
  1796. get_stringconst:=char(p^.value)
  1797. else
  1798. Message(cg_e_illegal_expression);
  1799. end
  1800. else
  1801. get_stringconst:=strpas(p^.value_str);
  1802. disposetree(p);
  1803. end;
  1804. end.
  1805. {
  1806. $Log$
  1807. Revision 1.73 1998-11-05 12:02:52 peter
  1808. * released useansistring
  1809. * removed -Sv, its now available in fpc modes
  1810. Revision 1.72 1998/11/04 10:11:41 peter
  1811. * ansistring fixes
  1812. Revision 1.71 1998/10/22 23:57:29 peter
  1813. * fixed filedef for typenodetype
  1814. Revision 1.70 1998/10/21 15:12:54 pierre
  1815. * bug fix for IOCHECK inside a procedure with iocheck modifier
  1816. * removed the GPF for unexistant overloading
  1817. (firstcall was called with procedinition=nil !)
  1818. * changed typen to what Florian proposed
  1819. gentypenode(p : pdef) sets the typenodetype field
  1820. and resulttype is only set if inside bt_type block !
  1821. Revision 1.69 1998/10/20 15:10:19 pierre
  1822. * type ptree only allowed inside expression
  1823. if following sizeof typeof low high or as first arg of new !!
  1824. Revision 1.68 1998/10/20 11:15:44 pierre
  1825. * calling of private method allowed inside child object method
  1826. Revision 1.67 1998/10/19 08:54:57 pierre
  1827. * wrong stabs info corrected once again !!
  1828. + variable vmt offset with vmt field only if required
  1829. implemented now !!!
  1830. Revision 1.66 1998/10/15 15:13:28 pierre
  1831. + added oo_hasconstructor and oo_hasdestructor
  1832. for objects options
  1833. Revision 1.65 1998/10/13 13:10:24 peter
  1834. * new style for m68k/i386 infos and enums
  1835. Revision 1.64 1998/10/12 12:20:55 pierre
  1836. + added tai_const_symbol_offset
  1837. for r : pointer = @var.field;
  1838. * better message for different arg names on implementation
  1839. of function
  1840. Revision 1.63 1998/10/12 10:28:30 florian
  1841. + auto dereferencing of pointers to structured types in delphi mode
  1842. Revision 1.62 1998/10/12 10:05:41 peter
  1843. * fixed mem leak with arrayconstrutor
  1844. Revision 1.61 1998/10/05 13:57:15 peter
  1845. * crash preventions
  1846. Revision 1.60 1998/10/05 12:32:46 peter
  1847. + assert() support
  1848. Revision 1.59 1998/10/01 14:56:24 peter
  1849. * crash preventions
  1850. Revision 1.58 1998/09/30 07:40:35 florian
  1851. * better error recovering
  1852. Revision 1.57 1998/09/28 16:18:16 florian
  1853. * two fixes to get ansi strings work
  1854. Revision 1.56 1998/09/26 17:45:36 peter
  1855. + idtoken and only one token table
  1856. Revision 1.55 1998/09/24 23:49:10 peter
  1857. + aktmodeswitches
  1858. Revision 1.54 1998/09/23 15:46:39 florian
  1859. * problem with with and classes fixed
  1860. Revision 1.53 1998/09/23 09:58:54 peter
  1861. * first working array of const things
  1862. Revision 1.52 1998/09/20 09:38:45 florian
  1863. * hasharray for defs fixed
  1864. * ansistring code generation corrected (init/final, assignement)
  1865. Revision 1.51 1998/09/18 16:03:43 florian
  1866. * some changes to compile with Delphi
  1867. Revision 1.50 1998/09/17 13:41:18 pierre
  1868. sizeof(TPOINT) problem
  1869. Revision 1.49.2.1 1998/09/17 08:42:31 pierre
  1870. TPOINT sizeof fix
  1871. Revision 1.49 1998/09/09 11:50:53 pierre
  1872. * forward def are not put in record or objects
  1873. + added check for forwards also in record and objects
  1874. * dummy parasymtable for unit initialization removed from
  1875. symtable stack
  1876. Revision 1.48 1998/09/07 22:25:53 peter
  1877. * fixed str(boolean,string) which was allowed
  1878. * fixed write(' ':<int expression>) only constants where allowed :(
  1879. Revision 1.47 1998/09/07 18:46:10 peter
  1880. * update smartlinking, uses getdatalabel
  1881. * renamed ptree.value vars to value_str,value_real,value_set
  1882. Revision 1.46 1998/09/04 08:42:03 peter
  1883. * updated some error messages
  1884. Revision 1.45 1998/09/01 17:39:49 peter
  1885. + internal constant functions
  1886. Revision 1.44 1998/08/28 10:54:24 peter
  1887. * fixed smallset generation from elements, it has never worked before!
  1888. Revision 1.43 1998/08/23 16:07:24 florian
  1889. * internalerror with mod/div fixed
  1890. Revision 1.42 1998/08/21 14:08:50 pierre
  1891. + TEST_FUNCRET now default (old code removed)
  1892. works also for m68k (at least compiles)
  1893. Revision 1.41 1998/08/20 21:36:39 peter
  1894. * fixed 'with object do' bug
  1895. Revision 1.40 1998/08/20 09:26:41 pierre
  1896. + funcret setting in underproc testing
  1897. compile with _dTEST_FUNCRET
  1898. Revision 1.39 1998/08/18 16:48:48 pierre
  1899. * bug for -So proc assignment to p^rocvar fixed
  1900. Revision 1.38 1998/08/18 14:17:09 pierre
  1901. * bug about assigning the return value of a function to
  1902. a procvar fixed : warning
  1903. assigning a proc to a procvar need @ in FPC mode !!
  1904. * missing file/line info restored
  1905. Revision 1.37 1998/08/18 09:24:43 pierre
  1906. * small warning position bug fixed
  1907. * support_mmx switches splitting was missing
  1908. * rhide error and warning output corrected
  1909. Revision 1.36 1998/08/15 16:50:29 peter
  1910. * fixed proc()=expr which was not allowed anymore by my previous fix
  1911. Revision 1.35 1998/08/14 18:18:46 peter
  1912. + dynamic set contruction
  1913. * smallsets are now working (always longint size)
  1914. Revision 1.34 1998/08/13 11:00:12 peter
  1915. * fixed procedure<>procedure construct
  1916. Revision 1.33 1998/08/11 15:31:39 peter
  1917. * write extended to ppu file
  1918. * new version 0.99.7
  1919. Revision 1.32 1998/08/11 14:05:32 peter
  1920. * fixed sizeof(array of char)
  1921. Revision 1.31 1998/08/10 14:50:11 peter
  1922. + localswitches, moduleswitches, globalswitches splitting
  1923. Revision 1.30 1998/07/28 21:52:54 florian
  1924. + implementation of raise and try..finally
  1925. + some misc. exception stuff
  1926. Revision 1.29 1998/07/27 21:57:13 florian
  1927. * fix to allow tv like stream registration:
  1928. @tmenu.load doesn't work if load had parameters or if load was only
  1929. declared in an anchestor class of tmenu
  1930. Revision 1.28 1998/07/14 21:46:51 peter
  1931. * updated messages file
  1932. Revision 1.27 1998/06/25 14:04:23 peter
  1933. + internal inc/dec
  1934. Revision 1.26 1998/06/09 16:01:46 pierre
  1935. + added procedure directive parsing for procvars
  1936. (accepted are popstack cdecl and pascal)
  1937. + added C vars with the following syntax
  1938. var C calias 'true_c_name';(can be followed by external)
  1939. reason is that you must add the Cprefix
  1940. which is target dependent
  1941. Revision 1.25 1998/06/05 14:37:33 pierre
  1942. * fixes for inline for operators
  1943. * inline procedure more correctly restricted
  1944. Revision 1.24 1998/06/04 23:51:52 peter
  1945. * m68k compiles
  1946. + .def file creation moved to gendef.pas so it could also be used
  1947. for win32
  1948. Revision 1.23 1998/06/04 09:55:40 pierre
  1949. * demangled name of procsym reworked to become independant of the mangling scheme
  1950. Revision 1.22 1998/06/02 17:03:03 pierre
  1951. * with node corrected for objects
  1952. * small bugs for SUPPORT_MMX fixed
  1953. Revision 1.21 1998/05/27 19:45:05 peter
  1954. * symtable.pas splitted into includefiles
  1955. * symtable adapted for $ifdef NEWPPU
  1956. Revision 1.20 1998/05/26 07:53:59 pierre
  1957. * bug fix for empty sets (nil pd was dereferenced )
  1958. Revision 1.19 1998/05/25 17:11:43 pierre
  1959. * firstpasscount bug fixed
  1960. now all is already set correctly the first time
  1961. under EXTDEBUG try -gp to skip all other firstpasses
  1962. it works !!
  1963. * small bug fixes
  1964. - for smallsets with -dTESTSMALLSET
  1965. - some warnings removed (by correcting code !)
  1966. Revision 1.18 1998/05/23 01:21:20 peter
  1967. + aktasmmode, aktoptprocessor, aktoutputformat
  1968. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1969. + $LIBNAME to set the library name where the unit will be put in
  1970. * splitted cgi386 a bit (codeseg to large for bp7)
  1971. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1972. Revision 1.17 1998/05/22 12:37:03 carl
  1973. * crash bugfix (patched msanually to main branch)
  1974. Revision 1.16 1998/05/21 19:33:32 peter
  1975. + better procedure directive handling and only one table
  1976. Revision 1.15 1998/05/20 09:42:35 pierre
  1977. + UseTokenInfo now default
  1978. * unit in interface uses and implementation uses gives error now
  1979. * only one error for unknown symbol (uses lastsymknown boolean)
  1980. the problem came from the label code !
  1981. + first inlined procedures and function work
  1982. (warning there might be allowed cases were the result is still wrong !!)
  1983. * UseBrower updated gives a global list of all position of all used symbols
  1984. with switch -gb
  1985. Revision 1.14 1998/05/11 13:07:56 peter
  1986. + $ifdef NEWPPU for the new ppuformat
  1987. + $define GDB not longer required
  1988. * removed all warnings and stripped some log comments
  1989. * no findfirst/findnext anymore to remove smartlink *.o files
  1990. Revision 1.13 1998/05/06 08:38:45 pierre
  1991. * better position info with UseTokenInfo
  1992. UseTokenInfo greatly simplified
  1993. + added check for changed tree after first time firstpass
  1994. (if we could remove all the cases were it happen
  1995. we could skip all firstpass if firstpasscount > 1)
  1996. Only with ExtDebug
  1997. Revision 1.12 1998/05/05 12:05:42 florian
  1998. * problems with properties fixed
  1999. * crash fixed: i:=l when i and l are undefined, was a problem with
  2000. implementation of private/protected
  2001. Revision 1.11 1998/05/04 11:22:26 florian
  2002. * problem with DOM solved: it crashes when accessing a property in a method
  2003. Revision 1.10 1998/05/01 16:38:45 florian
  2004. * handling of private and protected fixed
  2005. + change_keywords_to_tp implemented to remove
  2006. keywords which aren't supported by tp
  2007. * break and continue are now symbols of the system unit
  2008. + widestring, longstring and ansistring type released
  2009. Revision 1.9 1998/04/29 10:33:58 pierre
  2010. + added some code for ansistring (not complete nor working yet)
  2011. * corrected operator overloading
  2012. * corrected nasm output
  2013. + started inline procedures
  2014. + added starstarn : use ** for exponentiation (^ gave problems)
  2015. + started UseTokenInfo cond to get accurate positions
  2016. Revision 1.8 1998/04/14 23:27:03 florian
  2017. + exclude/include with constant second parameter added
  2018. Revision 1.7 1998/04/09 23:02:15 florian
  2019. * small problems solved to get remake3 work
  2020. Revision 1.6 1998/04/09 22:16:35 florian
  2021. * problem with previous REGALLOC solved
  2022. * improved property support
  2023. Revision 1.5 1998/04/08 10:26:09 florian
  2024. * correct error handling of virtual constructors
  2025. * problem with new type declaration handling fixed
  2026. Revision 1.4 1998/04/07 22:45:05 florian
  2027. * bug0092, bug0115 and bug0121 fixed
  2028. + packed object/class/array
  2029. Revision 1.3 1998/04/07 13:19:46 pierre
  2030. * bugfixes for reset_gdb_info
  2031. in MEM parsing for go32v2
  2032. better external symbol creation
  2033. support for rhgdb.exe (lowercase file names)
  2034. }