pexpr.pas 84 KB

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