pexpr.pas 83 KB

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