pexpr.pas 99 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. symtype,symdef,
  23. node,
  24. globals,
  25. cpuinfo;
  26. { reads a whole expression }
  27. function expr : tnode;
  28. { reads an expression without assignements and .. }
  29. function comp_expr(accept_equal : boolean):tnode;
  30. { reads a single factor }
  31. function factor(getaddr : boolean) : tnode;
  32. procedure string_dec(var t: ttype);
  33. function parse_paras(__colon,in_prop_paras : boolean) : tnode;
  34. { the ID token has to be consumed before calling this function }
  35. procedure do_member_read(classh:tobjectdef;getaddr : boolean;sym : tsym;var p1 : tnode;var again : boolean;callnflags:tnodeflags);
  36. {$ifdef int64funcresok}
  37. function get_intconst:TConstExprInt;
  38. {$else int64funcresok}
  39. function get_intconst:longint;
  40. {$endif int64funcresok}
  41. function get_stringconst:string;
  42. implementation
  43. uses
  44. {$ifdef delphi}
  45. SysUtils,
  46. {$endif}
  47. { common }
  48. cutils,
  49. { global }
  50. globtype,tokens,verbose,
  51. systems,widestr,
  52. { symtable }
  53. symconst,symbase,symsym,symtable,defutil,defcmp,
  54. { pass 1 }
  55. pass_1,htypechk,
  56. nmat,nadd,ncal,nmem,nset,ncnv,ninl,ncon,nld,nflw,nbas,
  57. { parser }
  58. scanner,
  59. pbase,pinline,
  60. { codegen }
  61. procinfo
  62. ;
  63. { sub_expr(opmultiply) is need to get -1 ** 4 to be
  64. read as - (1**4) and not (-1)**4 PM }
  65. type
  66. Toperator_precedence=(opcompare,opaddition,opmultiply,oppower);
  67. const
  68. highest_precedence = oppower;
  69. function sub_expr(pred_level:Toperator_precedence;accept_equal : boolean):tnode;forward;
  70. const
  71. { true, if the inherited call is anonymous }
  72. anon_inherited : boolean = false;
  73. procedure string_dec(var t: ttype);
  74. { reads a string type with optional length }
  75. { and returns a pointer to the string }
  76. { definition }
  77. var
  78. p : tnode;
  79. begin
  80. t:=cshortstringtype;
  81. consume(_STRING);
  82. if token=_LECKKLAMMER then
  83. begin
  84. consume(_LECKKLAMMER);
  85. p:=comp_expr(true);
  86. if not is_constintnode(p) then
  87. begin
  88. Message(cg_e_illegal_expression);
  89. { error recovery }
  90. consume(_RECKKLAMMER);
  91. end
  92. else
  93. begin
  94. if (tordconstnode(p).value<=0) then
  95. begin
  96. Message(parser_e_invalid_string_size);
  97. tordconstnode(p).value:=255;
  98. end;
  99. consume(_RECKKLAMMER);
  100. if tordconstnode(p).value>255 then
  101. begin
  102. { longstring is currently unsupported (CEC)! }
  103. { t.setdef(tstringdef.createlong(tordconstnode(p).value))}
  104. Message(parser_e_invalid_string_size);
  105. tordconstnode(p).value:=255;
  106. t.setdef(tstringdef.createshort(tordconstnode(p).value));
  107. end
  108. else
  109. if tordconstnode(p).value<>255 then
  110. t.setdef(tstringdef.createshort(tordconstnode(p).value));
  111. end;
  112. p.free;
  113. end
  114. else
  115. begin
  116. if cs_ansistrings in aktlocalswitches then
  117. t:=cansistringtype
  118. else
  119. t:=cshortstringtype;
  120. end;
  121. end;
  122. function parse_paras(__colon,in_prop_paras : boolean) : tnode;
  123. var
  124. p1,p2 : tnode;
  125. end_of_paras : ttoken;
  126. prev_in_args : boolean;
  127. old_allow_array_constructor : boolean;
  128. begin
  129. if in_prop_paras then
  130. end_of_paras:=_RECKKLAMMER
  131. else
  132. end_of_paras:=_RKLAMMER;
  133. if token=end_of_paras then
  134. begin
  135. parse_paras:=nil;
  136. exit;
  137. end;
  138. { save old values }
  139. prev_in_args:=in_args;
  140. old_allow_array_constructor:=allow_array_constructor;
  141. { set para parsing values }
  142. in_args:=true;
  143. inc(parsing_para_level);
  144. allow_array_constructor:=true;
  145. p2:=nil;
  146. while true do
  147. begin
  148. p1:=comp_expr(true);
  149. p2:=ccallparanode.create(p1,p2);
  150. { it's for the str(l:5,s); }
  151. if __colon and (token=_COLON) then
  152. begin
  153. consume(_COLON);
  154. p1:=comp_expr(true);
  155. p2:=ccallparanode.create(p1,p2);
  156. include(tcallparanode(p2).callparaflags,cpf_is_colon_para);
  157. if token=_COLON then
  158. begin
  159. consume(_COLON);
  160. p1:=comp_expr(true);
  161. p2:=ccallparanode.create(p1,p2);
  162. include(tcallparanode(p2).callparaflags,cpf_is_colon_para);
  163. end
  164. end;
  165. if token=_COMMA then
  166. consume(_COMMA)
  167. else
  168. break;
  169. end;
  170. allow_array_constructor:=old_allow_array_constructor;
  171. dec(parsing_para_level);
  172. in_args:=prev_in_args;
  173. parse_paras:=p2;
  174. end;
  175. procedure check_tp_procvar(var p : tnode);
  176. var
  177. hp,
  178. p1 : tnode;
  179. begin
  180. if (m_tp_procvar in aktmodeswitches) and
  181. (token<>_ASSIGNMENT) and
  182. (not got_addrn) and
  183. (block_type=bt_general) then
  184. begin
  185. { ignore vecn,subscriptn }
  186. hp:=p;
  187. repeat
  188. case hp.nodetype of
  189. vecn :
  190. hp:=tvecnode(hp).left;
  191. subscriptn :
  192. hp:=tsubscriptnode(hp).left;
  193. else
  194. break;
  195. end;
  196. until false;
  197. if (hp.nodetype=loadn) then
  198. begin
  199. { get the resulttype of p }
  200. do_resulttypepass(p);
  201. { convert the procvar load to a call:
  202. - not expecting a procvar
  203. - the procvar does not get arguments, when it
  204. requires arguments the callnode will fail
  205. Note: When arguments were passed there was no loadn }
  206. if (getprocvardef=nil) and
  207. (p.resulttype.def.deftype=procvardef) and
  208. (tprocvardef(p.resulttype.def).minparacount=0) then
  209. begin
  210. p1:=ccallnode.create_procvar(nil,p);
  211. resulttypepass(p1);
  212. p:=p1;
  213. end;
  214. end;
  215. end;
  216. end;
  217. function statement_syssym(l : longint) : tnode;
  218. var
  219. p1,p2,paras : tnode;
  220. err,
  221. prev_in_args : boolean;
  222. begin
  223. prev_in_args:=in_args;
  224. case l of
  225. in_new_x :
  226. begin
  227. if afterassignment or in_args then
  228. statement_syssym:=new_function
  229. else
  230. statement_syssym:=new_dispose_statement(true);
  231. end;
  232. in_dispose_x :
  233. begin
  234. statement_syssym:=new_dispose_statement(false);
  235. end;
  236. in_ord_x :
  237. begin
  238. consume(_LKLAMMER);
  239. in_args:=true;
  240. p1:=comp_expr(true);
  241. consume(_RKLAMMER);
  242. p1:=geninlinenode(in_ord_x,false,p1);
  243. statement_syssym := p1;
  244. end;
  245. in_exit :
  246. begin
  247. if try_to_consume(_LKLAMMER) then
  248. begin
  249. p1:=comp_expr(true);
  250. consume(_RKLAMMER);
  251. if (block_type=bt_except) then
  252. Message(parser_e_exit_with_argument_not__possible);
  253. if (not assigned(current_procinfo) or
  254. is_void(current_procinfo.procdef.rettype.def)) then
  255. Message(parser_e_void_function);
  256. end
  257. else
  258. p1:=nil;
  259. statement_syssym:=cexitnode.create(p1);
  260. end;
  261. in_break :
  262. begin
  263. statement_syssym:=cbreaknode.create;
  264. end;
  265. in_continue :
  266. begin
  267. statement_syssym:=ccontinuenode.create;
  268. end;
  269. in_typeof_x :
  270. begin
  271. consume(_LKLAMMER);
  272. in_args:=true;
  273. p1:=comp_expr(true);
  274. consume(_RKLAMMER);
  275. if p1.nodetype=typen then
  276. ttypenode(p1).allowed:=true;
  277. { Allow classrefdef, which is required for
  278. Typeof(self) in static class methods }
  279. if (p1.resulttype.def.deftype = objectdef) or
  280. (assigned(current_procinfo) and
  281. ((po_classmethod in current_procinfo.procdef.procoptions) or
  282. (po_staticmethod in current_procinfo.procdef.procoptions)) and
  283. (p1.resulttype.def.deftype=classrefdef)) then
  284. statement_syssym:=geninlinenode(in_typeof_x,false,p1)
  285. else
  286. begin
  287. Message(parser_e_class_id_expected);
  288. p1.destroy;
  289. statement_syssym:=cerrornode.create;
  290. end;
  291. end;
  292. in_sizeof_x :
  293. begin
  294. consume(_LKLAMMER);
  295. in_args:=true;
  296. p1:=comp_expr(true);
  297. consume(_RKLAMMER);
  298. if (p1.nodetype<>typen) and
  299. (
  300. (is_object(p1.resulttype.def) and
  301. (oo_has_constructor in tobjectdef(p1.resulttype.def).objectoptions)) or
  302. is_open_array(p1.resulttype.def) or
  303. is_open_string(p1.resulttype.def)
  304. ) then
  305. statement_syssym:=geninlinenode(in_sizeof_x,false,p1)
  306. else
  307. begin
  308. statement_syssym:=cordconstnode.create(p1.resulttype.def.size,s32bittype,true);
  309. { p1 not needed !}
  310. p1.destroy;
  311. end;
  312. end;
  313. in_typeinfo_x :
  314. begin
  315. consume(_LKLAMMER);
  316. in_args:=true;
  317. p1:=comp_expr(true);
  318. if p1.nodetype=typen then
  319. ttypenode(p1).allowed:=true
  320. else
  321. begin
  322. p1.destroy;
  323. p1:=cerrornode.create;
  324. Message(parser_e_illegal_parameter_list);
  325. end;
  326. consume(_RKLAMMER);
  327. p2:=geninlinenode(in_typeinfo_x,false,p1);
  328. statement_syssym:=p2;
  329. end;
  330. in_assigned_x :
  331. begin
  332. err:=false;
  333. consume(_LKLAMMER);
  334. in_args:=true;
  335. p1:=comp_expr(true);
  336. if not codegenerror then
  337. begin
  338. { With tp procvars we allways need to load a
  339. procvar when it is passed, but not when the
  340. callnode is inserted due a property }
  341. if (m_tp_procvar in aktmodeswitches) and
  342. (p1.nodetype=calln) and
  343. not(nf_isproperty in tcallnode(p1).flags) then
  344. load_procvar_from_calln(p1);
  345. case p1.resulttype.def.deftype of
  346. pointerdef,
  347. procvardef,
  348. classrefdef : ;
  349. objectdef :
  350. if not is_class_or_interface(p1.resulttype.def) then
  351. begin
  352. Message(parser_e_illegal_parameter_list);
  353. err:=true;
  354. end;
  355. else
  356. begin
  357. Message(parser_e_illegal_parameter_list);
  358. err:=true;
  359. end;
  360. end;
  361. end
  362. else
  363. err:=true;
  364. if not err then
  365. begin
  366. p2:=ccallparanode.create(p1,nil);
  367. p2:=geninlinenode(in_assigned_x,false,p2);
  368. end
  369. else
  370. begin
  371. p1.free;
  372. p2:=cerrornode.create;
  373. end;
  374. consume(_RKLAMMER);
  375. statement_syssym:=p2;
  376. end;
  377. in_addr_x :
  378. begin
  379. consume(_LKLAMMER);
  380. in_args:=true;
  381. p1:=comp_expr(true);
  382. p1:=caddrnode.create(p1);
  383. consume(_RKLAMMER);
  384. statement_syssym:=p1;
  385. end;
  386. in_ofs_x :
  387. begin
  388. consume(_LKLAMMER);
  389. in_args:=true;
  390. p1:=comp_expr(true);
  391. p1:=caddrnode.create(p1);
  392. do_resulttypepass(p1);
  393. { Ofs() returns a cardinal, not a pointer }
  394. p1.resulttype:=u32bittype;
  395. consume(_RKLAMMER);
  396. statement_syssym:=p1;
  397. end;
  398. in_seg_x :
  399. begin
  400. consume(_LKLAMMER);
  401. in_args:=true;
  402. p1:=comp_expr(true);
  403. p1:=geninlinenode(in_seg_x,false,p1);
  404. consume(_RKLAMMER);
  405. statement_syssym:=p1;
  406. end;
  407. in_high_x,
  408. in_low_x :
  409. begin
  410. consume(_LKLAMMER);
  411. in_args:=true;
  412. p1:=comp_expr(true);
  413. p2:=geninlinenode(l,false,p1);
  414. consume(_RKLAMMER);
  415. statement_syssym:=p2;
  416. end;
  417. in_succ_x,
  418. in_pred_x :
  419. begin
  420. consume(_LKLAMMER);
  421. in_args:=true;
  422. p1:=comp_expr(true);
  423. p2:=geninlinenode(l,false,p1);
  424. consume(_RKLAMMER);
  425. statement_syssym:=p2;
  426. end;
  427. in_inc_x,
  428. in_dec_x :
  429. begin
  430. consume(_LKLAMMER);
  431. in_args:=true;
  432. p1:=comp_expr(true);
  433. if token=_COMMA then
  434. begin
  435. consume(_COMMA);
  436. p2:=ccallparanode.create(comp_expr(true),nil);
  437. end
  438. else
  439. p2:=nil;
  440. p2:=ccallparanode.create(p1,p2);
  441. statement_syssym:=geninlinenode(l,false,p2);
  442. consume(_RKLAMMER);
  443. end;
  444. in_finalize_x:
  445. begin
  446. statement_syssym:=inline_finalize;
  447. end;
  448. in_copy_x:
  449. begin
  450. statement_syssym:=inline_copy;
  451. end;
  452. in_concat_x :
  453. begin
  454. consume(_LKLAMMER);
  455. in_args:=true;
  456. p2:=nil;
  457. while true do
  458. begin
  459. p1:=comp_expr(true);
  460. set_varstate(p1,vs_used,true);
  461. if not((p1.resulttype.def.deftype=stringdef) or
  462. ((p1.resulttype.def.deftype=orddef) and
  463. (torddef(p1.resulttype.def).typ=uchar))) then
  464. Message(parser_e_illegal_parameter_list);
  465. if p2<>nil then
  466. p2:=caddnode.create(addn,p2,p1)
  467. else
  468. p2:=p1;
  469. if token=_COMMA then
  470. consume(_COMMA)
  471. else
  472. break;
  473. end;
  474. consume(_RKLAMMER);
  475. statement_syssym:=p2;
  476. end;
  477. in_read_x,
  478. in_readln_x :
  479. begin
  480. if token=_LKLAMMER then
  481. begin
  482. consume(_LKLAMMER);
  483. paras:=parse_paras(false,false);
  484. consume(_RKLAMMER);
  485. end
  486. else
  487. paras:=nil;
  488. p1:=geninlinenode(l,false,paras);
  489. statement_syssym := p1;
  490. end;
  491. in_setlength_x:
  492. begin
  493. statement_syssym := inline_setlength;
  494. end;
  495. in_length_x:
  496. begin
  497. consume(_LKLAMMER);
  498. in_args:=true;
  499. p1:=comp_expr(true);
  500. p2:=geninlinenode(l,false,p1);
  501. consume(_RKLAMMER);
  502. statement_syssym:=p2;
  503. end;
  504. in_write_x,
  505. in_writeln_x :
  506. begin
  507. if token=_LKLAMMER then
  508. begin
  509. consume(_LKLAMMER);
  510. paras:=parse_paras(true,false);
  511. consume(_RKLAMMER);
  512. end
  513. else
  514. paras:=nil;
  515. p1 := geninlinenode(l,false,paras);
  516. statement_syssym := p1;
  517. end;
  518. in_str_x_string :
  519. begin
  520. consume(_LKLAMMER);
  521. paras:=parse_paras(true,false);
  522. consume(_RKLAMMER);
  523. p1 := geninlinenode(l,false,paras);
  524. statement_syssym := p1;
  525. end;
  526. in_val_x:
  527. Begin
  528. consume(_LKLAMMER);
  529. in_args := true;
  530. p1:= ccallparanode.create(comp_expr(true), nil);
  531. consume(_COMMA);
  532. p2 := ccallparanode.create(comp_expr(true),p1);
  533. if (token = _COMMA) then
  534. Begin
  535. consume(_COMMA);
  536. p2 := ccallparanode.create(comp_expr(true),p2)
  537. End;
  538. consume(_RKLAMMER);
  539. p2 := geninlinenode(l,false,p2);
  540. statement_syssym := p2;
  541. End;
  542. in_include_x_y,
  543. in_exclude_x_y :
  544. begin
  545. consume(_LKLAMMER);
  546. in_args:=true;
  547. p1:=comp_expr(true);
  548. consume(_COMMA);
  549. p2:=comp_expr(true);
  550. statement_syssym:=geninlinenode(l,false,ccallparanode.create(p1,ccallparanode.create(p2,nil)));
  551. consume(_RKLAMMER);
  552. end;
  553. in_assert_x_y :
  554. begin
  555. consume(_LKLAMMER);
  556. in_args:=true;
  557. p1:=comp_expr(true);
  558. if token=_COMMA then
  559. begin
  560. consume(_COMMA);
  561. p2:=comp_expr(true);
  562. end
  563. else
  564. begin
  565. { then insert an empty string }
  566. p2:=cstringconstnode.createstr('',st_default);
  567. end;
  568. statement_syssym:=geninlinenode(l,false,ccallparanode.create(p1,ccallparanode.create(p2,nil)));
  569. consume(_RKLAMMER);
  570. end;
  571. else
  572. internalerror(15);
  573. end;
  574. in_args:=prev_in_args;
  575. end;
  576. function maybe_load_methodpointer(st:tsymtable;var p1:tnode):boolean;
  577. begin
  578. maybe_load_methodpointer:=false;
  579. if not assigned(p1) then
  580. begin
  581. case st.symtabletype of
  582. withsymtable :
  583. begin
  584. if (st.defowner.deftype=objectdef) then
  585. p1:=tnode(twithsymtable(st).withrefnode).getcopy;
  586. end;
  587. objectsymtable :
  588. begin
  589. p1:=load_self_node;
  590. { We are calling a member }
  591. maybe_load_methodpointer:=true;
  592. end;
  593. end;
  594. end;
  595. end;
  596. { reads the parameter for a subroutine call }
  597. procedure do_proc_call(sym:tsym;st:tsymtable;obj:tobjectdef;getaddr:boolean;var again : boolean;var p1:tnode);
  598. var
  599. membercall,
  600. prevafterassn : boolean;
  601. vs : tvarsym;
  602. para,p2 : tnode;
  603. currpara : tparaitem;
  604. aprocdef : tprocdef;
  605. begin
  606. prevafterassn:=afterassignment;
  607. afterassignment:=false;
  608. membercall:=false;
  609. aprocdef:=nil;
  610. { when it is a call to a member we need to load the
  611. methodpointer first }
  612. membercall:=maybe_load_methodpointer(st,p1);
  613. { When we are expecting a procvar we also need
  614. to get the address in some cases }
  615. if assigned(getprocvardef) then
  616. begin
  617. if (block_type=bt_const) or
  618. getaddr then
  619. begin
  620. aprocdef:=Tprocsym(sym).search_procdef_byprocvardef(getprocvardef);
  621. getaddr:=true;
  622. end
  623. else
  624. if (m_tp_procvar in aktmodeswitches) then
  625. begin
  626. aprocdef:=Tprocsym(sym).search_procdef_byprocvardef(getprocvardef);
  627. if assigned(aprocdef) then
  628. getaddr:=true;
  629. end;
  630. end;
  631. { only need to get the address of the procedure? }
  632. if getaddr then
  633. begin
  634. { Retrieve info which procvar to call. For tp_procvar the
  635. aprocdef is already loaded above so we can reuse it }
  636. if not assigned(aprocdef) and
  637. assigned(getprocvardef) then
  638. aprocdef:=Tprocsym(sym).search_procdef_byprocvardef(getprocvardef);
  639. { generate a methodcallnode or proccallnode }
  640. { we shouldn't convert things like @tcollection.load }
  641. p2:=cloadnode.create_procvar(sym,aprocdef,st);
  642. if assigned(p1) then
  643. begin
  644. if (p1.nodetype<>typen) then
  645. tloadnode(p2).set_mp(p1)
  646. else
  647. p1.free;
  648. end;
  649. p1:=p2;
  650. { no postfix operators }
  651. again:=false;
  652. end
  653. else
  654. begin
  655. para:=nil;
  656. if anon_inherited then
  657. begin
  658. if not assigned(current_procinfo) then
  659. internalerror(200305054);
  660. currpara:=tparaitem(current_procinfo.procdef.para.first);
  661. while assigned(currpara) do
  662. begin
  663. if not currpara.is_hidden then
  664. begin
  665. vs:=tvarsym(currpara.parasym);
  666. para:=ccallparanode.create(cloadnode.create(vs,vs.owner),para);
  667. end;
  668. currpara:=tparaitem(currpara.next);
  669. end;
  670. end
  671. else
  672. begin
  673. if try_to_consume(_LKLAMMER) then
  674. begin
  675. para:=parse_paras(false,false);
  676. consume(_RKLAMMER);
  677. end;
  678. end;
  679. if assigned(obj) then
  680. begin
  681. if (st.symtabletype<>objectsymtable) then
  682. internalerror(200310031);
  683. p1:=ccallnode.create(para,tprocsym(sym),obj.symtable,p1);
  684. end
  685. else
  686. p1:=ccallnode.create(para,tprocsym(sym),st,p1);
  687. { indicate if this call was generated by a member and
  688. no explicit self is used, this is needed to determine
  689. how to handle a destructor call (PFV) }
  690. if membercall then
  691. include(p1.flags,nf_member_call);
  692. end;
  693. afterassignment:=prevafterassn;
  694. end;
  695. procedure handle_procvar(pv : tprocvardef;var p2 : tnode);
  696. var
  697. hp,hp2 : tnode;
  698. hpp : ^tnode;
  699. currprocdef : tprocdef;
  700. begin
  701. if not assigned(pv) then
  702. internalerror(200301121);
  703. if (m_tp_procvar in aktmodeswitches) then
  704. begin
  705. hp:=p2;
  706. hpp:=@p2;
  707. while assigned(hp) and
  708. (hp.nodetype=typeconvn) do
  709. begin
  710. hp:=ttypeconvnode(hp).left;
  711. { save orignal address of the old tree so we can replace the node }
  712. hpp:=@hp;
  713. end;
  714. if (hp.nodetype=calln) and
  715. { a procvar can't have parameters! }
  716. not assigned(tcallnode(hp).left) then
  717. begin
  718. currprocdef:=tcallnode(hp).symtableprocentry.search_procdef_byprocvardef(pv);
  719. if assigned(currprocdef) then
  720. begin
  721. hp2:=cloadnode.create_procvar(tprocsym(tcallnode(hp).symtableprocentry),currprocdef,tcallnode(hp).symtableproc);
  722. if (po_methodpointer in pv.procoptions) then
  723. tloadnode(hp2).set_mp(tnode(tcallnode(hp).methodpointer).getcopy);
  724. hp.destroy;
  725. { replace the old callnode with the new loadnode }
  726. hpp^:=hp2;
  727. end;
  728. end;
  729. end;
  730. end;
  731. { the following procedure handles the access to a property symbol }
  732. procedure handle_propertysym(sym : tsym;st : tsymtable;var p1 : tnode);
  733. procedure symlist_to_node(var p1:tnode;pl:tsymlist);
  734. var
  735. plist : psymlistitem;
  736. begin
  737. plist:=pl.firstsym;
  738. while assigned(plist) do
  739. begin
  740. case plist^.sltype of
  741. sl_load :
  742. begin
  743. { p1 can already contain the loadnode of
  744. the class variable. When there is no tree yet we
  745. may need to load it for with or objects }
  746. if not assigned(p1) then
  747. begin
  748. case st.symtabletype of
  749. withsymtable :
  750. p1:=tnode(twithsymtable(st).withrefnode).getcopy;
  751. objectsymtable :
  752. p1:=load_self_node;
  753. end;
  754. end;
  755. if assigned(p1) then
  756. p1:=csubscriptnode.create(plist^.sym,p1)
  757. else
  758. p1:=cloadnode.create(plist^.sym,st);
  759. end;
  760. sl_subscript :
  761. p1:=csubscriptnode.create(plist^.sym,p1);
  762. sl_vec :
  763. p1:=cvecnode.create(p1,cordconstnode.create(plist^.value,s32bittype,true));
  764. else
  765. internalerror(200110205);
  766. end;
  767. plist:=plist^.next;
  768. end;
  769. include(p1.flags,nf_isproperty);
  770. end;
  771. var
  772. paras : tnode;
  773. p2 : tnode;
  774. membercall : boolean;
  775. begin
  776. paras:=nil;
  777. { property parameters? read them only if the property really }
  778. { has parameters }
  779. if (ppo_hasparameters in tpropertysym(sym).propoptions) then
  780. begin
  781. if token=_LECKKLAMMER then
  782. begin
  783. consume(_LECKKLAMMER);
  784. paras:=parse_paras(false,true);
  785. consume(_RECKKLAMMER);
  786. end;
  787. end;
  788. { indexed property }
  789. if (ppo_indexed in tpropertysym(sym).propoptions) then
  790. begin
  791. p2:=cordconstnode.create(tpropertysym(sym).index,tpropertysym(sym).indextype,true);
  792. paras:=ccallparanode.create(p2,paras);
  793. end;
  794. { we need only a write property if a := follows }
  795. { if not(afterassignment) and not(in_args) then }
  796. if token=_ASSIGNMENT then
  797. begin
  798. { write property: }
  799. if not tpropertysym(sym).writeaccess.empty then
  800. begin
  801. case tpropertysym(sym).writeaccess.firstsym^.sym.typ of
  802. procsym :
  803. begin
  804. { generate the method call }
  805. membercall:=maybe_load_methodpointer(st,p1);
  806. p1:=ccallnode.create(paras,
  807. tprocsym(tpropertysym(sym).writeaccess.firstsym^.sym),st,p1);
  808. if membercall then
  809. include(tcallnode(p1).flags,nf_member_call);
  810. paras:=nil;
  811. consume(_ASSIGNMENT);
  812. { read the expression }
  813. if tpropertysym(sym).proptype.def.deftype=procvardef then
  814. getprocvardef:=tprocvardef(tpropertysym(sym).proptype.def);
  815. p2:=comp_expr(true);
  816. if assigned(getprocvardef) then
  817. handle_procvar(getprocvardef,p2);
  818. tcallnode(p1).left:=ccallparanode.create(p2,tcallnode(p1).left);
  819. include(tcallnode(p1).flags,nf_isproperty);
  820. getprocvardef:=nil;
  821. end;
  822. varsym :
  823. begin
  824. { generate access code }
  825. symlist_to_node(p1,tpropertysym(sym).writeaccess);
  826. consume(_ASSIGNMENT);
  827. { read the expression }
  828. p2:=comp_expr(true);
  829. p1:=cassignmentnode.create(p1,p2);
  830. end
  831. else
  832. begin
  833. p1:=cerrornode.create;
  834. Message(parser_e_no_procedure_to_access_property);
  835. end;
  836. end;
  837. end
  838. else
  839. begin
  840. p1:=cerrornode.create;
  841. Message(parser_e_no_procedure_to_access_property);
  842. end;
  843. end
  844. else
  845. begin
  846. { read property: }
  847. if not tpropertysym(sym).readaccess.empty then
  848. begin
  849. case tpropertysym(sym).readaccess.firstsym^.sym.typ of
  850. varsym :
  851. begin
  852. { generate access code }
  853. symlist_to_node(p1,tpropertysym(sym).readaccess);
  854. end;
  855. procsym :
  856. begin
  857. { generate the method call }
  858. membercall:=maybe_load_methodpointer(st,p1);
  859. p1:=ccallnode.create(paras,tprocsym(tpropertysym(sym).readaccess.firstsym^.sym),st,p1);
  860. if membercall then
  861. include(tcallnode(p1).flags,nf_member_call);
  862. paras:=nil;
  863. include(p1.flags,nf_isproperty);
  864. end
  865. else
  866. begin
  867. p1:=cerrornode.create;
  868. Message(type_e_mismatch);
  869. end;
  870. end;
  871. end
  872. else
  873. begin
  874. { error, no function to read property }
  875. p1:=cerrornode.create;
  876. Message(parser_e_no_procedure_to_access_property);
  877. end;
  878. end;
  879. { release paras if not used }
  880. if assigned(paras) then
  881. paras.free;
  882. end;
  883. { the ID token has to be consumed before calling this function }
  884. procedure do_member_read(classh:tobjectdef;getaddr : boolean;sym : tsym;var p1 : tnode;var again : boolean;callnflags:tnodeflags);
  885. var
  886. static_name : string;
  887. isclassref : boolean;
  888. srsymtable : tsymtable;
  889. {$ifdef CHECKINHERITEDRESULT}
  890. newstatement : tstatementnode;
  891. newblock : tblocknode;
  892. {$endif CHECKINHERITEDRESULT}
  893. begin
  894. if sym=nil then
  895. begin
  896. { pattern is still valid unless
  897. there is another ID just after the ID of sym }
  898. Message1(sym_e_id_no_member,pattern);
  899. p1.free;
  900. p1:=cerrornode.create;
  901. { try to clean up }
  902. again:=false;
  903. end
  904. else
  905. begin
  906. if assigned(p1) then
  907. begin
  908. if not assigned(p1.resulttype.def) then
  909. do_resulttypepass(p1);
  910. isclassref:=(p1.resulttype.def.deftype=classrefdef);
  911. end
  912. else
  913. isclassref:=false;
  914. { we assume, that only procsyms and varsyms are in an object }
  915. { symbol table, for classes, properties are allowed }
  916. case sym.typ of
  917. procsym:
  918. begin
  919. do_proc_call(sym,sym.owner,classh,
  920. (getaddr and not(token in [_CARET,_POINT])),
  921. again,p1);
  922. { add provided flags }
  923. if (p1.nodetype=calln) then
  924. p1.flags:=p1.flags+callnflags;
  925. { we need to know which procedure is called }
  926. do_resulttypepass(p1);
  927. { now we know the method that is called }
  928. if (p1.nodetype=calln) and
  929. assigned(tcallnode(p1).procdefinition) then
  930. begin
  931. { calling using classref? }
  932. if isclassref and
  933. not(po_classmethod in tcallnode(p1).procdefinition.procoptions) and
  934. not(tcallnode(p1).procdefinition.proctypeoption=potype_constructor) then
  935. Message(parser_e_only_class_methods_via_class_ref);
  936. {$ifdef CHECKINHERITEDRESULT}
  937. { when calling inherited constructor we need to check the return value }
  938. if (nf_inherited in callnflags) and
  939. (tcallnode(p1).procdefinition.proctypeoption=potype_constructor) then
  940. begin
  941. {
  942. For Classes:
  943. self:=inherited constructor
  944. if self=nil then
  945. exit
  946. For objects:
  947. if inherited constructor=false then
  948. begin
  949. self:=nil;
  950. exit;
  951. end;
  952. }
  953. if is_class(tprocdef(tcallnode(p1).procdefinition)._class) then
  954. begin
  955. newblock:=internalstatements(newstatement,true);
  956. addstatement(newstatement,cassignmentnode.create(
  957. ctypeconvnode.create(
  958. load_self_pointer_node,
  959. voidpointertype),
  960. ctypeconvnode.create(
  961. p1,
  962. voidpointertype)));
  963. addstatement(newstatement,cifnode.create(
  964. caddnode.create(equaln,
  965. load_self_pointer_node,
  966. cnilnode.create),
  967. cexitnode.create(nil),
  968. nil));
  969. p1:=newblock;
  970. end
  971. else
  972. if is_object(tprocdef(tcallnode(p1).procdefinition)._class) then
  973. begin
  974. newblock:=internalstatements(newstatement,true);
  975. addstatement(newstatement,call_fail_node);
  976. addstatement(newstatement,cexitnode.create(nil));
  977. p1:=cifnode.create(
  978. caddnode.create(equaln,
  979. cordconstnode.create(0,booltype,false),
  980. p1),
  981. newblock,
  982. nil);
  983. end
  984. else
  985. internalerror(200305133);
  986. end;
  987. {$endif CHECKINHERITEDRESULT}
  988. do_resulttypepass(p1);
  989. end;
  990. end;
  991. varsym:
  992. begin
  993. if (sp_static in sym.symoptions) then
  994. begin
  995. static_name:=lower(sym.owner.name^)+'_'+sym.name;
  996. searchsym(static_name,sym,srsymtable);
  997. check_hints(sym);
  998. p1.free;
  999. p1:=cloadnode.create(sym,srsymtable);
  1000. end
  1001. else
  1002. begin
  1003. if isclassref then
  1004. Message(parser_e_only_class_methods_via_class_ref);
  1005. p1:=csubscriptnode.create(sym,p1);
  1006. end;
  1007. end;
  1008. propertysym:
  1009. begin
  1010. if isclassref then
  1011. Message(parser_e_only_class_methods_via_class_ref);
  1012. handle_propertysym(sym,sym.owner,p1);
  1013. end;
  1014. else internalerror(16);
  1015. end;
  1016. end;
  1017. end;
  1018. {****************************************************************************
  1019. Factor
  1020. ****************************************************************************}
  1021. {$ifdef fpc}
  1022. {$maxfpuregisters 0}
  1023. {$endif fpc}
  1024. function factor(getaddr : boolean) : tnode;
  1025. {---------------------------------------------
  1026. Factor_read_id
  1027. ---------------------------------------------}
  1028. procedure factor_read_id(var p1:tnode;var again:boolean);
  1029. var
  1030. pc : pchar;
  1031. len : longint;
  1032. srsym : tsym;
  1033. possible_error : boolean;
  1034. srsymtable : tsymtable;
  1035. storesymtablestack : tsymtable;
  1036. htype : ttype;
  1037. static_name : string;
  1038. begin
  1039. { allow post fix operators }
  1040. again:=true;
  1041. consume_sym(srsym,srsymtable);
  1042. { Access to funcret or need to call the function? }
  1043. if (srsym.typ in [absolutesym,varsym]) and
  1044. (vo_is_funcret in tvarsym(srsym).varoptions) and
  1045. (
  1046. (token=_LKLAMMER) or
  1047. (not(m_fpc in aktmodeswitches) and
  1048. (afterassignment or in_args) and
  1049. not(vo_is_result in tvarsym(srsym).varoptions))
  1050. ) then
  1051. begin
  1052. storesymtablestack:=symtablestack;
  1053. symtablestack:=srsym.owner.next;
  1054. searchsym(srsym.name,srsym,srsymtable);
  1055. if not assigned(srsym) then
  1056. srsym:=generrorsym;
  1057. if (srsym.typ<>procsym) then
  1058. Message(cg_e_illegal_expression);
  1059. symtablestack:=storesymtablestack;
  1060. end;
  1061. begin
  1062. { check semantics of private }
  1063. if (srsym.typ in [propertysym,procsym,varsym]) and
  1064. (srsym.owner.symtabletype=objectsymtable) then
  1065. begin
  1066. if (sp_private in srsym.symoptions) and
  1067. (tobjectdef(srsym.owner.defowner).owner.symtabletype=globalsymtable) and
  1068. (tobjectdef(srsym.owner.defowner).owner.unitid<>0) then
  1069. Message(parser_e_cant_access_private_member);
  1070. end;
  1071. case srsym.typ of
  1072. absolutesym :
  1073. begin
  1074. p1:=cloadnode.create(srsym,srsymtable);
  1075. end;
  1076. varsym :
  1077. begin
  1078. if (sp_static in srsym.symoptions) then
  1079. begin
  1080. static_name:=lower(srsym.owner.name^)+'_'+srsym.name;
  1081. searchsym(static_name,srsym,srsymtable);
  1082. check_hints(srsym);
  1083. end
  1084. else
  1085. begin
  1086. { are we in a class method, we check here the
  1087. srsymtable, because a field in another object
  1088. also has objectsymtable. And withsymtable is
  1089. not possible for self in class methods (PFV) }
  1090. if (srsymtable.symtabletype=objectsymtable) and
  1091. assigned(current_procinfo) and
  1092. (po_classmethod in current_procinfo.procdef.procoptions) then
  1093. Message(parser_e_only_class_methods);
  1094. end;
  1095. case srsymtable.symtabletype of
  1096. objectsymtable :
  1097. p1:=csubscriptnode.create(srsym,load_self_node);
  1098. withsymtable :
  1099. p1:=csubscriptnode.create(srsym,tnode(twithsymtable(srsymtable).withrefnode).getcopy);
  1100. else
  1101. p1:=cloadnode.create(srsym,srsymtable);
  1102. end;
  1103. end;
  1104. typedconstsym :
  1105. begin
  1106. p1:=cloadnode.create(srsym,srsymtable);
  1107. end;
  1108. syssym :
  1109. begin
  1110. p1:=statement_syssym(tsyssym(srsym).number);
  1111. end;
  1112. typesym :
  1113. begin
  1114. htype.setsym(srsym);
  1115. if not assigned(htype.def) then
  1116. begin
  1117. again:=false;
  1118. end
  1119. else
  1120. begin
  1121. if token=_LKLAMMER then
  1122. begin
  1123. consume(_LKLAMMER);
  1124. p1:=comp_expr(true);
  1125. consume(_RKLAMMER);
  1126. p1:=ctypeconvnode.create_explicit(p1,htype);
  1127. end
  1128. else { not LKLAMMER }
  1129. if (token=_POINT) and
  1130. is_object(htype.def) then
  1131. begin
  1132. consume(_POINT);
  1133. if assigned(current_procinfo) and
  1134. assigned(current_procinfo.procdef._class) and
  1135. not(getaddr) then
  1136. begin
  1137. if current_procinfo.procdef._class.is_related(tobjectdef(htype.def)) then
  1138. begin
  1139. p1:=ctypenode.create(htype);
  1140. { search also in inherited methods }
  1141. srsym:=searchsym_in_class(tobjectdef(htype.def),pattern);
  1142. check_hints(srsym);
  1143. consume(_ID);
  1144. do_member_read(tobjectdef(htype.def),false,srsym,p1,again,[]);
  1145. end
  1146. else
  1147. begin
  1148. Message(parser_e_no_super_class);
  1149. again:=false;
  1150. end;
  1151. end
  1152. else
  1153. begin
  1154. { allows @TObject.Load }
  1155. { also allows static methods and variables }
  1156. p1:=ctypenode.create(htype);
  1157. { TP allows also @TMenu.Load if Load is only }
  1158. { defined in an anchestor class }
  1159. srsym:=search_class_member(tobjectdef(htype.def),pattern);
  1160. check_hints(srsym);
  1161. if not assigned(srsym) then
  1162. Message1(sym_e_id_no_member,pattern)
  1163. else if not(getaddr) and not(sp_static in srsym.symoptions) then
  1164. Message(sym_e_only_static_in_static)
  1165. else
  1166. begin
  1167. consume(_ID);
  1168. do_member_read(tobjectdef(htype.def),getaddr,srsym,p1,again,[]);
  1169. end;
  1170. end;
  1171. end
  1172. else
  1173. begin
  1174. { class reference ? }
  1175. if is_class(htype.def) then
  1176. begin
  1177. if getaddr and (token=_POINT) then
  1178. begin
  1179. consume(_POINT);
  1180. { allows @Object.Method }
  1181. { also allows static methods and variables }
  1182. p1:=ctypenode.create(htype);
  1183. { TP allows also @TMenu.Load if Load is only }
  1184. { defined in an anchestor class }
  1185. srsym:=search_class_member(tobjectdef(htype.def),pattern);
  1186. check_hints(srsym);
  1187. if not assigned(srsym) then
  1188. Message1(sym_e_id_no_member,pattern)
  1189. else
  1190. begin
  1191. consume(_ID);
  1192. do_member_read(tobjectdef(htype.def),getaddr,srsym,p1,again,[]);
  1193. end;
  1194. end
  1195. else
  1196. begin
  1197. p1:=ctypenode.create(htype);
  1198. { For a type block we simply return only
  1199. the type. For all other blocks we return
  1200. a loadvmt node }
  1201. if (block_type<>bt_type) then
  1202. p1:=cloadvmtaddrnode.create(p1);
  1203. end;
  1204. end
  1205. else
  1206. p1:=ctypenode.create(htype);
  1207. end;
  1208. end;
  1209. end;
  1210. enumsym :
  1211. begin
  1212. p1:=genenumnode(tenumsym(srsym));
  1213. end;
  1214. constsym :
  1215. begin
  1216. case tconstsym(srsym).consttyp of
  1217. constint :
  1218. begin
  1219. { do a very dirty trick to bootstrap this code }
  1220. if (tconstsym(srsym).value.valueord>=-(int64(2147483647)+int64(1))) and
  1221. (tconstsym(srsym).value.valueord<=2147483647) then
  1222. p1:=cordconstnode.create(tconstsym(srsym).value.valueord,s32bittype,true)
  1223. else if (tconstsym(srsym).value.valueord > maxlongint) and
  1224. (tconstsym(srsym).value.valueord <= int64(maxlongint)+int64(maxlongint)+1) then
  1225. p1:=cordconstnode.create(tconstsym(srsym).value.valueord,u32bittype,true)
  1226. else
  1227. p1:=cordconstnode.create(tconstsym(srsym).value.valueord,cs64bittype,true);
  1228. end;
  1229. conststring :
  1230. begin
  1231. len:=tconstsym(srsym).value.len;
  1232. if not(cs_ansistrings in aktlocalswitches) and (len>255) then
  1233. len:=255;
  1234. getmem(pc,len+1);
  1235. move(pchar(tconstsym(srsym).value.valueptr)^,pc^,len);
  1236. pc[len]:=#0;
  1237. p1:=cstringconstnode.createpchar(pc,len);
  1238. end;
  1239. constchar :
  1240. p1:=cordconstnode.create(tconstsym(srsym).value.valueord,cchartype,true);
  1241. constreal :
  1242. p1:=crealconstnode.create(pbestreal(tconstsym(srsym).value.valueptr)^,pbestrealtype^);
  1243. constbool :
  1244. p1:=cordconstnode.create(tconstsym(srsym).value.valueord,booltype,true);
  1245. constset :
  1246. p1:=csetconstnode.create(pconstset(tconstsym(srsym).value.valueptr),tconstsym(srsym).consttype);
  1247. constord :
  1248. p1:=cordconstnode.create(tconstsym(srsym).value.valueord,tconstsym(srsym).consttype,true);
  1249. constpointer :
  1250. p1:=cpointerconstnode.create(tconstsym(srsym).value.valueordptr,tconstsym(srsym).consttype);
  1251. constnil :
  1252. p1:=cnilnode.create;
  1253. constresourcestring:
  1254. begin
  1255. p1:=cloadnode.create(srsym,srsymtable);
  1256. do_resulttypepass(p1);
  1257. p1.resulttype:=cansistringtype;
  1258. end;
  1259. constguid :
  1260. p1:=cguidconstnode.create(pguid(tconstsym(srsym).value.valueptr)^);
  1261. end;
  1262. end;
  1263. procsym :
  1264. begin
  1265. { are we in a class method ? }
  1266. possible_error:=(srsymtable.symtabletype<>withsymtable) and
  1267. (srsym.owner.symtabletype=objectsymtable) and
  1268. not(is_interface(tdef(srsym.owner.defowner))) and
  1269. assigned(current_procinfo) and
  1270. (po_classmethod in current_procinfo.procdef.procoptions);
  1271. do_proc_call(srsym,srsymtable,nil,
  1272. (getaddr and not(token in [_CARET,_POINT])),
  1273. again,p1);
  1274. { we need to know which procedure is called }
  1275. if possible_error then
  1276. begin
  1277. do_resulttypepass(p1);
  1278. if not(tcallnode(p1).procdefinition.proctypeoption=potype_constructor) and
  1279. not(po_classmethod in tcallnode(p1).procdefinition.procoptions) then
  1280. Message(parser_e_only_class_methods);
  1281. end;
  1282. end;
  1283. propertysym :
  1284. begin
  1285. { access to property in a method }
  1286. { are we in a class method ? }
  1287. if (srsymtable.symtabletype=objectsymtable) and
  1288. assigned(current_procinfo) and
  1289. (po_classmethod in current_procinfo.procdef.procoptions) then
  1290. Message(parser_e_only_class_methods);
  1291. { no method pointer }
  1292. p1:=nil;
  1293. handle_propertysym(srsym,srsymtable,p1);
  1294. end;
  1295. labelsym :
  1296. begin
  1297. consume(_COLON);
  1298. if tlabelsym(srsym).defined then
  1299. Message(sym_e_label_already_defined);
  1300. tlabelsym(srsym).defined:=true;
  1301. p1:=clabelnode.create(tlabelsym(srsym),nil);
  1302. end;
  1303. errorsym :
  1304. begin
  1305. p1:=cerrornode.create;
  1306. if token=_LKLAMMER then
  1307. begin
  1308. consume(_LKLAMMER);
  1309. parse_paras(false,false);
  1310. consume(_RKLAMMER);
  1311. end;
  1312. end;
  1313. else
  1314. begin
  1315. p1:=cerrornode.create;
  1316. Message(cg_e_illegal_expression);
  1317. end;
  1318. end; { end case }
  1319. end;
  1320. end;
  1321. {---------------------------------------------
  1322. Factor_Read_Set
  1323. ---------------------------------------------}
  1324. { Read a set between [] }
  1325. function factor_read_set:tnode;
  1326. var
  1327. p1,p2 : tnode;
  1328. lastp,
  1329. buildp : tarrayconstructornode;
  1330. begin
  1331. buildp:=nil;
  1332. { be sure that a least one arrayconstructn is used, also for an
  1333. empty [] }
  1334. if token=_RECKKLAMMER then
  1335. buildp:=carrayconstructornode.create(nil,buildp)
  1336. else
  1337. begin
  1338. while true do
  1339. begin
  1340. p1:=comp_expr(true);
  1341. if token=_POINTPOINT then
  1342. begin
  1343. consume(_POINTPOINT);
  1344. p2:=comp_expr(true);
  1345. p1:=carrayconstructorrangenode.create(p1,p2);
  1346. end;
  1347. { insert at the end of the tree, to get the correct order }
  1348. if not assigned(buildp) then
  1349. begin
  1350. buildp:=carrayconstructornode.create(p1,nil);
  1351. lastp:=buildp;
  1352. end
  1353. else
  1354. begin
  1355. lastp.right:=carrayconstructornode.create(p1,nil);
  1356. lastp:=tarrayconstructornode(lastp.right);
  1357. end;
  1358. { there could be more elements }
  1359. if token=_COMMA then
  1360. consume(_COMMA)
  1361. else
  1362. break;
  1363. end;
  1364. end;
  1365. factor_read_set:=buildp;
  1366. end;
  1367. {---------------------------------------------
  1368. PostFixOperators
  1369. ---------------------------------------------}
  1370. procedure postfixoperators(var p1:tnode;var again:boolean);
  1371. { tries to avoid syntax errors after invalid qualifiers }
  1372. procedure recoverconsume_postfixops;
  1373. begin
  1374. while true do
  1375. begin
  1376. case token of
  1377. _CARET:
  1378. consume(_CARET);
  1379. _POINT:
  1380. begin
  1381. consume(_POINT);
  1382. if token=_ID then
  1383. consume(_ID);
  1384. end;
  1385. _LECKKLAMMER:
  1386. begin
  1387. consume(_LECKKLAMMER);
  1388. repeat
  1389. comp_expr(true);
  1390. if token=_COMMA then
  1391. consume(_COMMA)
  1392. else
  1393. break;
  1394. until false;
  1395. consume(_RECKKLAMMER);
  1396. end
  1397. else
  1398. break;
  1399. end;
  1400. end;
  1401. end;
  1402. var
  1403. store_static : boolean;
  1404. protsym : tpropertysym;
  1405. p2,p3 : tnode;
  1406. hsym : tsym;
  1407. classh : tobjectdef;
  1408. begin
  1409. again:=true;
  1410. while again do
  1411. begin
  1412. { we need the resulttype }
  1413. do_resulttypepass(p1);
  1414. if codegenerror then
  1415. begin
  1416. recoverconsume_postfixops;
  1417. exit;
  1418. end;
  1419. { handle token }
  1420. case token of
  1421. _CARET:
  1422. begin
  1423. consume(_CARET);
  1424. if (p1.resulttype.def.deftype<>pointerdef) then
  1425. begin
  1426. { ^ as binary operator is a problem!!!! (FK) }
  1427. again:=false;
  1428. Message(cg_e_invalid_qualifier);
  1429. recoverconsume_postfixops;
  1430. p1.destroy;
  1431. p1:=cerrornode.create;
  1432. end
  1433. else
  1434. begin
  1435. p1:=cderefnode.create(p1);
  1436. end;
  1437. end;
  1438. _LECKKLAMMER:
  1439. begin
  1440. if is_class_or_interface(p1.resulttype.def) then
  1441. begin
  1442. { default property }
  1443. protsym:=search_default_property(tobjectdef(p1.resulttype.def));
  1444. if not(assigned(protsym)) then
  1445. begin
  1446. p1.destroy;
  1447. p1:=cerrornode.create;
  1448. again:=false;
  1449. message(parser_e_no_default_property_available);
  1450. end
  1451. else
  1452. begin
  1453. { The property symbol is referenced indirect }
  1454. inc(protsym.refs);
  1455. handle_propertysym(protsym,protsym.owner,p1);
  1456. end;
  1457. end
  1458. else
  1459. begin
  1460. consume(_LECKKLAMMER);
  1461. repeat
  1462. case p1.resulttype.def.deftype of
  1463. pointerdef:
  1464. begin
  1465. { support delphi autoderef }
  1466. if (tpointerdef(p1.resulttype.def).pointertype.def.deftype=arraydef) and
  1467. (m_autoderef in aktmodeswitches) then
  1468. begin
  1469. p1:=cderefnode.create(p1);
  1470. end;
  1471. p2:=comp_expr(true);
  1472. p1:=cvecnode.create(p1,p2);
  1473. end;
  1474. stringdef :
  1475. begin
  1476. p2:=comp_expr(true);
  1477. p1:=cvecnode.create(p1,p2);
  1478. end;
  1479. arraydef :
  1480. begin
  1481. p2:=comp_expr(true);
  1482. { support SEG:OFS for go32v2 Mem[] }
  1483. if (target_info.system in [system_i386_go32v2,system_i386_watcom]) and
  1484. (p1.nodetype=loadn) and
  1485. assigned(tloadnode(p1).symtableentry) and
  1486. assigned(tloadnode(p1).symtableentry.owner.name) and
  1487. (tloadnode(p1).symtableentry.owner.name^='SYSTEM') and
  1488. ((tloadnode(p1).symtableentry.name='MEM') or
  1489. (tloadnode(p1).symtableentry.name='MEMW') or
  1490. (tloadnode(p1).symtableentry.name='MEML')) then
  1491. begin
  1492. if (token=_COLON) then
  1493. begin
  1494. consume(_COLON);
  1495. p3:=caddnode.create(muln,cordconstnode.create($10,s32bittype,false),p2);
  1496. p2:=comp_expr(true);
  1497. p2:=caddnode.create(addn,p2,p3);
  1498. p1:=cvecnode.create(p1,p2);
  1499. include(tvecnode(p1).flags,nf_memseg);
  1500. include(tvecnode(p1).flags,nf_memindex);
  1501. end
  1502. else
  1503. begin
  1504. p1:=cvecnode.create(p1,p2);
  1505. include(tvecnode(p1).flags,nf_memindex);
  1506. end;
  1507. end
  1508. else
  1509. p1:=cvecnode.create(p1,p2);
  1510. end;
  1511. else
  1512. begin
  1513. Message(cg_e_invalid_qualifier);
  1514. p1.destroy;
  1515. p1:=cerrornode.create;
  1516. comp_expr(true);
  1517. again:=false;
  1518. end;
  1519. end;
  1520. do_resulttypepass(p1);
  1521. if token=_COMMA then
  1522. consume(_COMMA)
  1523. else
  1524. break;
  1525. until false;
  1526. consume(_RECKKLAMMER);
  1527. end;
  1528. end;
  1529. _POINT :
  1530. begin
  1531. consume(_POINT);
  1532. if (p1.resulttype.def.deftype=pointerdef) and
  1533. (m_autoderef in aktmodeswitches) then
  1534. begin
  1535. p1:=cderefnode.create(p1);
  1536. do_resulttypepass(p1);
  1537. end;
  1538. case p1.resulttype.def.deftype of
  1539. recorddef:
  1540. begin
  1541. hsym:=tsym(trecorddef(p1.resulttype.def).symtable.search(pattern));
  1542. check_hints(hsym);
  1543. if assigned(hsym) and
  1544. (hsym.typ=varsym) then
  1545. p1:=csubscriptnode.create(hsym,p1)
  1546. else
  1547. begin
  1548. Message1(sym_e_illegal_field,pattern);
  1549. p1.destroy;
  1550. p1:=cerrornode.create;
  1551. end;
  1552. consume(_ID);
  1553. end;
  1554. variantdef:
  1555. begin
  1556. end;
  1557. classrefdef:
  1558. begin
  1559. classh:=tobjectdef(tclassrefdef(p1.resulttype.def).pointertype.def);
  1560. hsym:=searchsym_in_class(classh,pattern);
  1561. check_hints(hsym);
  1562. if hsym=nil then
  1563. begin
  1564. Message1(sym_e_id_no_member,pattern);
  1565. p1.destroy;
  1566. p1:=cerrornode.create;
  1567. { try to clean up }
  1568. consume(_ID);
  1569. end
  1570. else
  1571. begin
  1572. consume(_ID);
  1573. do_member_read(classh,getaddr,hsym,p1,again,[]);
  1574. end;
  1575. end;
  1576. objectdef:
  1577. begin
  1578. store_static:=allow_only_static;
  1579. allow_only_static:=false;
  1580. classh:=tobjectdef(p1.resulttype.def);
  1581. hsym:=searchsym_in_class(classh,pattern);
  1582. check_hints(hsym);
  1583. allow_only_static:=store_static;
  1584. if hsym=nil then
  1585. begin
  1586. Message1(sym_e_id_no_member,pattern);
  1587. p1.destroy;
  1588. p1:=cerrornode.create;
  1589. { try to clean up }
  1590. consume(_ID);
  1591. end
  1592. else
  1593. begin
  1594. consume(_ID);
  1595. do_member_read(classh,getaddr,hsym,p1,again,[]);
  1596. end;
  1597. end;
  1598. pointerdef:
  1599. begin
  1600. Message(cg_e_invalid_qualifier);
  1601. if tpointerdef(p1.resulttype.def).pointertype.def.deftype in [recorddef,objectdef,classrefdef] then
  1602. Message(parser_h_maybe_deref_caret_missing);
  1603. end;
  1604. else
  1605. begin
  1606. Message(cg_e_invalid_qualifier);
  1607. p1.destroy;
  1608. p1:=cerrornode.create;
  1609. consume(_ID);
  1610. end;
  1611. end;
  1612. end;
  1613. else
  1614. begin
  1615. { is this a procedure variable ? }
  1616. if assigned(p1.resulttype.def) then
  1617. begin
  1618. if (p1.resulttype.def.deftype=procvardef) then
  1619. begin
  1620. if assigned(getprocvardef) and
  1621. equal_defs(p1.resulttype.def,getprocvardef) then
  1622. again:=false
  1623. else
  1624. if (token=_LKLAMMER) or
  1625. ((tprocvardef(p1.resulttype.def).maxparacount=0) and
  1626. (not((token in [_ASSIGNMENT,_UNEQUAL,_EQUAL]))) and
  1627. (not afterassignment) and
  1628. (not in_args)) then
  1629. begin
  1630. if try_to_consume(_LKLAMMER) then
  1631. begin
  1632. p2:=parse_paras(false,false);
  1633. consume(_RKLAMMER);
  1634. end
  1635. else
  1636. p2:=nil;
  1637. p1:=ccallnode.create_procvar(p2,p1);
  1638. { proc():= is never possible }
  1639. if token=_ASSIGNMENT then
  1640. begin
  1641. Message(cg_e_illegal_expression);
  1642. p1.free;
  1643. p1:=cerrornode.create;
  1644. again:=false;
  1645. end;
  1646. end
  1647. else
  1648. again:=false;
  1649. end
  1650. else
  1651. again:=false;
  1652. end
  1653. else
  1654. again:=false;
  1655. end;
  1656. end;
  1657. end; { while again }
  1658. end;
  1659. {---------------------------------------------
  1660. Factor (Main)
  1661. ---------------------------------------------}
  1662. var
  1663. l : longint;
  1664. card : cardinal;
  1665. ic : TConstExprInt;
  1666. oldp1,
  1667. p1 : tnode;
  1668. code : integer;
  1669. again : boolean;
  1670. sym : tsym;
  1671. pd : tprocdef;
  1672. classh : tobjectdef;
  1673. d : bestreal;
  1674. hs : string;
  1675. htype : ttype;
  1676. filepos : tfileposinfo;
  1677. {---------------------------------------------
  1678. Helpers
  1679. ---------------------------------------------}
  1680. procedure check_tokenpos;
  1681. begin
  1682. if (p1<>oldp1) then
  1683. begin
  1684. if assigned(p1) then
  1685. p1.set_tree_filepos(filepos);
  1686. oldp1:=p1;
  1687. filepos:=akttokenpos;
  1688. end;
  1689. end;
  1690. begin
  1691. oldp1:=nil;
  1692. p1:=nil;
  1693. filepos:=akttokenpos;
  1694. again:=false;
  1695. if token=_ID then
  1696. begin
  1697. again:=true;
  1698. { Handle references to self }
  1699. if (idtoken=_SELF) and
  1700. not(block_type in [bt_const,bt_type]) and
  1701. assigned(current_procinfo) and
  1702. assigned(current_procinfo.procdef._class) then
  1703. begin
  1704. p1:=load_self_node;
  1705. consume(_ID);
  1706. again:=true;
  1707. end
  1708. else
  1709. factor_read_id(p1,again);
  1710. if again then
  1711. begin
  1712. check_tokenpos;
  1713. { handle post fix operators }
  1714. postfixoperators(p1,again);
  1715. end;
  1716. end
  1717. else
  1718. case token of
  1719. _INHERITED :
  1720. begin
  1721. again:=true;
  1722. consume(_INHERITED);
  1723. if assigned(current_procinfo) and
  1724. assigned(current_procinfo.procdef._class) then
  1725. begin
  1726. classh:=current_procinfo.procdef._class.childof;
  1727. { if inherited; only then we need the method with
  1728. the same name }
  1729. if token in endtokens then
  1730. begin
  1731. hs:=current_procinfo.procdef.procsym.name;
  1732. anon_inherited:=true;
  1733. { For message methods we need to search using the message
  1734. number or string }
  1735. pd:=tprocsym(current_procinfo.procdef.procsym).first_procdef;
  1736. if (po_msgint in pd.procoptions) then
  1737. sym:=searchsym_in_class_by_msgint(classh,pd.messageinf.i)
  1738. else
  1739. if (po_msgstr in pd.procoptions) then
  1740. sym:=searchsym_in_class_by_msgstr(classh,pd.messageinf.str)
  1741. else
  1742. sym:=searchsym_in_class(classh,hs);
  1743. end
  1744. else
  1745. begin
  1746. hs:=pattern;
  1747. consume(_ID);
  1748. anon_inherited:=false;
  1749. sym:=searchsym_in_class(classh,hs);
  1750. end;
  1751. if assigned(sym) then
  1752. begin
  1753. check_hints(sym);
  1754. { load the procdef from the inherited class and
  1755. not from self }
  1756. if sym.typ=procsym then
  1757. begin
  1758. htype.setdef(classh);
  1759. p1:=ctypenode.create(htype);
  1760. end;
  1761. do_member_read(classh,false,sym,p1,again,[nf_inherited,nf_anon_inherited]);
  1762. end
  1763. else
  1764. begin
  1765. if anon_inherited then
  1766. begin
  1767. { For message methods we need to call DefaultHandler }
  1768. if (po_msgint in pd.procoptions) or
  1769. (po_msgstr in pd.procoptions) then
  1770. begin
  1771. sym:=searchsym_in_class(classh,'DEFAULTHANDLER');
  1772. if not assigned(sym) or
  1773. (sym.typ<>procsym) then
  1774. internalerror(200303171);
  1775. p1:=nil;
  1776. do_proc_call(sym,sym.owner,classh,false,again,p1);
  1777. end
  1778. else
  1779. begin
  1780. { we need to ignore the inherited; }
  1781. p1:=cnothingnode.create;
  1782. end;
  1783. end
  1784. else
  1785. begin
  1786. Message1(sym_e_id_no_member,hs);
  1787. p1:=cerrornode.create;
  1788. end;
  1789. again:=false;
  1790. end;
  1791. { turn auto inheriting off }
  1792. anon_inherited:=false;
  1793. end
  1794. else
  1795. begin
  1796. Message(parser_e_generic_methods_only_in_methods);
  1797. again:=false;
  1798. p1:=cerrornode.create;
  1799. end;
  1800. postfixoperators(p1,again);
  1801. end;
  1802. _INTCONST :
  1803. begin
  1804. { try cardinal first }
  1805. val(pattern,card,code);
  1806. if code<>0 then
  1807. begin
  1808. { then longint }
  1809. valint(pattern,l,code);
  1810. if code <> 0 then
  1811. begin
  1812. { then int64 }
  1813. val(pattern,ic,code);
  1814. if code<>0 then
  1815. begin
  1816. {finally float }
  1817. val(pattern,d,code);
  1818. if code<>0 then
  1819. begin
  1820. Message(cg_e_invalid_integer);
  1821. consume(_INTCONST);
  1822. l:=1;
  1823. p1:=cordconstnode.create(l,s32bittype,true);
  1824. end
  1825. else
  1826. begin
  1827. consume(_INTCONST);
  1828. p1:=crealconstnode.create(d,pbestrealtype^);
  1829. end;
  1830. end
  1831. else
  1832. begin
  1833. consume(_INTCONST);
  1834. p1:=cordconstnode.create(ic,cs64bittype,true);
  1835. end
  1836. end
  1837. else
  1838. begin
  1839. consume(_INTCONST);
  1840. p1:=cordconstnode.create(l,defaultordconsttype,true)
  1841. end
  1842. end
  1843. else
  1844. begin
  1845. consume(_INTCONST);
  1846. { check whether the value isn't in the longint range as well }
  1847. { (longint is easier to perform calculations with) (JM) }
  1848. if card <= $7fffffff then
  1849. { no sign extension necessary, so not longint typecast (JM) }
  1850. p1:=cordconstnode.create(card,s32bittype,true)
  1851. else
  1852. p1:=cordconstnode.create(card,u32bittype,true)
  1853. end;
  1854. end;
  1855. _REALNUMBER :
  1856. begin
  1857. val(pattern,d,code);
  1858. if code<>0 then
  1859. begin
  1860. Message(parser_e_error_in_real);
  1861. d:=1.0;
  1862. end;
  1863. consume(_REALNUMBER);
  1864. p1:=crealconstnode.create(d,pbestrealtype^);
  1865. end;
  1866. _STRING :
  1867. begin
  1868. string_dec(htype);
  1869. { STRING can be also a type cast }
  1870. if token=_LKLAMMER then
  1871. begin
  1872. consume(_LKLAMMER);
  1873. p1:=comp_expr(true);
  1874. consume(_RKLAMMER);
  1875. p1:=ctypeconvnode.create_explicit(p1,htype);
  1876. { handle postfix operators here e.g. string(a)[10] }
  1877. again:=true;
  1878. postfixoperators(p1,again);
  1879. end
  1880. else
  1881. p1:=ctypenode.create(htype);
  1882. end;
  1883. _FILE :
  1884. begin
  1885. htype:=cfiletype;
  1886. consume(_FILE);
  1887. { FILE can be also a type cast }
  1888. if token=_LKLAMMER then
  1889. begin
  1890. consume(_LKLAMMER);
  1891. p1:=comp_expr(true);
  1892. consume(_RKLAMMER);
  1893. p1:=ctypeconvnode.create_explicit(p1,htype);
  1894. { handle postfix operators here e.g. string(a)[10] }
  1895. again:=true;
  1896. postfixoperators(p1,again);
  1897. end
  1898. else
  1899. begin
  1900. p1:=ctypenode.create(htype);
  1901. end;
  1902. end;
  1903. _CSTRING :
  1904. begin
  1905. p1:=cstringconstnode.createstr(pattern,st_default);
  1906. consume(_CSTRING);
  1907. end;
  1908. _CCHAR :
  1909. begin
  1910. p1:=cordconstnode.create(ord(pattern[1]),cchartype,true);
  1911. consume(_CCHAR);
  1912. end;
  1913. _CWSTRING:
  1914. begin
  1915. p1:=cstringconstnode.createwstr(patternw);
  1916. consume(_CWSTRING);
  1917. end;
  1918. _CWCHAR:
  1919. begin
  1920. p1:=cordconstnode.create(ord(getcharwidestring(patternw,0)),cwidechartype,true);
  1921. consume(_CWCHAR);
  1922. end;
  1923. _KLAMMERAFFE :
  1924. begin
  1925. consume(_KLAMMERAFFE);
  1926. got_addrn:=true;
  1927. { support both @<x> and @(<x>) }
  1928. if try_to_consume(_LKLAMMER) then
  1929. begin
  1930. p1:=factor(true);
  1931. if token in [_CARET,_POINT,_LECKKLAMMER] then
  1932. begin
  1933. again:=true;
  1934. postfixoperators(p1,again);
  1935. end;
  1936. consume(_RKLAMMER);
  1937. end
  1938. else
  1939. p1:=factor(true);
  1940. if token in [_CARET,_POINT,_LECKKLAMMER] then
  1941. begin
  1942. again:=true;
  1943. postfixoperators(p1,again);
  1944. end;
  1945. got_addrn:=false;
  1946. p1:=caddrnode.create(p1);
  1947. { Store the procvar that we are expecting, the
  1948. addrn will use the information to find the correct
  1949. procdef or it will return an error }
  1950. if assigned(getprocvardef) and
  1951. (taddrnode(p1).left.nodetype = loadn) then
  1952. taddrnode(p1).getprocvardef:=getprocvardef;
  1953. end;
  1954. _LKLAMMER :
  1955. begin
  1956. consume(_LKLAMMER);
  1957. p1:=comp_expr(true);
  1958. consume(_RKLAMMER);
  1959. { it's not a good solution }
  1960. { but (a+b)^ makes some problems }
  1961. if token in [_CARET,_POINT,_LECKKLAMMER] then
  1962. begin
  1963. again:=true;
  1964. postfixoperators(p1,again);
  1965. end;
  1966. end;
  1967. _LECKKLAMMER :
  1968. begin
  1969. consume(_LECKKLAMMER);
  1970. p1:=factor_read_set;
  1971. consume(_RECKKLAMMER);
  1972. end;
  1973. _PLUS :
  1974. begin
  1975. consume(_PLUS);
  1976. p1:=factor(false);
  1977. end;
  1978. _MINUS :
  1979. begin
  1980. consume(_MINUS);
  1981. p1:=sub_expr(oppower,false);
  1982. p1:=cunaryminusnode.create(p1);
  1983. end;
  1984. _OP_NOT :
  1985. begin
  1986. consume(_OP_NOT);
  1987. p1:=factor(false);
  1988. p1:=cnotnode.create(p1);
  1989. end;
  1990. _TRUE :
  1991. begin
  1992. consume(_TRUE);
  1993. p1:=cordconstnode.create(1,booltype,false);
  1994. end;
  1995. _FALSE :
  1996. begin
  1997. consume(_FALSE);
  1998. p1:=cordconstnode.create(0,booltype,false);
  1999. end;
  2000. _NIL :
  2001. begin
  2002. consume(_NIL);
  2003. p1:=cnilnode.create;
  2004. { It's really ugly code nil^, but delphi allows it }
  2005. if token in [_CARET] then
  2006. begin
  2007. again:=true;
  2008. postfixoperators(p1,again);
  2009. end;
  2010. end;
  2011. else
  2012. begin
  2013. p1:=cerrornode.create;
  2014. consume(token);
  2015. Message(cg_e_illegal_expression);
  2016. end;
  2017. end;
  2018. { generate error node if no node is created }
  2019. if not assigned(p1) then
  2020. begin
  2021. {$ifdef EXTDEBUG}
  2022. Comment(V_Warning,'factor: p1=nil');
  2023. {$endif}
  2024. p1:=cerrornode.create;
  2025. end;
  2026. { get the resulttype for the node }
  2027. if (not assigned(p1.resulttype.def)) then
  2028. do_resulttypepass(p1);
  2029. { tp7 procvar handling, but not if the next token
  2030. will be a := }
  2031. check_tp_procvar(p1);
  2032. factor:=p1;
  2033. check_tokenpos;
  2034. end;
  2035. {$ifdef fpc}
  2036. {$maxfpuregisters default}
  2037. {$endif fpc}
  2038. {****************************************************************************
  2039. Sub_Expr
  2040. ****************************************************************************}
  2041. const
  2042. { Warning these stay be ordered !! }
  2043. operator_levels:array[Toperator_precedence] of set of Ttoken=
  2044. ([_LT,_LTE,_GT,_GTE,_EQUAL,_UNEQUAL,_OP_IN,_OP_IS],
  2045. [_PLUS,_MINUS,_OP_OR,_OP_XOR],
  2046. [_CARET,_SYMDIF,_STARSTAR,_STAR,_SLASH,
  2047. _OP_AS,_OP_AND,_OP_DIV,_OP_MOD,_OP_SHL,_OP_SHR],
  2048. [_STARSTAR] );
  2049. function sub_expr(pred_level:Toperator_precedence;accept_equal : boolean):tnode;
  2050. {Reads a subexpression while the operators are of the current precedence
  2051. level, or any higher level. Replaces the old term, simpl_expr and
  2052. simpl2_expr.}
  2053. var
  2054. p1,p2 : tnode;
  2055. oldt : Ttoken;
  2056. filepos : tfileposinfo;
  2057. begin
  2058. if pred_level=highest_precedence then
  2059. p1:=factor(false)
  2060. else
  2061. p1:=sub_expr(succ(pred_level),true);
  2062. repeat
  2063. if (token in operator_levels[pred_level]) and
  2064. ((token<>_EQUAL) or accept_equal) then
  2065. begin
  2066. oldt:=token;
  2067. filepos:=akttokenpos;
  2068. consume(token);
  2069. if pred_level=highest_precedence then
  2070. p2:=factor(false)
  2071. else
  2072. p2:=sub_expr(succ(pred_level),true);
  2073. case oldt of
  2074. _PLUS :
  2075. p1:=caddnode.create(addn,p1,p2);
  2076. _MINUS :
  2077. p1:=caddnode.create(subn,p1,p2);
  2078. _STAR :
  2079. p1:=caddnode.create(muln,p1,p2);
  2080. _SLASH :
  2081. p1:=caddnode.create(slashn,p1,p2);
  2082. _EQUAL :
  2083. p1:=caddnode.create(equaln,p1,p2);
  2084. _GT :
  2085. p1:=caddnode.create(gtn,p1,p2);
  2086. _LT :
  2087. p1:=caddnode.create(ltn,p1,p2);
  2088. _GTE :
  2089. p1:=caddnode.create(gten,p1,p2);
  2090. _LTE :
  2091. p1:=caddnode.create(lten,p1,p2);
  2092. _SYMDIF :
  2093. p1:=caddnode.create(symdifn,p1,p2);
  2094. _STARSTAR :
  2095. p1:=caddnode.create(starstarn,p1,p2);
  2096. _OP_AS :
  2097. p1:=casnode.create(p1,p2);
  2098. _OP_IN :
  2099. p1:=cinnode.create(p1,p2);
  2100. _OP_IS :
  2101. p1:=cisnode.create(p1,p2);
  2102. _OP_OR :
  2103. p1:=caddnode.create(orn,p1,p2);
  2104. _OP_AND :
  2105. p1:=caddnode.create(andn,p1,p2);
  2106. _OP_DIV :
  2107. p1:=cmoddivnode.create(divn,p1,p2);
  2108. _OP_NOT :
  2109. p1:=cnotnode.create(p1);
  2110. _OP_MOD :
  2111. p1:=cmoddivnode.create(modn,p1,p2);
  2112. _OP_SHL :
  2113. p1:=cshlshrnode.create(shln,p1,p2);
  2114. _OP_SHR :
  2115. p1:=cshlshrnode.create(shrn,p1,p2);
  2116. _OP_XOR :
  2117. p1:=caddnode.create(xorn,p1,p2);
  2118. _ASSIGNMENT :
  2119. p1:=cassignmentnode.create(p1,p2);
  2120. _CARET :
  2121. p1:=caddnode.create(caretn,p1,p2);
  2122. _UNEQUAL :
  2123. p1:=caddnode.create(unequaln,p1,p2);
  2124. end;
  2125. p1.set_tree_filepos(filepos);
  2126. end
  2127. else
  2128. break;
  2129. until false;
  2130. sub_expr:=p1;
  2131. end;
  2132. function comp_expr(accept_equal : boolean):tnode;
  2133. var
  2134. oldafterassignment : boolean;
  2135. p1 : tnode;
  2136. begin
  2137. oldafterassignment:=afterassignment;
  2138. afterassignment:=true;
  2139. p1:=sub_expr(opcompare,accept_equal);
  2140. { get the resulttype for this expression }
  2141. if not assigned(p1.resulttype.def) then
  2142. do_resulttypepass(p1);
  2143. afterassignment:=oldafterassignment;
  2144. comp_expr:=p1;
  2145. end;
  2146. function expr : tnode;
  2147. var
  2148. p1,p2 : tnode;
  2149. oldafterassignment : boolean;
  2150. oldp1 : tnode;
  2151. filepos : tfileposinfo;
  2152. begin
  2153. oldafterassignment:=afterassignment;
  2154. p1:=sub_expr(opcompare,true);
  2155. { get the resulttype for this expression }
  2156. if not assigned(p1.resulttype.def) then
  2157. do_resulttypepass(p1);
  2158. filepos:=akttokenpos;
  2159. check_tp_procvar(p1);
  2160. if token in [_ASSIGNMENT,_PLUSASN,_MINUSASN,_STARASN,_SLASHASN] then
  2161. afterassignment:=true;
  2162. oldp1:=p1;
  2163. case token of
  2164. _POINTPOINT :
  2165. begin
  2166. consume(_POINTPOINT);
  2167. p2:=sub_expr(opcompare,true);
  2168. p1:=crangenode.create(p1,p2);
  2169. end;
  2170. _ASSIGNMENT :
  2171. begin
  2172. consume(_ASSIGNMENT);
  2173. if (p1.resulttype.def.deftype=procvardef) then
  2174. getprocvardef:=tprocvardef(p1.resulttype.def);
  2175. p2:=sub_expr(opcompare,true);
  2176. if assigned(getprocvardef) then
  2177. handle_procvar(getprocvardef,p2);
  2178. getprocvardef:=nil;
  2179. p1:=cassignmentnode.create(p1,p2);
  2180. end;
  2181. _PLUSASN :
  2182. begin
  2183. consume(_PLUSASN);
  2184. p2:=sub_expr(opcompare,true);
  2185. p1:=cassignmentnode.create(p1,caddnode.create(addn,p1.getcopy,p2));
  2186. end;
  2187. _MINUSASN :
  2188. begin
  2189. consume(_MINUSASN);
  2190. p2:=sub_expr(opcompare,true);
  2191. p1:=cassignmentnode.create(p1,caddnode.create(subn,p1.getcopy,p2));
  2192. end;
  2193. _STARASN :
  2194. begin
  2195. consume(_STARASN );
  2196. p2:=sub_expr(opcompare,true);
  2197. p1:=cassignmentnode.create(p1,caddnode.create(muln,p1.getcopy,p2));
  2198. end;
  2199. _SLASHASN :
  2200. begin
  2201. consume(_SLASHASN );
  2202. p2:=sub_expr(opcompare,true);
  2203. p1:=cassignmentnode.create(p1,caddnode.create(slashn,p1.getcopy,p2));
  2204. end;
  2205. end;
  2206. { get the resulttype for this expression }
  2207. if not assigned(p1.resulttype.def) then
  2208. do_resulttypepass(p1);
  2209. afterassignment:=oldafterassignment;
  2210. if p1<>oldp1 then
  2211. p1.set_tree_filepos(filepos);
  2212. expr:=p1;
  2213. end;
  2214. {$ifdef int64funcresok}
  2215. function get_intconst:TConstExprInt;
  2216. {$else int64funcresok}
  2217. function get_intconst:longint;
  2218. {$endif int64funcresok}
  2219. {Reads an expression, tries to evalute it and check if it is an integer
  2220. constant. Then the constant is returned.}
  2221. var
  2222. p:tnode;
  2223. begin
  2224. p:=comp_expr(true);
  2225. if not codegenerror then
  2226. begin
  2227. if (p.nodetype<>ordconstn) or
  2228. not(is_integer(p.resulttype.def)) then
  2229. Message(cg_e_illegal_expression)
  2230. else
  2231. get_intconst:=tordconstnode(p).value;
  2232. end;
  2233. p.free;
  2234. end;
  2235. function get_stringconst:string;
  2236. {Reads an expression, tries to evaluate it and checks if it is a string
  2237. constant. Then the constant is returned.}
  2238. var
  2239. p:tnode;
  2240. begin
  2241. get_stringconst:='';
  2242. p:=comp_expr(true);
  2243. if p.nodetype<>stringconstn then
  2244. begin
  2245. if (p.nodetype=ordconstn) and is_char(p.resulttype.def) then
  2246. get_stringconst:=char(tordconstnode(p).value)
  2247. else
  2248. Message(cg_e_illegal_expression);
  2249. end
  2250. else
  2251. get_stringconst:=strpas(tstringconstnode(p).value_str);
  2252. p.free;
  2253. end;
  2254. end.
  2255. {
  2256. $Log$
  2257. Revision 1.135 2003-10-09 15:20:56 peter
  2258. * self is not a token anymore. It is handled special when found
  2259. in a code block and when parsing an method
  2260. Revision 1.134 2003/10/09 15:00:13 florian
  2261. * fixed constructor call in class methods
  2262. Revision 1.133 2003/10/08 19:19:45 peter
  2263. * set_varstate cleanup
  2264. Revision 1.132 2003/10/05 12:56:04 peter
  2265. * fix assigned(property)
  2266. Revision 1.131 2003/10/02 21:15:31 peter
  2267. * protected visibility fixes
  2268. Revision 1.130 2003/10/01 20:34:49 peter
  2269. * procinfo unit contains tprocinfo
  2270. * cginfo renamed to cgbase
  2271. * moved cgmessage to verbose
  2272. * fixed ppc and sparc compiles
  2273. Revision 1.129 2003/09/23 17:56:05 peter
  2274. * locals and paras are allocated in the code generation
  2275. * tvarsym.localloc contains the location of para/local when
  2276. generating code for the current procedure
  2277. Revision 1.128 2003/09/06 22:27:09 florian
  2278. * fixed web bug 2669
  2279. * cosmetic fix in printnode
  2280. * tobjectdef.gettypename implemented
  2281. Revision 1.127 2003/09/05 17:41:12 florian
  2282. * merged Wiktor's Watcom patches in 1.1
  2283. Revision 1.126 2003/08/23 22:29:51 peter
  2284. * fixed static class check for properties
  2285. Revision 1.125 2003/08/23 18:41:52 peter
  2286. * allow typeof(self) in class methods
  2287. Revision 1.124 2003/08/10 17:25:23 peter
  2288. * fixed some reported bugs
  2289. Revision 1.123 2003/06/13 21:19:31 peter
  2290. * current_procdef removed, use current_procinfo.procdef instead
  2291. Revision 1.122 2003/06/03 21:02:57 peter
  2292. * don't set nf_member when loaded from with symtable
  2293. * allow static variables in class methods
  2294. Revision 1.121 2003/05/22 17:43:21 peter
  2295. * search defaulthandler only for message methods
  2296. Revision 1.120 2003/05/15 18:58:53 peter
  2297. * removed selfpointer_offset, vmtpointer_offset
  2298. * tvarsym.adjusted_address
  2299. * address in localsymtable is now in the real direction
  2300. * removed some obsolete globals
  2301. Revision 1.119 2003/05/13 20:54:39 peter
  2302. * ifdef'd code that checked for failed inherited constructors
  2303. Revision 1.118 2003/05/13 19:14:41 peter
  2304. * failn removed
  2305. * inherited result code check moven to pexpr
  2306. Revision 1.117 2003/05/11 21:37:03 peter
  2307. * moved implicit exception frame from ncgutil to psub
  2308. * constructor/destructor helpers moved from cobj/ncgutil to psub
  2309. Revision 1.116 2003/05/11 14:45:12 peter
  2310. * tloadnode does not support objectsymtable,withsymtable anymore
  2311. * withnode cleanup
  2312. * direct with rewritten to use temprefnode
  2313. Revision 1.115 2003/05/09 17:47:03 peter
  2314. * self moved to hidden parameter
  2315. * removed hdisposen,hnewn,selfn
  2316. Revision 1.114 2003/05/01 07:59:42 florian
  2317. * introduced defaultordconsttype to decribe the default size of ordinal constants
  2318. on 64 bit CPUs it's equal to cs64bitdef while on 32 bit CPUs it's equal to s32bitdef
  2319. + added defines CPU32 and CPU64 for 32 bit and 64 bit CPUs
  2320. * int64s/qwords are allowed as for loop counter on 64 bit CPUs
  2321. Revision 1.113 2003/04/27 11:21:33 peter
  2322. * aktprocdef renamed to current_procinfo.procdef
  2323. * procinfo renamed to current_procinfo
  2324. * procinfo will now be stored in current_module so it can be
  2325. cleaned up properly
  2326. * gen_main_procsym changed to create_main_proc and release_main_proc
  2327. to also generate a tprocinfo structure
  2328. * fixed unit implicit initfinal
  2329. Revision 1.112 2003/04/27 07:29:50 peter
  2330. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2331. a new procdef declaration
  2332. * aktprocsym removed
  2333. * lexlevel removed, use symtable.symtablelevel instead
  2334. * implicit init/final code uses the normal genentry/genexit
  2335. * funcret state checking updated for new funcret handling
  2336. Revision 1.111 2003/04/26 00:33:07 peter
  2337. * vo_is_result flag added for the special RESULT symbol
  2338. Revision 1.110 2003/04/25 20:59:33 peter
  2339. * removed funcretn,funcretsym, function result is now in varsym
  2340. and aliases for result and function name are added using absolutesym
  2341. * vs_hidden parameter for funcret passed in parameter
  2342. * vs_hidden fixes
  2343. * writenode changed to printnode and released from extdebug
  2344. * -vp option added to generate a tree.log with the nodetree
  2345. * nicer printnode for statements, callnode
  2346. Revision 1.109 2003/04/23 10:13:55 peter
  2347. * firstaddr will check procvardef
  2348. Revision 1.108 2003/04/22 23:50:23 peter
  2349. * firstpass uses expectloc
  2350. * checks if there are differences between the expectloc and
  2351. location.loc from secondpass in EXTDEBUG
  2352. Revision 1.107 2003/04/11 15:49:01 peter
  2353. * default property also increased the reference count for the
  2354. property symbol
  2355. Revision 1.106 2003/04/11 14:50:08 peter
  2356. * fix tw2454
  2357. Revision 1.105 2003/03/27 17:44:13 peter
  2358. * fixed small mem leaks
  2359. Revision 1.104 2003/03/17 18:55:30 peter
  2360. * allow more tokens instead of only semicolon after inherited
  2361. Revision 1.103 2003/03/17 16:54:41 peter
  2362. * support DefaultHandler and anonymous inheritance fixed
  2363. for message methods
  2364. Revision 1.102 2003/01/30 21:46:57 peter
  2365. * self fixes for static methods (merged)
  2366. Revision 1.101 2003/01/16 22:12:22 peter
  2367. * Find the correct procvar to load when using @ in fpc mode
  2368. Revision 1.100 2003/01/15 01:44:32 peter
  2369. * merged methodpointer fixes from 1.0.x
  2370. Revision 1.98 2003/01/12 17:51:42 peter
  2371. * tp procvar handling fix for tb0448
  2372. Revision 1.97 2003/01/05 22:44:14 peter
  2373. * remove a lot of code to support typen in loadn-procsym
  2374. Revision 1.96 2002/12/11 22:40:36 peter
  2375. * assigned(procvar) fix for delphi mode, fixes tb0430
  2376. Revision 1.95 2002/11/30 11:12:48 carl
  2377. + checking for symbols used with hint directives is done mostly in pexpr
  2378. only now
  2379. Revision 1.94 2002/11/27 15:33:47 peter
  2380. * the never ending story of tp procvar hacks
  2381. Revision 1.93 2002/11/26 22:58:24 peter
  2382. * fix for tw2178. When a ^ or . follows a procsym then the procsym
  2383. needs to be called
  2384. Revision 1.92 2002/11/25 17:43:22 peter
  2385. * splitted defbase in defutil,symutil,defcmp
  2386. * merged isconvertable and is_equal into compare_defs(_ext)
  2387. * made operator search faster by walking the list only once
  2388. Revision 1.91 2002/11/22 22:48:10 carl
  2389. * memory optimization with tconstsym (1.5%)
  2390. Revision 1.90 2002/11/20 22:49:55 pierre
  2391. * commented check code tht was invalid in 1.1
  2392. Revision 1.89 2002/11/18 18:34:41 peter
  2393. * fix crash with EXTDEBUG code
  2394. Revision 1.88 2002/11/18 17:48:21 peter
  2395. * fix tw2209 (merged)
  2396. Revision 1.87 2002/11/18 17:31:58 peter
  2397. * pass proccalloption to ret_in_xxx and push_xxx functions
  2398. Revision 1.86 2002/10/05 00:48:57 peter
  2399. * support inherited; support for overload as it is handled by
  2400. delphi. This is only for delphi mode as it is working is
  2401. undocumented and hard to predict what is done
  2402. Revision 1.85 2002/10/04 21:13:59 peter
  2403. * ignore vecn,subscriptn when checking for a procvar loadn
  2404. Revision 1.84 2002/10/02 20:51:22 peter
  2405. * don't check interfaces for class methods
  2406. Revision 1.83 2002/10/02 18:20:52 peter
  2407. * Copy() is now internal syssym that calls compilerprocs
  2408. Revision 1.82 2002/09/30 07:00:48 florian
  2409. * fixes to common code to get the alpha compiler compiled applied
  2410. Revision 1.81 2002/09/16 19:06:14 peter
  2411. * allow ^ after nil
  2412. Revision 1.80 2002/09/07 15:25:07 peter
  2413. * old logs removed and tabs fixed
  2414. Revision 1.79 2002/09/07 12:16:03 carl
  2415. * second part bug report 1996 fix, testrange in cordconstnode
  2416. only called if option is set (also make parsing a tiny faster)
  2417. Revision 1.78 2002/09/03 16:26:27 daniel
  2418. * Make Tprocdef.defs protected
  2419. Revision 1.77 2002/08/18 20:06:24 peter
  2420. * inlining is now also allowed in interface
  2421. * renamed write/load to ppuwrite/ppuload
  2422. * tnode storing in ppu
  2423. * nld,ncon,nbas are already updated for storing in ppu
  2424. Revision 1.76 2002/08/17 09:23:39 florian
  2425. * first part of procinfo rewrite
  2426. Revision 1.75 2002/08/01 16:37:47 jonas
  2427. - removed some superfluous "in_paras := true" statements
  2428. Revision 1.74 2002/07/26 21:15:41 florian
  2429. * rewrote the system handling
  2430. Revision 1.73 2002/07/23 09:51:23 daniel
  2431. * Tried to make Tprocsym.defs protected. I didn't succeed but the cleanups
  2432. are worth comitting.
  2433. Revision 1.72 2002/07/20 11:57:55 florian
  2434. * types.pas renamed to defbase.pas because D6 contains a types
  2435. unit so this would conflicts if D6 programms are compiled
  2436. + Willamette/SSE2 instructions to assembler added
  2437. Revision 1.71 2002/07/16 15:34:20 florian
  2438. * exit is now a syssym instead of a keyword
  2439. Revision 1.70 2002/07/06 20:18:02 carl
  2440. * longstring declaration now gives parser error since its not supported!
  2441. Revision 1.69 2002/06/12 15:46:14 jonas
  2442. * fixed web bug 1995
  2443. Revision 1.68 2002/05/18 13:34:12 peter
  2444. * readded missing revisions
  2445. Revision 1.67 2002/05/16 19:46:43 carl
  2446. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2447. + try to fix temp allocation (still in ifdef)
  2448. + generic constructor calls
  2449. + start of tassembler / tmodulebase class cleanup
  2450. Revision 1.65 2002/05/12 16:53:09 peter
  2451. * moved entry and exitcode to ncgutil and cgobj
  2452. * foreach gets extra argument for passing local data to the
  2453. iterator function
  2454. * -CR checks also class typecasts at runtime by changing them
  2455. into as
  2456. * fixed compiler to cycle with the -CR option
  2457. * fixed stabs with elf writer, finally the global variables can
  2458. be watched
  2459. * removed a lot of routines from cga unit and replaced them by
  2460. calls to cgobj
  2461. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2462. u32bit then the other is typecasted also to u32bit without giving
  2463. a rangecheck warning/error.
  2464. * fixed pascal calling method with reversing also the high tree in
  2465. the parast, detected by tcalcst3 test
  2466. Revision 1.64 2002/04/23 19:16:34 peter
  2467. * add pinline unit that inserts compiler supported functions using
  2468. one or more statements
  2469. * moved finalize and setlength from ninl to pinline
  2470. Revision 1.63 2002/04/21 19:02:05 peter
  2471. * removed newn and disposen nodes, the code is now directly
  2472. inlined from pexpr
  2473. * -an option that will write the secondpass nodes to the .s file, this
  2474. requires EXTDEBUG define to actually write the info
  2475. * fixed various internal errors and crashes due recent code changes
  2476. Revision 1.62 2002/04/16 16:11:17 peter
  2477. * using inherited; without a parent having the same function
  2478. will do nothing like delphi
  2479. Revision 1.61 2002/04/07 13:31:36 carl
  2480. + change unit use
  2481. Revision 1.60 2002/04/01 20:57:13 jonas
  2482. * fixed web bug 1907
  2483. * fixed some other procvar related bugs (all related to accepting procvar
  2484. constructs with either too many or too little parameters)
  2485. (both merged, includes second typo fix of pexpr.pas)
  2486. Revision 1.59 2002/03/31 20:26:35 jonas
  2487. + a_loadfpu_* and a_loadmm_* methods in tcg
  2488. * register allocation is now handled by a class and is mostly processor
  2489. independent (+rgobj.pas and i386/rgcpu.pas)
  2490. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  2491. * some small improvements and fixes to the optimizer
  2492. * some register allocation fixes
  2493. * some fpuvaroffset fixes in the unary minus node
  2494. * push/popusedregisters is now called rg.save/restoreusedregisters and
  2495. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  2496. also better optimizable)
  2497. * fixed and optimized register saving/restoring for new/dispose nodes
  2498. * LOC_FPU locations now also require their "register" field to be set to
  2499. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  2500. - list field removed of the tnode class because it's not used currently
  2501. and can cause hard-to-find bugs
  2502. }