pexpr.pas 78 KB

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