pexpr.pas 83 KB

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