pexpr.pas 81 KB

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