pexpr.pas 85 KB

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