pexpr.pas 88 KB

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