pexpr.pas 87 KB

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