pexpr.pas 99 KB

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