2
0

pparautl.pas 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl, Daniel Mantione
  3. Helpers for dealing with subroutine parameters during parsing
  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 pparautl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symconst,symdef;
  22. procedure insert_funcret_para(pd:tabstractprocdef);
  23. procedure insert_parentfp_para(pd:tabstractprocdef);
  24. procedure insert_self_and_vmt_para(pd:tabstractprocdef);
  25. procedure insert_funcret_local(pd:tprocdef);
  26. procedure insert_hidden_para(p:TObject;arg:pointer);
  27. procedure check_c_para(pd:Tabstractprocdef);
  28. procedure insert_struct_hidden_paras(astruct: tabstractrecorddef);
  29. type
  30. // flags of the *handle_calling_convention routines
  31. thccflag=(
  32. hcc_declaration, // declaration (as opposed to definition, i.e. interface rather than implementation)
  33. hcc_check, // perform checks and outup errors if found
  34. hcc_insert_hidden_paras // insert hidden parameters
  35. );
  36. thccflags=set of thccflag;
  37. const
  38. hcc_default_actions_intf=[hcc_declaration,hcc_check,hcc_insert_hidden_paras];
  39. hcc_default_actions_intf_struct=hcc_default_actions_intf-[hcc_insert_hidden_paras];
  40. hcc_default_actions_impl=[hcc_check,hcc_insert_hidden_paras];
  41. hcc_default_actions_parse=[hcc_check,hcc_insert_hidden_paras];
  42. PD_VIRTUAL_MUTEXCLPO = [po_interrupt,po_exports,po_overridingmethod,po_inline,po_staticmethod];
  43. procedure handle_calling_convention(pd:tabstractprocdef;flags:thccflags);
  44. function proc_add_definition(var currpd:tprocdef):boolean;
  45. { create "parent frame pointer" record skeleton for procdef, in which local
  46. variables and parameters from pd accessed from nested routines can be
  47. stored }
  48. procedure build_parentfpstruct(pd: tprocdef);
  49. implementation
  50. uses
  51. globals,globtype,cclasses,cutils,verbose,systems,fmodule,
  52. tokens,
  53. symtype,symbase,symsym,symtable,symutil,defutil,defcmp,blockutl,
  54. {$ifdef jvm}
  55. jvmdef,
  56. {$endif jvm}
  57. node,nbas,
  58. aasmbase,
  59. paramgr;
  60. procedure insert_funcret_para(pd:tabstractprocdef);
  61. var
  62. storepos : tfileposinfo;
  63. vs : tparavarsym;
  64. paranr : word;
  65. begin
  66. if not(pd.proctypeoption in [potype_constructor,potype_destructor]) and
  67. not is_void(pd.returndef) and
  68. not (df_generic in pd.defoptions) and
  69. paramanager.ret_in_param(pd.returndef,pd) then
  70. begin
  71. storepos:=current_tokenpos;
  72. if pd.typ=procdef then
  73. current_tokenpos:=tprocdef(pd).fileinfo;
  74. {$if defined(i386)}
  75. { For left to right add it at the end to be delphi compatible.
  76. In the case of safecalls with safecal-exceptions support the
  77. funcret-para is (from the 'c'-point of view) a normal parameter
  78. which has to be added to the end of the parameter-list }
  79. if (pd.proccalloption in (pushleftright_pocalls)) or
  80. ((tf_safecall_exceptions in target_info.flags) and
  81. (pd.proccalloption=pocall_safecall)) then
  82. paranr:=paranr_result_leftright
  83. else
  84. {$elseif defined(SUPPORT_SAFECALL)}
  85. if (tf_safecall_exceptions in target_info.flags) and
  86. (pd.proccalloption = pocall_safecall) then
  87. paranr:=paranr_result_leftright
  88. else
  89. {$endif}
  90. paranr:=paranr_result;
  91. { Generate result variable accessing function result }
  92. vs:=cparavarsym.create('$result',paranr,vs_var,pd.returndef,[vo_is_funcret,vo_is_hidden_para]);
  93. pd.parast.insert(vs);
  94. { Store this symbol as funcretsym for procedures }
  95. if pd.typ=procdef then
  96. tprocdef(pd).funcretsym:=vs;
  97. current_tokenpos:=storepos;
  98. end;
  99. end;
  100. procedure insert_parentfp_para(pd:tabstractprocdef);
  101. var
  102. storepos : tfileposinfo;
  103. vs : tparavarsym;
  104. paranr : longint;
  105. begin
  106. if pd.parast.symtablelevel>normal_function_level then
  107. begin
  108. storepos:=current_tokenpos;
  109. if pd.typ=procdef then
  110. current_tokenpos:=tprocdef(pd).fileinfo;
  111. { if no support for nested procvars is activated, use the old
  112. calling convention to pass the parent frame pointer for backwards
  113. compatibility }
  114. if not(m_nested_procvars in current_settings.modeswitches) then
  115. paranr:=paranr_parentfp
  116. { nested procvars require Delphi-style parentfp passing, see
  117. po_delphi_nested_cc declaration for more info }
  118. {$if defined(i386) or defined(i8086)}
  119. else if (pd.proccalloption in pushleftright_pocalls) then
  120. paranr:=paranr_parentfp_delphi_cc_leftright
  121. {$endif i386 or i8086}
  122. else
  123. paranr:=paranr_parentfp_delphi_cc;
  124. { Generate frame pointer. It can't be put in a register since it
  125. must be accessable from nested routines }
  126. if not(target_info.system in systems_fpnestedstruct) or
  127. { in case of errors or declared procvardef types, prevent invalid
  128. type cast and possible nil pointer dereference }
  129. not assigned(pd.owner.defowner) or
  130. (pd.owner.defowner.typ<>procdef) then
  131. begin
  132. vs:=cparavarsym.create('$parentfp',paranr,vs_value
  133. ,parentfpvoidpointertype,[vo_is_parentfp,vo_is_hidden_para]);
  134. vs.varregable:=vr_none;
  135. end
  136. else
  137. begin
  138. if not assigned(tprocdef(pd.owner.defowner).parentfpstruct) then
  139. build_parentfpstruct(tprocdef(pd.owner.defowner));
  140. vs:=cparavarsym.create('$parentfp',paranr,vs_value,
  141. tprocdef(pd.owner.defowner).parentfpstructptrtype,[vo_is_parentfp,vo_is_hidden_para]);
  142. end;
  143. pd.parast.insert(vs);
  144. current_tokenpos:=storepos;
  145. end;
  146. end;
  147. procedure insert_self_and_vmt_para(pd:tabstractprocdef);
  148. var
  149. storepos : tfileposinfo;
  150. vs : tparavarsym;
  151. hdef : tdef;
  152. selfdef : tdef;
  153. vsp : tvarspez;
  154. aliasvs : tabsolutevarsym;
  155. sl : tpropaccesslist;
  156. begin
  157. if (pd.typ=procdef) and
  158. is_objc_class_or_protocol(tprocdef(pd).struct) and
  159. (pd.parast.symtablelevel=normal_function_level) then
  160. begin
  161. { insert Objective-C self and selector parameters }
  162. vs:=cparavarsym.create('$_cmd',paranr_objc_cmd,vs_value,objc_seltype,[vo_is_msgsel,vo_is_hidden_para]);
  163. pd.parast.insert(vs);
  164. { make accessible to code }
  165. sl:=tpropaccesslist.create;
  166. sl.addsym(sl_load,vs);
  167. aliasvs:=cabsolutevarsym.create_ref('_CMD',objc_seltype,sl);
  168. include(aliasvs.varoptions,vo_is_msgsel);
  169. tlocalsymtable(tprocdef(pd).localst).insert(aliasvs);
  170. if (po_classmethod in pd.procoptions) then
  171. { compatible with what gcc does }
  172. hdef:=objc_idtype
  173. else
  174. hdef:=tprocdef(pd).struct;
  175. vs:=cparavarsym.create('$self',paranr_objc_self,vs_value,hdef,[vo_is_self,vo_is_hidden_para]);
  176. pd.parast.insert(vs);
  177. end
  178. else if (pd.typ=procvardef) and
  179. pd.is_methodpointer then
  180. begin
  181. { Generate self variable }
  182. vs:=cparavarsym.create('$self',paranr_self,vs_value,voidpointertype,[vo_is_self,vo_is_hidden_para]);
  183. pd.parast.insert(vs);
  184. end
  185. { while only procvardefs of this type can be declared in Pascal code,
  186. internally we also generate procdefs of this type when creating
  187. block wrappers }
  188. else if (po_is_block in pd.procoptions) then
  189. begin
  190. { generate the first hidden parameter, which is a so-called "block
  191. literal" describing the block and containing its invocation
  192. procedure }
  193. hdef:=cpointerdef.getreusable(get_block_literal_type_for_proc(pd));
  194. { mark as vo_is_parentfp so that proc2procvar comparisons will
  195. succeed when assigning arbitrary routines to the block }
  196. vs:=cparavarsym.create('$_block_literal',paranr_blockselfpara,vs_value,
  197. hdef,[vo_is_hidden_para,vo_is_parentfp]
  198. );
  199. pd.parast.insert(vs);
  200. if pd.typ=procdef then
  201. begin
  202. { make accessible to code }
  203. sl:=tpropaccesslist.create;
  204. sl.addsym(sl_load,vs);
  205. aliasvs:=cabsolutevarsym.create_ref('FPC_BLOCK_SELF',hdef,sl);
  206. include(aliasvs.varoptions,vo_is_parentfp);
  207. tlocalsymtable(tprocdef(pd).localst).insert(aliasvs);
  208. end;
  209. end
  210. else
  211. begin
  212. if (pd.typ=procdef) and
  213. assigned(tprocdef(pd).struct) and
  214. (pd.parast.symtablelevel=normal_function_level) then
  215. begin
  216. { static class methods have no hidden self/vmt pointer }
  217. if pd.no_self_node then
  218. exit;
  219. storepos:=current_tokenpos;
  220. current_tokenpos:=tprocdef(pd).fileinfo;
  221. { Generate VMT variable for constructor/destructor }
  222. if (pd.proctypeoption in [potype_constructor,potype_destructor]) and
  223. not(is_cppclass(tprocdef(pd).struct) or
  224. is_record(tprocdef(pd).struct) or
  225. is_javaclass(tprocdef(pd).struct) or
  226. (
  227. { no vmt for record/type helper constructors }
  228. is_objectpascal_helper(tprocdef(pd).struct) and
  229. (tobjectdef(tprocdef(pd).struct).extendeddef.typ<>objectdef)
  230. )) then
  231. begin
  232. vs:=cparavarsym.create('$vmt',paranr_vmt,vs_value,cclassrefdef.create(tprocdef(pd).struct),[vo_is_vmt,vo_is_hidden_para]);
  233. pd.parast.insert(vs);
  234. end;
  235. { for helpers the type of Self is equivalent to the extended
  236. type or equal to an instance of it }
  237. if is_objectpascal_helper(tprocdef(pd).struct) then
  238. selfdef:=tobjectdef(tprocdef(pd).struct).extendeddef
  239. else if is_objccategory(tprocdef(pd).struct) then
  240. selfdef:=tobjectdef(tprocdef(pd).struct).childof
  241. else
  242. selfdef:=tprocdef(pd).struct;
  243. { Generate self variable, for classes we need
  244. to use the generic voidpointer to be compatible with
  245. methodpointers }
  246. vsp:=vs_value;
  247. if (po_staticmethod in pd.procoptions) or
  248. (po_classmethod in pd.procoptions) then
  249. hdef:=cclassrefdef.create(selfdef)
  250. else
  251. begin
  252. if is_object(selfdef) or (selfdef.typ<>objectdef) then
  253. vsp:=vs_var;
  254. hdef:=selfdef;
  255. end;
  256. vs:=cparavarsym.create('$self',paranr_self,vsp,hdef,[vo_is_self,vo_is_hidden_para]);
  257. pd.parast.insert(vs);
  258. current_tokenpos:=storepos;
  259. end;
  260. end;
  261. end;
  262. procedure insert_funcret_local(pd:tprocdef);
  263. var
  264. storepos : tfileposinfo;
  265. vs : tlocalvarsym;
  266. aliasvs : tabsolutevarsym;
  267. sl : tpropaccesslist;
  268. hs : string;
  269. begin
  270. storepos:=current_tokenpos;
  271. current_tokenpos:=pd.fileinfo;
  272. { The result from constructors and destructors can't be accessed directly }
  273. if not(pd.proctypeoption in [potype_constructor,potype_destructor]) and
  274. not is_void(pd.returndef) and
  275. (not(po_assembler in pd.procoptions) or paramanager.asm_result_var(pd.returndef,pd)) then
  276. begin
  277. { We need to insert a varsym for the result in the localst
  278. when it is returning in a register }
  279. { we also need to do this for a generic procdef as we didn't allow
  280. the creation of a result symbol in insert_funcret_para, but we need
  281. a valid funcretsym }
  282. if (df_generic in pd.defoptions) or
  283. not paramanager.ret_in_param(pd.returndef,pd) then
  284. begin
  285. vs:=clocalvarsym.create('$result',vs_value,pd.returndef,[vo_is_funcret]);
  286. pd.localst.insert(vs);
  287. pd.funcretsym:=vs;
  288. end;
  289. { insert the name of the procedure as alias for the function result,
  290. we can't use realname because that will not work for compilerprocs
  291. as the name is lowercase and unreachable from the code }
  292. if (pd.proctypeoption<>potype_operator) or assigned(pd.resultname) then
  293. begin
  294. if assigned(pd.resultname) then
  295. hs:=pd.resultname^
  296. else
  297. hs:=pd.procsym.name;
  298. sl:=tpropaccesslist.create;
  299. sl.addsym(sl_load,pd.funcretsym);
  300. aliasvs:=cabsolutevarsym.create_ref(hs,pd.returndef,sl);
  301. include(aliasvs.varoptions,vo_is_funcret);
  302. tlocalsymtable(pd.localst).insert(aliasvs);
  303. end;
  304. { insert result also if support is on }
  305. if (m_result in current_settings.modeswitches) then
  306. begin
  307. sl:=tpropaccesslist.create;
  308. sl.addsym(sl_load,pd.funcretsym);
  309. aliasvs:=cabsolutevarsym.create_ref('RESULT',pd.returndef,sl);
  310. include(aliasvs.varoptions,vo_is_funcret);
  311. include(aliasvs.varoptions,vo_is_result);
  312. tlocalsymtable(pd.localst).insert(aliasvs);
  313. end;
  314. end;
  315. if pd.generate_safecall_wrapper then
  316. begin
  317. { vo_is_funcret is necessary so the local only gets freed after we loaded its
  318. value into the return register }
  319. vs:=clocalvarsym.create('$safecallresult',vs_value,search_system_type('HRESULT').typedef,[vo_is_funcret]);
  320. pd.localst.insert(vs);
  321. end;
  322. current_tokenpos:=storepos;
  323. end;
  324. procedure insert_hidden_para(p:TObject;arg:pointer);
  325. var
  326. hvs : tparavarsym;
  327. pd : tabstractprocdef absolute arg;
  328. begin
  329. if (tsym(p).typ<>paravarsym) then
  330. exit;
  331. with tparavarsym(p) do
  332. begin
  333. { We need a local copy for a value parameter when only the
  334. address is pushed. Open arrays and Array of Const are
  335. an exception because they are allocated at runtime and the
  336. address that is pushed is patched.
  337. Arrays passed to cdecl routines are special: they are pointers in
  338. C and hence must be passed as such. Due to historical reasons, if
  339. a cdecl routine is implemented in Pascal, we still make a copy on
  340. the callee side. Do this the same on platforms that normally must
  341. make a copy on the caller side, as otherwise the behaviour will
  342. be different (and less perfomant) for routines implemented in C }
  343. if (varspez=vs_value) and
  344. paramanager.push_addr_param(varspez,vardef,pd.proccalloption) and
  345. not(is_open_array(vardef) or
  346. is_array_of_const(vardef)) and
  347. (not(target_info.system in systems_caller_copy_addr_value_para) or
  348. ((pd.proccalloption in cdecl_pocalls) and
  349. (vardef.typ=arraydef))) then
  350. include(varoptions,vo_has_local_copy);
  351. { needs high parameter ? }
  352. if paramanager.push_high_param(varspez,vardef,pd.proccalloption) then
  353. begin
  354. hvs:=cparavarsym.create('$high'+name,paranr+1,vs_const,sizesinttype,[vo_is_high_para,vo_is_hidden_para]);
  355. hvs.symoptions:=[];
  356. owner.insert(hvs);
  357. { don't place to register if it will be accessed from implicit finally block }
  358. if (varspez=vs_value) and
  359. is_open_array(vardef) and
  360. is_managed_type(vardef) then
  361. hvs.varregable:=vr_none;
  362. end
  363. else
  364. begin
  365. { Give a warning that cdecl routines does not include high()
  366. support }
  367. if (pd.proccalloption in cdecl_pocalls) and
  368. paramanager.push_high_param(varspez,vardef,pocall_default) then
  369. begin
  370. if is_open_string(vardef) then
  371. MessagePos(fileinfo,parser_w_cdecl_no_openstring);
  372. if not(po_external in pd.procoptions) and
  373. (pd.typ<>procvardef) and
  374. not is_objc_class_or_protocol(tprocdef(pd).struct) then
  375. if is_array_of_const(vardef) then
  376. MessagePos(fileinfo,parser_e_varargs_need_cdecl_and_external)
  377. else
  378. MessagePos(fileinfo,parser_w_cdecl_has_no_high);
  379. end;
  380. if (vardef.typ=formaldef) and (Tformaldef(vardef).typed) then
  381. begin
  382. hvs:=cparavarsym.create('$typinfo'+name,paranr+1,vs_const,voidpointertype,
  383. [vo_is_typinfo_para,vo_is_hidden_para]);
  384. owner.insert(hvs);
  385. end;
  386. end;
  387. end;
  388. end;
  389. procedure check_c_para(pd:Tabstractprocdef);
  390. var
  391. i,
  392. lastparaidx : longint;
  393. sym : TSym;
  394. begin
  395. lastparaidx:=pd.parast.SymList.Count-1;
  396. for i:=0 to pd.parast.SymList.Count-1 do
  397. begin
  398. sym:=tsym(pd.parast.SymList[i]);
  399. if (sym.typ=paravarsym) and
  400. (tparavarsym(sym).vardef.typ=arraydef) then
  401. begin
  402. if not is_variant_array(tparavarsym(sym).vardef) and
  403. not is_array_of_const(tparavarsym(sym).vardef) and
  404. (tparavarsym(sym).varspez<>vs_var) then
  405. MessagePos(tparavarsym(sym).fileinfo,parser_h_c_arrays_are_references);
  406. if is_array_of_const(tparavarsym(sym).vardef) and
  407. (i<lastparaidx) and
  408. (tsym(pd.parast.SymList[i+1]).typ=paravarsym) and
  409. not(vo_is_high_para in tparavarsym(pd.parast.SymList[i+1]).varoptions) then
  410. MessagePos(tparavarsym(sym).fileinfo,parser_e_C_array_of_const_must_be_last);
  411. end;
  412. end;
  413. end;
  414. procedure insert_struct_hidden_paras(astruct: tabstractrecorddef);
  415. var
  416. pd: tdef;
  417. i: longint;
  418. oldpos: tfileposinfo;
  419. begin
  420. // handle calling conventions of record methods
  421. oldpos:=current_filepos;
  422. { don't keep track of procdefs in a separate list, because the
  423. compiler may add additional procdefs (e.g. property wrappers for
  424. the jvm backend) }
  425. for i := 0 to astruct.symtable.deflist.count - 1 do
  426. begin
  427. pd:=tdef(astruct.symtable.deflist[i]);
  428. if pd.typ<>procdef then
  429. continue;
  430. current_filepos:=tprocdef(pd).fileinfo;
  431. handle_calling_convention(tprocdef(pd),[hcc_declaration,hcc_insert_hidden_paras]);
  432. end;
  433. current_filepos:=oldpos;
  434. end;
  435. procedure set_addr_param_regable(p:TObject;arg:pointer);
  436. begin
  437. if (tsym(p).typ<>paravarsym) then
  438. exit;
  439. with tparavarsym(p) do
  440. begin
  441. if (not needs_finalization) and
  442. paramanager.push_addr_param(varspez,vardef,tprocdef(arg).proccalloption) then
  443. varregable:=vr_addr;
  444. end;
  445. end;
  446. procedure handle_calling_convention(pd:tabstractprocdef;flags:thccflags);
  447. begin
  448. if hcc_check in flags then
  449. begin
  450. { set the default calling convention if none provided }
  451. if (pd.typ=procdef) and
  452. (is_objc_class_or_protocol(tprocdef(pd).struct) or
  453. is_cppclass(tprocdef(pd).struct)) then
  454. begin
  455. { none of the explicit calling conventions should be allowed }
  456. if (po_hascallingconvention in pd.procoptions) then
  457. internalerror(2009032501);
  458. if is_cppclass(tprocdef(pd).struct) then
  459. pd.proccalloption:=pocall_cppdecl
  460. else
  461. pd.proccalloption:=pocall_cdecl;
  462. end
  463. else if not(po_hascallingconvention in pd.procoptions) then
  464. pd.proccalloption:=current_settings.defproccall
  465. else
  466. begin
  467. if pd.proccalloption=pocall_none then
  468. internalerror(200309081);
  469. end;
  470. { handle proccall specific settings }
  471. case pd.proccalloption of
  472. pocall_cdecl,
  473. pocall_cppdecl,
  474. pocall_sysv_abi_cdecl,
  475. pocall_ms_abi_cdecl:
  476. begin
  477. { check C cdecl para types }
  478. check_c_para(pd);
  479. end;
  480. pocall_far16 :
  481. begin
  482. { Temporary stub, must be rewritten to support OS/2 far16 }
  483. Message1(parser_w_proc_directive_ignored,'FAR16');
  484. end;
  485. else
  486. ;
  487. end;
  488. { Inlining is enabled and supported? }
  489. if (po_inline in pd.procoptions) and
  490. not(cs_do_inline in current_settings.localswitches) then
  491. begin
  492. { Give an error if inline is not supported by the compiler mode,
  493. otherwise only give a hint that this procedure will not be inlined }
  494. if not(m_default_inline in current_settings.modeswitches) then
  495. Message(parser_e_proc_inline_not_supported)
  496. else
  497. Message(parser_h_inlining_disabled);
  498. exclude(pd.procoptions,po_inline);
  499. end;
  500. { For varargs directive also cdecl and external must be defined }
  501. if (po_varargs in pd.procoptions) then
  502. begin
  503. { check first for external in the interface, if available there
  504. then the cdecl must also be there since there is no implementation
  505. available to contain it }
  506. if hcc_declaration in flags then
  507. begin
  508. { if external is available, then cdecl must also be available,
  509. procvars don't need external }
  510. if not((po_external in pd.procoptions) or
  511. (pd.typ=procvardef) or
  512. { for objcclasses this is checked later, because the entire
  513. class may be external. }
  514. is_objc_class_or_protocol(tprocdef(pd).struct)) and
  515. not(pd.proccalloption in (cdecl_pocalls + [pocall_stdcall])) then
  516. Message(parser_e_varargs_need_cdecl_and_external);
  517. end
  518. else
  519. begin
  520. { both must be defined now }
  521. if not((po_external in pd.procoptions) or
  522. (pd.typ=procvardef)) or
  523. not(pd.proccalloption in (cdecl_pocalls + [pocall_stdcall])) then
  524. Message(parser_e_varargs_need_cdecl_and_external);
  525. end;
  526. end;
  527. end;
  528. if hcc_insert_hidden_paras in flags then
  529. begin
  530. { If the paraloc info has been calculated already, it will be missing for
  531. the new parameters we add below. This should never be necessary before
  532. we add them, as users of this information would not process these extra
  533. parameters in that case }
  534. if pd.has_paraloc_info<>callnoside then
  535. internalerror(2019031610);
  536. { insert hidden high parameters }
  537. pd.parast.SymList.ForEachCall(@insert_hidden_para,pd);
  538. { insert hidden self parameter }
  539. insert_self_and_vmt_para(pd);
  540. { insert funcret parameter if required }
  541. insert_funcret_para(pd);
  542. { Make var parameters regable, this must be done after the calling
  543. convention is set. }
  544. { this must be done before parentfp is insert, because getting all cases
  545. where parentfp must be in a memory location isn't catched properly so
  546. we put parentfp never in a register }
  547. pd.parast.SymList.ForEachCall(@set_addr_param_regable,pd);
  548. { insert parentfp parameter if required }
  549. insert_parentfp_para(pd);
  550. end;
  551. { Calculate parameter tlist }
  552. pd.calcparas;
  553. end;
  554. function proc_add_definition(var currpd:tprocdef):boolean;
  555. function check_generic_parameters(fwpd,currpd:tprocdef):boolean;
  556. var
  557. i : longint;
  558. fwtype,
  559. currtype : ttypesym;
  560. begin
  561. result:=true;
  562. if fwpd.genericparas.count<>currpd.genericparas.count then
  563. internalerror(2018090101);
  564. for i:=0 to fwpd.genericparas.count-1 do
  565. begin
  566. fwtype:=ttypesym(fwpd.genericparas[i]);
  567. currtype:=ttypesym(currpd.genericparas[i]);
  568. if fwtype.name<>currtype.name then
  569. begin
  570. messagepos1(currtype.fileinfo,sym_e_generic_type_param_mismatch,currtype.realname);
  571. messagepos1(fwtype.fileinfo,sym_e_generic_type_param_decl,fwtype.realname);
  572. result:=false;
  573. end;
  574. end;
  575. end;
  576. function equal_generic_procdefs(fwpd,currpd:tprocdef):boolean;
  577. var
  578. i : longint;
  579. fwtype,
  580. currtype : ttypesym;
  581. foundretdef : boolean;
  582. begin
  583. result:=false;
  584. if fwpd.genericparas.count<>currpd.genericparas.count then
  585. exit;
  586. { comparing generic declarations is a bit more cumbersome as the
  587. defs of the generic parameter types are not equal, especially if the
  588. declaration contains constraints; essentially we have two cases:
  589. - proc declared in interface of unit (or in class/record/object)
  590. and defined in implementation; here the fwpd might contain
  591. constraints while currpd must only contain undefineddefs
  592. - forward declaration in implementation }
  593. foundretdef:=false;
  594. for i:=0 to fwpd.genericparas.count-1 do
  595. begin
  596. fwtype:=ttypesym(fwpd.genericparas[i]);
  597. currtype:=ttypesym(currpd.genericparas[i]);
  598. { if the type in the currpd isn't a pure undefineddef, then we can
  599. stop right there }
  600. if (currtype.typedef.typ<>undefineddef) or (df_genconstraint in currtype.typedef.defoptions) then
  601. exit;
  602. if not foundretdef then
  603. begin
  604. { if the returndef is the same as this parameter's def then this
  605. needs to be the case for both procdefs }
  606. foundretdef:=fwpd.returndef=fwtype.typedef;
  607. if foundretdef xor (currpd.returndef=currtype.typedef) then
  608. exit;
  609. end;
  610. end;
  611. if compare_paras(fwpd.paras,currpd.paras,cp_none,[cpo_ignorehidden,cpo_openequalisexact,cpo_ignoreuniv,cpo_generic])<>te_exact then
  612. exit;
  613. if not foundretdef then
  614. begin
  615. if (df_specialization in tstoreddef(fwpd.returndef).defoptions) and (df_specialization in tstoreddef(currpd.returndef).defoptions) then
  616. { for specializations we're happy with equal defs instead of exactly the same defs }
  617. result:=equal_defs(fwpd.returndef,currpd.returndef)
  618. else
  619. { the returndef isn't a type parameter, so compare as usual }
  620. result:=compare_defs(fwpd.returndef,currpd.returndef,nothingn)=te_exact;
  621. end
  622. else
  623. result:=true;
  624. end;
  625. {
  626. Add definition aprocdef to the overloaded definitions of aprocsym. If a
  627. forwarddef is found and reused it returns true
  628. }
  629. var
  630. fwpd : tprocdef;
  631. currparasym,
  632. fwparasym : tsym;
  633. currparacnt,
  634. fwparacnt,
  635. curridx,
  636. fwidx,
  637. i : longint;
  638. po_comp : tprocoptions;
  639. paracompopt: tcompare_paras_options;
  640. forwardfound : boolean;
  641. symentry: TSymEntry;
  642. item : tlinkedlistitem;
  643. begin
  644. forwardfound:=false;
  645. { check overloaded functions if the same function already exists }
  646. for i:=0 to tprocsym(currpd.procsym).ProcdefList.Count-1 do
  647. begin
  648. fwpd:=tprocdef(tprocsym(currpd.procsym).ProcdefList[i]);
  649. { can happen for internally generated routines }
  650. if (fwpd=currpd) then
  651. begin
  652. result:=true;
  653. exit;
  654. end;
  655. { Skip overloaded definitions that are declared in other units }
  656. if fwpd.procsym<>currpd.procsym then
  657. continue;
  658. { check the parameters, for delphi/tp it is possible to
  659. leave the parameters away in the implementation (forwarddef=false).
  660. But for an overload declared function this is not allowed }
  661. if { check if empty implementation arguments match is allowed }
  662. (
  663. not(m_repeat_forward in current_settings.modeswitches) and
  664. not(currpd.forwarddef) and
  665. is_bareprocdef(currpd) and
  666. not(po_overload in fwpd.procoptions)
  667. ) or
  668. (
  669. fwpd.is_generic and
  670. currpd.is_generic and
  671. equal_generic_procdefs(fwpd,currpd)
  672. ) or
  673. { check arguments, we need to check only the user visible parameters. The hidden parameters
  674. can be in a different location because of the calling convention, eg. L-R vs. R-L order (PFV)
  675. don't check default values here, because routines that are the same except for their default
  676. values should be reported as mismatches (since you can't overload based on different default
  677. parameter values) }
  678. (
  679. (compare_paras(fwpd.paras,currpd.paras,cp_none,[cpo_ignorehidden,cpo_openequalisexact,cpo_ignoreuniv])=te_exact) and
  680. (compare_defs(fwpd.returndef,currpd.returndef,nothingn)=te_exact)
  681. ) then
  682. begin
  683. { Check if we've found the forwarddef, if found then
  684. we need to update the forward def with the current
  685. implementation settings }
  686. if fwpd.forwarddef then
  687. begin
  688. forwardfound:=true;
  689. if not(m_repeat_forward in current_settings.modeswitches) and
  690. (fwpd.proccalloption<>currpd.proccalloption) then
  691. paracompopt:=[cpo_ignorehidden,cpo_comparedefaultvalue,cpo_openequalisexact,cpo_ignoreuniv]
  692. else
  693. paracompopt:=[cpo_comparedefaultvalue,cpo_openequalisexact,cpo_ignoreuniv];
  694. { Check calling convention }
  695. if (fwpd.proccalloption<>currpd.proccalloption) then
  696. begin
  697. { In delphi it is possible to specify the calling
  698. convention in the interface or implementation if
  699. there was no convention specified in the other
  700. part }
  701. if (m_delphi in current_settings.modeswitches) then
  702. begin
  703. if not(po_hascallingconvention in currpd.procoptions) then
  704. currpd.proccalloption:=fwpd.proccalloption
  705. else
  706. if not(po_hascallingconvention in fwpd.procoptions) then
  707. fwpd.proccalloption:=currpd.proccalloption
  708. else
  709. begin
  710. MessagePos(currpd.fileinfo,parser_e_call_convention_dont_match_forward);
  711. tprocsym(currpd.procsym).write_parameter_lists(currpd);
  712. { restore interface settings }
  713. currpd.proccalloption:=fwpd.proccalloption;
  714. end;
  715. end
  716. else
  717. begin
  718. MessagePos(currpd.fileinfo,parser_e_call_convention_dont_match_forward);
  719. tprocsym(currpd.procsym).write_parameter_lists(currpd);
  720. { restore interface settings }
  721. currpd.proccalloption:=fwpd.proccalloption;
  722. end;
  723. end;
  724. { Check static }
  725. if (po_staticmethod in fwpd.procoptions) then
  726. begin
  727. if not (po_staticmethod in currpd.procoptions) then
  728. begin
  729. include(currpd.procoptions, po_staticmethod);
  730. if (po_classmethod in currpd.procoptions) then
  731. begin
  732. { remove self from the hidden paras }
  733. symentry:=currpd.parast.Find('self');
  734. if symentry<>nil then
  735. begin
  736. currpd.parast.Delete(symentry);
  737. currpd.calcparas;
  738. end;
  739. end;
  740. end;
  741. end;
  742. { Check if the procedure type and return type are correct,
  743. also the parameters must match also with the type and that
  744. if the implementation has default parameters, the interface
  745. also has them and that if they both have them, that they
  746. have the same value }
  747. if ((m_repeat_forward in current_settings.modeswitches) or
  748. not is_bareprocdef(currpd)) and
  749. (
  750. (
  751. fwpd.is_generic and
  752. currpd.is_generic and
  753. not equal_generic_procdefs(fwpd,currpd)
  754. ) or
  755. (
  756. (
  757. not fwpd.is_generic or
  758. not currpd.is_generic
  759. ) and
  760. (
  761. (compare_paras(fwpd.paras,currpd.paras,cp_all,paracompopt)<>te_exact) or
  762. (compare_defs(fwpd.returndef,currpd.returndef,nothingn)<>te_exact)
  763. )
  764. )
  765. ) then
  766. begin
  767. MessagePos1(currpd.fileinfo,parser_e_header_dont_match_forward,
  768. fwpd.fullprocname(false));
  769. tprocsym(currpd.procsym).write_parameter_lists(currpd);
  770. break;
  771. end;
  772. { Check if both are declared forward }
  773. if fwpd.forwarddef and currpd.forwarddef then
  774. begin
  775. MessagePos1(currpd.fileinfo,parser_e_function_already_declared_public_forward,
  776. currpd.fullprocname(false));
  777. end;
  778. { internconst or internproc only need to be defined once }
  779. if (fwpd.proccalloption=pocall_internproc) then
  780. currpd.proccalloption:=fwpd.proccalloption
  781. else
  782. if (currpd.proccalloption=pocall_internproc) then
  783. fwpd.proccalloption:=currpd.proccalloption;
  784. { Check procedure options, Delphi requires that class is
  785. repeated in the implementation for class methods }
  786. if (m_fpc in current_settings.modeswitches) then
  787. po_comp:=[po_classmethod,po_varargs,po_methodpointer,po_interrupt]
  788. else
  789. po_comp:=[po_classmethod,po_methodpointer];
  790. if ((po_comp * fwpd.procoptions)<>(po_comp * currpd.procoptions)) or
  791. (fwpd.proctypeoption <> currpd.proctypeoption) or
  792. { if the implementation version has an "overload" modifier,
  793. the interface version must also have it (otherwise we can
  794. get annoying crashes due to interface crc changes) }
  795. (not(po_overload in fwpd.procoptions) and
  796. (po_overload in currpd.procoptions)) or
  797. { same with noreturn }
  798. (not(po_noreturn in fwpd.procoptions) and
  799. (po_noreturn in currpd.procoptions)) then
  800. begin
  801. MessagePos1(currpd.fileinfo,parser_e_header_dont_match_forward,
  802. fwpd.fullprocname(false));
  803. tprocsym(fwpd.procsym).write_parameter_lists(fwpd);
  804. { This error is non-fatal, we can recover }
  805. end;
  806. { Forward declaration is external? }
  807. if (po_external in fwpd.procoptions) then
  808. MessagePos(currpd.fileinfo,parser_e_proc_already_external);
  809. { check for conflicts with "virtual" if this is a virtual
  810. method, as "virtual" cannot be repeated in the
  811. implementation and hence does not get checked against }
  812. if (po_virtualmethod in fwpd.procoptions) then
  813. begin
  814. po_comp:=currpd.procoptions*PD_VIRTUAL_MUTEXCLPO;
  815. if po_comp<>[] then
  816. MessagePos2(currpd.fileinfo,parser_e_proc_dir_conflict,tokeninfo^[_VIRTUAL].str,get_first_proc_str(po_comp));
  817. end;
  818. { Check parameters }
  819. if (m_repeat_forward in current_settings.modeswitches) or
  820. (currpd.minparacount>0) then
  821. begin
  822. { If mangled names are equal then they have the same amount of arguments }
  823. { We can check the names of the arguments }
  824. { both symtables are in the same order from left to right }
  825. curridx:=0;
  826. fwidx:=0;
  827. currparacnt:=currpd.parast.SymList.Count;
  828. fwparacnt:=fwpd.parast.SymList.Count;
  829. repeat
  830. { skip default parameter constsyms }
  831. while (curridx<currparacnt) and
  832. (tsym(currpd.parast.SymList[curridx]).typ<>paravarsym) do
  833. inc(curridx);
  834. while (fwidx<fwparacnt) and
  835. (tsym(fwpd.parast.SymList[fwidx]).typ<>paravarsym) do
  836. inc(fwidx);
  837. { stop when one of the two lists is at the end }
  838. if (fwidx>=fwparacnt) or (curridx>=currparacnt) then
  839. break;
  840. { compare names of parameters, ignore implictly
  841. renamed parameters }
  842. currparasym:=tsym(currpd.parast.SymList[curridx]);
  843. fwparasym:=tsym(fwpd.parast.SymList[fwidx]);
  844. if not(sp_implicitrename in currparasym.symoptions) and
  845. not(sp_implicitrename in fwparasym.symoptions) then
  846. begin
  847. if (currparasym.name<>fwparasym.name) then
  848. begin
  849. MessagePos3(currpd.fileinfo,parser_e_header_different_var_names,
  850. tprocsym(currpd.procsym).realname,fwparasym.realname,currparasym.realname);
  851. break;
  852. end;
  853. end;
  854. { next parameter }
  855. inc(curridx);
  856. inc(fwidx);
  857. until false;
  858. end;
  859. { check that the type parameter names for generic methods match;
  860. we check this here and not in equal_generic_procdefs as the defs
  861. might still be different due to their parameters, so we'd generate
  862. errors without any need }
  863. if currpd.is_generic and fwpd.is_generic then
  864. { an error here is recoverable, so we simply continue }
  865. check_generic_parameters(fwpd,currpd);
  866. { Everything is checked, now we can update the forward declaration
  867. with the new data from the implementation }
  868. fwpd.forwarddef:=currpd.forwarddef;
  869. fwpd.hasforward:=true;
  870. fwpd.procoptions:=fwpd.procoptions+currpd.procoptions;
  871. { marked as local but exported from unit? }
  872. if (po_kylixlocal in fwpd.procoptions) and (fwpd.owner.symtabletype=globalsymtable) then
  873. MessagePos(fwpd.fileinfo,type_e_cant_export_local);
  874. if fwpd.extnumber=$ffff then
  875. fwpd.extnumber:=currpd.extnumber;
  876. while not currpd.aliasnames.empty do
  877. fwpd.aliasnames.insert(currpd.aliasnames.getfirst);
  878. { update fileinfo so position references the implementation,
  879. also update funcretsym if it is already generated }
  880. fwpd.fileinfo:=currpd.fileinfo;
  881. if assigned(fwpd.funcretsym) then
  882. fwpd.funcretsym.fileinfo:=currpd.fileinfo;
  883. if assigned(currpd.deprecatedmsg) then
  884. begin
  885. stringdispose(fwpd.deprecatedmsg);
  886. fwpd.deprecatedmsg:=stringdup(currpd.deprecatedmsg^);
  887. end;
  888. { import names }
  889. if assigned(currpd.import_dll) then
  890. begin
  891. stringdispose(fwpd.import_dll);
  892. fwpd.import_dll:=stringdup(currpd.import_dll^);
  893. end;
  894. if assigned(currpd.import_name) then
  895. begin
  896. stringdispose(fwpd.import_name);
  897. fwpd.import_name:=stringdup(currpd.import_name^);
  898. end;
  899. fwpd.import_nr:=currpd.import_nr;
  900. { for compilerproc defines we need to rename and update the
  901. symbolname to lowercase so users can' access it (can't do
  902. it immediately, because then the implementation symbol
  903. won't be matched) }
  904. if po_compilerproc in fwpd.procoptions then
  905. begin
  906. fwpd.setcompilerprocname;
  907. current_module.add_public_asmsym(fwpd.procsym.realname,AB_GLOBAL,AT_FUNCTION);
  908. end;
  909. if po_public in fwpd.procoptions then
  910. begin
  911. item:=fwpd.aliasnames.first;
  912. while assigned(item) do
  913. begin
  914. current_module.add_public_asmsym(TCmdStrListItem(item).str,AB_GLOBAL,AT_FUNCTION);
  915. item:=item.next;
  916. end;
  917. end;
  918. { Release current procdef }
  919. currpd.owner.deletedef(currpd);
  920. currpd:=fwpd;
  921. end
  922. else
  923. begin
  924. { abstract methods aren't forward defined, but this }
  925. { needs another error message }
  926. if (po_abstractmethod in fwpd.procoptions) then
  927. MessagePos(currpd.fileinfo,parser_e_abstract_no_definition)
  928. else
  929. begin
  930. MessagePos(currpd.fileinfo,parser_e_overloaded_have_same_parameters);
  931. tprocsym(currpd.procsym).write_parameter_lists(currpd);
  932. end;
  933. end;
  934. { we found one proc with the same arguments, there are no others
  935. so we can stop }
  936. break;
  937. end;
  938. { check for allowing overload directive }
  939. if not(m_fpc in current_settings.modeswitches) then
  940. begin
  941. { overload directive turns on overloading }
  942. if ((po_overload in currpd.procoptions) or
  943. (po_overload in fwpd.procoptions)) then
  944. begin
  945. { check if all procs have overloading, but not if the proc is a method or
  946. already declared forward, then the check is already done }
  947. if not(fwpd.hasforward or
  948. assigned(currpd.struct) or
  949. (currpd.forwarddef<>fwpd.forwarddef) or
  950. ((po_overload in currpd.procoptions) and
  951. (po_overload in fwpd.procoptions))) then
  952. begin
  953. MessagePos1(currpd.fileinfo,parser_e_no_overload_for_all_procs,currpd.procsym.realname);
  954. break;
  955. end
  956. end
  957. else
  958. begin
  959. if not(fwpd.forwarddef) then
  960. begin
  961. if (m_tp7 in current_settings.modeswitches) then
  962. MessagePos(currpd.fileinfo,parser_e_procedure_overloading_is_off)
  963. else
  964. MessagePos1(currpd.fileinfo,parser_e_no_overload_for_all_procs,currpd.procsym.realname);
  965. break;
  966. end;
  967. end;
  968. end; { equal arguments }
  969. end;
  970. { if we didn't reuse a forwarddef then we add the procdef to the overloaded
  971. list }
  972. if not forwardfound then
  973. begin
  974. { can happen in Delphi mode }
  975. if (currpd.proctypeoption = potype_function) and
  976. is_void(currpd.returndef) then
  977. MessagePos1(currpd.fileinfo,parser_e_no_funcret_specified,currpd.procsym.realname);
  978. tprocsym(currpd.procsym).ProcdefList.Add(currpd);
  979. if not currpd.forwarddef and (po_public in currpd.procoptions) then
  980. begin
  981. item:=currpd.aliasnames.first;
  982. while assigned(item) do
  983. begin
  984. current_module.add_public_asmsym(TCmdStrListItem(item).str,AB_GLOBAL,AT_FUNCTION);
  985. item:=item.next;
  986. end;
  987. end;
  988. end;
  989. proc_add_definition:=forwardfound;
  990. end;
  991. procedure build_parentfpstruct(pd: tprocdef);
  992. var
  993. nestedvars: tsym;
  994. nestedvarsst: tsymtable;
  995. pnestedvarsdef,
  996. nestedvarsdef: tdef;
  997. old_symtablestack: tsymtablestack;
  998. begin
  999. { make sure the defs are not registered in the current symtablestack,
  1000. because they may be for a parent procdef (changeowner does remove a def
  1001. from the symtable in which it was originally created, so that by itself
  1002. is not enough) }
  1003. old_symtablestack:=symtablestack;
  1004. symtablestack:=old_symtablestack.getcopyuntil(current_module.localsymtable);
  1005. { create struct to hold local variables and parameters that are
  1006. accessed from within nested routines (start with extra dollar to prevent
  1007. the JVM from thinking this is a nested class in the unit) }
  1008. nestedvarsst:=trecordsymtable.create('$'+current_module.realmodulename^+'$$_fpc_nestedvars$'+pd.unique_id_str,
  1009. current_settings.alignment.localalignmax,current_settings.alignment.localalignmin);
  1010. nestedvarsdef:=crecorddef.create(nestedvarsst.name^,nestedvarsst);
  1011. {$ifdef jvm}
  1012. maybe_guarantee_record_typesym(nestedvarsdef,nestedvarsdef.owner);
  1013. { don't add clone/FpcDeepCopy, because the field names are not all
  1014. representable in source form and we don't need them anyway }
  1015. symtablestack.push(trecorddef(nestedvarsdef).symtable);
  1016. maybe_add_public_default_java_constructor(trecorddef(nestedvarsdef));
  1017. insert_struct_hidden_paras(trecorddef(nestedvarsdef));
  1018. symtablestack.pop(trecorddef(nestedvarsdef).symtable);
  1019. {$endif}
  1020. symtablestack.free;
  1021. symtablestack:=old_symtablestack.getcopyuntil(pd.localst);
  1022. pnestedvarsdef:=cpointerdef.getreusable(nestedvarsdef);
  1023. if not(po_assembler in pd.procoptions) then
  1024. begin
  1025. nestedvars:=clocalvarsym.create('$nestedvars',vs_var,nestedvarsdef,[]);
  1026. include(nestedvars.symoptions,sp_internal);
  1027. pd.localst.insert(nestedvars);
  1028. pd.parentfpstruct:=nestedvars;
  1029. pd.parentfpinitblock:=cblocknode.create(nil);
  1030. end;
  1031. symtablestack.free;
  1032. pd.parentfpstructptrtype:=pnestedvarsdef;
  1033. symtablestack:=old_symtablestack;
  1034. end;
  1035. end.