pdecobj.pas 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Does object types for Free Pascal
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit pdecobj;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,
  22. globtype,symconst,symtype,symdef;
  23. { parses a object declaration }
  24. function object_dec(objecttype:tobjecttyp;const n:tidstring;genericdef:tstoreddef;genericlist:TFPObjectList;fd : tobjectdef;helpertype:thelpertype) : tobjectdef;
  25. function class_constructor_head:tprocdef;
  26. function class_destructor_head:tprocdef;
  27. function constructor_head:tprocdef;
  28. function destructor_head:tprocdef;
  29. procedure struct_property_dec(is_classproperty:boolean);
  30. implementation
  31. uses
  32. sysutils,cutils,
  33. globals,verbose,systems,tokens,
  34. symbase,symsym,symtable,
  35. node,nld,nmem,ncon,ncnv,ncal,
  36. fmodule,scanner,
  37. pbase,pexpr,pdecsub,pdecvar,ptype,pdecl,pgenutil,ppu
  38. ;
  39. const
  40. { Please leave this here, this module should NOT use
  41. these variables.
  42. Declaring it as string here results in an error when compiling (PFV) }
  43. current_procinfo = 'error';
  44. var
  45. current_objectdef : tobjectdef absolute current_structdef;
  46. function class_constructor_head:tprocdef;
  47. var
  48. pd : tprocdef;
  49. begin
  50. result:=nil;
  51. consume(_CONSTRUCTOR);
  52. { must be at same level as in implementation }
  53. parse_proc_head(current_structdef,potype_class_constructor,pd);
  54. if not assigned(pd) then
  55. begin
  56. consume(_SEMICOLON);
  57. exit;
  58. end;
  59. pd.calcparas;
  60. if (pd.maxparacount>0) then
  61. Message(parser_e_no_paras_for_class_constructor);
  62. consume(_SEMICOLON);
  63. include(current_structdef.objectoptions,oo_has_class_constructor);
  64. current_module.flags:=current_module.flags or uf_classinits;
  65. { no return value }
  66. pd.returndef:=voidtype;
  67. result:=pd;
  68. end;
  69. function constructor_head:tprocdef;
  70. var
  71. pd : tprocdef;
  72. begin
  73. result:=nil;
  74. consume(_CONSTRUCTOR);
  75. { must be at same level as in implementation }
  76. parse_proc_head(current_structdef,potype_constructor,pd);
  77. if not assigned(pd) then
  78. begin
  79. consume(_SEMICOLON);
  80. exit;
  81. end;
  82. if (cs_constructor_name in current_settings.globalswitches) and
  83. (pd.procsym.name<>'INIT') then
  84. Message(parser_e_constructorname_must_be_init);
  85. consume(_SEMICOLON);
  86. include(current_structdef.objectoptions,oo_has_constructor);
  87. { Set return type, class and record constructors return the
  88. created instance, object constructors return boolean }
  89. if is_class(pd.struct) or is_record(pd.struct) then
  90. pd.returndef:=pd.struct
  91. else
  92. {$ifdef CPU64bitaddr}
  93. pd.returndef:=bool64type;
  94. {$else CPU64bitaddr}
  95. pd.returndef:=bool32type;
  96. {$endif CPU64bitaddr}
  97. result:=pd;
  98. end;
  99. procedure struct_property_dec(is_classproperty:boolean);
  100. var
  101. p : tpropertysym;
  102. begin
  103. { check for a class, record or helper }
  104. if not((is_class_or_interface_or_dispinterface(current_structdef) or is_record(current_structdef) or is_objectpascal_helper(current_structdef)) or
  105. (not(m_tp7 in current_settings.modeswitches) and (is_object(current_structdef)))) then
  106. Message(parser_e_syntax_error);
  107. consume(_PROPERTY);
  108. p:=read_property_dec(is_classproperty,current_structdef);
  109. consume(_SEMICOLON);
  110. if try_to_consume(_DEFAULT) then
  111. begin
  112. if oo_has_default_property in current_structdef.objectoptions then
  113. message(parser_e_only_one_default_property);
  114. include(current_structdef.objectoptions,oo_has_default_property);
  115. include(p.propoptions,ppo_defaultproperty);
  116. if not(ppo_hasparameters in p.propoptions) then
  117. message(parser_e_property_need_paras);
  118. if (token=_COLON) then
  119. begin
  120. Message(parser_e_field_not_allowed_here);
  121. consume_all_until(_SEMICOLON);
  122. end;
  123. consume(_SEMICOLON);
  124. end;
  125. { parse possible enumerator modifier }
  126. if try_to_consume(_ENUMERATOR) then
  127. begin
  128. if (token = _ID) then
  129. begin
  130. if pattern='CURRENT' then
  131. begin
  132. if oo_has_enumerator_current in current_structdef.objectoptions then
  133. message(parser_e_only_one_enumerator_current);
  134. if not p.propaccesslist[palt_read].empty then
  135. begin
  136. include(current_structdef.objectoptions,oo_has_enumerator_current);
  137. include(p.propoptions,ppo_enumerator_current);
  138. end
  139. else
  140. Message(parser_e_enumerator_current_is_not_valid) // property has no reader
  141. end
  142. else
  143. Message1(parser_e_invalid_enumerator_identifier, pattern);
  144. consume(token);
  145. end
  146. else
  147. Message(parser_e_enumerator_identifier_required);
  148. consume(_SEMICOLON);
  149. end;
  150. { hint directives, these can be separated by semicolons here,
  151. that needs to be handled here with a loop (PFV) }
  152. while try_consume_hintdirective(p.symoptions,p.deprecatedmsg) do
  153. Consume(_SEMICOLON);
  154. end;
  155. function class_destructor_head:tprocdef;
  156. var
  157. pd : tprocdef;
  158. begin
  159. result:=nil;
  160. consume(_DESTRUCTOR);
  161. parse_proc_head(current_structdef,potype_class_destructor,pd);
  162. if not assigned(pd) then
  163. begin
  164. consume(_SEMICOLON);
  165. exit;
  166. end;
  167. pd.calcparas;
  168. if (pd.maxparacount>0) then
  169. Message(parser_e_no_paras_for_class_destructor);
  170. consume(_SEMICOLON);
  171. include(current_structdef.objectoptions,oo_has_class_destructor);
  172. current_module.flags:=current_module.flags or uf_classinits;
  173. { no return value }
  174. pd.returndef:=voidtype;
  175. result:=pd;
  176. end;
  177. function destructor_head:tprocdef;
  178. var
  179. pd : tprocdef;
  180. begin
  181. result:=nil;
  182. consume(_DESTRUCTOR);
  183. parse_proc_head(current_structdef,potype_destructor,pd);
  184. if not assigned(pd) then
  185. begin
  186. consume(_SEMICOLON);
  187. exit;
  188. end;
  189. if (cs_constructor_name in current_settings.globalswitches) and
  190. (pd.procsym.name<>'DONE') then
  191. Message(parser_e_destructorname_must_be_done);
  192. pd.calcparas;
  193. if not(pd.maxparacount=0) and
  194. (m_fpc in current_settings.modeswitches) then
  195. Message(parser_e_no_paras_for_destructor);
  196. consume(_SEMICOLON);
  197. include(current_structdef.objectoptions,oo_has_destructor);
  198. { no return value }
  199. pd.returndef:=voidtype;
  200. result:=pd;
  201. end;
  202. procedure setinterfacemethodoptions;
  203. var
  204. i : longint;
  205. def : tdef;
  206. begin
  207. include(current_structdef.objectoptions,oo_has_virtual);
  208. for i:=0 to current_structdef.symtable.DefList.count-1 do
  209. begin
  210. def:=tdef(current_structdef.symtable.DefList[i]);
  211. if assigned(def) and
  212. (def.typ=procdef) then
  213. begin
  214. include(tprocdef(def).procoptions,po_virtualmethod);
  215. tprocdef(def).forwarddef:=false;
  216. end;
  217. end;
  218. end;
  219. procedure setobjcclassmethodoptions;
  220. var
  221. i : longint;
  222. def : tdef;
  223. begin
  224. for i:=0 to current_structdef.symtable.DefList.count-1 do
  225. begin
  226. def:=tdef(current_structdef.symtable.DefList[i]);
  227. if assigned(def) and
  228. (def.typ=procdef) then
  229. begin
  230. include(tprocdef(def).procoptions,po_virtualmethod);
  231. end;
  232. end;
  233. end;
  234. procedure handleImplementedInterface(intfdef : tobjectdef);
  235. begin
  236. if not is_interface(intfdef) then
  237. begin
  238. Message1(type_e_interface_type_expected,intfdef.typename);
  239. exit;
  240. end;
  241. if current_objectdef.find_implemented_interface(intfdef)<>nil then
  242. Message1(sym_e_duplicate_id,intfdef.objname^)
  243. else
  244. begin
  245. { allocate and prepare the GUID only if the class
  246. implements some interfaces. }
  247. if current_objectdef.ImplementedInterfaces.count = 0 then
  248. current_objectdef.prepareguid;
  249. current_objectdef.ImplementedInterfaces.Add(TImplementedInterface.Create(intfdef));
  250. end;
  251. end;
  252. procedure handleImplementedProtocol(intfdef : tobjectdef);
  253. begin
  254. intfdef:=find_real_objcclass_definition(intfdef,false);
  255. if not is_objcprotocol(intfdef) then
  256. begin
  257. Message1(type_e_protocol_type_expected,intfdef.typename);
  258. exit;
  259. end;
  260. if ([oo_is_forward,oo_is_formal] * intfdef.objectoptions <> []) then
  261. begin
  262. Message1(parser_e_forward_protocol_declaration_must_be_resolved,intfdef.objrealname^);
  263. exit;
  264. end;
  265. if current_objectdef.find_implemented_interface(intfdef)<>nil then
  266. Message1(sym_e_duplicate_id,intfdef.objname^)
  267. else
  268. begin
  269. current_objectdef.ImplementedInterfaces.Add(TImplementedInterface.Create(intfdef));
  270. end;
  271. end;
  272. procedure readImplementedInterfacesAndProtocols(intf: boolean);
  273. var
  274. hdef : tdef;
  275. begin
  276. while try_to_consume(_COMMA) do
  277. begin
  278. { use single_type instead of id_type for specialize support }
  279. single_type(hdef,[stoAllowSpecialization,stoParseClassParent]);
  280. { TODO : handle a generic interface }
  281. if (hdef.typ<>objectdef) then
  282. begin
  283. if intf then
  284. Message1(type_e_interface_type_expected,hdef.typename)
  285. else
  286. Message1(type_e_protocol_type_expected,hdef.typename);
  287. continue;
  288. end;
  289. if intf then
  290. handleImplementedInterface(tobjectdef(hdef))
  291. else
  292. handleImplementedProtocol(tobjectdef(hdef));
  293. end;
  294. end;
  295. procedure readinterfaceiid;
  296. var
  297. p : tnode;
  298. valid : boolean;
  299. begin
  300. p:=comp_expr(true,false);
  301. if p.nodetype=stringconstn then
  302. begin
  303. stringdispose(current_objectdef.iidstr);
  304. current_objectdef.iidstr:=stringdup(strpas(tstringconstnode(p).value_str));
  305. valid:=string2guid(current_objectdef.iidstr^,current_objectdef.iidguid^);
  306. if (current_objectdef.objecttype in [odt_interfacecom,odt_dispinterface]) and
  307. not valid then
  308. Message(parser_e_improper_guid_syntax);
  309. include(current_structdef.objectoptions,oo_has_valid_guid);
  310. end
  311. else
  312. Message(parser_e_illegal_expression);
  313. p.free;
  314. end;
  315. procedure get_cpp_class_external_status(od: tobjectdef);
  316. var
  317. hs: string;
  318. begin
  319. { C++ classes can be external -> all methods inside are external
  320. (defined at the class level instead of per method, so that you cannot
  321. define some methods as external and some not)
  322. }
  323. if try_to_consume(_EXTERNAL) then
  324. begin
  325. if token in [_CSTRING,_CWSTRING,_CCHAR,_CWCHAR] then
  326. begin
  327. { Always add library prefix and suffix to create an uniform name }
  328. hs:=get_stringconst;
  329. if ExtractFileExt(hs)='' then
  330. hs:=ChangeFileExt(hs,target_info.sharedlibext);
  331. if Copy(hs,1,length(target_info.sharedlibprefix))<>target_info.sharedlibprefix then
  332. hs:=target_info.sharedlibprefix+hs;
  333. od.import_lib:=stringdup(hs);
  334. end;
  335. include(od.objectoptions, oo_is_external);
  336. { check if we shall use another name for the class }
  337. if try_to_consume(_NAME) then
  338. od.objextname:=stringdup(get_stringconst)
  339. else
  340. od.objextname:=stringdup(od.objrealname^);
  341. include(od.objectoptions,oo_is_external);
  342. end
  343. else
  344. od.objextname:=stringdup(od.objrealname^);
  345. { ToDo: read the namespace of the class (influences the mangled name)}
  346. end;
  347. procedure get_objc_class_or_protocol_external_status(od: tobjectdef);
  348. begin
  349. { Objective-C classes can be external -> all messages inside are
  350. external (defined at the class level instead of per method, so
  351. that you cannot define some methods as external and some not)
  352. }
  353. if try_to_consume(_EXTERNAL) then
  354. begin
  355. if try_to_consume(_NAME) then
  356. od.objextname:=stringdup(get_stringconst)
  357. else
  358. { the external name doesn't matter for formally declared
  359. classes, and allowing to specify one would mean that we would
  360. have to check it for consistency with the actual definition
  361. later on }
  362. od.objextname:=stringdup(od.objrealname^);
  363. include(od.objectoptions,oo_is_external);
  364. end
  365. else
  366. od.objextname:=stringdup(od.objrealname^);
  367. end;
  368. procedure parse_object_options;
  369. begin
  370. case current_objectdef.objecttype of
  371. odt_object,odt_class:
  372. begin
  373. while true do
  374. begin
  375. if try_to_consume(_ABSTRACT) then
  376. include(current_structdef.objectoptions,oo_is_abstract)
  377. else
  378. if try_to_consume(_SEALED) then
  379. include(current_structdef.objectoptions,oo_is_sealed)
  380. else
  381. break;
  382. end;
  383. if [oo_is_abstract, oo_is_sealed] * current_structdef.objectoptions = [oo_is_abstract, oo_is_sealed] then
  384. Message(parser_e_abstract_and_sealed_conflict);
  385. end;
  386. odt_cppclass:
  387. get_cpp_class_external_status(current_objectdef);
  388. odt_objcclass,odt_objcprotocol,odt_objccategory:
  389. get_objc_class_or_protocol_external_status(current_objectdef);
  390. odt_helper: ; // nothing
  391. end;
  392. end;
  393. procedure parse_parent_classes;
  394. var
  395. intfchildof,
  396. childof : tobjectdef;
  397. hdef : tdef;
  398. hasparentdefined : boolean;
  399. begin
  400. childof:=nil;
  401. intfchildof:=nil;
  402. hasparentdefined:=false;
  403. { reads the parent class }
  404. if (token=_LKLAMMER) or
  405. is_objccategory(current_structdef) then
  406. begin
  407. consume(_LKLAMMER);
  408. { use single_type instead of id_type for specialize support }
  409. single_type(hdef,[stoAllowSpecialization, stoParseClassParent]);
  410. if (not assigned(hdef)) or
  411. (hdef.typ<>objectdef) then
  412. begin
  413. if assigned(hdef) then
  414. Message1(type_e_class_type_expected,hdef.typename)
  415. else if is_objccategory(current_structdef) then
  416. { a category must specify the class to extend }
  417. Message(type_e_objcclass_type_expected);
  418. end
  419. else
  420. begin
  421. childof:=tobjectdef(hdef);
  422. { a mix of class, interfaces, objects and cppclasses
  423. isn't allowed }
  424. case current_objectdef.objecttype of
  425. odt_class:
  426. if not(is_class(childof)) then
  427. begin
  428. if is_interface(childof) then
  429. begin
  430. { we insert the interface after the child
  431. is set, see below
  432. }
  433. intfchildof:=childof;
  434. childof:=class_tobject;
  435. end
  436. else
  437. Message(parser_e_mix_of_classes_and_objects);
  438. end
  439. else
  440. if oo_is_sealed in childof.objectoptions then
  441. Message1(parser_e_sealed_descendant,childof.typename);
  442. odt_interfacecorba,
  443. odt_interfacecom:
  444. begin
  445. if not(is_interface(childof)) then
  446. Message(parser_e_mix_of_classes_and_objects);
  447. current_objectdef.objecttype:=childof.objecttype;
  448. end;
  449. odt_cppclass:
  450. if not(is_cppclass(childof)) then
  451. Message(parser_e_mix_of_classes_and_objects);
  452. odt_objcclass:
  453. if not(is_objcclass(childof) or
  454. is_objccategory(childof)) then
  455. begin
  456. if is_objcprotocol(childof) then
  457. begin
  458. if not(oo_is_classhelper in current_structdef.objectoptions) then
  459. begin
  460. intfchildof:=childof;
  461. childof:=nil;
  462. CGMessage(parser_h_no_objc_parent);
  463. end
  464. else
  465. { a category must specify the class to extend }
  466. CGMessage(type_e_objcclass_type_expected);
  467. end
  468. else
  469. Message(parser_e_mix_of_classes_and_objects);
  470. end
  471. else
  472. childof:=find_real_objcclass_definition(childof,true);
  473. odt_objcprotocol:
  474. begin
  475. if not(is_objcprotocol(childof)) then
  476. Message(parser_e_mix_of_classes_and_objects);
  477. intfchildof:=childof;
  478. childof:=nil;
  479. end;
  480. odt_object:
  481. if not(is_object(childof)) then
  482. Message(parser_e_mix_of_classes_and_objects)
  483. else
  484. if oo_is_sealed in childof.objectoptions then
  485. Message1(parser_e_sealed_descendant,childof.typename);
  486. odt_dispinterface:
  487. Message(parser_e_dispinterface_cant_have_parent);
  488. odt_helper:
  489. if not is_objectpascal_helper(childof) then
  490. begin
  491. Message(type_e_helper_type_expected);
  492. childof:=nil;
  493. end;
  494. end;
  495. end;
  496. hasparentdefined:=true;
  497. end;
  498. { if no parent class, then a class get tobject as parent }
  499. if not assigned(childof) then
  500. begin
  501. case current_objectdef.objecttype of
  502. odt_class:
  503. if current_objectdef<>class_tobject then
  504. childof:=class_tobject;
  505. odt_interfacecom:
  506. if current_objectdef<>interface_iunknown then
  507. childof:=interface_iunknown;
  508. odt_dispinterface:
  509. childof:=interface_idispatch;
  510. odt_objcclass:
  511. CGMessage(parser_h_no_objc_parent);
  512. end;
  513. end;
  514. if assigned(childof) then
  515. begin
  516. { Forbid not completly defined objects to be used as parents. This will
  517. also prevent circular loops of classes, because we set the forward flag
  518. at the start of the new definition and will reset it below after the
  519. parent has been set }
  520. if (oo_is_forward in childof.objectoptions) then
  521. Message1(parser_e_forward_declaration_must_be_resolved,childof.objrealname^)
  522. else if not(oo_is_formal in childof.objectoptions) then
  523. current_objectdef.set_parent(childof)
  524. else
  525. Message1(sym_e_objc_formal_class_not_resolved,childof.objrealname^);
  526. end;
  527. { remove forward flag, is resolved }
  528. exclude(current_structdef.objectoptions,oo_is_forward);
  529. if hasparentdefined then
  530. begin
  531. if current_objectdef.objecttype in [odt_class,odt_objcclass,odt_objcprotocol] then
  532. begin
  533. if assigned(intfchildof) then
  534. if current_objectdef.objecttype=odt_class then
  535. handleImplementedInterface(intfchildof)
  536. else
  537. handleImplementedProtocol(intfchildof);
  538. readImplementedInterfacesAndProtocols(current_objectdef.objecttype=odt_class);
  539. end;
  540. consume(_RKLAMMER);
  541. end;
  542. end;
  543. procedure parse_extended_type(helpertype:thelpertype);
  544. var
  545. hdef: tdef;
  546. begin
  547. if not is_objectpascal_helper(current_structdef) then
  548. Internalerror(2011021103);
  549. if helpertype=ht_none then
  550. Internalerror(2011021001);
  551. consume(_FOR);
  552. single_type(hdef,[stoParseClassParent]);
  553. if (not assigned(hdef)) or
  554. not (hdef.typ in [objectdef,recorddef]) then
  555. begin
  556. if helpertype=ht_class then
  557. Message1(type_e_class_type_expected,hdef.typename)
  558. else
  559. if helpertype=ht_record then
  560. Message1(type_e_record_type_expected,hdef.typename);
  561. end
  562. else
  563. begin
  564. case helpertype of
  565. ht_class:
  566. begin
  567. if not is_class(hdef) then
  568. Message1(type_e_class_type_expected,hdef.typename);
  569. { a class helper must extend the same class or a subclass
  570. of the class extended by the parent class helper }
  571. if assigned(current_objectdef.childof) then
  572. begin
  573. if not is_class(current_objectdef.childof.extendeddef) then
  574. Internalerror(2011021101);
  575. if not hdef.is_related(current_objectdef.childof.extendeddef) then
  576. Message1(type_e_class_helper_must_extend_subclass,current_objectdef.childof.extendeddef.typename);
  577. end;
  578. end;
  579. ht_record:
  580. begin
  581. if not is_record(hdef) then
  582. Message1(type_e_record_type_expected,hdef.typename);
  583. { a record helper must extend the same record as the
  584. parent helper }
  585. if assigned(current_objectdef.childof) then
  586. begin
  587. if not is_record(current_objectdef.childof.extendeddef) then
  588. Internalerror(2011021102);
  589. if hdef<>current_objectdef.childof.extendeddef then
  590. Message1(type_e_record_helper_must_extend_same_record,current_objectdef.childof.extendeddef.typename);
  591. end;
  592. end;
  593. end;
  594. current_objectdef.extendeddef:=tabstractrecorddef(hdef);
  595. end;
  596. end;
  597. procedure parse_guid;
  598. begin
  599. { read GUID }
  600. if (current_objectdef.objecttype in [odt_interfacecom,odt_interfacecorba,odt_dispinterface]) and
  601. try_to_consume(_LECKKLAMMER) then
  602. begin
  603. readinterfaceiid;
  604. consume(_RECKKLAMMER);
  605. end
  606. else if (current_objectdef.objecttype=odt_dispinterface) then
  607. message(parser_e_dispinterface_needs_a_guid);
  608. end;
  609. procedure parse_object_members;
  610. procedure chkobjc(pd: tprocdef);
  611. begin
  612. if is_objc_class_or_protocol(pd.struct) then
  613. begin
  614. include(pd.procoptions,po_objc);
  615. end;
  616. end;
  617. procedure chkcpp(pd:tprocdef);
  618. begin
  619. { nothing currently }
  620. end;
  621. procedure maybe_parse_hint_directives(pd:tprocdef);
  622. var
  623. dummysymoptions : tsymoptions;
  624. deprecatedmsg : pshortstring;
  625. begin
  626. dummysymoptions:=[];
  627. deprecatedmsg:=nil;
  628. while try_consume_hintdirective(dummysymoptions,deprecatedmsg) do
  629. Consume(_SEMICOLON);
  630. if assigned(pd) then
  631. begin
  632. pd.symoptions:=pd.symoptions+dummysymoptions;
  633. pd.deprecatedmsg:=deprecatedmsg;
  634. end
  635. else
  636. stringdispose(deprecatedmsg);
  637. end;
  638. var
  639. pd : tprocdef;
  640. has_destructor,
  641. oldparse_only: boolean;
  642. object_member_blocktype : tblock_type;
  643. fields_allowed, is_classdef, classfields: boolean;
  644. vdoptions: tvar_dec_options;
  645. begin
  646. { empty class declaration ? }
  647. if (current_objectdef.objecttype in [odt_class,odt_objcclass]) and
  648. (token=_SEMICOLON) then
  649. exit;
  650. { in "publishable" classes the default access type is published }
  651. if (oo_can_have_published in current_structdef.objectoptions) then
  652. current_structdef.symtable.currentvisibility:=vis_published
  653. else
  654. current_structdef.symtable.currentvisibility:=vis_public;
  655. has_destructor:=false;
  656. fields_allowed:=true;
  657. is_classdef:=false;
  658. classfields:=false;
  659. object_member_blocktype:=bt_general;
  660. repeat
  661. case token of
  662. _TYPE :
  663. begin
  664. if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper]) then
  665. Message(parser_e_type_var_const_only_in_records_and_classes);
  666. consume(_TYPE);
  667. object_member_blocktype:=bt_type;
  668. end;
  669. _VAR :
  670. begin
  671. if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper]) then
  672. Message(parser_e_type_var_const_only_in_records_and_classes);
  673. consume(_VAR);
  674. fields_allowed:=true;
  675. object_member_blocktype:=bt_general;
  676. classfields:=is_classdef;
  677. is_classdef:=false;
  678. end;
  679. _CONST:
  680. begin
  681. if not(current_objectdef.objecttype in [odt_class,odt_object,odt_helper]) then
  682. Message(parser_e_type_var_const_only_in_records_and_classes);
  683. consume(_CONST);
  684. object_member_blocktype:=bt_const;
  685. end;
  686. _ID :
  687. begin
  688. if is_objcprotocol(current_structdef) and
  689. ((idtoken=_REQUIRED) or
  690. (idtoken=_OPTIONAL)) then
  691. begin
  692. current_structdef.symtable.currentlyoptional:=(idtoken=_OPTIONAL);
  693. consume(idtoken)
  694. end
  695. else case idtoken of
  696. _PRIVATE :
  697. begin
  698. if is_interface(current_structdef) or
  699. is_objc_protocol_or_category(current_structdef) then
  700. Message(parser_e_no_access_specifier_in_interfaces);
  701. consume(_PRIVATE);
  702. current_structdef.symtable.currentvisibility:=vis_private;
  703. include(current_structdef.objectoptions,oo_has_private);
  704. fields_allowed:=true;
  705. is_classdef:=false;
  706. classfields:=false;
  707. object_member_blocktype:=bt_general;
  708. end;
  709. _PROTECTED :
  710. begin
  711. if is_interface(current_structdef) or
  712. is_objc_protocol_or_category(current_structdef) then
  713. Message(parser_e_no_access_specifier_in_interfaces);
  714. consume(_PROTECTED);
  715. current_structdef.symtable.currentvisibility:=vis_protected;
  716. include(current_structdef.objectoptions,oo_has_protected);
  717. fields_allowed:=true;
  718. is_classdef:=false;
  719. classfields:=false;
  720. object_member_blocktype:=bt_general;
  721. end;
  722. _PUBLIC :
  723. begin
  724. if is_interface(current_structdef) or
  725. is_objc_protocol_or_category(current_structdef) then
  726. Message(parser_e_no_access_specifier_in_interfaces);
  727. consume(_PUBLIC);
  728. current_structdef.symtable.currentvisibility:=vis_public;
  729. fields_allowed:=true;
  730. is_classdef:=false;
  731. classfields:=false;
  732. object_member_blocktype:=bt_general;
  733. end;
  734. _PUBLISHED :
  735. begin
  736. { we've to check for a pushlished section in non- }
  737. { publishable classes later, if a real declaration }
  738. { this is the way, delphi does it }
  739. if is_interface(current_structdef) then
  740. Message(parser_e_no_access_specifier_in_interfaces);
  741. { Objective-C classes do not support "published",
  742. as basically everything is published. }
  743. if is_objc_class_or_protocol(current_structdef) then
  744. Message(parser_e_no_objc_published);
  745. consume(_PUBLISHED);
  746. current_structdef.symtable.currentvisibility:=vis_published;
  747. fields_allowed:=true;
  748. is_classdef:=false;
  749. classfields:=false;
  750. object_member_blocktype:=bt_general;
  751. end;
  752. _STRICT :
  753. begin
  754. if is_interface(current_structdef) or
  755. is_objc_protocol_or_category(current_structdef) then
  756. Message(parser_e_no_access_specifier_in_interfaces);
  757. consume(_STRICT);
  758. if token=_ID then
  759. begin
  760. case idtoken of
  761. _PRIVATE:
  762. begin
  763. consume(_PRIVATE);
  764. current_structdef.symtable.currentvisibility:=vis_strictprivate;
  765. include(current_structdef.objectoptions,oo_has_strictprivate);
  766. end;
  767. _PROTECTED:
  768. begin
  769. consume(_PROTECTED);
  770. current_structdef.symtable.currentvisibility:=vis_strictprotected;
  771. include(current_structdef.objectoptions,oo_has_strictprotected);
  772. end;
  773. else
  774. message(parser_e_protected_or_private_expected);
  775. end;
  776. end
  777. else
  778. message(parser_e_protected_or_private_expected);
  779. fields_allowed:=true;
  780. is_classdef:=false;
  781. classfields:=false;
  782. object_member_blocktype:=bt_general;
  783. end
  784. else
  785. begin
  786. if object_member_blocktype=bt_general then
  787. begin
  788. if is_interface(current_structdef) or
  789. is_objc_protocol_or_category(current_structdef) or
  790. is_objectpascal_helper(current_structdef) then
  791. Message(parser_e_no_vars_in_interfaces);
  792. if (current_structdef.symtable.currentvisibility=vis_published) and
  793. not(oo_can_have_published in current_structdef.objectoptions) then
  794. Message(parser_e_cant_have_published);
  795. if (not fields_allowed) then
  796. Message(parser_e_field_not_allowed_here);
  797. vdoptions:=[vd_object];
  798. if classfields then
  799. include(vdoptions,vd_class);
  800. read_record_fields(vdoptions);
  801. end
  802. else if object_member_blocktype=bt_type then
  803. types_dec(true)
  804. else if object_member_blocktype=bt_const then
  805. consts_dec(true)
  806. else
  807. internalerror(201001110);
  808. end;
  809. end;
  810. end;
  811. _PROPERTY :
  812. begin
  813. struct_property_dec(is_classdef);
  814. fields_allowed:=false;
  815. is_classdef:=false;
  816. end;
  817. _CLASS:
  818. begin
  819. is_classdef:=false;
  820. { read class method/field/property }
  821. consume(_CLASS);
  822. { class modifier is only allowed for procedures, functions, }
  823. { constructors, destructors, fields and properties }
  824. if not(token in [_FUNCTION,_PROCEDURE,_PROPERTY,_VAR,_CONSTRUCTOR,_DESTRUCTOR]) then
  825. Message(parser_e_procedure_or_function_expected);
  826. if is_interface(current_structdef) then
  827. Message(parser_e_no_static_method_in_interfaces)
  828. else
  829. { class methods are also allowed for Objective-C protocols }
  830. is_classdef:=true;
  831. end;
  832. _PROCEDURE,
  833. _FUNCTION:
  834. begin
  835. if (current_structdef.symtable.currentvisibility=vis_published) and
  836. not(oo_can_have_published in current_structdef.objectoptions) then
  837. Message(parser_e_cant_have_published);
  838. oldparse_only:=parse_only;
  839. parse_only:=true;
  840. pd:=parse_proc_dec(is_classdef,current_structdef);
  841. { this is for error recovery as well as forward }
  842. { interface mappings, i.e. mapping to a method }
  843. { which isn't declared yet }
  844. if assigned(pd) then
  845. begin
  846. parse_object_proc_directives(pd);
  847. { check if dispid is set }
  848. if is_dispinterface(pd.struct) and not (po_dispid in pd.procoptions) then
  849. begin
  850. pd.dispid:=tobjectdef(pd.struct).get_next_dispid;
  851. include(pd.procoptions, po_dispid);
  852. end;
  853. { all Macintosh Object Pascal methods are virtual. }
  854. { this can't be a class method, because macpas mode }
  855. { has no m_class }
  856. if (m_mac in current_settings.modeswitches) then
  857. include(pd.procoptions,po_virtualmethod);
  858. { for record helpers only static class methods are allowed }
  859. if is_objectpascal_helper(current_structdef) and
  860. is_record(current_objectdef.extendeddef) and
  861. is_classdef and not (po_staticmethod in pd.procoptions) then
  862. MessagePos(pd.fileinfo, parser_e_class_methods_only_static_in_records);
  863. handle_calling_convention(pd);
  864. { add definition to procsym }
  865. proc_add_definition(pd);
  866. { add procdef options to objectdef options }
  867. if (po_msgint in pd.procoptions) then
  868. include(current_structdef.objectoptions,oo_has_msgint);
  869. if (po_msgstr in pd.procoptions) then
  870. include(current_structdef.objectoptions,oo_has_msgstr);
  871. if (po_virtualmethod in pd.procoptions) then
  872. include(current_structdef.objectoptions,oo_has_virtual);
  873. chkcpp(pd);
  874. chkobjc(pd);
  875. end;
  876. maybe_parse_hint_directives(pd);
  877. parse_only:=oldparse_only;
  878. fields_allowed:=false;
  879. is_classdef:=false;
  880. end;
  881. _CONSTRUCTOR :
  882. begin
  883. if (current_structdef.symtable.currentvisibility=vis_published) and
  884. not(oo_can_have_published in current_structdef.objectoptions) then
  885. Message(parser_e_cant_have_published);
  886. if not is_classdef and not(current_structdef.symtable.currentvisibility in [vis_public,vis_published]) then
  887. Message(parser_w_constructor_should_be_public);
  888. if is_interface(current_structdef) then
  889. Message(parser_e_no_con_des_in_interfaces);
  890. { Objective-C does not know the concept of a constructor }
  891. if is_objc_class_or_protocol(current_structdef) then
  892. Message(parser_e_objc_no_constructor_destructor);
  893. if is_objectpascal_helper(current_structdef) then
  894. if is_classdef then
  895. { class constructors are not allowed in class helpers }
  896. Message(parser_e_no_class_constructor_in_helpers)
  897. else
  898. if is_record(current_objectdef.extendeddef) then
  899. { as long as constructors aren't allowed in records they
  900. aren't allowed in helpers either }
  901. Message(parser_e_no_constructor_in_records);
  902. { only 1 class constructor is allowed }
  903. if is_classdef and (oo_has_class_constructor in current_structdef.objectoptions) then
  904. Message1(parser_e_only_one_class_constructor_allowed, current_structdef.objrealname^);
  905. oldparse_only:=parse_only;
  906. parse_only:=true;
  907. if is_classdef then
  908. pd:=class_constructor_head
  909. else
  910. pd:=constructor_head;
  911. parse_object_proc_directives(pd);
  912. handle_calling_convention(pd);
  913. { add definition to procsym }
  914. proc_add_definition(pd);
  915. { add procdef options to objectdef options }
  916. if (po_virtualmethod in pd.procoptions) then
  917. include(current_structdef.objectoptions,oo_has_virtual);
  918. chkcpp(pd);
  919. maybe_parse_hint_directives(pd);
  920. parse_only:=oldparse_only;
  921. fields_allowed:=false;
  922. is_classdef:=false;
  923. end;
  924. _DESTRUCTOR :
  925. begin
  926. if (current_structdef.symtable.currentvisibility=vis_published) and
  927. not(oo_can_have_published in current_structdef.objectoptions) then
  928. Message(parser_e_cant_have_published);
  929. if not is_classdef then
  930. if has_destructor then
  931. Message(parser_n_only_one_destructor)
  932. else
  933. has_destructor:=true;
  934. if is_interface(current_structdef) then
  935. Message(parser_e_no_con_des_in_interfaces);
  936. { (class) destructors are not allowed in class helpers }
  937. if is_objectpascal_helper(current_structdef) then
  938. Message(parser_e_no_destructor_in_records);
  939. if not is_classdef and (current_structdef.symtable.currentvisibility<>vis_public) then
  940. Message(parser_w_destructor_should_be_public);
  941. { Objective-C does not know the concept of a destructor }
  942. if is_objc_class_or_protocol(current_structdef) then
  943. Message(parser_e_objc_no_constructor_destructor);
  944. { only 1 class destructor is allowed }
  945. if is_classdef and (oo_has_class_destructor in current_structdef.objectoptions) then
  946. Message1(parser_e_only_one_class_destructor_allowed, current_structdef.objrealname^);
  947. oldparse_only:=parse_only;
  948. parse_only:=true;
  949. if is_classdef then
  950. pd:=class_destructor_head
  951. else
  952. pd:=destructor_head;
  953. parse_object_proc_directives(pd);
  954. handle_calling_convention(pd);
  955. { add definition to procsym }
  956. proc_add_definition(pd);
  957. { add procdef options to objectdef options }
  958. if (po_virtualmethod in pd.procoptions) then
  959. include(current_structdef.objectoptions,oo_has_virtual);
  960. chkcpp(pd);
  961. maybe_parse_hint_directives(pd);
  962. parse_only:=oldparse_only;
  963. fields_allowed:=false;
  964. is_classdef:=false;
  965. end;
  966. _END :
  967. begin
  968. consume(_END);
  969. break;
  970. end;
  971. else
  972. consume(_ID); { Give a ident expected message, like tp7 }
  973. end;
  974. until false;
  975. end;
  976. function object_dec(objecttype:tobjecttyp;const n:tidstring;genericdef:tstoreddef;genericlist:TFPObjectList;fd : tobjectdef;helpertype:thelpertype) : tobjectdef;
  977. var
  978. old_current_structdef: tabstractrecorddef;
  979. old_current_genericdef,
  980. old_current_specializedef: tstoreddef;
  981. old_parse_generic: boolean;
  982. list: TFPObjectList;
  983. s: String;
  984. st: TSymtable;
  985. begin
  986. old_current_structdef:=current_structdef;
  987. old_current_genericdef:=current_genericdef;
  988. old_current_specializedef:=current_specializedef;
  989. old_parse_generic:=parse_generic;
  990. current_structdef:=nil;
  991. current_genericdef:=nil;
  992. current_specializedef:=nil;
  993. { objects and class types can't be declared local }
  994. if not(symtablestack.top.symtabletype in [globalsymtable,staticsymtable,objectsymtable,recordsymtable]) and
  995. not assigned(genericlist) then
  996. Message(parser_e_no_local_objects);
  997. { reuse forward objectdef? }
  998. if assigned(fd) then
  999. begin
  1000. if fd.objecttype<>objecttype then
  1001. begin
  1002. Message(parser_e_forward_mismatch);
  1003. { recover }
  1004. current_structdef:=tobjectdef.create(current_objectdef.objecttype,n,nil);
  1005. include(current_structdef.objectoptions,oo_is_forward);
  1006. end
  1007. else
  1008. current_structdef:=fd
  1009. end
  1010. else
  1011. begin
  1012. { anonym objects aren't allow (o : object a : longint; end;) }
  1013. if n='' then
  1014. Message(parser_f_no_anonym_objects);
  1015. { create new class }
  1016. current_structdef:=tobjectdef.create(objecttype,n,nil);
  1017. { include always the forward flag, it'll be removed after the parent class have been
  1018. added. This is to prevent circular childof loops }
  1019. include(current_structdef.objectoptions,oo_is_forward);
  1020. if (cs_compilesystem in current_settings.moduleswitches) then
  1021. begin
  1022. case current_objectdef.objecttype of
  1023. odt_interfacecom :
  1024. if (current_structdef.objname^='IUNKNOWN') then
  1025. interface_iunknown:=current_objectdef
  1026. else
  1027. if (current_structdef.objname^='IDISPATCH') then
  1028. interface_idispatch:=current_objectdef;
  1029. odt_class :
  1030. if (current_structdef.objname^='TOBJECT') then
  1031. class_tobject:=current_objectdef;
  1032. end;
  1033. end;
  1034. if (current_module.modulename^='OBJCBASE') then
  1035. begin
  1036. case current_objectdef.objecttype of
  1037. odt_objcclass:
  1038. if (current_objectdef.objname^='Protocol') then
  1039. objc_protocoltype:=current_objectdef;
  1040. end;
  1041. end;
  1042. end;
  1043. { usage of specialized type inside its generic template }
  1044. if assigned(genericdef) then
  1045. current_specializedef:=current_structdef
  1046. { reject declaration of generic class inside generic class }
  1047. else if assigned(genericlist) then
  1048. current_genericdef:=current_structdef;
  1049. { nested types of specializations are specializations as well }
  1050. if assigned(old_current_structdef) and
  1051. (df_specialization in old_current_structdef.defoptions) then
  1052. include(current_structdef.defoptions,df_specialization);
  1053. { set published flag in $M+ mode, it can also be inherited and will
  1054. be added when the parent class set with tobjectdef.set_parent (PFV) }
  1055. if (cs_generate_rtti in current_settings.localswitches) and
  1056. (current_objectdef.objecttype in [odt_interfacecom,odt_class,odt_helper]) then
  1057. include(current_structdef.objectoptions,oo_can_have_published);
  1058. { Objective-C objectdefs can be "formal definitions", in which case
  1059. the syntax is "type tc = objcclass external;" -> we have to parse
  1060. its object options (external) already here, to make sure that such
  1061. definitions are recognised as formal defs }
  1062. if objecttype in [odt_objcclass,odt_objcprotocol,odt_objccategory] then
  1063. parse_object_options;
  1064. { forward def? }
  1065. if not assigned(fd) and
  1066. (token=_SEMICOLON) then
  1067. begin
  1068. { add to the list of definitions to check that the forward
  1069. is resolved. this is required for delphi mode }
  1070. current_module.checkforwarddefs.add(current_structdef);
  1071. end
  1072. else
  1073. begin
  1074. { change objccategories into objcclass helpers }
  1075. if (objecttype=odt_objccategory) then
  1076. begin
  1077. current_objectdef.objecttype:=odt_objcclass;
  1078. include(current_structdef.objectoptions,oo_is_classhelper);
  1079. end;
  1080. { include the class helper flag for Object Pascal helpers }
  1081. if (objecttype=odt_helper) then
  1082. include(current_objectdef.objectoptions,oo_is_classhelper);
  1083. { parse list of options (abstract / sealed) }
  1084. if not(objecttype in [odt_objcclass,odt_objcprotocol,odt_objccategory]) then
  1085. parse_object_options;
  1086. symtablestack.push(current_structdef.symtable);
  1087. insert_generic_parameter_types(current_structdef,genericdef,genericlist);
  1088. { when we are parsing a generic already then this is a generic as
  1089. well }
  1090. if old_parse_generic then
  1091. include(current_structdef.defoptions, df_generic);
  1092. parse_generic:=(df_generic in current_structdef.defoptions);
  1093. { parse list of parent classes }
  1094. { for record helpers in mode Delphi this is not allowed }
  1095. if not (is_objectpascal_helper(current_objectdef) and
  1096. (m_delphi in current_settings.modeswitches) and
  1097. (helpertype=ht_record)) then
  1098. parse_parent_classes
  1099. else
  1100. { remove forward flag, is resolved (this is normally done inside
  1101. parse_parent_classes) }
  1102. exclude(current_structdef.objectoptions,oo_is_forward);
  1103. { parse extended type for helpers }
  1104. if is_objectpascal_helper(current_structdef) then
  1105. parse_extended_type(helpertype);
  1106. { parse optional GUID for interfaces }
  1107. parse_guid;
  1108. { parse and insert object members }
  1109. parse_object_members;
  1110. symtablestack.pop(current_structdef.symtable);
  1111. end;
  1112. { generate vmt space if needed }
  1113. if not(oo_has_vmt in current_structdef.objectoptions) and
  1114. not(oo_is_forward in current_structdef.objectoptions) and
  1115. (
  1116. ([oo_has_virtual,oo_has_constructor,oo_has_destructor]*current_structdef.objectoptions<>[]) or
  1117. (current_objectdef.objecttype in [odt_class])
  1118. ) then
  1119. current_objectdef.insertvmt;
  1120. { for implemented classes with a vmt check if there is a constructor }
  1121. if (oo_has_vmt in current_structdef.objectoptions) and
  1122. not(oo_is_forward in current_structdef.objectoptions) and
  1123. not(oo_has_constructor in current_structdef.objectoptions) and
  1124. not is_objc_class_or_protocol(current_structdef) then
  1125. Message1(parser_w_virtual_without_constructor,current_structdef.objrealname^);
  1126. if is_interface(current_structdef) or
  1127. is_objcprotocol(current_structdef) then
  1128. setinterfacemethodoptions
  1129. else if is_objcclass(current_structdef) then
  1130. setobjcclassmethodoptions;
  1131. { if this helper is defined in the implementation section of the unit
  1132. or inside the main project file, the extendeddefs list of the current
  1133. module must be updated (it will be removed when poping the symtable) }
  1134. if is_objectpascal_helper(current_structdef) then
  1135. begin
  1136. { the topmost symtable must be a static symtable }
  1137. st:=current_structdef.owner;
  1138. while st.symtabletype in [objectsymtable,recordsymtable] do
  1139. st:=st.defowner.owner;
  1140. if st.symtabletype=staticsymtable then
  1141. begin
  1142. s:=make_mangledname('',current_objectdef.extendeddef.symtable,'');
  1143. list:=TFPObjectList(current_module.extendeddefs.Find(s));
  1144. if not assigned(list) then
  1145. begin
  1146. list:=TFPObjectList.Create(false);
  1147. current_module.extendeddefs.Add(s, list);
  1148. end;
  1149. list.add(current_structdef);
  1150. end;
  1151. end;
  1152. { return defined objectdef }
  1153. result:=current_objectdef;
  1154. { restore old state }
  1155. current_structdef:=old_current_structdef;
  1156. current_genericdef:=old_current_genericdef;
  1157. current_specializedef:=old_current_specializedef;
  1158. parse_generic:=old_parse_generic;
  1159. end;
  1160. end.