pexpr.pas 82 KB

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