pexpr.pas 100 KB

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