pexpr.pas 88 KB

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