pexpr.pas 84 KB

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