pdecsub.pas 88 KB

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