pexpr.pas 85 KB

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