pexpr.pas 96 KB

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