pexpr.pas 99 KB

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