pexpr.pas 81 KB

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