pdecsub.pas 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403
  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(pd: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(pd:tprocdef);
  1609. var
  1610. currpara : tparaitem;
  1611. st : tsymtable;
  1612. begin
  1613. st:=pd.parast;
  1614. if po_leftright in pd.procoptions then
  1615. begin
  1616. { pushed from left to right, so the in reverse order
  1617. on the stack }
  1618. currpara:=tparaitem(pd.para.last);
  1619. while assigned(currpara) do
  1620. begin
  1621. if not(assigned(currpara.parasym) and (currpara.parasym.typ=varsym)) then
  1622. internalerror(200304231);
  1623. st.insertvardata(currpara.parasym);
  1624. currpara:=tparaitem(currpara.previous);
  1625. end;
  1626. end
  1627. else
  1628. begin
  1629. { pushed from right to left }
  1630. currpara:=tparaitem(pd.para.first);
  1631. while assigned(currpara) do
  1632. begin
  1633. if not(assigned(currpara.parasym) and (currpara.parasym.typ=varsym)) then
  1634. internalerror(200304232);
  1635. st.insertvardata(currpara.parasym);
  1636. currpara:=tparaitem(currpara.next);
  1637. end;
  1638. end;
  1639. end;
  1640. procedure parse_proc_directives(var pdflags:word);
  1641. {
  1642. Parse the procedure directives. It does not matter if procedure directives
  1643. are written using ;procdir; or ['procdir'] syntax.
  1644. }
  1645. var
  1646. res : boolean;
  1647. begin
  1648. while token in [_ID,_LECKKLAMMER] do
  1649. begin
  1650. if try_to_consume(_LECKKLAMMER) then
  1651. begin
  1652. repeat
  1653. parse_proc_direc(pdflags);
  1654. until not try_to_consume(_COMMA);
  1655. consume(_RECKKLAMMER);
  1656. { we always expect at least '[];' }
  1657. res:=true;
  1658. end
  1659. else
  1660. begin
  1661. res:=parse_proc_direc(pdflags);
  1662. end;
  1663. { A procedure directive normally followed by a semicolon, but in
  1664. a const section we should stop when _EQUAL is found }
  1665. if res then
  1666. begin
  1667. if (block_type=bt_const) and
  1668. (token=_EQUAL) then
  1669. break;
  1670. { support procedure proc;stdcall export; in Delphi mode only }
  1671. if not((m_delphi in aktmodeswitches) and
  1672. is_proc_directive(token)) then
  1673. consume(_SEMICOLON);
  1674. end
  1675. else
  1676. break;
  1677. end;
  1678. handle_calling_convention(aktprocsym,aktprocdef);
  1679. { calculate addresses in parasymtable }
  1680. if aktprocdef.deftype=procdef then
  1681. calc_parasymtable_addresses(aktprocdef);
  1682. end;
  1683. procedure parse_var_proc_directives(var sym : tsym);
  1684. var
  1685. pdflags : word;
  1686. oldsym : tprocsym;
  1687. olddef : tprocdef;
  1688. pd : tabstractprocdef;
  1689. begin
  1690. oldsym:=aktprocsym;
  1691. olddef:=aktprocdef;
  1692. pdflags:=pd_procvar;
  1693. { we create a temporary aktprocsym to read the directives }
  1694. aktprocsym:=tprocsym.create(sym.name);
  1695. case sym.typ of
  1696. varsym :
  1697. pd:=tabstractprocdef(tvarsym(sym).vartype.def);
  1698. typedconstsym :
  1699. pd:=tabstractprocdef(ttypedconstsym(sym).typedconsttype.def);
  1700. typesym :
  1701. pd:=tabstractprocdef(ttypesym(sym).restype.def);
  1702. else
  1703. internalerror(994932432);
  1704. end;
  1705. if pd.deftype<>procvardef then
  1706. internalerror(994932433);
  1707. tabstractprocdef(aktprocdef):=pd;
  1708. { names should never be used anyway }
  1709. inc(lexlevel);
  1710. parse_proc_directives(pdflags);
  1711. dec(lexlevel);
  1712. aktprocsym.free;
  1713. aktprocsym:=oldsym;
  1714. aktprocdef:=olddef;
  1715. end;
  1716. procedure parse_object_proc_directives(var sym : tprocsym);
  1717. var
  1718. pdflags : word;
  1719. begin
  1720. pdflags:=pd_object;
  1721. inc(lexlevel);
  1722. parse_proc_directives(pdflags);
  1723. dec(lexlevel);
  1724. if (po_containsself in aktprocdef.procoptions) and
  1725. (([po_msgstr,po_msgint]*aktprocdef.procoptions)=[]) then
  1726. Message(parser_e_self_in_non_message_handler);
  1727. end;
  1728. function proc_add_definition(aprocsym:tprocsym;var aprocdef : tprocdef) : boolean;
  1729. {
  1730. Add definition aprocdef to the overloaded definitions of aprocsym. If a
  1731. forwarddef is found and reused it returns true
  1732. }
  1733. var
  1734. hd : tprocdef;
  1735. ad,fd : tsym;
  1736. i : cardinal;
  1737. forwardfound : boolean;
  1738. po_comp : tprocoptions;
  1739. begin
  1740. forwardfound:=false;
  1741. { check overloaded functions if the same function already exists }
  1742. for i:=1 to aprocsym.procdef_count do
  1743. begin
  1744. hd:=aprocsym.procdef[i];
  1745. { Skip overloaded definitions that are declared in other
  1746. units }
  1747. if hd.procsym<>aprocsym then
  1748. continue;
  1749. { check the parameters, for delphi/tp it is possible to
  1750. leave the parameters away in the implementation (forwarddef=false).
  1751. But for an overload declared function this is not allowed }
  1752. if { check if empty implementation arguments match is allowed }
  1753. (
  1754. not(m_repeat_forward in aktmodeswitches) and
  1755. not(aprocdef.forwarddef) and
  1756. (aprocdef.maxparacount=0) and
  1757. not(po_overload in hd.procoptions)
  1758. ) or
  1759. { check arguments }
  1760. (
  1761. (compare_paras(aprocdef.para,hd.para,cp_none,false)>=te_equal) and
  1762. { for operators equal_paras is not enough !! }
  1763. ((aprocdef.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
  1764. equal_defs(hd.rettype.def,aprocdef.rettype.def))
  1765. ) then
  1766. begin
  1767. { Check if we've found the forwarddef, if found then
  1768. we need to update the forward def with the current
  1769. implementation settings }
  1770. if hd.forwarddef then
  1771. begin
  1772. forwardfound:=true;
  1773. { Check if the procedure type and return type are correct,
  1774. also the parameters must match also with the type }
  1775. if (hd.proctypeoption<>aprocdef.proctypeoption) or
  1776. (
  1777. (m_repeat_forward in aktmodeswitches) and
  1778. (not((aprocdef.maxparacount=0) or
  1779. (compare_paras(aprocdef.para,hd.para,cp_all,false)>=te_equal)))
  1780. ) or
  1781. (
  1782. ((m_repeat_forward in aktmodeswitches) or
  1783. not(is_void(aprocdef.rettype.def))) and
  1784. (not equal_defs(hd.rettype.def,aprocdef.rettype.def))) then
  1785. begin
  1786. MessagePos1(aprocdef.fileinfo,parser_e_header_dont_match_forward,
  1787. aprocdef.fullprocname);
  1788. aprocsym.write_parameter_lists(aprocdef);
  1789. break;
  1790. end;
  1791. { Check if both are declared forward }
  1792. if hd.forwarddef and aprocdef.forwarddef then
  1793. begin
  1794. MessagePos1(aprocdef.fileinfo,parser_e_function_already_declared_public_forward,
  1795. aprocdef.fullprocname);
  1796. end;
  1797. { internconst or internproc only need to be defined once }
  1798. if (hd.proccalloption=pocall_internproc) then
  1799. aprocdef.proccalloption:=hd.proccalloption
  1800. else
  1801. if (aprocdef.proccalloption=pocall_internproc) then
  1802. hd.proccalloption:=aprocdef.proccalloption;
  1803. if (po_internconst in hd.procoptions) then
  1804. include(aprocdef.procoptions,po_internconst)
  1805. else if (po_internconst in aprocdef.procoptions) then
  1806. include(hd.procoptions,po_internconst);
  1807. { Check calling convention }
  1808. if (hd.proccalloption<>aprocdef.proccalloption) then
  1809. begin
  1810. { In delphi it is possible to specify the calling
  1811. convention in the interface or implementation if
  1812. there was no convention specified in the other
  1813. part }
  1814. if (m_delphi in aktmodeswitches) then
  1815. begin
  1816. if (aprocdef.proccalloption=pocall_none) then
  1817. aprocdef.proccalloption:=hd.proccalloption
  1818. else
  1819. if (hd.proccalloption=pocall_none) then
  1820. hd.proccalloption:=aprocdef.proccalloption
  1821. else
  1822. begin
  1823. MessagePos(aprocdef.fileinfo,parser_e_call_convention_dont_match_forward);
  1824. aprocsym.write_parameter_lists(aprocdef);
  1825. { restore interface settings }
  1826. aprocdef.proccalloption:=hd.proccalloption;
  1827. end;
  1828. end
  1829. else
  1830. begin
  1831. MessagePos(aprocdef.fileinfo,parser_e_call_convention_dont_match_forward);
  1832. aprocsym.write_parameter_lists(aprocdef);
  1833. { restore interface settings }
  1834. aprocdef.proccalloption:=hd.proccalloption;
  1835. end;
  1836. end;
  1837. { Check procedure options, Delphi requires that class is
  1838. repeated in the implementation for class methods }
  1839. po_comp:=po_compatibility_options-[po_iocheck,po_staticmethod,po_exports];
  1840. if (m_delphi in aktmodeswitches) then
  1841. include(po_comp,po_classmethod);
  1842. if ((po_comp * hd.procoptions)<>(po_comp * aprocdef.procoptions)) then
  1843. begin
  1844. MessagePos1(aprocdef.fileinfo,parser_e_header_dont_match_forward,
  1845. aprocdef.fullprocname);
  1846. aprocsym.write_parameter_lists(aprocdef);
  1847. { This error is non-fatal, we can recover }
  1848. end;
  1849. { Check manglednames }
  1850. if (m_repeat_forward in aktmodeswitches) or
  1851. aprocdef.haspara then
  1852. begin
  1853. { If mangled names are equal then they have the same amount of arguments }
  1854. { We can check the names of the arguments }
  1855. { both symtables are in the same order from left to right }
  1856. ad:=tsym(hd.parast.symindex.first);
  1857. fd:=tsym(aprocdef.parast.symindex.first);
  1858. repeat
  1859. { skip default parameter constsyms }
  1860. while assigned(ad) and (ad.typ<>varsym) do
  1861. ad:=tsym(ad.indexnext);
  1862. while assigned(fd) and (fd.typ<>varsym) do
  1863. fd:=tsym(fd.indexnext);
  1864. { stop when one of the two lists is at the end }
  1865. if not assigned(ad) or not assigned(fd) then
  1866. break;
  1867. if (ad.name<>fd.name) then
  1868. begin
  1869. MessagePos3(aprocdef.fileinfo,parser_e_header_different_var_names,
  1870. aprocsym.name,ad.name,fd.name);
  1871. break;
  1872. end;
  1873. ad:=tsym(ad.indexnext);
  1874. fd:=tsym(fd.indexnext);
  1875. until false;
  1876. if assigned(ad) xor assigned(fd) then
  1877. internalerror(200204178);
  1878. end;
  1879. { Everything is checked, now we can update the forward declaration
  1880. with the new data from the implementation }
  1881. hd.forwarddef:=aprocdef.forwarddef;
  1882. hd.hasforward:=true;
  1883. hd.parast.address_fixup:=aprocdef.parast.address_fixup;
  1884. hd.procoptions:=hd.procoptions+aprocdef.procoptions;
  1885. if hd.extnumber=65535 then
  1886. hd.extnumber:=aprocdef.extnumber;
  1887. while not aprocdef.aliasnames.empty do
  1888. hd.aliasnames.insert(aprocdef.aliasnames.getfirst);
  1889. { update mangledname if the implementation has a fixed mangledname set }
  1890. if aprocdef.has_mangledname then
  1891. begin
  1892. { rename also asmsymbol first, because the name can already be used }
  1893. objectlibrary.renameasmsymbol(hd.mangledname,aprocdef.mangledname);
  1894. hd.setmangledname(aprocdef.mangledname);
  1895. end;
  1896. { for compilerproc defines we need to rename and update the
  1897. symbolname to lowercase }
  1898. if (aprocdef.proccalloption=pocall_compilerproc) then
  1899. begin
  1900. { rename to lowercase so users can't access it }
  1901. aprocsym.owner.rename(aprocsym.name,lower(aprocsym.name));
  1902. { also update the realname that is stored in the ppu }
  1903. stringdispose(aprocsym._realname);
  1904. aprocsym._realname:=stringdup('$'+aprocsym.name);
  1905. { the mangeled name is already changed by the pd_compilerproc }
  1906. { handler. It must be done immediately because if we have a }
  1907. { call to a compilerproc before it's implementation is }
  1908. { encountered, it must already use the new mangled name (JM) }
  1909. end;
  1910. { return the forwarddef }
  1911. aprocdef:=hd;
  1912. end
  1913. else
  1914. begin
  1915. { abstract methods aren't forward defined, but this }
  1916. { needs another error message }
  1917. if (po_abstractmethod in hd.procoptions) then
  1918. MessagePos(aprocdef.fileinfo,parser_e_abstract_no_definition)
  1919. else
  1920. MessagePos(aprocdef.fileinfo,parser_e_overloaded_have_same_parameters);
  1921. end;
  1922. { we found one proc with the same arguments, there are no others
  1923. so we can stop }
  1924. break;
  1925. end;
  1926. { check for allowing overload directive }
  1927. if not(m_fpc in aktmodeswitches) then
  1928. begin
  1929. { overload directive turns on overloading }
  1930. if ((po_overload in aprocdef.procoptions) or
  1931. (po_overload in hd.procoptions)) then
  1932. begin
  1933. { check if all procs have overloading, but not if the proc was
  1934. already declared forward, then the check is already done }
  1935. if not(hd.hasforward or
  1936. (aprocdef.forwarddef<>hd.forwarddef) or
  1937. ((po_overload in aprocdef.procoptions) and
  1938. (po_overload in hd.procoptions))) then
  1939. begin
  1940. MessagePos1(aprocdef.fileinfo,parser_e_no_overload_for_all_procs,aprocsym.realname);
  1941. break;
  1942. end;
  1943. end
  1944. else
  1945. begin
  1946. if not(hd.forwarddef) then
  1947. begin
  1948. MessagePos(aprocdef.fileinfo,parser_e_procedure_overloading_is_off);
  1949. break;
  1950. end;
  1951. end;
  1952. end; { equal arguments }
  1953. end;
  1954. { if we didn't reuse a forwarddef then we add the procdef to the overloaded
  1955. list }
  1956. if not forwardfound then
  1957. begin
  1958. aprocsym.addprocdef(aprocdef);
  1959. { add overloadnumber for unique naming, the overloadcount is
  1960. counted per module and 0 for the first procedure }
  1961. aprocdef.overloadnumber:=aprocsym.overloadcount;
  1962. inc(aprocsym.overloadcount);
  1963. end;
  1964. { insert otsym only in the right symtable }
  1965. if ((procinfo.flags and pi_operator)<>0) and
  1966. assigned(otsym) then
  1967. begin
  1968. if not parse_only then
  1969. begin
  1970. if paramanager.ret_in_param(aprocdef.rettype.def,aprocdef.proccalloption) then
  1971. begin
  1972. aprocdef.parast.insert(otsym);
  1973. { this allows to read the funcretoffset }
  1974. otsym.address:=-4;
  1975. otsym.varspez:=vs_var;
  1976. end
  1977. else
  1978. begin
  1979. if not assigned(aprocdef.localst) then
  1980. aprocdef.insert_localst;
  1981. aprocdef.localst.insert(otsym);
  1982. aprocdef.localst.insertvardata(otsym);
  1983. end;
  1984. end
  1985. else
  1986. begin
  1987. { this is not required anymore }
  1988. otsym.free;
  1989. otsym:=nil;
  1990. end;
  1991. end;
  1992. paramanager.create_param_loc_info(aprocdef);
  1993. proc_add_definition:=forwardfound;
  1994. end;
  1995. end.
  1996. {
  1997. $Log$
  1998. Revision 1.112 2003-04-22 13:47:08 peter
  1999. * fixed C style array of const
  2000. * fixed C array passing
  2001. * fixed left to right with high parameters
  2002. Revision 1.111 2003/04/10 17:57:53 peter
  2003. * vs_hidden released
  2004. Revision 1.110 2003/03/28 19:16:56 peter
  2005. * generic constructor working for i386
  2006. * remove fixed self register
  2007. * esi added as address register for i386
  2008. Revision 1.109 2003/03/23 23:21:42 hajny
  2009. + emx target added
  2010. Revision 1.108 2003/03/19 17:34:04 peter
  2011. * only allow class [procedure|function]
  2012. Revision 1.107 2003/03/17 18:56:02 peter
  2013. * fix crash with duplicate id
  2014. Revision 1.106 2003/03/17 15:54:22 peter
  2015. * store symoptions also for procdef
  2016. * check symoptions (private,public) when calculating possible
  2017. overload candidates
  2018. Revision 1.105 2003/01/15 20:02:28 carl
  2019. * fix highname problem
  2020. Revision 1.104 2003/01/12 15:42:23 peter
  2021. * m68k pathexist update from 1.0.x
  2022. * palmos res update from 1.0.x
  2023. Revision 1.103 2003/01/07 19:16:38 peter
  2024. * removed some duplicate code when creating aktprocsym
  2025. Revision 1.102 2003/01/05 18:17:45 peter
  2026. * more conflicts for constructor/destructor types
  2027. Revision 1.100 2003/01/02 19:49:00 peter
  2028. * update self parameter only for methodpointer and methods
  2029. Revision 1.99 2003/01/01 22:51:03 peter
  2030. * high value insertion changed so it works also when 2 parameters
  2031. are passed
  2032. Revision 1.98 2003/01/01 14:35:33 peter
  2033. * don't check for export directive repeat
  2034. Revision 1.97 2002/12/29 18:16:06 peter
  2035. * delphi allows setting calling convention in interface or
  2036. implementation
  2037. Revision 1.96 2002/12/29 14:55:44 peter
  2038. * fix static method check
  2039. * don't require class for class methods in the implementation for
  2040. non delphi modes
  2041. Revision 1.95 2002/12/27 15:25:14 peter
  2042. * check procoptions when a forward is found
  2043. * exclude some call directives for constructor/destructor
  2044. Revision 1.94 2002/12/25 01:26:56 peter
  2045. * duplicate procsym-unitsym fix
  2046. Revision 1.93 2002/12/24 21:21:06 peter
  2047. * remove code that skipped the _ prefix for win32 imports
  2048. Revision 1.92 2002/12/23 21:24:22 peter
  2049. * fix wrong internalerror when var names were different
  2050. Revision 1.91 2002/12/23 20:58:52 peter
  2051. * cdecl array fix, hack to change it to vs_var is not needed
  2052. Revision 1.90 2002/12/17 22:19:33 peter
  2053. * fixed pushing of records>8 bytes with stdcall
  2054. * simplified hightree loading
  2055. Revision 1.89 2002/12/15 21:07:30 peter
  2056. * don't allow external in object declarations
  2057. Revision 1.88 2002/12/15 19:34:31 florian
  2058. + some front end stuff for vs_hidden added
  2059. Revision 1.87 2002/12/07 14:27:07 carl
  2060. * 3% memory optimization
  2061. * changed some types
  2062. + added type checking with different size for call node and for
  2063. parameters
  2064. Revision 1.86 2002/12/06 17:51:10 peter
  2065. * merged cdecl and array fixes
  2066. Revision 1.85 2002/12/01 22:06:14 carl
  2067. * cleanup of error messages
  2068. Revision 1.84 2002/11/29 22:31:19 carl
  2069. + unimplemented hint directive added
  2070. * hint directive parsing implemented
  2071. * warning on these directives
  2072. Revision 1.83 2002/11/27 02:35:28 peter
  2073. * fixed typo in method comparing
  2074. Revision 1.82 2002/11/25 17:43:21 peter
  2075. * splitted defbase in defutil,symutil,defcmp
  2076. * merged isconvertable and is_equal into compare_defs(_ext)
  2077. * made operator search faster by walking the list only once
  2078. Revision 1.81 2002/11/18 17:31:58 peter
  2079. * pass proccalloption to ret_in_xxx and push_xxx functions
  2080. Revision 1.80 2002/11/17 16:31:56 carl
  2081. * memory optimization (3-4%) : cleanup of tai fields,
  2082. cleanup of tdef and tsym fields.
  2083. * make it work for m68k
  2084. Revision 1.79 2002/11/16 14:20:50 peter
  2085. * fix infinite loop in pd_inline
  2086. Revision 1.78 2002/11/15 01:58:53 peter
  2087. * merged changes from 1.0.7 up to 04-11
  2088. - -V option for generating bug report tracing
  2089. - more tracing for option parsing
  2090. - errors for cdecl and high()
  2091. - win32 import stabs
  2092. - win32 records<=8 are returned in eax:edx (turned off by default)
  2093. - heaptrc update
  2094. - more info for temp management in .s file with EXTDEBUG
  2095. Revision 1.77 2002/10/06 15:09:12 peter
  2096. * variant:=nil supported
  2097. Revision 1.76 2002/09/27 21:13:29 carl
  2098. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  2099. Revision 1.75 2002/09/16 14:11:13 peter
  2100. * add argument to equal_paras() to support default values or not
  2101. Revision 1.74 2002/09/10 16:27:28 peter
  2102. * don't insert parast in symtablestack, because typesyms should not be
  2103. searched in the the parast
  2104. Revision 1.73 2002/09/09 19:39:07 peter
  2105. * check return type for forwarddefs also not delphi mode when
  2106. the type is not void
  2107. Revision 1.72 2002/09/09 17:34:15 peter
  2108. * tdicationary.replace added to replace and item in a dictionary. This
  2109. is only allowed for the same name
  2110. * varsyms are inserted in symtable before the types are parsed. This
  2111. fixes the long standing "var longint : longint" bug
  2112. - consume_idlist and idstringlist removed. The loops are inserted
  2113. at the callers place and uses the symtable for duplicate id checking
  2114. Revision 1.71 2002/09/07 15:25:06 peter
  2115. * old logs removed and tabs fixed
  2116. Revision 1.70 2002/09/03 16:26:27 daniel
  2117. * Make Tprocdef.defs protected
  2118. Revision 1.69 2002/09/01 12:11:33 peter
  2119. * calc param_offset after parameters are read, because the calculation
  2120. depends on po_containself
  2121. Revision 1.68 2002/08/25 19:25:20 peter
  2122. * sym.insert_in_data removed
  2123. * symtable.insertvardata/insertconstdata added
  2124. * removed insert_in_data call from symtable.insert, it needs to be
  2125. called separatly. This allows to deref the address calculation
  2126. * procedures now calculate the parast addresses after the procedure
  2127. directives are parsed. This fixes the cdecl parast problem
  2128. * push_addr_param has an extra argument that specifies if cdecl is used
  2129. or not
  2130. Revision 1.67 2002/08/25 11:33:06 peter
  2131. * also check the paratypes when a forward was found
  2132. Revision 1.66 2002/08/19 19:36:44 peter
  2133. * More fixes for cross unit inlining, all tnodes are now implemented
  2134. * Moved pocall_internconst to po_internconst because it is not a
  2135. calling type at all and it conflicted when inlining of these small
  2136. functions was requested
  2137. Revision 1.65 2002/08/18 20:06:24 peter
  2138. * inlining is now also allowed in interface
  2139. * renamed write/load to ppuwrite/ppuload
  2140. * tnode storing in ppu
  2141. * nld,ncon,nbas are already updated for storing in ppu
  2142. Revision 1.64 2002/08/17 09:23:39 florian
  2143. * first part of procinfo rewrite
  2144. Revision 1.63 2002/08/11 14:32:27 peter
  2145. * renamed current_library to objectlibrary
  2146. Revision 1.62 2002/08/11 13:24:12 peter
  2147. * saving of asmsymbols in ppu supported
  2148. * asmsymbollist global is removed and moved into a new class
  2149. tasmlibrarydata that will hold the info of a .a file which
  2150. corresponds with a single module. Added librarydata to tmodule
  2151. to keep the library info stored for the module. In the future the
  2152. objectfiles will also be stored to the tasmlibrarydata class
  2153. * all getlabel/newasmsymbol and friends are moved to the new class
  2154. Revision 1.61 2002/07/26 21:15:40 florian
  2155. * rewrote the system handling
  2156. Revision 1.60 2002/07/20 11:57:55 florian
  2157. * types.pas renamed to defbase.pas because D6 contains a types
  2158. unit so this would conflicts if D6 programms are compiled
  2159. + Willamette/SSE2 instructions to assembler added
  2160. Revision 1.59 2002/07/11 14:41:28 florian
  2161. * start of the new generic parameter handling
  2162. Revision 1.58 2002/07/01 18:46:25 peter
  2163. * internal linker
  2164. * reorganized aasm layer
  2165. Revision 1.57 2002/05/18 13:34:12 peter
  2166. * readded missing revisions
  2167. Revision 1.56 2002/05/16 19:46:42 carl
  2168. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2169. + try to fix temp allocation (still in ifdef)
  2170. + generic constructor calls
  2171. + start of tassembler / tmodulebase class cleanup
  2172. Revision 1.54 2002/05/12 16:53:08 peter
  2173. * moved entry and exitcode to ncgutil and cgobj
  2174. * foreach gets extra argument for passing local data to the
  2175. iterator function
  2176. * -CR checks also class typecasts at runtime by changing them
  2177. into as
  2178. * fixed compiler to cycle with the -CR option
  2179. * fixed stabs with elf writer, finally the global variables can
  2180. be watched
  2181. * removed a lot of routines from cga unit and replaced them by
  2182. calls to cgobj
  2183. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2184. u32bit then the other is typecasted also to u32bit without giving
  2185. a rangecheck warning/error.
  2186. * fixed pascal calling method with reversing also the high tree in
  2187. the parast, detected by tcalcst3 test
  2188. Revision 1.53 2002/04/21 19:02:04 peter
  2189. * removed newn and disposen nodes, the code is now directly
  2190. inlined from pexpr
  2191. * -an option that will write the secondpass nodes to the .s file, this
  2192. requires EXTDEBUG define to actually write the info
  2193. * fixed various internal errors and crashes due recent code changes
  2194. Revision 1.52 2002/04/20 21:32:24 carl
  2195. + generic FPC_CHECKPOINTER
  2196. + first parameter offset in stack now portable
  2197. * rename some constants
  2198. + move some cpu stuff to other units
  2199. - remove unused constents
  2200. * fix stacksize for some targets
  2201. * fix generic size problems which depend now on EXTEND_SIZE constant
  2202. Revision 1.51 2002/04/20 15:27:05 carl
  2203. - remove ifdef i386 define
  2204. Revision 1.50 2002/04/19 15:46:02 peter
  2205. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  2206. in most cases and not written to the ppu
  2207. * add mangeledname_prefix() routine to generate the prefix of
  2208. manglednames depending on the current procedure, object and module
  2209. * removed static procprefix since the mangledname is now build only
  2210. on demand from tprocdef.mangledname
  2211. }