pexpr.pas 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698
  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. {$ifdef TEST_PROCSYMS}
  1752. p1.unit_specific:=unit_specific;
  1753. {$endif TEST_PROCSYMS}
  1754. {tcallnode(p1).symtableprocentry:=tprocsym(sym);}
  1755. if token=_LKLAMMER then
  1756. begin
  1757. consume(_LKLAMMER);
  1758. tcallnode(p1).left:=parse_paras(false,false);
  1759. consume(_RKLAMMER);
  1760. end;
  1761. { proc():= is never possible }
  1762. if token=_ASSIGNMENT then
  1763. begin
  1764. Message(cg_e_illegal_expression);
  1765. p1:=cerrornode.create;
  1766. again:=false;
  1767. end;
  1768. end
  1769. else
  1770. again:=false;
  1771. end
  1772. else
  1773. again:=false;
  1774. end
  1775. else
  1776. again:=false;
  1777. end;
  1778. end;
  1779. end; { while again }
  1780. end;
  1781. {---------------------------------------------
  1782. Factor (Main)
  1783. ---------------------------------------------}
  1784. var
  1785. l : longint;
  1786. card : cardinal;
  1787. ic : TConstExprInt;
  1788. oldp1,
  1789. p1 : tnode;
  1790. code : integer;
  1791. {$ifdef TEST_PROCSYMS}
  1792. unit_specific,
  1793. {$endif TEST_PROCSYMS}
  1794. again : boolean;
  1795. sym : tsym;
  1796. classh : tobjectdef;
  1797. d : bestreal;
  1798. hs : string;
  1799. htype : ttype;
  1800. filepos : tfileposinfo;
  1801. {---------------------------------------------
  1802. Helpers
  1803. ---------------------------------------------}
  1804. procedure check_tokenpos;
  1805. begin
  1806. if (p1<>oldp1) then
  1807. begin
  1808. if assigned(p1) then
  1809. p1.set_tree_filepos(filepos);
  1810. oldp1:=p1;
  1811. filepos:=akttokenpos;
  1812. end;
  1813. end;
  1814. begin
  1815. oldp1:=nil;
  1816. p1:=nil;
  1817. filepos:=akttokenpos;
  1818. again:=false;
  1819. if token=_ID then
  1820. begin
  1821. factor_read_id(p1,again);
  1822. if again then
  1823. begin
  1824. check_tokenpos;
  1825. { handle post fix operators }
  1826. postfixoperators(p1,again);
  1827. end;
  1828. end
  1829. else
  1830. case token of
  1831. _SELF :
  1832. begin
  1833. again:=true;
  1834. consume(_SELF);
  1835. if not assigned(procinfo^._class) then
  1836. begin
  1837. p1:=cerrornode.create;
  1838. again:=false;
  1839. Message(parser_e_self_not_in_method);
  1840. end
  1841. else
  1842. begin
  1843. if (po_classmethod in aktprocdef.procoptions) then
  1844. begin
  1845. { self in class methods is a class reference type }
  1846. htype.setdef(procinfo^._class);
  1847. p1:=cselfnode.create(tobjectdef(tclassrefdef.create(htype)));
  1848. end
  1849. else
  1850. p1:=cselfnode.create(procinfo^._class);
  1851. postfixoperators(p1,again);
  1852. end;
  1853. end;
  1854. _INHERITED :
  1855. begin
  1856. again:=true;
  1857. consume(_INHERITED);
  1858. if assigned(procinfo^._class) then
  1859. begin
  1860. { if inherited; only then we need the method with
  1861. the same name }
  1862. if token=_SEMICOLON then
  1863. begin
  1864. hs:=aktprocsym.name;
  1865. auto_inherited:=true
  1866. end
  1867. else
  1868. begin
  1869. hs:=pattern;
  1870. consume(_ID);
  1871. auto_inherited:=false;
  1872. end;
  1873. classh:=procinfo^._class.childof;
  1874. while assigned(classh) do
  1875. begin
  1876. sym:=tsym(tobjectdef(classh).symtable.search(hs));
  1877. if assigned(sym) then
  1878. begin
  1879. if sym.typ=procsym then
  1880. begin
  1881. htype.setdef(classh);
  1882. p1:=ctypenode.create(htype);
  1883. end;
  1884. do_member_read(false,sym,p1,again);
  1885. break;
  1886. end;
  1887. classh:=classh.childof;
  1888. end;
  1889. if classh=nil then
  1890. begin
  1891. Message1(sym_e_id_no_member,hs);
  1892. again:=false;
  1893. p1:=cerrornode.create;
  1894. end;
  1895. { turn auto inheriting off }
  1896. auto_inherited:=false;
  1897. end
  1898. else
  1899. begin
  1900. Message(parser_e_generic_methods_only_in_methods);
  1901. again:=false;
  1902. p1:=cerrornode.create;
  1903. end;
  1904. postfixoperators(p1,again);
  1905. end;
  1906. _INTCONST :
  1907. begin
  1908. { try cardinal first }
  1909. val(pattern,card,code);
  1910. if code<>0 then
  1911. begin
  1912. { then longint }
  1913. valint(pattern,l,code);
  1914. if code <> 0 then
  1915. begin
  1916. { then int64 }
  1917. val(pattern,ic,code);
  1918. if code<>0 then
  1919. begin
  1920. {finally float }
  1921. val(pattern,d,code);
  1922. if code<>0 then
  1923. begin
  1924. Message(cg_e_invalid_integer);
  1925. consume(_INTCONST);
  1926. l:=1;
  1927. p1:=cordconstnode.create(l,s32bittype);
  1928. end
  1929. else
  1930. begin
  1931. consume(_INTCONST);
  1932. p1:=crealconstnode.create(d,pbestrealtype^);
  1933. end;
  1934. end
  1935. else
  1936. begin
  1937. consume(_INTCONST);
  1938. p1:=cordconstnode.create(ic,cs64bittype);
  1939. end
  1940. end
  1941. else
  1942. begin
  1943. consume(_INTCONST);
  1944. p1:=cordconstnode.create(l,s32bittype)
  1945. end
  1946. end
  1947. else
  1948. begin
  1949. consume(_INTCONST);
  1950. { check whether the value isn't in the longint range as well }
  1951. { (longint is easier to perform calculations with) (JM) }
  1952. if card <= $7fffffff then
  1953. { no sign extension necessary, so not longint typecast (JM) }
  1954. p1:=cordconstnode.create(card,s32bittype)
  1955. else
  1956. p1:=cordconstnode.create(card,u32bittype)
  1957. end;
  1958. end;
  1959. _REALNUMBER :
  1960. begin
  1961. val(pattern,d,code);
  1962. if code<>0 then
  1963. begin
  1964. Message(parser_e_error_in_real);
  1965. d:=1.0;
  1966. end;
  1967. consume(_REALNUMBER);
  1968. p1:=crealconstnode.create(d,pbestrealtype^);
  1969. end;
  1970. _STRING :
  1971. begin
  1972. string_dec(htype);
  1973. { STRING can be also a type cast }
  1974. if token=_LKLAMMER then
  1975. begin
  1976. consume(_LKLAMMER);
  1977. p1:=comp_expr(true);
  1978. consume(_RKLAMMER);
  1979. p1:=ctypeconvnode.create(p1,htype);
  1980. include(p1.flags,nf_explizit);
  1981. { handle postfix operators here e.g. string(a)[10] }
  1982. again:=true;
  1983. postfixoperators(p1,again);
  1984. end
  1985. else
  1986. p1:=ctypenode.create(htype);
  1987. end;
  1988. _FILE :
  1989. begin
  1990. htype:=cfiletype;
  1991. consume(_FILE);
  1992. { FILE can be also a type cast }
  1993. if token=_LKLAMMER then
  1994. begin
  1995. consume(_LKLAMMER);
  1996. p1:=comp_expr(true);
  1997. consume(_RKLAMMER);
  1998. p1:=ctypeconvnode.create(p1,htype);
  1999. include(p1.flags,nf_explizit);
  2000. { handle postfix operators here e.g. string(a)[10] }
  2001. again:=true;
  2002. postfixoperators(p1,again);
  2003. end
  2004. else
  2005. begin
  2006. p1:=ctypenode.create(htype);
  2007. end;
  2008. end;
  2009. _CSTRING :
  2010. begin
  2011. p1:=cstringconstnode.createstr(pattern,st_default);
  2012. consume(_CSTRING);
  2013. end;
  2014. _CCHAR :
  2015. begin
  2016. p1:=cordconstnode.create(ord(pattern[1]),cchartype);
  2017. consume(_CCHAR);
  2018. end;
  2019. _CWSTRING:
  2020. begin
  2021. p1:=cstringconstnode.createwstr(patternw);
  2022. consume(_CWSTRING);
  2023. end;
  2024. _CWCHAR:
  2025. begin
  2026. p1:=cordconstnode.create(ord(getcharwidestring(patternw,0)),cwidechartype);
  2027. consume(_CWCHAR);
  2028. end;
  2029. _KLAMMERAFFE :
  2030. begin
  2031. consume(_KLAMMERAFFE);
  2032. got_addrn:=true;
  2033. { support both @<x> and @(<x>) }
  2034. if token=_LKLAMMER then
  2035. begin
  2036. consume(_LKLAMMER);
  2037. p1:=factor(true);
  2038. consume(_RKLAMMER);
  2039. if token in [_CARET,_POINT,_LECKKLAMMER] then
  2040. begin
  2041. again:=true;
  2042. postfixoperators(p1,again);
  2043. end;
  2044. end
  2045. else
  2046. p1:=factor(true);
  2047. got_addrn:=false;
  2048. p1:=caddrnode.create(p1);
  2049. if getprocvar then
  2050. taddrnode(p1).getprocvardef:=getprocvardef;
  2051. end;
  2052. _LKLAMMER :
  2053. begin
  2054. consume(_LKLAMMER);
  2055. p1:=comp_expr(true);
  2056. consume(_RKLAMMER);
  2057. { it's not a good solution }
  2058. { but (a+b)^ makes some problems }
  2059. if token in [_CARET,_POINT,_LECKKLAMMER] then
  2060. begin
  2061. again:=true;
  2062. postfixoperators(p1,again);
  2063. end;
  2064. end;
  2065. _LECKKLAMMER :
  2066. begin
  2067. consume(_LECKKLAMMER);
  2068. p1:=factor_read_set;
  2069. consume(_RECKKLAMMER);
  2070. end;
  2071. _PLUS :
  2072. begin
  2073. consume(_PLUS);
  2074. p1:=factor(false);
  2075. end;
  2076. _MINUS :
  2077. begin
  2078. consume(_MINUS);
  2079. p1:=sub_expr(oppower,false);
  2080. p1:=cunaryminusnode.create(p1);
  2081. end;
  2082. _OP_NOT :
  2083. begin
  2084. consume(_OP_NOT);
  2085. p1:=factor(false);
  2086. p1:=cnotnode.create(p1);
  2087. end;
  2088. _TRUE :
  2089. begin
  2090. consume(_TRUE);
  2091. p1:=cordconstnode.create(1,booltype);
  2092. end;
  2093. _FALSE :
  2094. begin
  2095. consume(_FALSE);
  2096. p1:=cordconstnode.create(0,booltype);
  2097. end;
  2098. _NIL :
  2099. begin
  2100. consume(_NIL);
  2101. p1:=cnilnode.create;
  2102. end;
  2103. else
  2104. begin
  2105. p1:=cerrornode.create;
  2106. consume(token);
  2107. Message(cg_e_illegal_expression);
  2108. end;
  2109. end;
  2110. { generate error node if no node is created }
  2111. if not assigned(p1) then
  2112. begin
  2113. {$ifdef EXTDEBUG}
  2114. Comment(V_Warning,'factor: p1=nil');
  2115. {$endif}
  2116. p1:=cerrornode.create;
  2117. end;
  2118. { get the resulttype for the node }
  2119. if (not assigned(p1.resulttype.def)) then
  2120. do_resulttypepass(p1);
  2121. { tp7 procvar handling, but not if the next token
  2122. will be a := }
  2123. if (m_tp_procvar in aktmodeswitches) and
  2124. (token<>_ASSIGNMENT) then
  2125. check_tp_procvar(p1);
  2126. factor:=p1;
  2127. check_tokenpos;
  2128. end;
  2129. {$ifdef fpc}
  2130. {$maxfpuregisters default}
  2131. {$endif fpc}
  2132. {****************************************************************************
  2133. Sub_Expr
  2134. ****************************************************************************}
  2135. const
  2136. { Warning these stay be ordered !! }
  2137. operator_levels:array[Toperator_precedence] of set of Ttoken=
  2138. ([_LT,_LTE,_GT,_GTE,_EQUAL,_UNEQUAL,_OP_IN,_OP_IS],
  2139. [_PLUS,_MINUS,_OP_OR,_OP_XOR],
  2140. [_CARET,_SYMDIF,_STARSTAR,_STAR,_SLASH,
  2141. _OP_AS,_OP_AND,_OP_DIV,_OP_MOD,_OP_SHL,_OP_SHR],
  2142. [_STARSTAR] );
  2143. function sub_expr(pred_level:Toperator_precedence;accept_equal : boolean):tnode;
  2144. {Reads a subexpression while the operators are of the current precedence
  2145. level, or any higher level. Replaces the old term, simpl_expr and
  2146. simpl2_expr.}
  2147. var
  2148. p1,p2 : tnode;
  2149. oldt : Ttoken;
  2150. filepos : tfileposinfo;
  2151. begin
  2152. if pred_level=highest_precedence then
  2153. p1:=factor(false)
  2154. else
  2155. p1:=sub_expr(succ(pred_level),true);
  2156. repeat
  2157. if (token in operator_levels[pred_level]) and
  2158. ((token<>_EQUAL) or accept_equal) then
  2159. begin
  2160. oldt:=token;
  2161. filepos:=akttokenpos;
  2162. consume(token);
  2163. if pred_level=highest_precedence then
  2164. p2:=factor(false)
  2165. else
  2166. p2:=sub_expr(succ(pred_level),true);
  2167. case oldt of
  2168. _PLUS :
  2169. p1:=caddnode.create(addn,p1,p2);
  2170. _MINUS :
  2171. p1:=caddnode.create(subn,p1,p2);
  2172. _STAR :
  2173. p1:=caddnode.create(muln,p1,p2);
  2174. _SLASH :
  2175. p1:=caddnode.create(slashn,p1,p2);
  2176. _EQUAL :
  2177. p1:=caddnode.create(equaln,p1,p2);
  2178. _GT :
  2179. p1:=caddnode.create(gtn,p1,p2);
  2180. _LT :
  2181. p1:=caddnode.create(ltn,p1,p2);
  2182. _GTE :
  2183. p1:=caddnode.create(gten,p1,p2);
  2184. _LTE :
  2185. p1:=caddnode.create(lten,p1,p2);
  2186. _SYMDIF :
  2187. p1:=caddnode.create(symdifn,p1,p2);
  2188. _STARSTAR :
  2189. p1:=caddnode.create(starstarn,p1,p2);
  2190. _OP_AS :
  2191. p1:=casnode.create(p1,p2);
  2192. _OP_IN :
  2193. p1:=cinnode.create(p1,p2);
  2194. _OP_IS :
  2195. p1:=cisnode.create(p1,p2);
  2196. _OP_OR :
  2197. p1:=caddnode.create(orn,p1,p2);
  2198. _OP_AND :
  2199. p1:=caddnode.create(andn,p1,p2);
  2200. _OP_DIV :
  2201. p1:=cmoddivnode.create(divn,p1,p2);
  2202. _OP_NOT :
  2203. p1:=cnotnode.create(p1);
  2204. _OP_MOD :
  2205. p1:=cmoddivnode.create(modn,p1,p2);
  2206. _OP_SHL :
  2207. p1:=cshlshrnode.create(shln,p1,p2);
  2208. _OP_SHR :
  2209. p1:=cshlshrnode.create(shrn,p1,p2);
  2210. _OP_XOR :
  2211. p1:=caddnode.create(xorn,p1,p2);
  2212. _ASSIGNMENT :
  2213. p1:=cassignmentnode.create(p1,p2);
  2214. _CARET :
  2215. p1:=caddnode.create(caretn,p1,p2);
  2216. _UNEQUAL :
  2217. p1:=caddnode.create(unequaln,p1,p2);
  2218. end;
  2219. p1.set_tree_filepos(filepos);
  2220. end
  2221. else
  2222. break;
  2223. until false;
  2224. sub_expr:=p1;
  2225. end;
  2226. function comp_expr(accept_equal : boolean):tnode;
  2227. var
  2228. oldafterassignment : boolean;
  2229. p1 : tnode;
  2230. begin
  2231. oldafterassignment:=afterassignment;
  2232. afterassignment:=true;
  2233. p1:=sub_expr(opcompare,accept_equal);
  2234. { get the resulttype for this expression }
  2235. if not assigned(p1.resulttype.def) then
  2236. do_resulttypepass(p1);
  2237. afterassignment:=oldafterassignment;
  2238. comp_expr:=p1;
  2239. end;
  2240. function expr : tnode;
  2241. var
  2242. p1,p2 : tnode;
  2243. oldafterassignment : boolean;
  2244. oldp1 : tnode;
  2245. filepos : tfileposinfo;
  2246. begin
  2247. oldafterassignment:=afterassignment;
  2248. p1:=sub_expr(opcompare,true);
  2249. { get the resulttype for this expression }
  2250. if not assigned(p1.resulttype.def) then
  2251. do_resulttypepass(p1);
  2252. filepos:=akttokenpos;
  2253. if (m_tp_procvar in aktmodeswitches) and
  2254. (token<>_ASSIGNMENT) then
  2255. check_tp_procvar(p1);
  2256. if token in [_ASSIGNMENT,_PLUSASN,_MINUSASN,_STARASN,_SLASHASN] then
  2257. afterassignment:=true;
  2258. oldp1:=p1;
  2259. case token of
  2260. _POINTPOINT :
  2261. begin
  2262. consume(_POINTPOINT);
  2263. p2:=sub_expr(opcompare,true);
  2264. p1:=crangenode.create(p1,p2);
  2265. end;
  2266. _ASSIGNMENT :
  2267. begin
  2268. consume(_ASSIGNMENT);
  2269. if (p1.resulttype.def.deftype=procvardef) then
  2270. begin
  2271. getprocvar:=true;
  2272. getprocvardef:=tprocvardef(p1.resulttype.def);
  2273. end;
  2274. p2:=sub_expr(opcompare,true);
  2275. if getprocvar then
  2276. handle_procvar(getprocvardef,p2,true);
  2277. getprocvar:=false;
  2278. p1:=cassignmentnode.create(p1,p2);
  2279. end;
  2280. _PLUSASN :
  2281. begin
  2282. consume(_PLUSASN);
  2283. p2:=sub_expr(opcompare,true);
  2284. p1:=cassignmentnode.create(p1,caddnode.create(addn,p1.getcopy,p2));
  2285. end;
  2286. _MINUSASN :
  2287. begin
  2288. consume(_MINUSASN);
  2289. p2:=sub_expr(opcompare,true);
  2290. p1:=cassignmentnode.create(p1,caddnode.create(subn,p1.getcopy,p2));
  2291. end;
  2292. _STARASN :
  2293. begin
  2294. consume(_STARASN );
  2295. p2:=sub_expr(opcompare,true);
  2296. p1:=cassignmentnode.create(p1,caddnode.create(muln,p1.getcopy,p2));
  2297. end;
  2298. _SLASHASN :
  2299. begin
  2300. consume(_SLASHASN );
  2301. p2:=sub_expr(opcompare,true);
  2302. p1:=cassignmentnode.create(p1,caddnode.create(slashn,p1.getcopy,p2));
  2303. end;
  2304. end;
  2305. { get the resulttype for this expression }
  2306. if not assigned(p1.resulttype.def) then
  2307. do_resulttypepass(p1);
  2308. afterassignment:=oldafterassignment;
  2309. if p1<>oldp1 then
  2310. p1.set_tree_filepos(filepos);
  2311. expr:=p1;
  2312. end;
  2313. {$ifdef int64funcresok}
  2314. function get_intconst:TConstExprInt;
  2315. {$else int64funcresok}
  2316. function get_intconst:longint;
  2317. {$endif int64funcresok}
  2318. {Reads an expression, tries to evalute it and check if it is an integer
  2319. constant. Then the constant is returned.}
  2320. var
  2321. p:tnode;
  2322. begin
  2323. p:=comp_expr(true);
  2324. if not codegenerror then
  2325. begin
  2326. if (p.nodetype<>ordconstn) or
  2327. not(is_integer(p.resulttype.def)) then
  2328. Message(cg_e_illegal_expression)
  2329. else
  2330. get_intconst:=tordconstnode(p).value;
  2331. end;
  2332. p.free;
  2333. end;
  2334. function get_stringconst:string;
  2335. {Reads an expression, tries to evaluate it and checks if it is a string
  2336. constant. Then the constant is returned.}
  2337. var
  2338. p:tnode;
  2339. begin
  2340. get_stringconst:='';
  2341. p:=comp_expr(true);
  2342. if p.nodetype<>stringconstn then
  2343. begin
  2344. if (p.nodetype=ordconstn) and is_char(p.resulttype.def) then
  2345. get_stringconst:=char(tordconstnode(p).value)
  2346. else
  2347. Message(cg_e_illegal_expression);
  2348. end
  2349. else
  2350. get_stringconst:=strpas(tstringconstnode(p).value_str);
  2351. p.free;
  2352. end;
  2353. end.
  2354. {
  2355. $Log$
  2356. Revision 1.49 2001-11-02 22:58:05 peter
  2357. * procsym definition rewrite
  2358. Revision 1.48 2001/10/28 17:22:25 peter
  2359. * allow assignment of overloaded procedures to procvars when we know
  2360. which procedure to take
  2361. Revision 1.47 2001/10/24 11:51:39 marco
  2362. * Make new/dispose system functions instead of keywords
  2363. Revision 1.46 2001/10/21 13:10:51 peter
  2364. * better support for indexed properties
  2365. Revision 1.45 2001/10/21 12:33:07 peter
  2366. * array access for properties added
  2367. Revision 1.44 2001/10/20 19:28:39 peter
  2368. * interface 2 guid support
  2369. * guid constants support
  2370. Revision 1.43 2001/10/18 16:30:38 jonas
  2371. * property parameters are now fully parsed by the firstcall code to
  2372. check for the correct amount and types (merged)
  2373. Revision 1.42 2001/09/02 21:18:28 peter
  2374. * split constsym.value in valueord,valueordptr,valueptr. The valueordptr
  2375. is used for holding target platform pointer values. As those can be
  2376. bigger than the source platform.
  2377. Revision 1.41 2001/08/26 13:36:45 florian
  2378. * some cg reorganisation
  2379. * some PPC updates
  2380. Revision 1.40 2001/08/22 21:16:21 florian
  2381. * some interfaces related problems regarding
  2382. mapping of interface implementions fixed
  2383. Revision 1.39 2001/08/06 21:40:47 peter
  2384. * funcret moved from tprocinfo to tprocdef
  2385. Revision 1.38 2001/07/09 21:15:41 peter
  2386. * Length made internal
  2387. * Add array support for Length
  2388. Revision 1.37 2001/06/29 14:16:57 jonas
  2389. * fixed inconsistent handling of procvars in FPC mode (sometimes @ was
  2390. required to assign the address of a procedure to a procvar, sometimes
  2391. not. Now it is always required) (merged)
  2392. Revision 1.36 2001/06/04 18:16:42 peter
  2393. * fixed tp procvar support in parameters of a called procvar
  2394. * typenode cleanup, no special handling needed anymore for bt_type
  2395. Revision 1.35 2001/06/04 11:45:35 peter
  2396. * parse const after .. using bt_const block to allow expressions, this
  2397. is Delphi compatible
  2398. Revision 1.34 2001/05/19 21:15:53 peter
  2399. * allow typenodes for typeinfo and typeof
  2400. * tp procvar fixes for properties
  2401. Revision 1.33 2001/05/19 12:23:59 peter
  2402. * fixed crash with auto dereferencing
  2403. Revision 1.32 2001/05/09 19:52:51 peter
  2404. * removed unused allow_type
  2405. Revision 1.31 2001/05/04 15:52:03 florian
  2406. * some Delphi incompatibilities fixed:
  2407. - out, dispose and new can be used as idenfiers now
  2408. - const p = apointerype(nil); is supported now
  2409. + support for const p = apointertype(pointer(1234)); added
  2410. Revision 1.30 2001/04/14 14:07:10 peter
  2411. * moved more code from pass_1 to det_resulttype
  2412. Revision 1.29 2001/04/13 23:50:24 peter
  2413. * fpc mode now requires @ also when left of assignment is an procvardef
  2414. Revision 1.28 2001/04/13 01:22:12 peter
  2415. * symtable change to classes
  2416. * range check generation and errors fixed, make cycle DEBUG=1 works
  2417. * memory leaks fixed
  2418. Revision 1.27 2001/04/04 22:43:52 peter
  2419. * remove unnecessary calls to firstpass
  2420. Revision 1.26 2001/04/02 21:20:33 peter
  2421. * resulttype rewrite
  2422. Revision 1.25 2001/03/11 22:58:50 peter
  2423. * getsym redesign, removed the globals srsym,srsymtable
  2424. Revision 1.24 2000/12/25 00:07:27 peter
  2425. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  2426. tlinkedlist objects)
  2427. Revision 1.23 2000/12/19 20:36:03 peter
  2428. * cardinal const expr fix from jonas
  2429. Revision 1.22 2000/12/17 14:00:18 peter
  2430. * fixed static variables
  2431. Revision 1.21 2000/12/15 13:26:01 jonas
  2432. * only return int64's from functions if it int64funcresok is defined
  2433. + added int64funcresok define to options.pas
  2434. Revision 1.20 2000/12/15 12:13:52 michael
  2435. + Fix from Peter
  2436. Revision 1.19 2000/12/07 17:19:42 jonas
  2437. * new constant handling: from now on, hex constants >$7fffffff are
  2438. parsed as unsigned constants (otherwise, $80000000 got sign extended
  2439. and became $ffffffff80000000), all constants in the longint range
  2440. become longints, all constants >$7fffffff and <=cardinal($ffffffff)
  2441. are cardinals and the rest are int64's.
  2442. * added lots of longint typecast to prevent range check errors in the
  2443. compiler and rtl
  2444. * type casts of symbolic ordinal constants are now preserved
  2445. * fixed bug where the original resulttype.def wasn't restored correctly
  2446. after doing a 64bit rangecheck
  2447. Revision 1.18 2000/11/29 00:30:36 florian
  2448. * unused units removed from uses clause
  2449. * some changes for widestrings
  2450. Revision 1.17 2000/11/09 17:46:55 florian
  2451. * System.TypeInfo fixed
  2452. + System.Finalize implemented
  2453. + some new keywords for interface support added
  2454. Revision 1.16 2000/11/06 20:30:55 peter
  2455. * more fixes to get make cycle working
  2456. Revision 1.15 2000/11/04 14:25:20 florian
  2457. + merged Attila's changes for interfaces, not tested yet
  2458. Revision 1.14 2000/10/31 22:02:49 peter
  2459. * symtable splitted, no real code changes
  2460. Revision 1.13 2000/10/26 23:40:54 peter
  2461. * fixed crash with call from type decl which is not allowed (merged)
  2462. Revision 1.12 2000/10/21 18:16:12 florian
  2463. * a lot of changes:
  2464. - basic dyn. array support
  2465. - basic C++ support
  2466. - some work for interfaces done
  2467. ....
  2468. Revision 1.11 2000/10/14 10:14:51 peter
  2469. * moehrendorf oct 2000 rewrite
  2470. Revision 1.10 2000/10/01 19:48:25 peter
  2471. * lot of compile updates for cg11
  2472. Revision 1.9 2000/09/24 21:19:50 peter
  2473. * delphi compile fixes
  2474. Revision 1.8 2000/09/24 15:06:22 peter
  2475. * use defines.inc
  2476. Revision 1.7 2000/08/27 16:11:51 peter
  2477. * moved some util functions from globals,cobjects to cutils
  2478. * splitted files into finput,fmodule
  2479. Revision 1.6 2000/08/20 15:12:49 peter
  2480. * auto derefence mode for array pointer (merged)
  2481. Revision 1.5 2000/08/16 18:33:53 peter
  2482. * splitted namedobjectitem.next into indexnext and listnext so it
  2483. can be used in both lists
  2484. * don't allow "word = word" type definitions (merged)
  2485. Revision 1.4 2000/08/16 13:06:06 florian
  2486. + support of 64 bit integer constants
  2487. Revision 1.3 2000/08/04 22:00:52 peter
  2488. * merges from fixes
  2489. Revision 1.2 2000/07/13 11:32:44 michael
  2490. + removed logs
  2491. }