pexpr.pas 86 KB

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