pdecsub.pas 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl, Daniel Mantione
  4. Does the parsing of the procedures/functions
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit pdecsub;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. tokens,symconst,symtype,symdef,symsym;
  23. const
  24. pd_global = $1; { directive must be global }
  25. pd_body = $2; { directive needs a body }
  26. pd_implemen = $4; { directive can be used implementation section }
  27. pd_interface = $8; { directive can be used interface section }
  28. pd_object = $10; { directive can be used object declaration }
  29. pd_procvar = $20; { directive can be used procvar declaration }
  30. pd_notobject = $40; { directive can not be used object declaration }
  31. pd_notobjintf= $80; { directive can not be used interface declaration }
  32. function is_proc_directive(tok:ttoken):boolean;
  33. procedure insert_hidden_para(pd:tabstractprocdef);
  34. procedure check_self_para(aktprocdef:tabstractprocdef);
  35. procedure parameter_dec(aktprocdef:tabstractprocdef);
  36. procedure parse_proc_directives(var pdflags:word);
  37. procedure handle_calling_convention(sym:tprocsym;def:tabstractprocdef);
  38. procedure calc_parasymtable_addresses(def:tprocdef);
  39. procedure parse_proc_head(options:tproctypeoption);
  40. procedure parse_proc_dec;
  41. procedure parse_var_proc_directives(var sym : tsym);
  42. procedure parse_object_proc_directives(var sym : tprocsym);
  43. function proc_add_definition(aprocsym:tprocsym;var aprocdef : tprocdef) : boolean;
  44. implementation
  45. uses
  46. {$ifdef delphi}
  47. sysutils,
  48. {$else delphi}
  49. strings,
  50. {$endif delphi}
  51. { common }
  52. cutils,cclasses,
  53. { global }
  54. globtype,globals,verbose,
  55. systems,cpubase,
  56. { aasm }
  57. aasmbase,aasmtai,aasmcpu,
  58. { symtable }
  59. symbase,symtable,defutil,defcmp,paramgr,
  60. { pass 1 }
  61. node,htypechk,
  62. nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
  63. { parser }
  64. fmodule,scanner,
  65. pbase,pexpr,ptype,pdecl,
  66. { linking }
  67. import,gendef,
  68. { codegen }
  69. cpuinfo,cgbase
  70. ;
  71. procedure insert_hidden_para(pd:tabstractprocdef);
  72. var
  73. currpara : tparaitem;
  74. hvs : tvarsym;
  75. begin
  76. { walk from right to left, so we can insert the
  77. high parameters after the current parameter }
  78. currpara:=tparaitem(pd.para.last);
  79. while assigned(currpara) do
  80. begin
  81. { need high parameter ? }
  82. if paramanager.push_high_param(currpara.paratype.def,pd.proccalloption) then
  83. begin
  84. if assigned(currpara.parasym) then
  85. begin
  86. hvs:=tvarsym.create('$high'+tvarsym(currpara.parasym).name,s32bittype);
  87. hvs.varspez:=vs_const;
  88. include(hvs.varoptions,vo_is_high_value);
  89. tvarsym(currpara.parasym).owner.insert(hvs);
  90. tvarsym(currpara.parasym).highvarsym:=hvs;
  91. end
  92. else
  93. hvs:=nil;
  94. pd.concatpara(currpara,s32bittype,hvs,vs_hidden,nil);
  95. end
  96. else
  97. begin
  98. { Give a warning that cdecl routines does not include high()
  99. support }
  100. if (pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) and
  101. paramanager.push_high_param(currpara.paratype.def,pocall_fpccall) then
  102. begin
  103. if is_open_string(currpara.paratype.def) then
  104. Message(parser_w_cdecl_no_openstring);
  105. Message(parser_w_cdecl_has_no_high);
  106. end;
  107. end;
  108. currpara:=tparaitem(currpara.previous);
  109. end;
  110. end;
  111. procedure checkvaluepara(p:tnamedindexitem;arg:pointer);
  112. begin
  113. if tsym(p).typ<>varsym then
  114. exit;
  115. with tvarsym(p) do
  116. begin
  117. { do we need a local copy? Then rename the varsym, do this after the
  118. insert so the dup id checking is done correctly.
  119. array of const and open array do not need this, the local copy routine
  120. will patch the pushed value to point to the local copy }
  121. if (varspez=vs_value) and
  122. paramanager.push_addr_param(vartype.def,aktprocdef.proccalloption) and
  123. not(is_array_of_const(vartype.def) or
  124. is_open_array(vartype.def)) then
  125. aktprocdef.parast.symsearch.rename(name,'val'+name);
  126. end;
  127. end;
  128. procedure check_c_para(p:tnamedindexitem;arg:pointer);
  129. begin
  130. if (tsym(p).typ<>varsym) then
  131. exit;
  132. with tvarsym(p) do
  133. begin
  134. case vartype.def.deftype of
  135. arraydef :
  136. begin
  137. if not is_variant_array(vartype.def) and
  138. not is_array_of_const(vartype.def) then
  139. begin
  140. if (varspez<>vs_var) then
  141. Message(parser_h_c_arrays_are_references);
  142. end;
  143. if is_array_of_const(vartype.def) and
  144. assigned(indexnext) and
  145. (tsym(indexnext).typ=varsym) and
  146. not(vo_is_high_value in tvarsym(indexnext).varoptions) then
  147. Message(parser_e_C_array_of_const_must_be_last);
  148. end;
  149. end;
  150. end;
  151. end;
  152. procedure check_self_para(aktprocdef:tabstractprocdef);
  153. var
  154. hpara : tparaitem;
  155. begin
  156. hpara:=aktprocdef.selfpara;
  157. if assigned(hpara) and
  158. (
  159. ((aktprocdef.deftype=procvardef) and
  160. (po_methodpointer in aktprocdef.procoptions)) or
  161. ((aktprocdef.deftype=procdef) and
  162. assigned(tprocdef(aktprocdef)._class))
  163. ) then
  164. begin
  165. include(aktprocdef.procoptions,po_containsself);
  166. if hpara.paratyp <> vs_value then
  167. CGMessage(parser_e_self_call_by_value);
  168. if (aktprocdef.deftype=procdef) then
  169. begin
  170. inc(procinfo.selfpointer_offset,tvarsym(hpara.parasym).address);
  171. if compare_defs(hpara.paratype.def,tprocdef(aktprocdef)._class,nothingn)=te_incompatible then
  172. CGMessage2(type_e_incompatible_types,hpara.paratype.def.typename,tprocdef(aktprocdef)._class.typename);
  173. end;
  174. end;
  175. end;
  176. procedure parameter_dec(aktprocdef:tabstractprocdef);
  177. {
  178. handle_procvar needs the same changes
  179. }
  180. var
  181. is_procvar : boolean;
  182. sc : tsinglelist;
  183. tt : ttype;
  184. arrayelementtype : ttype;
  185. vs : tvarsym;
  186. srsym : tsym;
  187. hs1 : string;
  188. varspez : Tvarspez;
  189. hpara : tparaitem;
  190. tdefaultvalue : tconstsym;
  191. defaultrequired : boolean;
  192. old_object_option : tsymoptions;
  193. dummyst : tparasymtable;
  194. currparast : tparasymtable;
  195. begin
  196. consume(_LKLAMMER);
  197. { Delphi/Kylix supports nonsense like }
  198. { procedure p(); }
  199. if try_to_consume(_RKLAMMER) and
  200. not(m_tp7 in aktmodeswitches) then
  201. exit;
  202. { parsing a proc or procvar ? }
  203. is_procvar:=(aktprocdef.deftype=procvardef);
  204. { create dummy symtable for procvars }
  205. if is_procvar then
  206. begin
  207. dummyst:=tparasymtable.create;
  208. currparast:=dummyst;
  209. end
  210. else
  211. begin
  212. currparast:=tparasymtable(tprocdef(aktprocdef).parast);
  213. end;
  214. { reset }
  215. sc:=tsinglelist.create;
  216. defaultrequired:=false;
  217. { the variables are always public }
  218. old_object_option:=current_object_option;
  219. current_object_option:=[sp_public];
  220. inc(testcurobject);
  221. repeat
  222. if try_to_consume(_VAR) then
  223. varspez:=vs_var
  224. else
  225. if try_to_consume(_CONST) then
  226. varspez:=vs_const
  227. else
  228. if (idtoken=_OUT) and (m_out in aktmodeswitches) then
  229. begin
  230. consume(_OUT);
  231. varspez:=vs_out
  232. end
  233. else
  234. varspez:=vs_value;
  235. tdefaultvalue:=nil;
  236. tt.reset;
  237. { read identifiers and insert with error type }
  238. sc.reset;
  239. repeat
  240. vs:=tvarsym.create(orgpattern,generrortype);
  241. currparast.insert(vs);
  242. if assigned(vs.owner) then
  243. sc.insert(vs)
  244. else
  245. vs.free;
  246. consume(_ID);
  247. until not try_to_consume(_COMMA);
  248. { read type declaration, force reading for value and const paras }
  249. if (token=_COLON) or (varspez=vs_value) then
  250. begin
  251. consume(_COLON);
  252. { check for an open array }
  253. if token=_ARRAY then
  254. begin
  255. consume(_ARRAY);
  256. consume(_OF);
  257. { define range and type of range }
  258. tt.setdef(tarraydef.create(0,-1,s32bittype));
  259. { array of const ? }
  260. if (token=_CONST) and (m_objpas in aktmodeswitches) then
  261. begin
  262. consume(_CONST);
  263. srsym:=searchsymonlyin(systemunit,'TVARREC');
  264. if not assigned(srsym) then
  265. InternalError(1234124);
  266. tarraydef(tt.def).setelementtype(ttypesym(srsym).restype);
  267. tarraydef(tt.def).IsArrayOfConst:=true;
  268. end
  269. else
  270. begin
  271. { define field type }
  272. single_type(arrayelementtype,hs1,false);
  273. tarraydef(tt.def).setelementtype(arrayelementtype);
  274. end;
  275. end
  276. else
  277. begin
  278. { open string ? }
  279. if (varspez=vs_var) and
  280. (
  281. (
  282. ((token=_STRING) or (idtoken=_SHORTSTRING)) and
  283. (cs_openstring in aktmoduleswitches) and
  284. not(cs_ansistrings in aktlocalswitches)
  285. ) or
  286. (idtoken=_OPENSTRING)) then
  287. begin
  288. consume(token);
  289. tt:=openshortstringtype;
  290. hs1:='openstring';
  291. end
  292. else
  293. begin
  294. { everything else }
  295. single_type(tt,hs1,false);
  296. end;
  297. { default parameter }
  298. if (m_default_para in aktmodeswitches) then
  299. begin
  300. if try_to_consume(_EQUAL) then
  301. begin
  302. vs:=tvarsym(sc.first);
  303. if assigned(vs.listnext) then
  304. Message(parser_e_default_value_only_one_para);
  305. { prefix 'def' to the parameter name }
  306. tdefaultvalue:=ReadConstant('$def'+vs.name,vs.fileinfo);
  307. if assigned(tdefaultvalue) then
  308. tprocdef(aktprocdef).parast.insert(tdefaultvalue);
  309. defaultrequired:=true;
  310. end
  311. else
  312. begin
  313. if defaultrequired then
  314. Message1(parser_e_default_value_expected_for_para,vs.name);
  315. end;
  316. end;
  317. end;
  318. end
  319. else
  320. begin
  321. {$ifndef UseNiceNames}
  322. hs1:='$$$';
  323. {$else UseNiceNames}
  324. hs1:='var';
  325. {$endif UseNiceNames}
  326. tt:=cformaltype;
  327. end;
  328. vs:=tvarsym(sc.first);
  329. while assigned(vs) do
  330. begin
  331. { update varsym }
  332. vs.vartype:=tt;
  333. vs.varspez:=varspez;
  334. { For proc vars we only need the definitions }
  335. if not is_procvar then
  336. begin
  337. if (varspez in [vs_var,vs_const,vs_out]) and
  338. paramanager.push_addr_param(tt.def,aktprocdef.proccalloption) then
  339. include(vs.varoptions,vo_regable);
  340. hpara:=aktprocdef.concatpara(nil,tt,vs,varspez,tdefaultvalue);
  341. end
  342. else
  343. hpara:=aktprocdef.concatpara(nil,tt,nil,varspez,tdefaultvalue);
  344. { save position of self parameter }
  345. if vs.name='SELF' then
  346. aktprocdef.selfpara:=hpara;
  347. vs:=tvarsym(vs.listnext);
  348. end;
  349. until not try_to_consume(_SEMICOLON);
  350. { remove parasymtable from stack }
  351. if is_procvar then
  352. dummyst.free;
  353. sc.free;
  354. { check for a self parameter, only for normal procedures. For
  355. procvars we need to wait until the 'of object' is parsed }
  356. if not is_procvar then
  357. check_self_para(aktprocdef);
  358. { reset object options }
  359. dec(testcurobject);
  360. current_object_option:=old_object_option;
  361. consume(_RKLAMMER);
  362. end;
  363. procedure parse_proc_head(options:tproctypeoption);
  364. var
  365. orgsp,sp:stringid;
  366. paramoffset:longint;
  367. sym:tsym;
  368. st : tsymtable;
  369. srsymtable : tsymtable;
  370. storepos,procstartfilepos : tfileposinfo;
  371. searchagain : boolean;
  372. i: longint;
  373. begin
  374. { Save the position where this procedure really starts }
  375. procstartfilepos:=akttokenpos;
  376. aktprocdef:=nil;
  377. if (options=potype_operator) then
  378. begin
  379. sp:=overloaded_names[optoken];
  380. orgsp:=sp;
  381. end
  382. else
  383. begin
  384. sp:=pattern;
  385. orgsp:=orgpattern;
  386. consume(_ID);
  387. end;
  388. { examine interface map: function/procedure iname.functionname=locfuncname }
  389. if parse_only and
  390. assigned(procinfo._class) and
  391. assigned(procinfo._class.implementedinterfaces) and
  392. (procinfo._class.implementedinterfaces.count>0) and
  393. try_to_consume(_POINT) then
  394. begin
  395. storepos:=akttokenpos;
  396. akttokenpos:=procstartfilepos;
  397. { get interface syms}
  398. searchsym(sp,sym,srsymtable);
  399. if not assigned(sym) then
  400. begin
  401. identifier_not_found(orgsp);
  402. sym:=generrorsym;
  403. end;
  404. akttokenpos:=storepos;
  405. { load proc name }
  406. if sym.typ=typesym then
  407. i:=procinfo._class.implementedinterfaces.searchintf(ttypesym(sym).restype.def);
  408. { qualifier is interface name? }
  409. if (sym.typ<>typesym) or (ttypesym(sym).restype.def.deftype<>objectdef) or
  410. (i=-1) then
  411. begin
  412. Message(parser_e_interface_id_expected);
  413. aktprocsym:=nil;
  414. end
  415. else
  416. begin
  417. aktprocsym:=tprocsym(procinfo._class.implementedinterfaces.interfaces(i).symtable.search(sp));
  418. { the method can be declared after the mapping FK
  419. if not(assigned(aktprocsym)) then
  420. Message(parser_e_methode_id_expected);
  421. }
  422. end;
  423. consume(_ID);
  424. consume(_EQUAL);
  425. if (token=_ID) { and assigned(aktprocsym) } then
  426. procinfo._class.implementedinterfaces.addmappings(i,sp,pattern);
  427. consume(_ID);
  428. exit;
  429. end;
  430. { method ? }
  431. if not(parse_only) and
  432. (lexlevel=normal_function_level) and
  433. try_to_consume(_POINT) then
  434. begin
  435. { search for object name }
  436. storepos:=akttokenpos;
  437. akttokenpos:=procstartfilepos;
  438. searchsym(sp,sym,srsymtable);
  439. if not assigned(sym) then
  440. begin
  441. identifier_not_found(orgsp);
  442. sym:=generrorsym;
  443. end;
  444. akttokenpos:=storepos;
  445. { consume proc name }
  446. sp:=pattern;
  447. orgsp:=orgpattern;
  448. procstartfilepos:=akttokenpos;
  449. consume(_ID);
  450. { qualifier is class name ? }
  451. if (sym.typ<>typesym) or
  452. (ttypesym(sym).restype.def.deftype<>objectdef) then
  453. begin
  454. Message(parser_e_class_id_expected);
  455. aktprocsym:=nil;
  456. aktprocdef:=nil;
  457. end
  458. else
  459. begin
  460. { used to allow private syms to be seen }
  461. aktobjectdef:=tobjectdef(ttypesym(sym).restype.def);
  462. procinfo._class:=tobjectdef(ttypesym(sym).restype.def);
  463. aktprocsym:=tprocsym(procinfo._class.symtable.search(sp));
  464. {The procedure has been found. So it is
  465. a global one. Set the flags to mark this.}
  466. procinfo.flags:=procinfo.flags or pi_is_global;
  467. aktobjectdef:=nil;
  468. { we solve this below }
  469. if assigned(aktprocsym) then
  470. begin
  471. if aktprocsym.typ<>procsym then
  472. begin
  473. { we use a different error message for tp7 so it looks more compatible }
  474. if (m_fpc in aktmodeswitches) then
  475. Message1(parser_e_overloaded_no_procedure,aktprocsym.realname)
  476. else
  477. Message(parser_e_methode_id_expected);
  478. { rename the name to an unique name to avoid an
  479. error when inserting the symbol in the symtable }
  480. orgsp:=orgsp+'$'+tostr(aktfilepos.line);
  481. aktprocsym:=nil;
  482. end;
  483. end
  484. else
  485. Message(parser_e_methode_id_expected);
  486. end;
  487. end
  488. else
  489. begin
  490. { check for constructor/destructor which is not allowed here }
  491. if (not parse_only) and
  492. (options in [potype_constructor,potype_destructor]) then
  493. Message(parser_e_constructors_always_objects);
  494. repeat
  495. searchagain:=false;
  496. akttokenpos:=procstartfilepos;
  497. aktprocsym:=tprocsym(symtablestack.search(sp));
  498. if not(parse_only) and
  499. not assigned(aktprocsym) and
  500. (symtablestack.symtabletype=staticsymtable) and
  501. assigned(symtablestack.next) and
  502. (symtablestack.next.unitid=0) then
  503. begin
  504. {The procedure we prepare for is in the implementation
  505. part of the unit we compile. It is also possible that we
  506. are compiling a program, which is also some kind of
  507. implementaion part.
  508. We need to find out if the procedure is global. If it is
  509. global, it is in the global symtable.}
  510. aktprocsym:=tprocsym(symtablestack.next.search(sp));
  511. end;
  512. { Check if overloaded is a procsym }
  513. if assigned(aktprocsym) and
  514. (aktprocsym.typ<>procsym) then
  515. begin
  516. { when the other symbol is a unit symbol then hide the unit
  517. symbol. Only in tp mode because it's bad programming }
  518. if (m_duplicate_names in aktmodeswitches) and
  519. (aktprocsym.typ=unitsym) then
  520. begin
  521. aktprocsym.owner.rename(aktprocsym.name,'hidden'+aktprocsym.name);
  522. searchagain:=true;
  523. end
  524. else
  525. begin
  526. { we use a different error message for tp7 so it looks more compatible }
  527. if (m_fpc in aktmodeswitches) then
  528. Message1(parser_e_overloaded_no_procedure,aktprocsym.realname)
  529. else
  530. DuplicateSym(aktprocsym);
  531. { rename the name to an unique name to avoid an
  532. error when inserting the symbol in the symtable }
  533. orgsp:=orgsp+'$'+tostr(aktfilepos.line);
  534. { generate a new aktprocsym }
  535. aktprocsym:=nil;
  536. end;
  537. end;
  538. until not searchagain;
  539. end;
  540. { test again if assigned, it can be reset to recover }
  541. if not assigned(aktprocsym) then
  542. begin
  543. { create a new procsym and set the real filepos }
  544. akttokenpos:=procstartfilepos;
  545. { for operator we have only one procsym for each overloaded
  546. operation }
  547. if (options=potype_operator) then
  548. begin
  549. { is the current overload sym already in the current unit }
  550. if assigned(overloaded_operators[optoken]) and
  551. (overloaded_operators[optoken].owner=symtablestack) then
  552. aktprocsym:=overloaded_operators[optoken]
  553. else
  554. begin
  555. { create the procsym with saving the original case }
  556. aktprocsym:=tprocsym.create('$'+sp);
  557. if assigned(overloaded_operators[optoken]) then
  558. overloaded_operators[optoken].concat_procdefs_to(aktprocsym);
  559. end;
  560. end
  561. else
  562. aktprocsym:=tprocsym.create(orgsp);
  563. symtablestack.insert(aktprocsym);
  564. end
  565. else
  566. begin
  567. { Set global flag when found in globalsytmable }
  568. if (not parse_only) and
  569. (aktprocsym.owner.symtabletype=globalsymtable) then
  570. procinfo.flags:=procinfo.flags or pi_is_global;
  571. end;
  572. st:=symtablestack;
  573. aktprocdef:=tprocdef.create;
  574. aktprocdef.symtablelevel:=symtablestack.symtablelevel;
  575. if assigned(procinfo._class) then
  576. aktprocdef._class := procinfo._class;
  577. { set the options from the caller (podestructor or poconstructor) }
  578. aktprocdef.proctypeoption:=options;
  579. { add procsym to the procdef }
  580. aktprocdef.procsym:=aktprocsym;
  581. { save file position and symbol options }
  582. aktprocdef.fileinfo:=procstartfilepos;
  583. aktprocdef.symoptions:=current_object_option;
  584. { this must also be inserted in the right symtable !! PM }
  585. { otherwise we get subbtle problems with
  586. definitions of args defs in staticsymtable for
  587. implementation of a global method }
  588. if token=_LKLAMMER then
  589. parameter_dec(aktprocdef);
  590. { calculate the offset of the parameters }
  591. paramoffset:=target_info.first_parm_offset;
  592. { calculate frame pointer offset }
  593. if lexlevel>normal_function_level then
  594. begin
  595. procinfo.framepointer_offset:=paramoffset;
  596. inc(paramoffset,pointer_size);
  597. { this is needed to get correct framepointer push for local
  598. forward functions !! }
  599. aktprocdef.parast.symtablelevel:=lexlevel;
  600. end;
  601. { Get self, vmt offsets }
  602. if assigned (procinfo._Class) then
  603. begin
  604. { self pointer offset, must be done after parsing the parameters }
  605. { self isn't pushed in nested procedure of methods }
  606. if (lexlevel=normal_function_level) then
  607. begin
  608. if assigned(aktprocdef) and
  609. not(po_containsself in aktprocdef.procoptions) then
  610. begin
  611. procinfo.selfpointer_offset:=paramoffset;
  612. inc(paramoffset,POINTER_SIZE);
  613. end;
  614. end;
  615. { Special parameters for de-/constructors }
  616. case aktprocdef.proctypeoption of
  617. potype_constructor :
  618. begin
  619. procinfo.vmtpointer_offset:=paramoffset;
  620. inc(paramoffset,POINTER_SIZE);
  621. end;
  622. potype_destructor :
  623. begin
  624. if is_object(procinfo._class) then
  625. begin
  626. procinfo.vmtpointer_offset:=paramoffset;
  627. inc(paramoffset,POINTER_SIZE);
  628. end
  629. else
  630. if is_class(procinfo._class) then
  631. begin
  632. procinfo.inheritedflag_offset:=paramoffset;
  633. inc(paramoffset,POINTER_SIZE);
  634. end
  635. else
  636. internalerror(200303261);
  637. end;
  638. end;
  639. end;
  640. procinfo.para_offset:=paramoffset;
  641. { so we only restore the symtable now }
  642. symtablestack:=st;
  643. if (options=potype_operator) then
  644. overloaded_operators[optoken]:=aktprocsym;
  645. end;
  646. procedure parse_proc_dec;
  647. var
  648. hs : string;
  649. isclassmethod : boolean;
  650. begin
  651. inc(lexlevel);
  652. { read class method }
  653. if try_to_consume(_CLASS) then
  654. begin
  655. { class method only allowed for procedures and functions }
  656. if not(token in [_FUNCTION,_PROCEDURE]) then
  657. Message(parser_e_procedure_or_function_expected);
  658. isclassmethod:=true;
  659. end
  660. else
  661. isclassmethod:=false;
  662. case token of
  663. _FUNCTION : begin
  664. consume(_FUNCTION);
  665. parse_proc_head(potype_none);
  666. if token<>_COLON then
  667. begin
  668. if assigned(aktprocsym) and
  669. not(is_interface(aktprocdef._class)) and
  670. not(aktprocdef.forwarddef) or
  671. (m_repeat_forward in aktmodeswitches) then
  672. begin
  673. consume(_COLON);
  674. consume_all_until(_SEMICOLON);
  675. end;
  676. end
  677. else
  678. begin
  679. consume(_COLON);
  680. inc(testcurobject);
  681. single_type(aktprocdef.rettype,hs,false);
  682. aktprocdef.test_if_fpu_result;
  683. if (aktprocdef.rettype.def.deftype=stringdef) and
  684. (tstringdef(aktprocdef.rettype.def).string_typ<>st_shortstring) then
  685. procinfo.no_fast_exit:=true;
  686. dec(testcurobject);
  687. end;
  688. end;
  689. _PROCEDURE : begin
  690. consume(_PROCEDURE);
  691. parse_proc_head(potype_none);
  692. if assigned(aktprocsym) then
  693. aktprocdef.rettype:=voidtype;
  694. end;
  695. _CONSTRUCTOR : begin
  696. consume(_CONSTRUCTOR);
  697. parse_proc_head(potype_constructor);
  698. if assigned(procinfo._class) and
  699. is_class(procinfo._class) then
  700. begin
  701. { CLASS constructors return the created instance }
  702. aktprocdef.rettype.setdef(procinfo._class);
  703. end
  704. else
  705. begin
  706. { OBJECT constructors return a boolean }
  707. aktprocdef.rettype:=booltype;
  708. end;
  709. end;
  710. _DESTRUCTOR : begin
  711. consume(_DESTRUCTOR);
  712. parse_proc_head(potype_destructor);
  713. aktprocdef.rettype:=voidtype;
  714. end;
  715. _OPERATOR : begin
  716. if lexlevel>normal_function_level then
  717. Message(parser_e_no_local_operator);
  718. consume(_OPERATOR);
  719. if (token in [first_overloaded..last_overloaded]) then
  720. begin
  721. procinfo.flags:=procinfo.flags or pi_operator;
  722. optoken:=token;
  723. end
  724. else
  725. begin
  726. Message(parser_e_overload_operator_failed);
  727. { Use the dummy NOTOKEN that is also declared
  728. for the overloaded_operator[] }
  729. optoken:=NOTOKEN;
  730. end;
  731. consume(Token);
  732. parse_proc_head(potype_operator);
  733. if token<>_ID then
  734. begin
  735. otsym:=nil;
  736. if not(m_result in aktmodeswitches) then
  737. consume(_ID);
  738. end
  739. else
  740. begin
  741. otsym:=tvarsym.create(pattern,voidtype);
  742. consume(_ID);
  743. end;
  744. if not try_to_consume(_COLON) then
  745. begin
  746. consume(_COLON);
  747. aktprocdef.rettype:=generrortype;
  748. consume_all_until(_SEMICOLON);
  749. end
  750. else
  751. begin
  752. single_type(aktprocdef.rettype,hs,false);
  753. aktprocdef.test_if_fpu_result;
  754. if (optoken in [_EQUAL,_GT,_LT,_GTE,_LTE]) and
  755. ((aktprocdef.rettype.def.deftype<>orddef) or
  756. (torddef(aktprocdef.rettype.def).typ<>bool8bit)) then
  757. Message(parser_e_comparative_operator_return_boolean);
  758. if assigned(otsym) then
  759. otsym.vartype.def:=aktprocdef.rettype.def;
  760. if (optoken=_ASSIGNMENT) and
  761. equal_defs(aktprocdef.rettype.def,
  762. tvarsym(aktprocdef.parast.symindex.first).vartype.def) then
  763. message(parser_e_no_such_assignment)
  764. else if not isoperatoracceptable(aktprocdef,optoken) then
  765. Message(parser_e_overload_impossible);
  766. end;
  767. end;
  768. end;
  769. if isclassmethod and
  770. assigned(aktprocsym) then
  771. include(aktprocdef.procoptions,po_classmethod);
  772. { support procedure proc;stdcall export; in Delphi mode only }
  773. if not((m_delphi in aktmodeswitches) and
  774. is_proc_directive(token)) then
  775. consume(_SEMICOLON);
  776. dec(lexlevel);
  777. end;
  778. {****************************************************************************
  779. Procedure directive handlers
  780. ****************************************************************************}
  781. procedure pd_far;
  782. begin
  783. Message1(parser_w_proc_directive_ignored,'FAR');
  784. end;
  785. procedure pd_near;
  786. begin
  787. Message1(parser_w_proc_directive_ignored,'NEAR');
  788. end;
  789. procedure pd_export;
  790. begin
  791. if assigned(procinfo._class) then
  792. Message(parser_e_methods_dont_be_export);
  793. if lexlevel<>normal_function_level then
  794. Message(parser_e_dont_nest_export);
  795. { only os/2 and emx need this }
  796. if target_info.system in [system_i386_os2,system_i386_emx] then
  797. begin
  798. aktprocdef.aliasnames.insert(aktprocsym.realname);
  799. procinfo.exported:=true;
  800. if cs_link_deffile in aktglobalswitches then
  801. deffile.AddExport(aktprocdef.mangledname);
  802. end;
  803. end;
  804. procedure pd_forward;
  805. begin
  806. aktprocdef.forwarddef:=true;
  807. end;
  808. procedure pd_alias;
  809. begin
  810. consume(_COLON);
  811. aktprocdef.aliasnames.insert(get_stringconst);
  812. end;
  813. procedure pd_asmname;
  814. begin
  815. aktprocdef.setmangledname(target_info.Cprefix+pattern);
  816. if token=_CCHAR then
  817. consume(_CCHAR)
  818. else
  819. consume(_CSTRING);
  820. { we don't need anything else }
  821. aktprocdef.forwarddef:=false;
  822. end;
  823. procedure pd_inline;
  824. var
  825. hp : tparaitem;
  826. begin
  827. { check if there is an array of const }
  828. hp:=tparaitem(aktprocdef.para.first);
  829. while assigned(hp) do
  830. begin
  831. if assigned(hp.paratype.def) and
  832. (hp.paratype.def.deftype=arraydef) then
  833. begin
  834. with tarraydef(hp.paratype.def) do
  835. if IsVariant or IsConstructor {or IsArrayOfConst} then
  836. begin
  837. Message1(parser_w_not_supported_for_inline,'array of const');
  838. Message(parser_w_inlining_disabled);
  839. aktprocdef.proccalloption:=pocall_fpccall;
  840. end;
  841. end;
  842. hp:=tparaitem(hp.next);
  843. end;
  844. end;
  845. procedure pd_intern;
  846. begin
  847. consume(_COLON);
  848. aktprocdef.extnumber:=get_intconst;
  849. end;
  850. procedure pd_interrupt;
  851. begin
  852. if lexlevel<>normal_function_level then
  853. Message(parser_e_dont_nest_interrupt);
  854. end;
  855. procedure pd_abstract;
  856. begin
  857. if (po_virtualmethod in aktprocdef.procoptions) then
  858. include(aktprocdef.procoptions,po_abstractmethod)
  859. else
  860. Message(parser_e_only_virtual_methods_abstract);
  861. { the method is defined }
  862. aktprocdef.forwarddef:=false;
  863. end;
  864. procedure pd_virtual;
  865. {$ifdef WITHDMT}
  866. var
  867. pt : tnode;
  868. {$endif WITHDMT}
  869. begin
  870. if (aktprocdef.proctypeoption=potype_constructor) and
  871. is_object(aktprocdef._class) then
  872. Message(parser_e_constructor_cannot_be_not_virtual);
  873. {$ifdef WITHDMT}
  874. if is_object(aktprocdef._class) and
  875. (token<>_SEMICOLON) then
  876. begin
  877. { any type of parameter is allowed here! }
  878. pt:=comp_expr(true);
  879. if is_constintnode(pt) then
  880. begin
  881. include(aktprocdef.procoptions,po_msgint);
  882. aktprocdef.messageinf.i:=pt^.value;
  883. end
  884. else
  885. Message(parser_e_ill_msg_expr);
  886. disposetree(pt);
  887. end;
  888. {$endif WITHDMT}
  889. end;
  890. procedure pd_static;
  891. begin
  892. if (cs_static_keyword in aktmoduleswitches) then
  893. begin
  894. include(aktprocsym.symoptions,sp_static);
  895. include(aktprocdef.procoptions,po_staticmethod);
  896. end;
  897. end;
  898. procedure pd_override;
  899. begin
  900. if not(is_class_or_interface(aktprocdef._class)) then
  901. Message(parser_e_no_object_override);
  902. end;
  903. procedure pd_overload;
  904. begin
  905. include(aktprocsym.symoptions,sp_has_overloaded);
  906. end;
  907. procedure pd_message;
  908. var
  909. pt : tnode;
  910. begin
  911. if not is_class(aktprocdef._class) then
  912. Message(parser_e_msg_only_for_classes);
  913. { check parameter type }
  914. if not(po_containsself in aktprocdef.procoptions) and
  915. ((aktprocdef.minparacount<>1) or
  916. (aktprocdef.maxparacount<>1) or
  917. (TParaItem(aktprocdef.Para.first).paratyp<>vs_var)) then
  918. Message(parser_e_ill_msg_param);
  919. pt:=comp_expr(true);
  920. if pt.nodetype=stringconstn then
  921. begin
  922. include(aktprocdef.procoptions,po_msgstr);
  923. aktprocdef.messageinf.str:=strnew(tstringconstnode(pt).value_str);
  924. end
  925. else
  926. if is_constintnode(pt) then
  927. begin
  928. include(aktprocdef.procoptions,po_msgint);
  929. aktprocdef.messageinf.i:=tordconstnode(pt).value;
  930. end
  931. else
  932. Message(parser_e_ill_msg_expr);
  933. pt.free;
  934. end;
  935. procedure pd_reintroduce;
  936. begin
  937. Message1(parser_w_proc_directive_ignored,'REINTRODUCE');
  938. end;
  939. procedure pd_syscall;
  940. begin
  941. aktprocdef.forwarddef:=false;
  942. aktprocdef.extnumber:=get_intconst;
  943. end;
  944. procedure pd_external;
  945. {
  946. If import_dll=nil the procedure is assumed to be in another
  947. object file. In that object file it should have the name to
  948. which import_name is pointing to. Otherwise, the procedure is
  949. assumed to be in the DLL to which import_dll is pointing to. In
  950. that case either import_nr<>0 or import_name<>nil is true, so
  951. the procedure is either imported by number or by name. (DM)
  952. }
  953. var
  954. pd : tprocdef;
  955. import_dll,
  956. import_name : string;
  957. import_nr : word;
  958. begin
  959. aktprocdef.forwarddef:=false;
  960. { forbid local external procedures }
  961. if lexlevel>normal_function_level then
  962. Message(parser_e_no_local_external);
  963. { If the procedure should be imported from a DLL, a constant string follows.
  964. This isn't really correct, an contant string expression follows
  965. so we check if an semicolon follows, else a string constant have to
  966. follow (FK) }
  967. import_nr:=0;
  968. import_name:='';
  969. if not(token=_SEMICOLON) and not(idtoken=_NAME) then
  970. begin
  971. import_dll:=get_stringconst;
  972. if (idtoken=_NAME) then
  973. begin
  974. consume(_NAME);
  975. import_name:=get_stringconst;
  976. end;
  977. if (idtoken=_INDEX) then
  978. begin
  979. {After the word index follows the index number in the DLL.}
  980. consume(_INDEX);
  981. import_nr:=get_intconst;
  982. end;
  983. { default is to used the realname of the procedure }
  984. if (import_nr=0) and (import_name='') then
  985. import_name:=aktprocsym.realname;
  986. { create importlib if not already done }
  987. if not(current_module.uses_imports) then
  988. begin
  989. current_module.uses_imports:=true;
  990. importlib.preparelib(current_module.modulename^);
  991. end;
  992. if not(m_repeat_forward in aktmodeswitches) then
  993. begin
  994. { we can only have one overloaded here ! }
  995. if aktprocsym.procdef_count>1 then
  996. pd:=aktprocsym.procdef[2]
  997. else
  998. pd:=aktprocdef;
  999. end
  1000. else
  1001. pd:=aktprocdef;
  1002. importlib.importproceduredef(pd,import_dll,import_nr,import_name);
  1003. end
  1004. else
  1005. begin
  1006. if (idtoken=_NAME) then
  1007. begin
  1008. consume(_NAME);
  1009. import_name:=get_stringconst;
  1010. aktprocdef.setmangledname(import_name);
  1011. end;
  1012. end;
  1013. end;
  1014. type
  1015. pd_handler=procedure;
  1016. proc_dir_rec=record
  1017. idtok : ttoken;
  1018. pd_flags : longint;
  1019. handler : pd_handler;
  1020. pocall : tproccalloption;
  1021. pooption : tprocoptions;
  1022. mutexclpocall : tproccalloptions;
  1023. mutexclpotype : tproctypeoptions;
  1024. mutexclpo : tprocoptions;
  1025. end;
  1026. const
  1027. {Should contain the number of procedure directives we support.}
  1028. num_proc_directives=36;
  1029. proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
  1030. (
  1031. (
  1032. idtok:_ABSTRACT;
  1033. pd_flags : pd_interface+pd_object+pd_notobjintf;
  1034. handler : {$ifdef FPCPROCVAR}@{$endif}pd_abstract;
  1035. pocall : pocall_none;
  1036. pooption : [po_abstractmethod];
  1037. mutexclpocall : [pocall_internproc,pocall_inline];
  1038. mutexclpotype : [potype_constructor,potype_destructor];
  1039. mutexclpo : [po_exports,po_interrupt,po_external]
  1040. ),(
  1041. idtok:_ALIAS;
  1042. pd_flags : pd_implemen+pd_body+pd_notobjintf;
  1043. handler : {$ifdef FPCPROCVAR}@{$endif}pd_alias;
  1044. pocall : pocall_none;
  1045. pooption : [];
  1046. mutexclpocall : [pocall_inline];
  1047. mutexclpotype : [];
  1048. mutexclpo : [po_external]
  1049. ),(
  1050. idtok:_ASMNAME;
  1051. pd_flags : pd_interface+pd_implemen+pd_notobjintf;
  1052. handler : {$ifdef FPCPROCVAR}@{$endif}pd_asmname;
  1053. pocall : pocall_cdecl;
  1054. pooption : [po_external];
  1055. mutexclpocall : [pocall_internproc,pocall_inline];
  1056. mutexclpotype : [];
  1057. mutexclpo : [po_external]
  1058. ),(
  1059. idtok:_ASSEMBLER;
  1060. pd_flags : pd_implemen+pd_body+pd_notobjintf;
  1061. handler : nil;
  1062. pocall : pocall_none;
  1063. pooption : [po_assembler];
  1064. mutexclpocall : [];
  1065. mutexclpotype : [];
  1066. mutexclpo : [po_external]
  1067. ),(
  1068. idtok:_CDECL;
  1069. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1070. handler : nil;
  1071. pocall : pocall_cdecl;
  1072. pooption : [];
  1073. mutexclpocall : [];
  1074. mutexclpotype : [potype_constructor,potype_destructor];
  1075. mutexclpo : [po_assembler,po_external,po_virtualmethod]
  1076. ),(
  1077. idtok:_DYNAMIC;
  1078. pd_flags : pd_interface+pd_object+pd_notobjintf;
  1079. handler : {$ifdef FPCPROCVAR}@{$endif}pd_virtual;
  1080. pocall : pocall_none;
  1081. pooption : [po_virtualmethod];
  1082. mutexclpocall : [pocall_internproc,pocall_inline];
  1083. mutexclpotype : [];
  1084. mutexclpo : [po_exports,po_interrupt,po_external]
  1085. ),(
  1086. idtok:_EXPORT;
  1087. pd_flags : pd_body+pd_global+pd_interface+pd_implemen{??}+pd_notobjintf;
  1088. handler : {$ifdef FPCPROCVAR}@{$endif}pd_export;
  1089. pocall : pocall_none;
  1090. pooption : [po_exports];
  1091. mutexclpocall : [pocall_internproc,pocall_inline];
  1092. mutexclpotype : [potype_constructor,potype_destructor];
  1093. mutexclpo : [po_external,po_interrupt]
  1094. ),(
  1095. idtok:_EXTERNAL;
  1096. pd_flags : pd_implemen+pd_interface+pd_notobject+pd_notobjintf;
  1097. handler : {$ifdef FPCPROCVAR}@{$endif}pd_external;
  1098. pocall : pocall_none;
  1099. pooption : [po_external];
  1100. mutexclpocall : [pocall_internproc,pocall_inline,pocall_palmossyscall];
  1101. mutexclpotype : [potype_constructor,potype_destructor];
  1102. mutexclpo : [po_exports,po_interrupt,po_assembler]
  1103. ),(
  1104. idtok:_FAR;
  1105. pd_flags : pd_implemen+pd_body+pd_interface+pd_procvar+pd_notobject+pd_notobjintf;
  1106. handler : {$ifdef FPCPROCVAR}@{$endif}pd_far;
  1107. pocall : pocall_none;
  1108. pooption : [];
  1109. mutexclpocall : [pocall_internproc,pocall_inline];
  1110. mutexclpotype : [];
  1111. mutexclpo : []
  1112. ),(
  1113. idtok:_FAR16;
  1114. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar+pd_notobject;
  1115. handler : nil;
  1116. pocall : pocall_far16;
  1117. pooption : [];
  1118. mutexclpocall : [];
  1119. mutexclpotype : [];
  1120. mutexclpo : [po_external,po_leftright]
  1121. ),(
  1122. idtok:_FORWARD;
  1123. pd_flags : pd_implemen+pd_notobject+pd_notobjintf;
  1124. handler : {$ifdef FPCPROCVAR}@{$endif}pd_forward;
  1125. pocall : pocall_none;
  1126. pooption : [];
  1127. mutexclpocall : [pocall_internproc,pocall_inline];
  1128. mutexclpotype : [];
  1129. mutexclpo : [po_external]
  1130. ),(
  1131. idtok:_FPCCALL;
  1132. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1133. handler : nil;
  1134. pocall : pocall_fpccall;
  1135. pooption : [];
  1136. mutexclpocall : [];
  1137. mutexclpotype : [];
  1138. mutexclpo : [po_leftright]
  1139. ),(
  1140. idtok:_INLINE;
  1141. pd_flags : pd_interface+pd_implemen+pd_body+pd_notobjintf;
  1142. handler : {$ifdef FPCPROCVAR}@{$endif}pd_inline;
  1143. pocall : pocall_inline;
  1144. pooption : [];
  1145. mutexclpocall : [];
  1146. mutexclpotype : [potype_constructor,potype_destructor];
  1147. mutexclpo : [po_exports,po_external,po_interrupt]
  1148. ),(
  1149. idtok:_INTERNCONST;
  1150. pd_flags : pd_implemen+pd_body+pd_notobject+pd_notobjintf;
  1151. handler : {$ifdef FPCPROCVAR}@{$endif}pd_intern;
  1152. pocall : pocall_none;
  1153. pooption : [po_internconst];
  1154. mutexclpocall : [];
  1155. mutexclpotype : [potype_operator];
  1156. mutexclpo : []
  1157. ),(
  1158. idtok:_INTERNPROC;
  1159. pd_flags : pd_implemen+pd_notobject+pd_notobjintf;
  1160. handler : {$ifdef FPCPROCVAR}@{$endif}pd_intern;
  1161. pocall : pocall_internproc;
  1162. pooption : [];
  1163. mutexclpocall : [];
  1164. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1165. mutexclpo : [po_exports,po_external,po_interrupt,po_assembler,po_iocheck,po_leftright]
  1166. ),(
  1167. idtok:_INTERRUPT;
  1168. pd_flags : pd_implemen+pd_body+pd_notobject+pd_notobjintf;
  1169. handler : {$ifdef FPCPROCVAR}@{$endif}pd_interrupt;
  1170. pocall : pocall_none;
  1171. pooption : [po_interrupt];
  1172. mutexclpocall : [pocall_internproc,pocall_cdecl,pocall_cppdecl,
  1173. pocall_inline,pocall_pascal,pocall_system,pocall_far16,pocall_fpccall];
  1174. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1175. mutexclpo : [po_external,po_leftright,po_clearstack]
  1176. ),(
  1177. idtok:_IOCHECK;
  1178. pd_flags : pd_implemen+pd_body+pd_notobjintf;
  1179. handler : nil;
  1180. pocall : pocall_none;
  1181. pooption : [po_iocheck];
  1182. mutexclpocall : [pocall_internproc];
  1183. mutexclpotype : [];
  1184. mutexclpo : [po_external]
  1185. ),(
  1186. idtok:_MESSAGE;
  1187. pd_flags : pd_interface+pd_object+pd_notobjintf;
  1188. handler : {$ifdef FPCPROCVAR}@{$endif}pd_message;
  1189. pocall : pocall_none;
  1190. pooption : []; { can be po_msgstr or po_msgint }
  1191. mutexclpocall : [pocall_inline,pocall_internproc];
  1192. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1193. mutexclpo : [po_interrupt,po_external]
  1194. ),(
  1195. idtok:_NEAR;
  1196. pd_flags : pd_implemen+pd_body+pd_procvar+pd_notobjintf;
  1197. handler : {$ifdef FPCPROCVAR}@{$endif}pd_near;
  1198. pocall : pocall_none;
  1199. pooption : [];
  1200. mutexclpocall : [pocall_internproc];
  1201. mutexclpotype : [];
  1202. mutexclpo : []
  1203. ),(
  1204. idtok:_OVERLOAD;
  1205. pd_flags : pd_implemen+pd_interface+pd_body;
  1206. handler : {$ifdef FPCPROCVAR}@{$endif}pd_overload;
  1207. pocall : pocall_none;
  1208. pooption : [po_overload];
  1209. mutexclpocall : [pocall_internproc];
  1210. mutexclpotype : [];
  1211. mutexclpo : []
  1212. ),(
  1213. idtok:_OVERRIDE;
  1214. pd_flags : pd_interface+pd_object+pd_notobjintf;
  1215. handler : {$ifdef FPCPROCVAR}@{$endif}pd_override;
  1216. pocall : pocall_none;
  1217. pooption : [po_overridingmethod,po_virtualmethod];
  1218. mutexclpocall : [pocall_inline,pocall_internproc];
  1219. mutexclpotype : [];
  1220. mutexclpo : [po_exports,po_external,po_interrupt]
  1221. ),(
  1222. idtok:_PASCAL;
  1223. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1224. handler : nil;
  1225. pocall : pocall_pascal;
  1226. pooption : [];
  1227. mutexclpocall : [];
  1228. mutexclpotype : [potype_constructor,potype_destructor];
  1229. mutexclpo : [po_external]
  1230. ),(
  1231. idtok:_POPSTACK;
  1232. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1233. handler : nil;
  1234. pocall : pocall_none;
  1235. pooption : [po_clearstack];
  1236. mutexclpocall : [pocall_inline,pocall_internproc,pocall_stdcall];
  1237. mutexclpotype : [potype_constructor,potype_destructor];
  1238. mutexclpo : [po_assembler,po_external]
  1239. ),(
  1240. idtok:_PUBLIC;
  1241. pd_flags : pd_implemen+pd_body+pd_global+pd_notobject+pd_notobjintf;
  1242. handler : nil;
  1243. pocall : pocall_none;
  1244. pooption : [];
  1245. mutexclpocall : [pocall_internproc,pocall_inline];
  1246. mutexclpotype : [];
  1247. mutexclpo : [po_external]
  1248. ),(
  1249. idtok:_REGISTER;
  1250. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1251. handler : nil;
  1252. pocall : pocall_register;
  1253. pooption : [];
  1254. mutexclpocall : [];
  1255. mutexclpotype : [potype_constructor,potype_destructor];
  1256. mutexclpo : [po_external]
  1257. ),(
  1258. idtok:_REINTRODUCE;
  1259. pd_flags : pd_interface+pd_object;
  1260. handler : {$ifdef FPCPROCVAR}@{$endif}pd_reintroduce;
  1261. pocall : pocall_none;
  1262. pooption : [];
  1263. mutexclpocall : [];
  1264. mutexclpotype : [];
  1265. mutexclpo : []
  1266. ),(
  1267. idtok:_SAFECALL;
  1268. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1269. handler : nil;
  1270. pocall : pocall_safecall;
  1271. pooption : [];
  1272. mutexclpocall : [];
  1273. mutexclpotype : [potype_constructor,potype_destructor];
  1274. mutexclpo : [po_external]
  1275. ),(
  1276. idtok:_SAVEREGISTERS;
  1277. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar+pd_notobjintf;
  1278. handler : nil;
  1279. pocall : pocall_none;
  1280. pooption : [po_saveregisters];
  1281. mutexclpocall : [pocall_internproc];
  1282. mutexclpotype : [potype_constructor,potype_destructor];
  1283. mutexclpo : [po_external]
  1284. ),(
  1285. idtok:_STATIC;
  1286. pd_flags : pd_interface+pd_object+pd_notobjintf;
  1287. handler : {$ifdef FPCPROCVAR}@{$endif}pd_static;
  1288. pocall : pocall_none;
  1289. pooption : [po_staticmethod];
  1290. mutexclpocall : [pocall_inline,pocall_internproc];
  1291. mutexclpotype : [potype_constructor,potype_destructor];
  1292. mutexclpo : [po_external,po_interrupt,po_exports]
  1293. ),(
  1294. idtok:_STDCALL;
  1295. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1296. handler : nil;
  1297. pocall : pocall_stdcall;
  1298. pooption : [];
  1299. mutexclpocall : [];
  1300. mutexclpotype : [potype_constructor,potype_destructor];
  1301. mutexclpo : [po_external]
  1302. ),(
  1303. idtok:_SYSCALL;
  1304. pd_flags : pd_interface+pd_implemen+pd_notobjintf;
  1305. handler : {$ifdef FPCPROCVAR}@{$endif}pd_syscall;
  1306. pocall : pocall_palmossyscall;
  1307. pooption : [];
  1308. mutexclpocall : [];
  1309. mutexclpotype : [potype_constructor,potype_destructor];
  1310. mutexclpo : [po_external,po_assembler,po_interrupt,po_exports]
  1311. ),(
  1312. idtok:_SYSTEM;
  1313. pd_flags : pd_implemen+pd_notobject+pd_notobjintf;
  1314. handler : nil;
  1315. pocall : pocall_system;
  1316. pooption : [];
  1317. mutexclpocall : [];
  1318. mutexclpotype : [potype_constructor,potype_destructor];
  1319. mutexclpo : [po_external,po_assembler,po_interrupt]
  1320. ),(
  1321. idtok:_VIRTUAL;
  1322. pd_flags : pd_interface+pd_object+pd_notobjintf;
  1323. handler : {$ifdef FPCPROCVAR}@{$endif}pd_virtual;
  1324. pocall : pocall_none;
  1325. pooption : [po_virtualmethod];
  1326. mutexclpocall : [pocall_inline,pocall_internproc];
  1327. mutexclpotype : [];
  1328. mutexclpo : [po_external,po_interrupt,po_exports]
  1329. ),(
  1330. idtok:_CPPDECL;
  1331. pd_flags : pd_interface+pd_implemen+pd_body+pd_procvar;
  1332. handler : nil;
  1333. pocall : pocall_cppdecl;
  1334. pooption : [po_savestdregs];
  1335. mutexclpocall : [];
  1336. mutexclpotype : [potype_constructor,potype_destructor];
  1337. mutexclpo : [po_assembler,po_external,po_virtualmethod]
  1338. ),(
  1339. idtok:_VARARGS;
  1340. pd_flags : pd_interface+pd_implemen+pd_procvar;
  1341. handler : nil;
  1342. pocall : pocall_none;
  1343. pooption : [po_varargs];
  1344. mutexclpocall : [pocall_internproc,pocall_stdcall,pocall_register,
  1345. pocall_inline,pocall_far16,pocall_fpccall];
  1346. mutexclpotype : [];
  1347. mutexclpo : [po_assembler,po_interrupt,po_leftright]
  1348. ),(
  1349. idtok:_COMPILERPROC;
  1350. pd_flags : pd_interface+pd_implemen+pd_body+pd_notobjintf;
  1351. handler : nil;
  1352. pocall : pocall_compilerproc;
  1353. pooption : [];
  1354. mutexclpocall : [];
  1355. mutexclpotype : [potype_constructor,potype_destructor];
  1356. mutexclpo : [po_interrupt]
  1357. )
  1358. );
  1359. function is_proc_directive(tok:ttoken):boolean;
  1360. var
  1361. i : longint;
  1362. begin
  1363. is_proc_directive:=false;
  1364. for i:=1 to num_proc_directives do
  1365. if proc_direcdata[i].idtok=idtoken then
  1366. begin
  1367. is_proc_directive:=true;
  1368. exit;
  1369. end;
  1370. end;
  1371. function parse_proc_direc(var pdflags:word):boolean;
  1372. {
  1373. Parse the procedure directive, returns true if a correct directive is found
  1374. }
  1375. var
  1376. p : longint;
  1377. found : boolean;
  1378. name : stringid;
  1379. begin
  1380. parse_proc_direc:=false;
  1381. name:=tokeninfo^[idtoken].str;
  1382. found:=false;
  1383. { Hint directive? Then exit immediatly }
  1384. if (m_hintdirective in aktmodeswitches) then
  1385. begin
  1386. case idtoken of
  1387. _LIBRARY,
  1388. _PLATFORM,
  1389. _UNIMPLEMENTED,
  1390. _DEPRECATED :
  1391. exit;
  1392. end;
  1393. end;
  1394. { retrieve data for directive if found }
  1395. for p:=1 to num_proc_directives do
  1396. if proc_direcdata[p].idtok=idtoken then
  1397. begin
  1398. found:=true;
  1399. break;
  1400. end;
  1401. { Check if the procedure directive is known }
  1402. if not found then
  1403. begin
  1404. { parsing a procvar type the name can be any
  1405. next variable !! }
  1406. if (pdflags and (pd_procvar or pd_object))=0 then
  1407. Message1(parser_w_unknown_proc_directive_ignored,name);
  1408. exit;
  1409. end;
  1410. { static needs a special treatment }
  1411. if (idtoken=_STATIC) and not (cs_static_keyword in aktmoduleswitches) then
  1412. exit;
  1413. { Conflicts between directives ? }
  1414. if (aktprocdef.proctypeoption in proc_direcdata[p].mutexclpotype) or
  1415. (aktprocdef.proccalloption in proc_direcdata[p].mutexclpocall) or
  1416. ((aktprocdef.procoptions*proc_direcdata[p].mutexclpo)<>[]) then
  1417. begin
  1418. Message1(parser_e_proc_dir_conflict,name);
  1419. exit;
  1420. end;
  1421. { set calling convention }
  1422. if proc_direcdata[p].pocall<>pocall_none then
  1423. begin
  1424. if aktprocdef.proccalloption<>pocall_none then
  1425. begin
  1426. Message2(parser_w_proc_overriding_calling,
  1427. proccalloptionStr[aktprocdef.proccalloption],
  1428. proccalloptionStr[proc_direcdata[p].pocall]);
  1429. end;
  1430. aktprocdef.proccalloption:=proc_direcdata[p].pocall;
  1431. end;
  1432. { check if method and directive not for object, like public.
  1433. This needs to be checked also for procvars }
  1434. if ((proc_direcdata[p].pd_flags and pd_notobject)<>0) and
  1435. (aktprocdef.owner.symtabletype=objectsymtable) then
  1436. exit;
  1437. if aktprocdef.deftype=procdef then
  1438. begin
  1439. { Check if the directive is only for objects }
  1440. if ((proc_direcdata[p].pd_flags and pd_object)<>0) and
  1441. not assigned(aktprocdef._class) then
  1442. exit;
  1443. { check if method and directive not for interface }
  1444. if ((proc_direcdata[p].pd_flags and pd_notobjintf)<>0) and
  1445. is_interface(aktprocdef._class) then
  1446. exit;
  1447. end;
  1448. { consume directive, and turn flag on }
  1449. consume(token);
  1450. parse_proc_direc:=true;
  1451. { Check the pd_flags if the directive should be allowed }
  1452. if ((pdflags and pd_interface)<>0) and
  1453. ((proc_direcdata[p].pd_flags and pd_interface)=0) then
  1454. begin
  1455. Message1(parser_e_proc_dir_not_allowed_in_interface,name);
  1456. exit;
  1457. end;
  1458. if ((pdflags and pd_implemen)<>0) and
  1459. ((proc_direcdata[p].pd_flags and pd_implemen)=0) then
  1460. begin
  1461. Message1(parser_e_proc_dir_not_allowed_in_implementation,name);
  1462. exit;
  1463. end;
  1464. if ((pdflags and pd_procvar)<>0) and
  1465. ((proc_direcdata[p].pd_flags and pd_procvar)=0) then
  1466. begin
  1467. Message1(parser_e_proc_dir_not_allowed_in_procvar,name);
  1468. exit;
  1469. end;
  1470. { Return the new pd_flags }
  1471. if (proc_direcdata[p].pd_flags and pd_body)=0 then
  1472. pdflags:=pdflags and (not pd_body);
  1473. if (proc_direcdata[p].pd_flags and pd_global)<>0 then
  1474. pdflags:=pdflags or pd_global;
  1475. { Add the correct flag }
  1476. aktprocdef.procoptions:=aktprocdef.procoptions+proc_direcdata[p].pooption;
  1477. { Call the handler }
  1478. if pointer({$ifndef FPCPROCVAR}@{$endif}proc_direcdata[p].handler)<>nil then
  1479. proc_direcdata[p].handler{$ifdef FPCPROCVAR}(){$endif};
  1480. end;
  1481. procedure handle_calling_convention(sym:tprocsym;def:tabstractprocdef);
  1482. begin
  1483. { set the default calling convention }
  1484. if def.proccalloption=pocall_none then
  1485. def.proccalloption:=aktdefproccall;
  1486. { handle proccall specific settings }
  1487. case def.proccalloption of
  1488. pocall_cdecl :
  1489. begin
  1490. { use popstack and save std registers }
  1491. include(def.procoptions,po_clearstack);
  1492. include(def.procoptions,po_savestdregs);
  1493. { set mangledname }
  1494. if (def.deftype=procdef) then
  1495. begin
  1496. if not tprocdef(def).has_mangledname then
  1497. begin
  1498. if assigned(tprocdef(def)._class) then
  1499. tprocdef(def).setmangledname(target_info.Cprefix+tprocdef(def)._class.objrealname^+'_'+sym.realname)
  1500. else
  1501. tprocdef(def).setmangledname(target_info.Cprefix+sym.realname);
  1502. end;
  1503. if not assigned(tprocdef(def).parast) then
  1504. internalerror(200110234);
  1505. { check C cdecl para types }
  1506. tprocdef(def).parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_c_para,nil);
  1507. { Adjust alignment to match cdecl or stdcall }
  1508. tprocdef(def).parast.dataalignment:=std_param_align;
  1509. end;
  1510. end;
  1511. pocall_cppdecl :
  1512. begin
  1513. if not assigned(sym) then
  1514. internalerror(200110231);
  1515. { use popstack and save std registers }
  1516. include(def.procoptions,po_clearstack);
  1517. include(def.procoptions,po_savestdregs);
  1518. { set mangledname }
  1519. if (def.deftype=procdef) then
  1520. begin
  1521. if not tprocdef(def).has_mangledname then
  1522. tprocdef(def).setmangledname(target_info.Cprefix+tprocdef(def).cplusplusmangledname);
  1523. if not assigned(tprocdef(def).parast) then
  1524. internalerror(200110235);
  1525. { check C cdecl para types }
  1526. tprocdef(def).parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}check_c_para,nil);
  1527. { Adjust alignment to match cdecl or stdcall }
  1528. tprocdef(def).parast.dataalignment:=std_param_align;
  1529. end;
  1530. end;
  1531. pocall_stdcall :
  1532. begin
  1533. include(def.procoptions,po_savestdregs);
  1534. if (def.deftype=procdef) then
  1535. begin
  1536. if not assigned(tprocdef(def).parast) then
  1537. internalerror(200110236);
  1538. { Adjust alignment to match cdecl or stdcall }
  1539. tprocdef(def).parast.dataalignment:=std_param_align;
  1540. end;
  1541. end;
  1542. pocall_safecall :
  1543. begin
  1544. include(def.procoptions,po_savestdregs);
  1545. end;
  1546. pocall_compilerproc :
  1547. begin
  1548. if (not assigned(sym)) or
  1549. (def.deftype<>procdef) then
  1550. internalerror(200110232);
  1551. tprocdef(def).setmangledname(lower(sym.name));
  1552. end;
  1553. pocall_pascal :
  1554. begin
  1555. include(def.procoptions,po_leftright);
  1556. end;
  1557. pocall_register :
  1558. begin
  1559. Message1(parser_w_proc_directive_ignored,'REGISTER');
  1560. end;
  1561. pocall_far16 :
  1562. begin
  1563. { Temporary stub, must be rewritten to support OS/2 far16 }
  1564. Message1(parser_w_proc_directive_ignored,'FAR16');
  1565. end;
  1566. pocall_system :
  1567. begin
  1568. include(def.procoptions,po_clearstack);
  1569. if (not assigned(sym)) or
  1570. (def.deftype<>procdef) then
  1571. internalerror(200110233);
  1572. if not tprocdef(def).has_mangledname then
  1573. tprocdef(def).setmangledname(sym.realname);
  1574. end;
  1575. pocall_palmossyscall :
  1576. begin
  1577. { use popstack and save std registers }
  1578. include(def.procoptions,po_clearstack);
  1579. include(def.procoptions,po_savestdregs);
  1580. if (def.deftype=procdef) then
  1581. begin
  1582. if not assigned(tprocdef(def).parast) then
  1583. internalerror(200110236);
  1584. { Adjust positions of args for cdecl or stdcall }
  1585. tprocdef(def).parast.dataalignment:=std_param_align;
  1586. end;
  1587. end;
  1588. pocall_inline :
  1589. begin
  1590. if not(cs_support_inline in aktmoduleswitches) then
  1591. begin
  1592. Message(parser_e_proc_inline_not_supported);
  1593. def.proccalloption:=pocall_fpccall;
  1594. end;
  1595. end;
  1596. end;
  1597. { insert hidden high parameters }
  1598. insert_hidden_para(def);
  1599. { insert local valXXX value parameters }
  1600. if (def.deftype=procdef) then
  1601. tprocdef(def).parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}checkvaluepara,nil);
  1602. { add mangledname to external list }
  1603. if (def.deftype=procdef) and
  1604. (po_external in def.procoptions) and
  1605. target_info.DllScanSupported then
  1606. current_module.externals.insert(tExternalsItem.create(tprocdef(def).mangledname));
  1607. end;
  1608. procedure calc_parasymtable_addresses(def:tprocdef);
  1609. var
  1610. lastps,
  1611. ps : tsym;
  1612. st : tsymtable;
  1613. begin
  1614. st:=def.parast;
  1615. if po_leftright in def.procoptions then
  1616. begin
  1617. { pushed in reversed order, left to right }
  1618. lastps:=nil;
  1619. while assigned(st.symindex.first) and (lastps<>tsym(st.symindex.first)) do
  1620. begin
  1621. ps:=tsym(st.symindex.first);
  1622. while assigned(ps.indexnext) and (tsym(ps.indexnext)<>lastps) do
  1623. ps:=tsym(ps.indexnext);
  1624. if (ps.typ=varsym) then
  1625. st.insertvardata(ps);
  1626. lastps:=ps;
  1627. end;
  1628. end
  1629. else
  1630. begin
  1631. { pushed in normal order, right to left }
  1632. ps:=tsym(st.symindex.first);
  1633. while assigned(ps) do
  1634. begin
  1635. if (ps.typ=varsym) and
  1636. not(vo_is_high_value in tvarsym(ps).varoptions) then
  1637. begin
  1638. st.insertvardata(ps);
  1639. if assigned(tvarsym(ps).highvarsym) then
  1640. st.insertvardata(tvarsym(ps).highvarsym);
  1641. end;
  1642. ps:=tsym(ps.indexnext);
  1643. end;
  1644. end;
  1645. end;
  1646. procedure parse_proc_directives(var pdflags:word);
  1647. {
  1648. Parse the procedure directives. It does not matter if procedure directives
  1649. are written using ;procdir; or ['procdir'] syntax.
  1650. }
  1651. var
  1652. res : boolean;
  1653. begin
  1654. while token in [_ID,_LECKKLAMMER] do
  1655. begin
  1656. if try_to_consume(_LECKKLAMMER) then
  1657. begin
  1658. repeat
  1659. parse_proc_direc(pdflags);
  1660. until not try_to_consume(_COMMA);
  1661. consume(_RECKKLAMMER);
  1662. { we always expect at least '[];' }
  1663. res:=true;
  1664. end
  1665. else
  1666. begin
  1667. res:=parse_proc_direc(pdflags);
  1668. end;
  1669. { A procedure directive normally followed by a semicolon, but in
  1670. a const section we should stop when _EQUAL is found }
  1671. if res then
  1672. begin
  1673. if (block_type=bt_const) and
  1674. (token=_EQUAL) then
  1675. break;
  1676. { support procedure proc;stdcall export; in Delphi mode only }
  1677. if not((m_delphi in aktmodeswitches) and
  1678. is_proc_directive(token)) then
  1679. consume(_SEMICOLON);
  1680. end
  1681. else
  1682. break;
  1683. end;
  1684. handle_calling_convention(aktprocsym,aktprocdef);
  1685. { calculate addresses in parasymtable }
  1686. if aktprocdef.deftype=procdef then
  1687. calc_parasymtable_addresses(aktprocdef);
  1688. end;
  1689. procedure parse_var_proc_directives(var sym : tsym);
  1690. var
  1691. pdflags : word;
  1692. oldsym : tprocsym;
  1693. olddef : tprocdef;
  1694. pd : tabstractprocdef;
  1695. begin
  1696. oldsym:=aktprocsym;
  1697. olddef:=aktprocdef;
  1698. pdflags:=pd_procvar;
  1699. { we create a temporary aktprocsym to read the directives }
  1700. aktprocsym:=tprocsym.create(sym.name);
  1701. case sym.typ of
  1702. varsym :
  1703. pd:=tabstractprocdef(tvarsym(sym).vartype.def);
  1704. typedconstsym :
  1705. pd:=tabstractprocdef(ttypedconstsym(sym).typedconsttype.def);
  1706. typesym :
  1707. pd:=tabstractprocdef(ttypesym(sym).restype.def);
  1708. else
  1709. internalerror(994932432);
  1710. end;
  1711. if pd.deftype<>procvardef then
  1712. internalerror(994932433);
  1713. tabstractprocdef(aktprocdef):=pd;
  1714. { names should never be used anyway }
  1715. inc(lexlevel);
  1716. parse_proc_directives(pdflags);
  1717. dec(lexlevel);
  1718. aktprocsym.free;
  1719. aktprocsym:=oldsym;
  1720. aktprocdef:=olddef;
  1721. end;
  1722. procedure parse_object_proc_directives(var sym : tprocsym);
  1723. var
  1724. pdflags : word;
  1725. begin
  1726. pdflags:=pd_object;
  1727. inc(lexlevel);
  1728. parse_proc_directives(pdflags);
  1729. dec(lexlevel);
  1730. if (po_containsself in aktprocdef.procoptions) and
  1731. (([po_msgstr,po_msgint]*aktprocdef.procoptions)=[]) then
  1732. Message(parser_e_self_in_non_message_handler);
  1733. end;
  1734. function proc_add_definition(aprocsym:tprocsym;var aprocdef : tprocdef) : boolean;
  1735. {
  1736. Add definition aprocdef to the overloaded definitions of aprocsym. If a
  1737. forwarddef is found and reused it returns true
  1738. }
  1739. var
  1740. hd : tprocdef;
  1741. ad,fd : tsym;
  1742. i : cardinal;
  1743. forwardfound : boolean;
  1744. po_comp : tprocoptions;
  1745. begin
  1746. forwardfound:=false;
  1747. { check overloaded functions if the same function already exists }
  1748. for i:=1 to aprocsym.procdef_count do
  1749. begin
  1750. hd:=aprocsym.procdef[i];
  1751. { Skip overloaded definitions that are declared in other
  1752. units }
  1753. if hd.procsym<>aprocsym then
  1754. continue;
  1755. { check the parameters, for delphi/tp it is possible to
  1756. leave the parameters away in the implementation (forwarddef=false).
  1757. But for an overload declared function this is not allowed }
  1758. if { check if empty implementation arguments match is allowed }
  1759. (
  1760. not(m_repeat_forward in aktmodeswitches) and
  1761. not(aprocdef.forwarddef) and
  1762. (aprocdef.maxparacount=0) and
  1763. not(po_overload in hd.procoptions)
  1764. ) or
  1765. { check arguments }
  1766. (
  1767. (compare_paras(aprocdef.para,hd.para,cp_none,false)>=te_equal) and
  1768. { for operators equal_paras is not enough !! }
  1769. ((aprocdef.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
  1770. equal_defs(hd.rettype.def,aprocdef.rettype.def))
  1771. ) then
  1772. begin
  1773. { Check if we've found the forwarddef, if found then
  1774. we need to update the forward def with the current
  1775. implementation settings }
  1776. if hd.forwarddef then
  1777. begin
  1778. forwardfound:=true;
  1779. { Check if the procedure type and return type are correct,
  1780. also the parameters must match also with the type }
  1781. if (hd.proctypeoption<>aprocdef.proctypeoption) or
  1782. (
  1783. (m_repeat_forward in aktmodeswitches) and
  1784. (not((aprocdef.maxparacount=0) or
  1785. (compare_paras(aprocdef.para,hd.para,cp_all,false)>=te_equal)))
  1786. ) or
  1787. (
  1788. ((m_repeat_forward in aktmodeswitches) or
  1789. not(is_void(aprocdef.rettype.def))) and
  1790. (not equal_defs(hd.rettype.def,aprocdef.rettype.def))) then
  1791. begin
  1792. MessagePos1(aprocdef.fileinfo,parser_e_header_dont_match_forward,
  1793. aprocdef.fullprocname);
  1794. aprocsym.write_parameter_lists(aprocdef);
  1795. break;
  1796. end;
  1797. { Check if both are declared forward }
  1798. if hd.forwarddef and aprocdef.forwarddef then
  1799. begin
  1800. MessagePos1(aprocdef.fileinfo,parser_e_function_already_declared_public_forward,
  1801. aprocdef.fullprocname);
  1802. end;
  1803. { internconst or internproc only need to be defined once }
  1804. if (hd.proccalloption=pocall_internproc) then
  1805. aprocdef.proccalloption:=hd.proccalloption
  1806. else
  1807. if (aprocdef.proccalloption=pocall_internproc) then
  1808. hd.proccalloption:=aprocdef.proccalloption;
  1809. if (po_internconst in hd.procoptions) then
  1810. include(aprocdef.procoptions,po_internconst)
  1811. else if (po_internconst in aprocdef.procoptions) then
  1812. include(hd.procoptions,po_internconst);
  1813. { Check calling convention }
  1814. if (hd.proccalloption<>aprocdef.proccalloption) then
  1815. begin
  1816. { In delphi it is possible to specify the calling
  1817. convention in the interface or implementation if
  1818. there was no convention specified in the other
  1819. part }
  1820. if (m_delphi in aktmodeswitches) then
  1821. begin
  1822. if (aprocdef.proccalloption=pocall_none) then
  1823. aprocdef.proccalloption:=hd.proccalloption
  1824. else
  1825. if (hd.proccalloption=pocall_none) then
  1826. hd.proccalloption:=aprocdef.proccalloption
  1827. else
  1828. begin
  1829. MessagePos(aprocdef.fileinfo,parser_e_call_convention_dont_match_forward);
  1830. aprocsym.write_parameter_lists(aprocdef);
  1831. { restore interface settings }
  1832. aprocdef.proccalloption:=hd.proccalloption;
  1833. end;
  1834. end
  1835. else
  1836. begin
  1837. MessagePos(aprocdef.fileinfo,parser_e_call_convention_dont_match_forward);
  1838. aprocsym.write_parameter_lists(aprocdef);
  1839. { restore interface settings }
  1840. aprocdef.proccalloption:=hd.proccalloption;
  1841. end;
  1842. end;
  1843. { Check procedure options, Delphi requires that class is
  1844. repeated in the implementation for class methods }
  1845. po_comp:=po_compatibility_options-[po_iocheck,po_staticmethod,po_exports];
  1846. if (m_delphi in aktmodeswitches) then
  1847. include(po_comp,po_classmethod);
  1848. if ((po_comp * hd.procoptions)<>(po_comp * aprocdef.procoptions)) then
  1849. begin
  1850. MessagePos1(aprocdef.fileinfo,parser_e_header_dont_match_forward,
  1851. aprocdef.fullprocname);
  1852. aprocsym.write_parameter_lists(aprocdef);
  1853. { This error is non-fatal, we can recover }
  1854. end;
  1855. { Check manglednames }
  1856. if (m_repeat_forward in aktmodeswitches) or
  1857. aprocdef.haspara then
  1858. begin
  1859. { If mangled names are equal then they have the same amount of arguments }
  1860. { We can check the names of the arguments }
  1861. { both symtables are in the same order from left to right }
  1862. ad:=tsym(hd.parast.symindex.first);
  1863. fd:=tsym(aprocdef.parast.symindex.first);
  1864. repeat
  1865. { skip default parameter constsyms }
  1866. while assigned(ad) and (ad.typ<>varsym) do
  1867. ad:=tsym(ad.indexnext);
  1868. while assigned(fd) and (fd.typ<>varsym) do
  1869. fd:=tsym(fd.indexnext);
  1870. { stop when one of the two lists is at the end }
  1871. if not assigned(ad) or not assigned(fd) then
  1872. break;
  1873. if (ad.name<>fd.name) then
  1874. begin
  1875. MessagePos3(aprocdef.fileinfo,parser_e_header_different_var_names,
  1876. aprocsym.name,ad.name,fd.name);
  1877. break;
  1878. end;
  1879. ad:=tsym(ad.indexnext);
  1880. fd:=tsym(fd.indexnext);
  1881. until false;
  1882. if assigned(ad) xor assigned(fd) then
  1883. internalerror(200204178);
  1884. end;
  1885. { Everything is checked, now we can update the forward declaration
  1886. with the new data from the implementation }
  1887. hd.forwarddef:=aprocdef.forwarddef;
  1888. hd.hasforward:=true;
  1889. hd.parast.address_fixup:=aprocdef.parast.address_fixup;
  1890. hd.procoptions:=hd.procoptions+aprocdef.procoptions;
  1891. if hd.extnumber=65535 then
  1892. hd.extnumber:=aprocdef.extnumber;
  1893. while not aprocdef.aliasnames.empty do
  1894. hd.aliasnames.insert(aprocdef.aliasnames.getfirst);
  1895. { update mangledname if the implementation has a fixed mangledname set }
  1896. if aprocdef.has_mangledname then
  1897. begin
  1898. { rename also asmsymbol first, because the name can already be used }
  1899. objectlibrary.renameasmsymbol(hd.mangledname,aprocdef.mangledname);
  1900. hd.setmangledname(aprocdef.mangledname);
  1901. end;
  1902. { for compilerproc defines we need to rename and update the
  1903. symbolname to lowercase }
  1904. if (aprocdef.proccalloption=pocall_compilerproc) then
  1905. begin
  1906. { rename to lowercase so users can't access it }
  1907. aprocsym.owner.rename(aprocsym.name,lower(aprocsym.name));
  1908. { also update the realname that is stored in the ppu }
  1909. stringdispose(aprocsym._realname);
  1910. aprocsym._realname:=stringdup('$'+aprocsym.name);
  1911. { the mangeled name is already changed by the pd_compilerproc }
  1912. { handler. It must be done immediately because if we have a }
  1913. { call to a compilerproc before it's implementation is }
  1914. { encountered, it must already use the new mangled name (JM) }
  1915. end;
  1916. { return the forwarddef }
  1917. aprocdef:=hd;
  1918. end
  1919. else
  1920. begin
  1921. { abstract methods aren't forward defined, but this }
  1922. { needs another error message }
  1923. if (po_abstractmethod in hd.procoptions) then
  1924. MessagePos(aprocdef.fileinfo,parser_e_abstract_no_definition)
  1925. else
  1926. MessagePos(aprocdef.fileinfo,parser_e_overloaded_have_same_parameters);
  1927. end;
  1928. { we found one proc with the same arguments, there are no others
  1929. so we can stop }
  1930. break;
  1931. end;
  1932. { check for allowing overload directive }
  1933. if not(m_fpc in aktmodeswitches) then
  1934. begin
  1935. { overload directive turns on overloading }
  1936. if ((po_overload in aprocdef.procoptions) or
  1937. (po_overload in hd.procoptions)) then
  1938. begin
  1939. { check if all procs have overloading, but not if the proc was
  1940. already declared forward, then the check is already done }
  1941. if not(hd.hasforward or
  1942. (aprocdef.forwarddef<>hd.forwarddef) or
  1943. ((po_overload in aprocdef.procoptions) and
  1944. (po_overload in hd.procoptions))) then
  1945. begin
  1946. MessagePos1(aprocdef.fileinfo,parser_e_no_overload_for_all_procs,aprocsym.realname);
  1947. break;
  1948. end;
  1949. end
  1950. else
  1951. begin
  1952. if not(hd.forwarddef) then
  1953. begin
  1954. MessagePos(aprocdef.fileinfo,parser_e_procedure_overloading_is_off);
  1955. break;
  1956. end;
  1957. end;
  1958. end; { equal arguments }
  1959. end;
  1960. { if we didn't reuse a forwarddef then we add the procdef to the overloaded
  1961. list }
  1962. if not forwardfound then
  1963. begin
  1964. aprocsym.addprocdef(aprocdef);
  1965. { add overloadnumber for unique naming, the overloadcount is
  1966. counted per module and 0 for the first procedure }
  1967. aprocdef.overloadnumber:=aprocsym.overloadcount;
  1968. inc(aprocsym.overloadcount);
  1969. end;
  1970. { insert otsym only in the right symtable }
  1971. if ((procinfo.flags and pi_operator)<>0) and
  1972. assigned(otsym) then
  1973. begin
  1974. if not parse_only then
  1975. begin
  1976. if paramanager.ret_in_param(aprocdef.rettype.def,aprocdef.proccalloption) then
  1977. begin
  1978. aprocdef.parast.insert(otsym);
  1979. { this allows to read the funcretoffset }
  1980. otsym.address:=-4;
  1981. otsym.varspez:=vs_var;
  1982. end
  1983. else
  1984. begin
  1985. if not assigned(aprocdef.localst) then
  1986. aprocdef.insert_localst;
  1987. aprocdef.localst.insert(otsym);
  1988. aprocdef.localst.insertvardata(otsym);
  1989. end;
  1990. end
  1991. else
  1992. begin
  1993. { this is not required anymore }
  1994. otsym.free;
  1995. otsym:=nil;
  1996. end;
  1997. end;
  1998. paramanager.create_param_loc_info(aprocdef);
  1999. proc_add_definition:=forwardfound;
  2000. end;
  2001. end.
  2002. {
  2003. $Log$
  2004. Revision 1.111 2003-04-10 17:57:53 peter
  2005. * vs_hidden released
  2006. Revision 1.110 2003/03/28 19:16:56 peter
  2007. * generic constructor working for i386
  2008. * remove fixed self register
  2009. * esi added as address register for i386
  2010. Revision 1.109 2003/03/23 23:21:42 hajny
  2011. + emx target added
  2012. Revision 1.108 2003/03/19 17:34:04 peter
  2013. * only allow class [procedure|function]
  2014. Revision 1.107 2003/03/17 18:56:02 peter
  2015. * fix crash with duplicate id
  2016. Revision 1.106 2003/03/17 15:54:22 peter
  2017. * store symoptions also for procdef
  2018. * check symoptions (private,public) when calculating possible
  2019. overload candidates
  2020. Revision 1.105 2003/01/15 20:02:28 carl
  2021. * fix highname problem
  2022. Revision 1.104 2003/01/12 15:42:23 peter
  2023. * m68k pathexist update from 1.0.x
  2024. * palmos res update from 1.0.x
  2025. Revision 1.103 2003/01/07 19:16:38 peter
  2026. * removed some duplicate code when creating aktprocsym
  2027. Revision 1.102 2003/01/05 18:17:45 peter
  2028. * more conflicts for constructor/destructor types
  2029. Revision 1.100 2003/01/02 19:49:00 peter
  2030. * update self parameter only for methodpointer and methods
  2031. Revision 1.99 2003/01/01 22:51:03 peter
  2032. * high value insertion changed so it works also when 2 parameters
  2033. are passed
  2034. Revision 1.98 2003/01/01 14:35:33 peter
  2035. * don't check for export directive repeat
  2036. Revision 1.97 2002/12/29 18:16:06 peter
  2037. * delphi allows setting calling convention in interface or
  2038. implementation
  2039. Revision 1.96 2002/12/29 14:55:44 peter
  2040. * fix static method check
  2041. * don't require class for class methods in the implementation for
  2042. non delphi modes
  2043. Revision 1.95 2002/12/27 15:25:14 peter
  2044. * check procoptions when a forward is found
  2045. * exclude some call directives for constructor/destructor
  2046. Revision 1.94 2002/12/25 01:26:56 peter
  2047. * duplicate procsym-unitsym fix
  2048. Revision 1.93 2002/12/24 21:21:06 peter
  2049. * remove code that skipped the _ prefix for win32 imports
  2050. Revision 1.92 2002/12/23 21:24:22 peter
  2051. * fix wrong internalerror when var names were different
  2052. Revision 1.91 2002/12/23 20:58:52 peter
  2053. * cdecl array fix, hack to change it to vs_var is not needed
  2054. Revision 1.90 2002/12/17 22:19:33 peter
  2055. * fixed pushing of records>8 bytes with stdcall
  2056. * simplified hightree loading
  2057. Revision 1.89 2002/12/15 21:07:30 peter
  2058. * don't allow external in object declarations
  2059. Revision 1.88 2002/12/15 19:34:31 florian
  2060. + some front end stuff for vs_hidden added
  2061. Revision 1.87 2002/12/07 14:27:07 carl
  2062. * 3% memory optimization
  2063. * changed some types
  2064. + added type checking with different size for call node and for
  2065. parameters
  2066. Revision 1.86 2002/12/06 17:51:10 peter
  2067. * merged cdecl and array fixes
  2068. Revision 1.85 2002/12/01 22:06:14 carl
  2069. * cleanup of error messages
  2070. Revision 1.84 2002/11/29 22:31:19 carl
  2071. + unimplemented hint directive added
  2072. * hint directive parsing implemented
  2073. * warning on these directives
  2074. Revision 1.83 2002/11/27 02:35:28 peter
  2075. * fixed typo in method comparing
  2076. Revision 1.82 2002/11/25 17:43:21 peter
  2077. * splitted defbase in defutil,symutil,defcmp
  2078. * merged isconvertable and is_equal into compare_defs(_ext)
  2079. * made operator search faster by walking the list only once
  2080. Revision 1.81 2002/11/18 17:31:58 peter
  2081. * pass proccalloption to ret_in_xxx and push_xxx functions
  2082. Revision 1.80 2002/11/17 16:31:56 carl
  2083. * memory optimization (3-4%) : cleanup of tai fields,
  2084. cleanup of tdef and tsym fields.
  2085. * make it work for m68k
  2086. Revision 1.79 2002/11/16 14:20:50 peter
  2087. * fix infinite loop in pd_inline
  2088. Revision 1.78 2002/11/15 01:58:53 peter
  2089. * merged changes from 1.0.7 up to 04-11
  2090. - -V option for generating bug report tracing
  2091. - more tracing for option parsing
  2092. - errors for cdecl and high()
  2093. - win32 import stabs
  2094. - win32 records<=8 are returned in eax:edx (turned off by default)
  2095. - heaptrc update
  2096. - more info for temp management in .s file with EXTDEBUG
  2097. Revision 1.77 2002/10/06 15:09:12 peter
  2098. * variant:=nil supported
  2099. Revision 1.76 2002/09/27 21:13:29 carl
  2100. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  2101. Revision 1.75 2002/09/16 14:11:13 peter
  2102. * add argument to equal_paras() to support default values or not
  2103. Revision 1.74 2002/09/10 16:27:28 peter
  2104. * don't insert parast in symtablestack, because typesyms should not be
  2105. searched in the the parast
  2106. Revision 1.73 2002/09/09 19:39:07 peter
  2107. * check return type for forwarddefs also not delphi mode when
  2108. the type is not void
  2109. Revision 1.72 2002/09/09 17:34:15 peter
  2110. * tdicationary.replace added to replace and item in a dictionary. This
  2111. is only allowed for the same name
  2112. * varsyms are inserted in symtable before the types are parsed. This
  2113. fixes the long standing "var longint : longint" bug
  2114. - consume_idlist and idstringlist removed. The loops are inserted
  2115. at the callers place and uses the symtable for duplicate id checking
  2116. Revision 1.71 2002/09/07 15:25:06 peter
  2117. * old logs removed and tabs fixed
  2118. Revision 1.70 2002/09/03 16:26:27 daniel
  2119. * Make Tprocdef.defs protected
  2120. Revision 1.69 2002/09/01 12:11:33 peter
  2121. * calc param_offset after parameters are read, because the calculation
  2122. depends on po_containself
  2123. Revision 1.68 2002/08/25 19:25:20 peter
  2124. * sym.insert_in_data removed
  2125. * symtable.insertvardata/insertconstdata added
  2126. * removed insert_in_data call from symtable.insert, it needs to be
  2127. called separatly. This allows to deref the address calculation
  2128. * procedures now calculate the parast addresses after the procedure
  2129. directives are parsed. This fixes the cdecl parast problem
  2130. * push_addr_param has an extra argument that specifies if cdecl is used
  2131. or not
  2132. Revision 1.67 2002/08/25 11:33:06 peter
  2133. * also check the paratypes when a forward was found
  2134. Revision 1.66 2002/08/19 19:36:44 peter
  2135. * More fixes for cross unit inlining, all tnodes are now implemented
  2136. * Moved pocall_internconst to po_internconst because it is not a
  2137. calling type at all and it conflicted when inlining of these small
  2138. functions was requested
  2139. Revision 1.65 2002/08/18 20:06:24 peter
  2140. * inlining is now also allowed in interface
  2141. * renamed write/load to ppuwrite/ppuload
  2142. * tnode storing in ppu
  2143. * nld,ncon,nbas are already updated for storing in ppu
  2144. Revision 1.64 2002/08/17 09:23:39 florian
  2145. * first part of procinfo rewrite
  2146. Revision 1.63 2002/08/11 14:32:27 peter
  2147. * renamed current_library to objectlibrary
  2148. Revision 1.62 2002/08/11 13:24:12 peter
  2149. * saving of asmsymbols in ppu supported
  2150. * asmsymbollist global is removed and moved into a new class
  2151. tasmlibrarydata that will hold the info of a .a file which
  2152. corresponds with a single module. Added librarydata to tmodule
  2153. to keep the library info stored for the module. In the future the
  2154. objectfiles will also be stored to the tasmlibrarydata class
  2155. * all getlabel/newasmsymbol and friends are moved to the new class
  2156. Revision 1.61 2002/07/26 21:15:40 florian
  2157. * rewrote the system handling
  2158. Revision 1.60 2002/07/20 11:57:55 florian
  2159. * types.pas renamed to defbase.pas because D6 contains a types
  2160. unit so this would conflicts if D6 programms are compiled
  2161. + Willamette/SSE2 instructions to assembler added
  2162. Revision 1.59 2002/07/11 14:41:28 florian
  2163. * start of the new generic parameter handling
  2164. Revision 1.58 2002/07/01 18:46:25 peter
  2165. * internal linker
  2166. * reorganized aasm layer
  2167. Revision 1.57 2002/05/18 13:34:12 peter
  2168. * readded missing revisions
  2169. Revision 1.56 2002/05/16 19:46:42 carl
  2170. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2171. + try to fix temp allocation (still in ifdef)
  2172. + generic constructor calls
  2173. + start of tassembler / tmodulebase class cleanup
  2174. Revision 1.54 2002/05/12 16:53:08 peter
  2175. * moved entry and exitcode to ncgutil and cgobj
  2176. * foreach gets extra argument for passing local data to the
  2177. iterator function
  2178. * -CR checks also class typecasts at runtime by changing them
  2179. into as
  2180. * fixed compiler to cycle with the -CR option
  2181. * fixed stabs with elf writer, finally the global variables can
  2182. be watched
  2183. * removed a lot of routines from cga unit and replaced them by
  2184. calls to cgobj
  2185. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2186. u32bit then the other is typecasted also to u32bit without giving
  2187. a rangecheck warning/error.
  2188. * fixed pascal calling method with reversing also the high tree in
  2189. the parast, detected by tcalcst3 test
  2190. Revision 1.53 2002/04/21 19:02:04 peter
  2191. * removed newn and disposen nodes, the code is now directly
  2192. inlined from pexpr
  2193. * -an option that will write the secondpass nodes to the .s file, this
  2194. requires EXTDEBUG define to actually write the info
  2195. * fixed various internal errors and crashes due recent code changes
  2196. Revision 1.52 2002/04/20 21:32:24 carl
  2197. + generic FPC_CHECKPOINTER
  2198. + first parameter offset in stack now portable
  2199. * rename some constants
  2200. + move some cpu stuff to other units
  2201. - remove unused constents
  2202. * fix stacksize for some targets
  2203. * fix generic size problems which depend now on EXTEND_SIZE constant
  2204. Revision 1.51 2002/04/20 15:27:05 carl
  2205. - remove ifdef i386 define
  2206. Revision 1.50 2002/04/19 15:46:02 peter
  2207. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  2208. in most cases and not written to the ppu
  2209. * add mangeledname_prefix() routine to generate the prefix of
  2210. manglednames depending on the current procedure, object and module
  2211. * removed static procprefix since the mangledname is now build only
  2212. on demand from tprocdef.mangledname
  2213. }