pexpr.pas 81 KB

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