pdecsub.pas 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502
  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. type
  24. tpdflag=(
  25. pd_body, { directive needs a body }
  26. pd_implemen, { directive can be used implementation section }
  27. pd_interface, { directive can be used interface section }
  28. pd_object, { directive can be used object declaration }
  29. pd_procvar, { directive can be used procvar declaration }
  30. pd_notobject, { directive can not be used object declaration }
  31. pd_notobjintf, { directive can not be used interface declaration }
  32. pd_notprocvar { directive can not be used procvar declaration }
  33. );
  34. tpdflags=set of tpdflag;
  35. function check_proc_directive(isprocvar:boolean):boolean;
  36. procedure insert_funcret_local(pd:tprocdef);
  37. function proc_add_definition(var pd:tprocdef):boolean;
  38. function proc_get_importname(pd:tprocdef):string;
  39. procedure proc_set_mangledname(pd:tprocdef);
  40. procedure handle_calling_convention(pd:tabstractprocdef);
  41. procedure parse_parameter_dec(pd:tabstractprocdef);
  42. procedure parse_proc_directives(pd:tabstractprocdef;var pdflags:tpdflags);
  43. procedure parse_var_proc_directives(sym:tsym);
  44. procedure parse_object_proc_directives(pd:tabstractprocdef);
  45. function parse_proc_head(aclass:tobjectdef;potype:tproctypeoption;var pd:tprocdef):boolean;
  46. function parse_proc_dec(aclass:tobjectdef):tprocdef;
  47. implementation
  48. uses
  49. strings,
  50. { common }
  51. cutils,cclasses,
  52. { global }
  53. globtype,globals,verbose,
  54. systems,
  55. cpuinfo,
  56. { symtable }
  57. symbase,symtable,defutil,defcmp,paramgr,cpupara,
  58. { pass 1 }
  59. node,htypechk,
  60. nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,
  61. { parser }
  62. scanner,
  63. pbase,pexpr,ptype,pdecl
  64. ;
  65. const
  66. { Please leave this here, this module should NOT use
  67. these variables.
  68. Declaring it as string here results in an error when compiling (PFV) }
  69. current_procinfo = 'error';
  70. procedure insert_funcret_para(pd:tabstractprocdef);
  71. var
  72. storepos : tfileposinfo;
  73. vs : tparavarsym;
  74. paranr : word;
  75. begin
  76. if not(pd.proctypeoption in [potype_constructor,potype_destructor]) and
  77. not is_void(pd.rettype.def) and
  78. paramanager.ret_in_param(pd.rettype.def,pd.proccalloption) then
  79. begin
  80. storepos:=akttokenpos;
  81. if pd.deftype=procdef then
  82. akttokenpos:=tprocdef(pd).fileinfo;
  83. { For left to right add it at the end to be delphi compatible }
  84. if pd.proccalloption in pushleftright_pocalls then
  85. paranr:=paranr_result_leftright
  86. else
  87. paranr:=paranr_result;
  88. { Generate result variable accessing function result }
  89. vs:=tparavarsym.create('$result',paranr,vs_var,pd.rettype,[vo_is_funcret,vo_is_hidden_para]);
  90. pd.parast.insert(vs);
  91. { Store the this symbol as funcretsym for procedures }
  92. if pd.deftype=procdef then
  93. tprocdef(pd).funcretsym:=vs;
  94. akttokenpos:=storepos;
  95. end;
  96. end;
  97. procedure insert_parentfp_para(pd:tabstractprocdef);
  98. var
  99. storepos : tfileposinfo;
  100. vs : tparavarsym;
  101. begin
  102. if pd.parast.symtablelevel>normal_function_level then
  103. begin
  104. storepos:=akttokenpos;
  105. if pd.deftype=procdef then
  106. akttokenpos:=tprocdef(pd).fileinfo;
  107. { Generate result variable accessing function result, it
  108. can't be put in a register since it must be accessable
  109. from the framepointer }
  110. vs:=tparavarsym.create('$parentfp',paranr_parentfp,vs_var,voidpointertype,[vo_is_parentfp,vo_is_hidden_para]);
  111. vs.varregable:=vr_none;
  112. pd.parast.insert(vs);
  113. akttokenpos:=storepos;
  114. end;
  115. end;
  116. procedure insert_self_and_vmt_para(pd:tabstractprocdef);
  117. var
  118. storepos : tfileposinfo;
  119. vs : tparavarsym;
  120. tt : ttype;
  121. vsp : tvarspez;
  122. begin
  123. if (pd.deftype=procvardef) and
  124. pd.is_methodpointer then
  125. begin
  126. { Generate self variable }
  127. tt:=voidpointertype;
  128. vs:=tparavarsym.create('$self',paranr_self,vs_value,tt,[vo_is_self,vo_is_hidden_para]);
  129. pd.parast.insert(vs);
  130. end
  131. else
  132. begin
  133. if (pd.deftype=procdef) and
  134. assigned(tprocdef(pd)._class) and
  135. (pd.parast.symtablelevel=normal_function_level) then
  136. begin
  137. storepos:=akttokenpos;
  138. akttokenpos:=tprocdef(pd).fileinfo;
  139. { Generate VMT variable for constructor/destructor }
  140. if pd.proctypeoption in [potype_constructor,potype_destructor] then
  141. begin
  142. { can't use classrefdef as type because inheriting
  143. will then always file because of a type mismatch }
  144. tt:=voidpointertype;
  145. vs:=tparavarsym.create('$vmt',paranr_vmt,vs_value,tt,[vo_is_vmt,vo_is_hidden_para]);
  146. pd.parast.insert(vs);
  147. end;
  148. { Generate self variable, for classes we need
  149. to use the generic voidpointer to be compatible with
  150. methodpointers }
  151. vsp:=vs_value;
  152. if (po_staticmethod in pd.procoptions) or
  153. (po_classmethod in pd.procoptions) then
  154. begin
  155. tt.setdef(tprocdef(pd)._class);
  156. tt.setdef(tclassrefdef.create(tt));
  157. end
  158. else
  159. begin
  160. if is_object(tprocdef(pd)._class) then
  161. vsp:=vs_var;
  162. tt.setdef(tprocdef(pd)._class);
  163. end;
  164. vs:=tparavarsym.create('$self',paranr_self,vsp,tt,[vo_is_self,vo_is_hidden_para]);
  165. pd.parast.insert(vs);
  166. akttokenpos:=storepos;
  167. end;
  168. end;
  169. end;
  170. procedure insert_funcret_local(pd:tprocdef);
  171. var
  172. storepos : tfileposinfo;
  173. vs : tlocalvarsym;
  174. aliasvs : tabsolutevarsym;
  175. sl : tsymlist;
  176. begin
  177. { The result from constructors and destructors can't be accessed directly }
  178. if not(pd.proctypeoption in [potype_constructor,potype_destructor]) and
  179. not is_void(pd.rettype.def) then
  180. begin
  181. storepos:=akttokenpos;
  182. akttokenpos:=pd.fileinfo;
  183. { We always need a localsymtable }
  184. if not assigned(pd.localst) then
  185. pd.insert_localst;
  186. { We need to insert a varsym for the result in the localst
  187. when it is returning in a register }
  188. if not paramanager.ret_in_param(pd.rettype.def,pd.proccalloption) then
  189. begin
  190. vs:=tlocalvarsym.create('$result',vs_value,pd.rettype,[vo_is_funcret]);
  191. pd.localst.insert(vs);
  192. pd.funcretsym:=vs;
  193. end;
  194. { insert the name of the procedure as alias for the function result,
  195. we can't use realname because that will not work for compilerprocs
  196. as the name is lowercase and unreachable from the code }
  197. if pd.resultname='' then
  198. pd.resultname:=pd.procsym.name;
  199. sl:=tsymlist.create;
  200. sl.addsym(sl_load,pd.funcretsym);
  201. aliasvs:=tabsolutevarsym.create_ref(pd.resultname,pd.rettype,sl);
  202. include(aliasvs.varoptions,vo_is_funcret);
  203. pd.localst.insert(aliasvs);
  204. { insert result also if support is on }
  205. if (m_result in aktmodeswitches) then
  206. begin
  207. sl:=tsymlist.create;
  208. sl.addsym(sl_load,pd.funcretsym);
  209. aliasvs:=tabsolutevarsym.create_ref('RESULT',pd.rettype,sl);
  210. include(aliasvs.varoptions,vo_is_funcret);
  211. include(aliasvs.varoptions,vo_is_result);
  212. pd.localst.insert(aliasvs);
  213. end;
  214. akttokenpos:=storepos;
  215. end;
  216. end;
  217. procedure insert_hidden_para(p:tnamedindexitem;arg:pointer);
  218. var
  219. hvs : tparavarsym;
  220. pd : tabstractprocdef absolute arg;
  221. begin
  222. if (tsym(p).typ<>paravarsym) then
  223. exit;
  224. with tparavarsym(p) do
  225. begin
  226. { We need a local copy for a value parameter when only the
  227. address is pushed. Open arrays and Array of Const are
  228. an exception because they are allocated at runtime and the
  229. address that is pushed is patched }
  230. if (varspez=vs_value) and
  231. paramanager.push_addr_param(varspez,vartype.def,pd.proccalloption) and
  232. not(is_open_array(vartype.def) or
  233. is_array_of_const(vartype.def)) then
  234. include(varoptions,vo_has_local_copy);
  235. { needs high parameter ? }
  236. if paramanager.push_high_param(varspez,vartype.def,pd.proccalloption) then
  237. begin
  238. hvs:=tparavarsym.create('$high'+name,paranr+1,vs_const,sinttype,[vo_is_high_para,vo_is_hidden_para]);
  239. owner.insert(hvs);
  240. end
  241. else
  242. begin
  243. { Give a warning that cdecl routines does not include high()
  244. support }
  245. if (pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) and
  246. paramanager.push_high_param(varspez,vartype.def,pocall_default) then
  247. begin
  248. if is_open_string(vartype.def) then
  249. Message(parser_w_cdecl_no_openstring);
  250. if not (po_external in pd.procoptions) then
  251. Message(parser_w_cdecl_has_no_high);
  252. end;
  253. end;
  254. end;
  255. end;
  256. procedure check_c_para(p:tnamedindexitem;arg:pointer);
  257. begin
  258. if (tsym(p).typ<>paravarsym) then
  259. exit;
  260. with tparavarsym(p) do
  261. begin
  262. case vartype.def.deftype of
  263. arraydef :
  264. begin
  265. if not is_variant_array(vartype.def) and
  266. not is_array_of_const(vartype.def) then
  267. begin
  268. if (varspez<>vs_var) then
  269. Message(parser_h_c_arrays_are_references);
  270. end;
  271. if is_array_of_const(vartype.def) and
  272. assigned(indexnext) and
  273. (tsym(indexnext).typ=paravarsym) and
  274. not(vo_is_high_para in tparavarsym(indexnext).varoptions) then
  275. Message(parser_e_C_array_of_const_must_be_last);
  276. end;
  277. end;
  278. end;
  279. end;
  280. procedure check_msg_para(p:tnamedindexitem;arg:pointer);
  281. begin
  282. if (tsym(p).typ<>paravarsym) then
  283. exit;
  284. with tparavarsym(p) do
  285. begin
  286. { Count parameters }
  287. if (paranr>=10) then
  288. inc(plongint(arg)^);
  289. { First parameter must be var }
  290. if (paranr=10) and
  291. (varspez<>vs_var) then
  292. Message(parser_e_ill_msg_param);
  293. end;
  294. end;
  295. procedure check_inline_para(p:tnamedindexitem;arg:pointer);
  296. var
  297. pd : tabstractprocdef absolute arg;
  298. begin
  299. if (pd.proccalloption<>pocall_inline) or
  300. (tsym(p).typ<>paravarsym) then
  301. exit;
  302. with tparavarsym(p) do
  303. begin
  304. case vartype.def.deftype of
  305. arraydef :
  306. begin
  307. with tarraydef(vartype.def) do
  308. if IsVariant or IsConstructor then
  309. begin
  310. Message1(parser_w_not_supported_for_inline,'array of const');
  311. Message(parser_w_inlining_disabled);
  312. pd.proccalloption:=pocall_default;
  313. end;
  314. end;
  315. end;
  316. end;
  317. end;
  318. procedure set_addr_param_regable(p:tnamedindexitem;arg:pointer);
  319. begin
  320. if (tsym(p).typ<>paravarsym) then
  321. exit;
  322. with tparavarsym(p) do
  323. begin
  324. if not vartype.def.needs_inittable and
  325. paramanager.push_addr_param(varspez,vartype.def,tprocdef(arg).proccalloption) then
  326. varregable:=vr_intreg;
  327. end;
  328. end;
  329. procedure parse_parameter_dec(pd:tabstractprocdef);
  330. {
  331. handle_procvar needs the same changes
  332. }
  333. var
  334. sc : tsinglelist;
  335. tt : ttype;
  336. arrayelementtype : ttype;
  337. vs : tparavarsym;
  338. srsym : tsym;
  339. hs1 : string;
  340. varspez : Tvarspez;
  341. defaultvalue : tconstsym;
  342. defaultrequired : boolean;
  343. old_object_option : tsymoptions;
  344. currparast : tparasymtable;
  345. explicit_paraloc : boolean;
  346. locationstr : string;
  347. paranr : integer;
  348. begin
  349. explicit_paraloc:=false;
  350. consume(_LKLAMMER);
  351. { Delphi/Kylix supports nonsense like }
  352. { procedure p(); }
  353. if try_to_consume(_RKLAMMER) and
  354. not(m_tp7 in aktmodeswitches) then
  355. exit;
  356. { parsing a proc or procvar ? }
  357. currparast:=tparasymtable(pd.parast);
  358. { reset }
  359. sc:=tsinglelist.create;
  360. defaultrequired:=false;
  361. paranr:=0;
  362. { the variables are always public }
  363. old_object_option:=current_object_option;
  364. current_object_option:=[sp_public];
  365. inc(testcurobject);
  366. repeat
  367. if try_to_consume(_VAR) then
  368. varspez:=vs_var
  369. else
  370. if try_to_consume(_CONST) then
  371. varspez:=vs_const
  372. else
  373. if (idtoken=_OUT) and (m_out in aktmodeswitches) then
  374. begin
  375. consume(_OUT);
  376. varspez:=vs_out
  377. end
  378. else
  379. if (token=_POINTPOINTPOINT) and (m_mac in aktmodeswitches) then
  380. begin
  381. consume(_POINTPOINTPOINT);
  382. include(pd.procoptions,po_varargs);
  383. break;
  384. end
  385. else
  386. varspez:=vs_value;
  387. defaultvalue:=nil;
  388. tt.reset;
  389. { read identifiers and insert with error type }
  390. sc.reset;
  391. repeat
  392. inc(paranr);
  393. vs:=tparavarsym.create(orgpattern,paranr*10,varspez,generrortype,[]);
  394. currparast.insert(vs);
  395. if assigned(vs.owner) then
  396. sc.insert(vs)
  397. else
  398. vs.free;
  399. consume(_ID);
  400. until not try_to_consume(_COMMA);
  401. locationstr:='';
  402. { read type declaration, force reading for value and const paras }
  403. if (token=_COLON) or (varspez=vs_value) then
  404. begin
  405. consume(_COLON);
  406. { check for an open array }
  407. if token=_ARRAY then
  408. begin
  409. consume(_ARRAY);
  410. consume(_OF);
  411. { define range and type of range }
  412. tt.setdef(tarraydef.create(0,-1,s32inttype));
  413. { array of const ? }
  414. if (token=_CONST) and (m_objpas in aktmodeswitches) then
  415. begin
  416. consume(_CONST);
  417. srsym:=searchsymonlyin(systemunit,'TVARREC');
  418. if not assigned(srsym) then
  419. InternalError(200404181);
  420. tarraydef(tt.def).setelementtype(ttypesym(srsym).restype);
  421. tarraydef(tt.def).IsArrayOfConst:=true;
  422. end
  423. else
  424. begin
  425. { define field type }
  426. single_type(arrayelementtype,hs1,false);
  427. tarraydef(tt.def).setelementtype(arrayelementtype);
  428. end;
  429. end
  430. else
  431. begin
  432. { open string ? }
  433. if (varspez=vs_var) and
  434. (
  435. (
  436. ((token=_STRING) or (idtoken=_SHORTSTRING)) and
  437. (cs_openstring in aktmoduleswitches) and
  438. not(cs_ansistrings in aktlocalswitches)
  439. ) or
  440. (idtoken=_OPENSTRING)) then
  441. begin
  442. consume(token);
  443. tt:=openshortstringtype;
  444. hs1:='openstring';
  445. end
  446. else
  447. begin
  448. { everything else }
  449. if (m_mac in aktmodeswitches) then
  450. try_to_consume(_UNIV); {currently does nothing}
  451. single_type(tt,hs1,false);
  452. end;
  453. if (target_info.system in [system_powerpc_morphos,system_m68k_amiga]) then
  454. begin
  455. if (idtoken=_LOCATION) then
  456. begin
  457. consume(_LOCATION);
  458. locationstr:=pattern;
  459. consume(_CSTRING);
  460. end
  461. else
  462. begin
  463. if explicit_paraloc then
  464. Message(parser_e_paraloc_all_paras);
  465. locationstr:='';
  466. end;
  467. end
  468. else
  469. locationstr:='';
  470. { default parameter }
  471. if (m_default_para in aktmodeswitches) then
  472. begin
  473. if try_to_consume(_EQUAL) then
  474. begin
  475. vs:=tparavarsym(sc.first);
  476. if assigned(vs.listnext) then
  477. Message(parser_e_default_value_only_one_para);
  478. { prefix 'def' to the parameter name }
  479. defaultvalue:=ReadConstant('$def'+vs.name,vs.fileinfo);
  480. if assigned(defaultvalue) then
  481. begin
  482. include(defaultvalue.symoptions,sp_internal);
  483. pd.parast.insert(defaultvalue);
  484. end;
  485. defaultrequired:=true;
  486. end
  487. else
  488. begin
  489. if defaultrequired then
  490. Message1(parser_e_default_value_expected_for_para,vs.name);
  491. end;
  492. end;
  493. end;
  494. end
  495. else
  496. begin
  497. {$ifndef UseNiceNames}
  498. hs1:='$$$';
  499. {$else UseNiceNames}
  500. hs1:='var';
  501. {$endif UseNiceNames}
  502. tt:=cformaltype;
  503. end;
  504. { File types are only allowed for var parameters }
  505. if (tt.def.deftype=filedef) and
  506. (varspez<>vs_var) then
  507. CGMessage(cg_e_file_must_call_by_reference);
  508. vs:=tparavarsym(sc.first);
  509. while assigned(vs) do
  510. begin
  511. { update varsym }
  512. vs.vartype:=tt;
  513. vs.defaultconstsym:=defaultvalue;
  514. if (target_info.system in [system_powerpc_morphos,system_m68k_amiga]) then
  515. begin
  516. if locationstr<>'' then
  517. begin
  518. if assigned(sc.first.listnext) then
  519. Message(parser_e_paraloc_only_one_para);
  520. if (paranr>1) and not(explicit_paraloc) then
  521. Message(parser_e_paraloc_all_paras);
  522. explicit_paraloc:=true;
  523. include(vs.varoptions,vo_has_explicit_paraloc);
  524. if not(paramanager.parseparaloc(vs,upper(locationstr))) then
  525. message(parser_e_illegal_explicit_paraloc);
  526. end
  527. else
  528. if explicit_paraloc then
  529. Message(parser_e_paraloc_all_paras);
  530. end;
  531. vs:=tparavarsym(vs.listnext);
  532. end;
  533. until not try_to_consume(_SEMICOLON);
  534. if explicit_paraloc then
  535. begin
  536. pd.has_paraloc_info:=true;
  537. include(pd.procoptions,po_explicitparaloc);
  538. end;
  539. { remove parasymtable from stack }
  540. sc.free;
  541. { reset object options }
  542. dec(testcurobject);
  543. current_object_option:=old_object_option;
  544. consume(_RKLAMMER);
  545. end;
  546. function parse_proc_head(aclass:tobjectdef;potype:tproctypeoption;var pd:tprocdef):boolean;
  547. var
  548. orgsp,sp : stringid;
  549. sym : tsym;
  550. srsym : tsym;
  551. srsymtable : tsymtable;
  552. storepos,
  553. procstartfilepos : tfileposinfo;
  554. searchagain : boolean;
  555. i : longint;
  556. st : tsymtable;
  557. aprocsym : tprocsym;
  558. begin
  559. { Save the position where this procedure really starts }
  560. procstartfilepos:=akttokenpos;
  561. result:=false;
  562. pd:=nil;
  563. aprocsym:=nil;
  564. if (potype=potype_operator) then
  565. begin
  566. sp:=overloaded_names[optoken];
  567. orgsp:=sp;
  568. end
  569. else
  570. begin
  571. sp:=pattern;
  572. orgsp:=orgpattern;
  573. consume(_ID);
  574. end;
  575. { examine interface map: function/procedure iname.functionname=locfuncname }
  576. if assigned(aclass) and
  577. assigned(aclass.implementedinterfaces) and
  578. (aclass.implementedinterfaces.count>0) and
  579. try_to_consume(_POINT) then
  580. begin
  581. storepos:=akttokenpos;
  582. akttokenpos:=procstartfilepos;
  583. { get interface syms}
  584. searchsym(sp,sym,srsymtable);
  585. if not assigned(sym) then
  586. begin
  587. identifier_not_found(orgsp);
  588. sym:=generrorsym;
  589. end;
  590. akttokenpos:=storepos;
  591. { qualifier is interface? }
  592. if (sym.typ=typesym) and
  593. (ttypesym(sym).restype.def.deftype=objectdef) then
  594. i:=aclass.implementedinterfaces.searchintf(ttypesym(sym).restype.def)
  595. else
  596. i:=-1;
  597. if (i=-1) then
  598. Message(parser_e_interface_id_expected);
  599. consume(_ID);
  600. consume(_EQUAL);
  601. if (token=_ID) then
  602. aclass.implementedinterfaces.addmappings(i,sp,pattern);
  603. consume(_ID);
  604. result:=true;
  605. exit;
  606. end;
  607. { method ? }
  608. if not assigned(aclass) and
  609. (potype<>potype_operator) and
  610. (symtablestack.symtablelevel=main_program_level) and
  611. try_to_consume(_POINT) then
  612. begin
  613. { search for object name }
  614. storepos:=akttokenpos;
  615. akttokenpos:=procstartfilepos;
  616. searchsym(sp,sym,srsymtable);
  617. if not assigned(sym) then
  618. begin
  619. identifier_not_found(orgsp);
  620. sym:=generrorsym;
  621. end;
  622. akttokenpos:=storepos;
  623. { consume proc name }
  624. sp:=pattern;
  625. orgsp:=orgpattern;
  626. procstartfilepos:=akttokenpos;
  627. consume(_ID);
  628. { qualifier is class name ? }
  629. if (sym.typ=typesym) and
  630. (ttypesym(sym).restype.def.deftype=objectdef) then
  631. begin
  632. aclass:=tobjectdef(ttypesym(sym).restype.def);
  633. aprocsym:=tprocsym(aclass.symtable.search(sp));
  634. { we solve this below }
  635. if assigned(aprocsym) then
  636. begin
  637. if aprocsym.typ<>procsym then
  638. begin
  639. { we use a different error message for tp7 so it looks more compatible }
  640. if (m_fpc in aktmodeswitches) then
  641. Message1(parser_e_overloaded_no_procedure,aprocsym.realname)
  642. else
  643. Message(parser_e_methode_id_expected);
  644. { rename the name to an unique name to avoid an
  645. error when inserting the symbol in the symtable }
  646. orgsp:=orgsp+'$'+tostr(aktfilepos.line);
  647. aprocsym:=nil;
  648. end;
  649. end
  650. else
  651. begin
  652. Message(parser_e_methode_id_expected);
  653. { recover by making it a normal procedure instead of method }
  654. aclass:=nil;
  655. end;
  656. end
  657. else
  658. Message(parser_e_class_id_expected);
  659. end
  660. else
  661. begin
  662. { check for constructor/destructor which is not allowed here }
  663. if (not parse_only) and
  664. (potype in [potype_constructor,potype_destructor]) then
  665. Message(parser_e_constructors_always_objects);
  666. repeat
  667. searchagain:=false;
  668. akttokenpos:=procstartfilepos;
  669. srsym:=tsym(symtablestack.search(sp));
  670. if not(parse_only) and
  671. not assigned(srsym) and
  672. (symtablestack.symtabletype=staticsymtable) and
  673. assigned(symtablestack.next) and
  674. (symtablestack.next.unitid=0) then
  675. begin
  676. { The procedure we prepare for is in the implementation
  677. part of the unit we compile. It is also possible that we
  678. are compiling a program, which is also some kind of
  679. implementaion part.
  680. We need to find out if the procedure is global. If it is
  681. global, it is in the global symtable.}
  682. srsym:=tsym(symtablestack.next.search(sp));
  683. end;
  684. { Check if overloaded is a procsym }
  685. if assigned(srsym) then
  686. begin
  687. if srsym.typ=procsym then
  688. aprocsym:=tprocsym(srsym)
  689. else
  690. begin
  691. { when the other symbol is a unit symbol then hide the unit
  692. symbol }
  693. if (srsym.typ=unitsym) then
  694. begin
  695. srsym.owner.rename(srsym.name,'hidden'+srsym.name);
  696. searchagain:=true;
  697. end
  698. else
  699. begin
  700. { we use a different error message for tp7 so it looks more compatible }
  701. if (m_fpc in aktmodeswitches) then
  702. Message1(parser_e_overloaded_no_procedure,srsym.realname)
  703. else
  704. tstoredsymtable(symtablestack).DuplicateSym(nil,srsym);
  705. { rename the name to an unique name to avoid an
  706. error when inserting the symbol in the symtable }
  707. orgsp:=orgsp+'$'+tostr(aktfilepos.line);
  708. end;
  709. end;
  710. end;
  711. until not searchagain;
  712. end;
  713. { test again if assigned, it can be reset to recover }
  714. if not assigned(aprocsym) then
  715. begin
  716. { create a new procsym and set the real filepos }
  717. akttokenpos:=procstartfilepos;
  718. { for operator we have only one procsym for each overloaded
  719. operation }
  720. if (potype=potype_operator) then
  721. begin
  722. Aprocsym:=Tprocsym(symtablestack.search(sp));
  723. if Aprocsym=nil then
  724. Aprocsym:=tprocsym.create('$'+sp);
  725. end
  726. else
  727. aprocsym:=tprocsym.create(orgsp);
  728. symtablestack.insert(aprocsym);
  729. end;
  730. { to get the correct symtablelevel we must ignore objectsymtables }
  731. st:=symtablestack;
  732. while not(st.symtabletype in [staticsymtable,globalsymtable,localsymtable]) do
  733. st:=st.next;
  734. pd:=tprocdef.create(st.symtablelevel+1);
  735. pd._class:=aclass;
  736. pd.procsym:=aprocsym;
  737. pd.proctypeoption:=potype;
  738. { methods need to be exported }
  739. if assigned(aclass) and
  740. (
  741. (symtablestack.symtabletype=objectsymtable) or
  742. (symtablestack.symtablelevel=main_program_level)
  743. ) then
  744. include(pd.procoptions,po_global);
  745. { symbol options that need to be kept per procdef }
  746. pd.fileinfo:=procstartfilepos;
  747. pd.symoptions:=current_object_option;
  748. { parse parameters }
  749. if token=_LKLAMMER then
  750. parse_parameter_dec(pd);
  751. result:=true;
  752. end;
  753. function parse_proc_dec(aclass:tobjectdef):tprocdef;
  754. var
  755. pd : tprocdef;
  756. hs : string;
  757. isclassmethod : boolean;
  758. begin
  759. pd:=nil;
  760. { read class method }
  761. if try_to_consume(_CLASS) then
  762. begin
  763. { class method only allowed for procedures and functions }
  764. if not(token in [_FUNCTION,_PROCEDURE]) then
  765. Message(parser_e_procedure_or_function_expected);
  766. isclassmethod:=true;
  767. end
  768. else
  769. isclassmethod:=false;
  770. case token of
  771. _FUNCTION :
  772. begin
  773. consume(_FUNCTION);
  774. if parse_proc_head(aclass,potype_none,pd) then
  775. begin
  776. { pd=nil when it is a interface mapping }
  777. if assigned(pd) then
  778. begin
  779. if try_to_consume(_COLON) then
  780. begin
  781. inc(testcurobject);
  782. single_type(pd.rettype,hs,false);
  783. pd.test_if_fpu_result;
  784. dec(testcurobject);
  785. end
  786. else
  787. begin
  788. if (
  789. parse_only and
  790. not(is_interface(pd._class))
  791. ) or
  792. (m_repeat_forward in aktmodeswitches) then
  793. begin
  794. consume(_COLON);
  795. consume_all_until(_SEMICOLON);
  796. end;
  797. end;
  798. if isclassmethod then
  799. include(pd.procoptions,po_classmethod);
  800. end;
  801. end
  802. else
  803. begin
  804. { recover }
  805. consume(_COLON);
  806. consume_all_until(_SEMICOLON);
  807. end;
  808. end;
  809. _PROCEDURE :
  810. begin
  811. consume(_PROCEDURE);
  812. if parse_proc_head(aclass,potype_none,pd) then
  813. begin
  814. { pd=nil when it is a interface mapping }
  815. if assigned(pd) then
  816. begin
  817. pd.rettype:=voidtype;
  818. if isclassmethod then
  819. include(pd.procoptions,po_classmethod);
  820. end;
  821. end;
  822. end;
  823. _CONSTRUCTOR :
  824. begin
  825. consume(_CONSTRUCTOR);
  826. parse_proc_head(aclass,potype_constructor,pd);
  827. if assigned(pd) and
  828. assigned(pd._class) then
  829. begin
  830. { Set return type, class constructors return the
  831. created instance, object constructors return boolean }
  832. if is_class(pd._class) then
  833. pd.rettype.setdef(pd._class)
  834. else
  835. pd.rettype:=booltype;
  836. end;
  837. end;
  838. _DESTRUCTOR :
  839. begin
  840. consume(_DESTRUCTOR);
  841. parse_proc_head(aclass,potype_destructor,pd);
  842. if assigned(pd) then
  843. pd.rettype:=voidtype;
  844. end;
  845. _OPERATOR :
  846. begin
  847. consume(_OPERATOR);
  848. if (token in [first_overloaded..last_overloaded]) then
  849. begin
  850. optoken:=token;
  851. end
  852. else
  853. begin
  854. Message(parser_e_overload_operator_failed);
  855. { Use the dummy NOTOKEN that is also declared
  856. for the overloaded_operator[] }
  857. optoken:=NOTOKEN;
  858. end;
  859. consume(token);
  860. parse_proc_head(aclass,potype_operator,pd);
  861. if assigned(pd) then
  862. begin
  863. if pd.parast.symtablelevel>normal_function_level then
  864. Message(parser_e_no_local_operator);
  865. if token<>_ID then
  866. begin
  867. if not(m_result in aktmodeswitches) then
  868. consume(_ID);
  869. end
  870. else
  871. begin
  872. pd.resultname:=orgpattern;
  873. consume(_ID);
  874. end;
  875. if not try_to_consume(_COLON) then
  876. begin
  877. consume(_COLON);
  878. pd.rettype:=generrortype;
  879. consume_all_until(_SEMICOLON);
  880. end
  881. else
  882. begin
  883. single_type(pd.rettype,hs,false);
  884. pd.test_if_fpu_result;
  885. if (optoken in [_EQUAL,_GT,_LT,_GTE,_LTE]) and
  886. ((pd.rettype.def.deftype<>orddef) or
  887. (torddef(pd.rettype.def).typ<>bool8bit)) then
  888. Message(parser_e_comparative_operator_return_boolean);
  889. if (optoken=_ASSIGNMENT) and
  890. equal_defs(pd.rettype.def,
  891. tparavarsym(pd.parast.symindex.first).vartype.def) then
  892. message(parser_e_no_such_assignment)
  893. else if not isoperatoracceptable(pd,optoken) then
  894. Message(parser_e_overload_impossible);
  895. end;
  896. end
  897. else
  898. begin
  899. { recover }
  900. try_to_consume(_ID);
  901. consume(_COLON);
  902. consume_all_until(_SEMICOLON);
  903. end;
  904. end;
  905. end;
  906. { support procedure proc stdcall export; }
  907. if not(check_proc_directive(false)) then
  908. consume(_SEMICOLON);
  909. result:=pd;
  910. end;
  911. {****************************************************************************
  912. Procedure directive handlers
  913. ****************************************************************************}
  914. procedure pd_far(pd:tabstractprocdef);
  915. begin
  916. Message1(parser_w_proc_directive_ignored,'FAR');
  917. end;
  918. procedure pd_near(pd:tabstractprocdef);
  919. begin
  920. Message1(parser_w_proc_directive_ignored,'NEAR');
  921. end;
  922. procedure pd_export(pd:tabstractprocdef);
  923. begin
  924. if pd.deftype<>procdef then
  925. internalerror(200304264);
  926. if assigned(tprocdef(pd)._class) then
  927. Message(parser_e_methods_dont_be_export);
  928. if pd.parast.symtablelevel>normal_function_level then
  929. Message(parser_e_dont_nest_export);
  930. end;
  931. procedure pd_forward(pd:tabstractprocdef);
  932. begin
  933. if pd.deftype<>procdef then
  934. internalerror(200304265);
  935. tprocdef(pd).forwarddef:=true;
  936. end;
  937. procedure pd_alias(pd:tabstractprocdef);
  938. begin
  939. if pd.deftype<>procdef then
  940. internalerror(200304266);
  941. consume(_COLON);
  942. tprocdef(pd).aliasnames.insert(get_stringconst);
  943. include(pd.procoptions,po_has_public_name);
  944. end;
  945. procedure pd_public(pd:tabstractprocdef);
  946. begin
  947. if pd.deftype<>procdef then
  948. internalerror(200304266);
  949. if try_to_consume(_NAME) then
  950. begin
  951. tprocdef(pd).aliasnames.insert(get_stringconst);
  952. include(pd.procoptions,po_has_public_name);
  953. end;
  954. end;
  955. procedure pd_asmname(pd:tabstractprocdef);
  956. begin
  957. if pd.deftype<>procdef then
  958. internalerror(200304267);
  959. tprocdef(pd).aliasnames.insert(target_info.Cprefix+pattern);
  960. if token=_CCHAR then
  961. consume(_CCHAR)
  962. else
  963. consume(_CSTRING);
  964. { we don't need anything else }
  965. tprocdef(pd).forwarddef:=false;
  966. end;
  967. procedure pd_inline(pd:tabstractprocdef);
  968. begin
  969. { Check if there are parameters that can't be inlined }
  970. pd.parast.foreach_static(@check_inline_para,pd);
  971. end;
  972. procedure pd_internconst(pd:tabstractprocdef);
  973. begin
  974. if pd.deftype<>procdef then
  975. internalerror(200304268);
  976. consume(_COLON);
  977. tprocdef(pd).extnumber:=get_intconst;
  978. end;
  979. procedure pd_internproc(pd:tabstractprocdef);
  980. begin
  981. if pd.deftype<>procdef then
  982. internalerror(200304268);
  983. consume(_COLON);
  984. tprocdef(pd).extnumber:=get_intconst;
  985. { the proc is defined }
  986. tprocdef(pd).forwarddef:=false;
  987. end;
  988. procedure pd_interrupt(pd:tabstractprocdef);
  989. begin
  990. if pd.parast.symtablelevel>normal_function_level then
  991. Message(parser_e_dont_nest_interrupt);
  992. end;
  993. procedure pd_abstract(pd:tabstractprocdef);
  994. begin
  995. if pd.deftype<>procdef then
  996. internalerror(200304269);
  997. if (po_virtualmethod in pd.procoptions) then
  998. include(pd.procoptions,po_abstractmethod)
  999. else
  1000. Message(parser_e_only_virtual_methods_abstract);
  1001. { the method is defined }
  1002. tprocdef(pd).forwarddef:=false;
  1003. end;
  1004. procedure pd_virtual(pd:tabstractprocdef);
  1005. {$ifdef WITHDMT}
  1006. var
  1007. pt : tnode;
  1008. {$endif WITHDMT}
  1009. begin
  1010. if pd.deftype<>procdef then
  1011. internalerror(2003042610);
  1012. if (pd.proctypeoption=potype_constructor) and
  1013. is_object(tprocdef(pd)._class) then
  1014. Message(parser_e_constructor_cannot_be_not_virtual);
  1015. {$ifdef WITHDMT}
  1016. if is_object(tprocdef(pd)._class) and
  1017. (token<>_SEMICOLON) then
  1018. begin
  1019. { any type of parameter is allowed here! }
  1020. pt:=comp_expr(true);
  1021. if is_constintnode(pt) then
  1022. begin
  1023. include(pd.procoptions,po_msgint);
  1024. pd.messageinf.i:=pt^.value;
  1025. end
  1026. else
  1027. Message(parser_e_ill_msg_expr);
  1028. disposetree(pt);
  1029. end;
  1030. {$endif WITHDMT}
  1031. end;
  1032. procedure pd_static(pd:tabstractprocdef);
  1033. begin
  1034. if (cs_static_keyword in aktmoduleswitches) then
  1035. begin
  1036. if pd.deftype=procdef then
  1037. include(tprocdef(pd).procsym.symoptions,sp_static);
  1038. include(pd.procoptions,po_staticmethod);
  1039. end;
  1040. end;
  1041. procedure pd_override(pd:tabstractprocdef);
  1042. begin
  1043. if pd.deftype<>procdef then
  1044. internalerror(2003042611);
  1045. if not(is_class_or_interface(tprocdef(pd)._class)) then
  1046. Message(parser_e_no_object_override);
  1047. end;
  1048. procedure pd_overload(pd:tabstractprocdef);
  1049. begin
  1050. if pd.deftype<>procdef then
  1051. internalerror(2003042612);
  1052. include(tprocdef(pd).procsym.symoptions,sp_has_overloaded);
  1053. end;
  1054. procedure pd_message(pd:tabstractprocdef);
  1055. var
  1056. pt : tnode;
  1057. paracnt : longint;
  1058. begin
  1059. if pd.deftype<>procdef then
  1060. internalerror(2003042613);
  1061. if not is_class(tprocdef(pd)._class) then
  1062. Message(parser_e_msg_only_for_classes);
  1063. { check parameter type }
  1064. paracnt:=0;
  1065. pd.parast.foreach_static(@check_msg_para,@paracnt);
  1066. if paracnt<>1 then
  1067. Message(parser_e_ill_msg_param);
  1068. pt:=comp_expr(true);
  1069. if pt.nodetype=stringconstn then
  1070. begin
  1071. include(pd.procoptions,po_msgstr);
  1072. tprocdef(pd).messageinf.str:=strnew(tstringconstnode(pt).value_str);
  1073. end
  1074. else
  1075. if is_constintnode(pt) then
  1076. begin
  1077. include(pd.procoptions,po_msgint);
  1078. tprocdef(pd).messageinf.i:=tordconstnode(pt).value;
  1079. end
  1080. else
  1081. Message(parser_e_ill_msg_expr);
  1082. pt.free;
  1083. end;
  1084. procedure pd_reintroduce(pd:tabstractprocdef);
  1085. begin
  1086. if pd.deftype<>procdef then
  1087. internalerror(200401211);
  1088. if not(is_class_or_interface(tprocdef(pd)._class)) then
  1089. Message(parser_e_no_object_reintroduce);
  1090. end;
  1091. procedure pd_syscall(pd:tabstractprocdef);
  1092. {$ifdef powerpc}
  1093. var
  1094. vs : tparavarsym;
  1095. sym : tsym;
  1096. symtable : tsymtable;
  1097. {$endif powerpc}
  1098. begin
  1099. if pd.deftype<>procdef then
  1100. internalerror(2003042614);
  1101. tprocdef(pd).forwarddef:=false;
  1102. {$ifdef powerpc}
  1103. if target_info.system in [system_powerpc_morphos,system_m68k_amiga] then
  1104. begin
  1105. if consume_sym(sym,symtable) then
  1106. begin
  1107. if (sym.typ=globalvarsym) and
  1108. (
  1109. (tabstractvarsym(sym).vartype.def.deftype=pointerdef) or
  1110. is_32bitint(tabstractvarsym(sym).vartype.def)
  1111. ) then
  1112. begin
  1113. tprocdef(pd).libsym:=sym;
  1114. vs:=tparavarsym.create('$syscalllib',paranr_syscall,vs_value,tabstractvarsym(sym).vartype,[vo_is_syscall_lib,vo_is_hidden_para,vo_has_explicit_paraloc]);
  1115. paramanager.parseparaloc(vs,'A6');
  1116. pd.parast.insert(vs);
  1117. end
  1118. else
  1119. Message(parser_e_32bitint_or_pointer_variable_expected);
  1120. end;
  1121. (paramanager as tppcparamanager).create_funcretloc_info(pd,calleeside);
  1122. (paramanager as tppcparamanager).create_funcretloc_info(pd,callerside);
  1123. end;
  1124. {$endif powerpc}
  1125. tprocdef(pd).extnumber:=get_intconst;
  1126. end;
  1127. procedure pd_external(pd:tabstractprocdef);
  1128. {
  1129. If import_dll=nil the procedure is assumed to be in another
  1130. object file. In that object file it should have the name to
  1131. which import_name is pointing to. Otherwise, the procedure is
  1132. assumed to be in the DLL to which import_dll is pointing to. In
  1133. that case either import_nr<>0 or import_name<>nil is true, so
  1134. the procedure is either imported by number or by name. (DM)
  1135. }
  1136. begin
  1137. if pd.deftype<>procdef then
  1138. internalerror(2003042615);
  1139. with tprocdef(pd) do
  1140. begin
  1141. forwarddef:=false;
  1142. { forbid local external procedures }
  1143. if parast.symtablelevel>normal_function_level then
  1144. Message(parser_e_no_local_proc_external);
  1145. { If the procedure should be imported from a DLL, a constant string follows.
  1146. This isn't really correct, an contant string expression follows
  1147. so we check if an semicolon follows, else a string constant have to
  1148. follow (FK) }
  1149. if not(token=_SEMICOLON) and not(idtoken=_NAME) then
  1150. begin
  1151. import_dll:=stringdup(get_stringconst);
  1152. if (idtoken=_NAME) then
  1153. begin
  1154. consume(_NAME);
  1155. import_name:=stringdup(get_stringconst);
  1156. if import_name^='' then
  1157. message(parser_e_empty_import_name);
  1158. end;
  1159. if (idtoken=_INDEX) then
  1160. begin
  1161. {After the word index follows the index number in the DLL.}
  1162. consume(_INDEX);
  1163. import_nr:=get_intconst;
  1164. end;
  1165. { default is to used the realname of the procedure }
  1166. if (import_nr=0) and not assigned(import_name) then
  1167. import_name:=stringdup(procsym.realname);
  1168. end
  1169. else
  1170. begin
  1171. if (idtoken=_NAME) then
  1172. begin
  1173. consume(_NAME);
  1174. import_name:=stringdup(get_stringconst);
  1175. if import_name^='' then
  1176. message(parser_e_empty_import_name);
  1177. end;
  1178. end;
  1179. end;
  1180. end;
  1181. type
  1182. pd_handler=procedure(pd:tabstractprocdef);
  1183. proc_dir_rec=record
  1184. idtok : ttoken;
  1185. pd_flags : tpdflags;
  1186. handler : pd_handler;
  1187. pocall : tproccalloption;
  1188. pooption : tprocoptions;
  1189. mutexclpocall : tproccalloptions;
  1190. mutexclpotype : tproctypeoptions;
  1191. mutexclpo : tprocoptions;
  1192. end;
  1193. const
  1194. {Should contain the number of procedure directives we support.}
  1195. num_proc_directives=36;
  1196. proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
  1197. (
  1198. (
  1199. idtok:_ABSTRACT;
  1200. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1201. handler : @pd_abstract;
  1202. pocall : pocall_none;
  1203. pooption : [po_abstractmethod];
  1204. mutexclpocall : [pocall_internproc,pocall_inline];
  1205. mutexclpotype : [];
  1206. mutexclpo : [po_exports,po_interrupt,po_external]
  1207. ),(
  1208. idtok:_ALIAS;
  1209. pd_flags : [pd_implemen,pd_body,pd_notobjintf];
  1210. handler : @pd_alias;
  1211. pocall : pocall_none;
  1212. pooption : [];
  1213. mutexclpocall : [pocall_inline];
  1214. mutexclpotype : [];
  1215. mutexclpo : [po_external]
  1216. ),(
  1217. idtok:_ASMNAME;
  1218. pd_flags : [pd_interface,pd_implemen,pd_notobjintf];
  1219. handler : @pd_asmname;
  1220. pocall : pocall_cdecl;
  1221. pooption : [po_external];
  1222. mutexclpocall : [pocall_internproc,pocall_inline];
  1223. mutexclpotype : [];
  1224. mutexclpo : [po_external]
  1225. ),(
  1226. idtok:_ASSEMBLER;
  1227. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobjintf];
  1228. handler : nil;
  1229. pocall : pocall_none;
  1230. pooption : [po_assembler];
  1231. mutexclpocall : [];
  1232. mutexclpotype : [];
  1233. mutexclpo : [po_external]
  1234. ),(
  1235. idtok:_C; {same as cdecl for mode mac}
  1236. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1237. handler : nil;
  1238. pocall : pocall_cdecl;
  1239. pooption : [];
  1240. mutexclpocall : [];
  1241. mutexclpotype : [potype_constructor,potype_destructor];
  1242. mutexclpo : [po_assembler,po_external]
  1243. ),(
  1244. idtok:_CDECL;
  1245. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1246. handler : nil;
  1247. pocall : pocall_cdecl;
  1248. pooption : [];
  1249. mutexclpocall : [];
  1250. mutexclpotype : [potype_constructor,potype_destructor];
  1251. mutexclpo : [po_assembler,po_external]
  1252. ),(
  1253. idtok:_DYNAMIC;
  1254. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1255. handler : @pd_virtual;
  1256. pocall : pocall_none;
  1257. pooption : [po_virtualmethod];
  1258. mutexclpocall : [pocall_internproc,pocall_inline];
  1259. mutexclpotype : [];
  1260. mutexclpo : [po_exports,po_interrupt,po_external,po_overridingmethod]
  1261. ),(
  1262. idtok:_EXPORT;
  1263. pd_flags : [pd_body,pd_interface,pd_implemen,pd_notobjintf];
  1264. handler : @pd_export;
  1265. pocall : pocall_none;
  1266. pooption : [po_exports,po_global];
  1267. mutexclpocall : [pocall_internproc,pocall_inline];
  1268. mutexclpotype : [potype_constructor,potype_destructor];
  1269. mutexclpo : [po_external,po_interrupt]
  1270. ),(
  1271. idtok:_EXTERNAL;
  1272. pd_flags : [pd_implemen,pd_interface,pd_notobject,pd_notobjintf];
  1273. handler : @pd_external;
  1274. pocall : pocall_none;
  1275. pooption : [po_external];
  1276. mutexclpocall : [pocall_internproc,pocall_inline,pocall_syscall];
  1277. mutexclpotype : [potype_constructor,potype_destructor];
  1278. mutexclpo : [po_public,po_exports,po_interrupt,po_assembler]
  1279. ),(
  1280. idtok:_FAR;
  1281. pd_flags : [pd_implemen,pd_body,pd_interface,pd_procvar,pd_notobject,pd_notobjintf];
  1282. handler : @pd_far;
  1283. pocall : pocall_none;
  1284. pooption : [];
  1285. mutexclpocall : [pocall_internproc,pocall_inline];
  1286. mutexclpotype : [];
  1287. mutexclpo : []
  1288. ),(
  1289. idtok:_FAR16;
  1290. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar,pd_notobject];
  1291. handler : nil;
  1292. pocall : pocall_far16;
  1293. pooption : [];
  1294. mutexclpocall : [];
  1295. mutexclpotype : [];
  1296. mutexclpo : [po_external]
  1297. ),(
  1298. idtok:_FORWARD;
  1299. pd_flags : [pd_implemen,pd_notobject,pd_notobjintf];
  1300. handler : @pd_forward;
  1301. pocall : pocall_none;
  1302. pooption : [];
  1303. mutexclpocall : [pocall_internproc,pocall_inline];
  1304. mutexclpotype : [];
  1305. mutexclpo : [po_external]
  1306. ),(
  1307. idtok:_OLDFPCCALL;
  1308. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1309. handler : nil;
  1310. pocall : pocall_oldfpccall;
  1311. pooption : [];
  1312. mutexclpocall : [];
  1313. mutexclpotype : [];
  1314. mutexclpo : []
  1315. ),(
  1316. idtok:_INLINE;
  1317. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobjintf];
  1318. handler : @pd_inline;
  1319. pocall : pocall_inline;
  1320. pooption : [];
  1321. mutexclpocall : [];
  1322. mutexclpotype : [potype_constructor,potype_destructor];
  1323. mutexclpo : [po_exports,po_external,po_interrupt,po_virtualmethod]
  1324. ),(
  1325. idtok:_INTERNCONST;
  1326. pd_flags : [pd_interface,pd_body,pd_notobject,pd_notobjintf];
  1327. handler : @pd_internconst;
  1328. pocall : pocall_none;
  1329. pooption : [po_internconst];
  1330. mutexclpocall : [];
  1331. mutexclpotype : [potype_operator];
  1332. mutexclpo : []
  1333. ),(
  1334. idtok:_INTERNPROC;
  1335. pd_flags : [pd_interface,pd_notobject,pd_notobjintf];
  1336. handler : @pd_internproc;
  1337. pocall : pocall_internproc;
  1338. pooption : [];
  1339. mutexclpocall : [];
  1340. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1341. mutexclpo : [po_exports,po_external,po_interrupt,po_assembler,po_iocheck,po_virtualmethod]
  1342. ),(
  1343. idtok:_INTERRUPT;
  1344. pd_flags : [pd_implemen,pd_body,pd_notobject,pd_notobjintf];
  1345. handler : @pd_interrupt;
  1346. pocall : pocall_none;
  1347. pooption : [po_interrupt];
  1348. mutexclpocall : [pocall_internproc,pocall_cdecl,pocall_cppdecl,pocall_stdcall,
  1349. pocall_inline,pocall_pascal,pocall_far16,pocall_oldfpccall];
  1350. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1351. mutexclpo : [po_external]
  1352. ),(
  1353. idtok:_IOCHECK;
  1354. pd_flags : [pd_implemen,pd_body,pd_notobjintf];
  1355. handler : nil;
  1356. pocall : pocall_none;
  1357. pooption : [po_iocheck];
  1358. mutexclpocall : [pocall_internproc];
  1359. mutexclpotype : [];
  1360. mutexclpo : [po_external]
  1361. ),(
  1362. idtok:_MESSAGE;
  1363. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1364. handler : @pd_message;
  1365. pocall : pocall_none;
  1366. pooption : []; { can be po_msgstr or po_msgint }
  1367. mutexclpocall : [pocall_inline,pocall_internproc];
  1368. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1369. mutexclpo : [po_interrupt,po_external]
  1370. ),(
  1371. idtok:_NEAR;
  1372. pd_flags : [pd_implemen,pd_body,pd_procvar,pd_notobjintf];
  1373. handler : @pd_near;
  1374. pocall : pocall_none;
  1375. pooption : [];
  1376. mutexclpocall : [pocall_internproc];
  1377. mutexclpotype : [];
  1378. mutexclpo : []
  1379. ),(
  1380. idtok:_NOSTACKFRAME;
  1381. pd_flags : [pd_implemen,pd_body,pd_procvar,pd_notobjintf];
  1382. handler : nil;
  1383. pocall : pocall_none;
  1384. pooption : [po_nostackframe];
  1385. mutexclpocall : [pocall_internproc];
  1386. mutexclpotype : [];
  1387. mutexclpo : []
  1388. ),(
  1389. idtok:_OVERLOAD;
  1390. pd_flags : [pd_implemen,pd_interface,pd_body];
  1391. handler : @pd_overload;
  1392. pocall : pocall_none;
  1393. pooption : [po_overload];
  1394. mutexclpocall : [pocall_internproc];
  1395. mutexclpotype : [];
  1396. mutexclpo : []
  1397. ),(
  1398. idtok:_OVERRIDE;
  1399. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1400. handler : @pd_override;
  1401. pocall : pocall_none;
  1402. pooption : [po_overridingmethod,po_virtualmethod];
  1403. mutexclpocall : [pocall_inline,pocall_internproc];
  1404. mutexclpotype : [];
  1405. mutexclpo : [po_exports,po_external,po_interrupt,po_virtualmethod]
  1406. ),(
  1407. idtok:_PASCAL;
  1408. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1409. handler : nil;
  1410. pocall : pocall_pascal;
  1411. pooption : [];
  1412. mutexclpocall : [];
  1413. mutexclpotype : [potype_constructor,potype_destructor];
  1414. mutexclpo : [po_external]
  1415. ),(
  1416. idtok:_PUBLIC;
  1417. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobject,pd_notobjintf];
  1418. handler : @pd_public;
  1419. pocall : pocall_none;
  1420. pooption : [po_public,po_global];
  1421. mutexclpocall : [pocall_internproc,pocall_inline];
  1422. mutexclpotype : [];
  1423. mutexclpo : [po_external]
  1424. ),(
  1425. idtok:_REGISTER;
  1426. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1427. handler : nil;
  1428. pocall : pocall_register;
  1429. pooption : [];
  1430. mutexclpocall : [];
  1431. mutexclpotype : [potype_constructor,potype_destructor];
  1432. mutexclpo : [po_external]
  1433. ),(
  1434. idtok:_REINTRODUCE;
  1435. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1436. handler : @pd_reintroduce;
  1437. pocall : pocall_none;
  1438. pooption : [po_reintroduce];
  1439. mutexclpocall : [pocall_inline,pocall_internproc];
  1440. mutexclpotype : [];
  1441. mutexclpo : [po_external,po_interrupt,po_exports,po_overridingmethod]
  1442. ),(
  1443. idtok:_SAFECALL;
  1444. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1445. handler : nil;
  1446. pocall : pocall_safecall;
  1447. pooption : [];
  1448. mutexclpocall : [];
  1449. mutexclpotype : [potype_constructor,potype_destructor];
  1450. mutexclpo : [po_external]
  1451. ),(
  1452. idtok:_SOFTFLOAT;
  1453. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1454. handler : nil;
  1455. pocall : pocall_softfloat;
  1456. pooption : [];
  1457. mutexclpocall : [];
  1458. mutexclpotype : [potype_constructor,potype_destructor];
  1459. { it's available with po_external because the libgcc floating point routines on the arm
  1460. uses this calling convention }
  1461. mutexclpo : []
  1462. ),(
  1463. idtok:_STATIC;
  1464. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1465. handler : @pd_static;
  1466. pocall : pocall_none;
  1467. pooption : [po_staticmethod];
  1468. mutexclpocall : [pocall_inline,pocall_internproc];
  1469. mutexclpotype : [potype_constructor,potype_destructor];
  1470. mutexclpo : [po_external,po_interrupt,po_exports]
  1471. ),(
  1472. idtok:_STDCALL;
  1473. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1474. handler : nil;
  1475. pocall : pocall_stdcall;
  1476. pooption : [];
  1477. mutexclpocall : [];
  1478. mutexclpotype : [potype_constructor,potype_destructor];
  1479. mutexclpo : [po_external]
  1480. ),(
  1481. idtok:_SYSCALL;
  1482. pd_flags : [pd_interface,pd_implemen,pd_notobject,pd_notobjintf];
  1483. handler : @pd_syscall;
  1484. pocall : pocall_syscall;
  1485. pooption : [];
  1486. mutexclpocall : [];
  1487. mutexclpotype : [potype_constructor,potype_destructor];
  1488. mutexclpo : [po_external,po_assembler,po_interrupt,po_exports]
  1489. ),(
  1490. idtok:_VIRTUAL;
  1491. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1492. handler : @pd_virtual;
  1493. pocall : pocall_none;
  1494. pooption : [po_virtualmethod];
  1495. mutexclpocall : [pocall_inline,pocall_internproc];
  1496. mutexclpotype : [];
  1497. mutexclpo : [po_external,po_interrupt,po_exports,po_overridingmethod]
  1498. ),(
  1499. idtok:_CPPDECL;
  1500. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1501. handler : nil;
  1502. pocall : pocall_cppdecl;
  1503. pooption : [];
  1504. mutexclpocall : [];
  1505. mutexclpotype : [potype_constructor,potype_destructor];
  1506. mutexclpo : [po_assembler,po_external,po_virtualmethod]
  1507. ),(
  1508. idtok:_VARARGS;
  1509. pd_flags : [pd_interface,pd_implemen,pd_procvar];
  1510. handler : nil;
  1511. pocall : pocall_none;
  1512. pooption : [po_varargs];
  1513. mutexclpocall : [pocall_internproc,pocall_stdcall,pocall_register,
  1514. pocall_inline,pocall_far16,pocall_oldfpccall];
  1515. mutexclpotype : [];
  1516. mutexclpo : [po_assembler,po_interrupt]
  1517. ),(
  1518. idtok:_COMPILERPROC;
  1519. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobjintf];
  1520. handler : nil;
  1521. pocall : pocall_compilerproc;
  1522. pooption : [];
  1523. mutexclpocall : [];
  1524. mutexclpotype : [potype_constructor,potype_destructor];
  1525. mutexclpo : [po_interrupt]
  1526. )
  1527. );
  1528. function check_proc_directive(isprocvar:boolean):boolean;
  1529. var
  1530. i : longint;
  1531. begin
  1532. result:=false;
  1533. for i:=1 to num_proc_directives do
  1534. if proc_direcdata[i].idtok=idtoken then
  1535. begin
  1536. if ((not isprocvar) or
  1537. (pd_procvar in proc_direcdata[i].pd_flags)) and
  1538. { don't eat a public directive in classes }
  1539. not((idtoken=_PUBLIC) and (symtablestack.symtabletype=objectsymtable)) then
  1540. result:=true;
  1541. exit;
  1542. end;
  1543. end;
  1544. function parse_proc_direc(pd:tabstractprocdef;var pdflags:tpdflags):boolean;
  1545. {
  1546. Parse the procedure directive, returns true if a correct directive is found
  1547. }
  1548. var
  1549. p : longint;
  1550. found : boolean;
  1551. name : stringid;
  1552. begin
  1553. parse_proc_direc:=false;
  1554. name:=tokeninfo^[idtoken].str;
  1555. found:=false;
  1556. { Hint directive? Then exit immediatly }
  1557. if (m_hintdirective in aktmodeswitches) then
  1558. begin
  1559. case idtoken of
  1560. _LIBRARY,
  1561. _PLATFORM,
  1562. _UNIMPLEMENTED,
  1563. _DEPRECATED :
  1564. exit;
  1565. end;
  1566. end;
  1567. { C directive is MAC only, because it breaks too much existing code
  1568. on other platforms (PFV) }
  1569. if (idtoken=_C) and
  1570. not(m_mac in aktmodeswitches) then
  1571. exit;
  1572. { retrieve data for directive if found }
  1573. for p:=1 to num_proc_directives do
  1574. if proc_direcdata[p].idtok=idtoken then
  1575. begin
  1576. found:=true;
  1577. break;
  1578. end;
  1579. { Check if the procedure directive is known }
  1580. if not found then
  1581. begin
  1582. { parsing a procvar type the name can be any
  1583. next variable !! }
  1584. if ((pdflags * [pd_procvar,pd_object])=[]) and
  1585. not(idtoken=_PROPERTY) then
  1586. Message1(parser_w_unknown_proc_directive_ignored,name);
  1587. exit;
  1588. end;
  1589. { static needs a special treatment }
  1590. if (idtoken=_STATIC) and not (cs_static_keyword in aktmoduleswitches) then
  1591. exit;
  1592. { Conflicts between directives ? }
  1593. if (pd.proctypeoption in proc_direcdata[p].mutexclpotype) or
  1594. (pd.proccalloption in proc_direcdata[p].mutexclpocall) or
  1595. ((pd.procoptions*proc_direcdata[p].mutexclpo)<>[]) then
  1596. begin
  1597. Message1(parser_e_proc_dir_conflict,name);
  1598. exit;
  1599. end;
  1600. { set calling convention }
  1601. if proc_direcdata[p].pocall<>pocall_none then
  1602. begin
  1603. if (po_hascallingconvention in pd.procoptions) then
  1604. begin
  1605. Message2(parser_w_proc_overriding_calling,
  1606. proccalloptionStr[pd.proccalloption],
  1607. proccalloptionStr[proc_direcdata[p].pocall]);
  1608. end;
  1609. { check if the target processor supports this calling convention }
  1610. if not(proc_direcdata[p].pocall in supported_calling_conventions) then
  1611. begin
  1612. Message1(parser_e_illegal_calling_convention,proccalloptionStr[proc_direcdata[p].pocall]);
  1613. { recover }
  1614. proc_direcdata[p].pocall:=pocall_stdcall;
  1615. end;
  1616. pd.proccalloption:=proc_direcdata[p].pocall;
  1617. include(pd.procoptions,po_hascallingconvention);
  1618. end;
  1619. { check if method and directive not for object, like public.
  1620. This needs to be checked also for procvars }
  1621. if (pd_notobject in proc_direcdata[p].pd_flags) and
  1622. (pd.owner.symtabletype=objectsymtable) then
  1623. exit;
  1624. if pd.deftype=procdef then
  1625. begin
  1626. { Check if the directive is only for objects }
  1627. if (pd_object in proc_direcdata[p].pd_flags) and
  1628. not assigned(tprocdef(pd)._class) then
  1629. exit;
  1630. { check if method and directive not for interface }
  1631. if (pd_notobjintf in proc_direcdata[p].pd_flags) and
  1632. is_interface(tprocdef(pd)._class) then
  1633. exit;
  1634. end
  1635. { don't eat public in object/class declarions }
  1636. else if (pd.deftype=procvardef) and (proc_direcdata[p].idtok=_PUBLIC) and
  1637. (symtablestack.symtabletype=objectsymtable) then
  1638. exit;
  1639. { consume directive, and turn flag on }
  1640. consume(token);
  1641. parse_proc_direc:=true;
  1642. { Check the pd_flags if the directive should be allowed }
  1643. if (pd_interface in pdflags) and
  1644. not(pd_interface in proc_direcdata[p].pd_flags) then
  1645. begin
  1646. Message1(parser_e_proc_dir_not_allowed_in_interface,name);
  1647. exit;
  1648. end;
  1649. if (pd_implemen in pdflags) and
  1650. not(pd_implemen in proc_direcdata[p].pd_flags) then
  1651. begin
  1652. Message1(parser_e_proc_dir_not_allowed_in_implementation,name);
  1653. exit;
  1654. end;
  1655. if (pd_procvar in pdflags) and
  1656. not(pd_procvar in proc_direcdata[p].pd_flags) then
  1657. begin
  1658. Message1(parser_e_proc_dir_not_allowed_in_procvar,name);
  1659. exit;
  1660. end;
  1661. { Return the new pd_flags }
  1662. if not(pd_body in proc_direcdata[p].pd_flags) then
  1663. exclude(pdflags,pd_body);
  1664. { Add the correct flag }
  1665. pd.procoptions:=pd.procoptions+proc_direcdata[p].pooption;
  1666. { Call the handler }
  1667. if pointer(proc_direcdata[p].handler)<>nil then
  1668. proc_direcdata[p].handler(pd);
  1669. end;
  1670. function proc_get_importname(pd:tprocdef):string;
  1671. begin
  1672. result:='';
  1673. if not(po_external in pd.procoptions) then
  1674. internalerror(200412151);
  1675. { import by number? }
  1676. if pd.import_nr<>0 then
  1677. begin
  1678. { Nothing to do }
  1679. end
  1680. else
  1681. { external name specified }
  1682. if assigned(pd.import_name) then
  1683. begin
  1684. { Win32 imports need to use the normal name since to functions
  1685. can refer to the same DLL function. This is also needed for compatability
  1686. with Delphi and TP7 }
  1687. if not(
  1688. assigned(pd.import_dll) and
  1689. (target_info.system in [system_i386_win32,system_i386_wdosx,
  1690. system_i386_emx,system_i386_os2])
  1691. ) then
  1692. begin
  1693. if not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1694. result:=pd.import_name^
  1695. else
  1696. result:=target_info.Cprefix+pd.import_name^;
  1697. end;
  1698. end
  1699. else
  1700. begin
  1701. { Default names when importing variables }
  1702. case pd.proccalloption of
  1703. pocall_cdecl :
  1704. begin
  1705. if assigned(pd._class) then
  1706. result:=target_info.Cprefix+pd._class.objrealname^+'_'+pd.procsym.realname
  1707. else
  1708. result:=target_info.Cprefix+pd.procsym.realname;
  1709. end;
  1710. pocall_cppdecl :
  1711. begin
  1712. result:=target_info.Cprefix+pd.cplusplusmangledname;
  1713. end;
  1714. else
  1715. begin
  1716. {In MacPas a single "external" has the same effect as "external name 'xxx'" }
  1717. if (m_mac in aktmodeswitches) then
  1718. result:=tprocdef(pd).procsym.realname;
  1719. end;
  1720. end;
  1721. end;
  1722. end;
  1723. procedure proc_set_mangledname(pd:tprocdef);
  1724. var
  1725. s : string;
  1726. begin
  1727. { When the mangledname is already set we aren't allowed to change
  1728. it because it can already be used somewhere (PFV) }
  1729. if not(po_has_mangledname in pd.procoptions) then
  1730. begin
  1731. if (po_external in pd.procoptions) then
  1732. begin
  1733. { External Procedures are only allowed to change the mangledname
  1734. in their first declaration }
  1735. if (pd.forwarddef or (not pd.hasforward)) then
  1736. begin
  1737. s:=proc_get_importname(pd);
  1738. if s<>'' then
  1739. pd.setmangledname(s);
  1740. end;
  1741. end
  1742. else
  1743. { Normal procedures }
  1744. begin
  1745. case pd.proccalloption of
  1746. pocall_compilerproc :
  1747. begin
  1748. pd.setmangledname(lower(pd.procsym.name));
  1749. end;
  1750. end;
  1751. end;
  1752. end;
  1753. { Public/exported alias names }
  1754. if (po_public in pd.procoptions) and
  1755. not(po_has_public_name in pd.procoptions) then
  1756. begin
  1757. case pd.proccalloption of
  1758. pocall_cdecl :
  1759. begin
  1760. if assigned(pd._class) then
  1761. pd.aliasnames.insert(target_info.Cprefix+pd._class.objrealname^+'_'+pd.procsym.realname)
  1762. else
  1763. pd.aliasnames.insert(target_info.Cprefix+pd.procsym.realname);
  1764. end;
  1765. pocall_cppdecl :
  1766. begin
  1767. pd.aliasnames.insert(target_info.Cprefix+pd.cplusplusmangledname);
  1768. end;
  1769. end;
  1770. { prevent adding the alias a second time }
  1771. include(pd.procoptions,po_has_public_name);
  1772. end;
  1773. end;
  1774. procedure handle_calling_convention(pd:tabstractprocdef);
  1775. begin
  1776. { set the default calling convention if none provided }
  1777. if not(po_hascallingconvention in pd.procoptions) then
  1778. pd.proccalloption:=aktdefproccall
  1779. else
  1780. begin
  1781. if pd.proccalloption=pocall_none then
  1782. internalerror(200309081);
  1783. end;
  1784. { handle proccall specific settings }
  1785. case pd.proccalloption of
  1786. pocall_cdecl,
  1787. pocall_cppdecl :
  1788. begin
  1789. { check C cdecl para types }
  1790. pd.parast.foreach_static(@check_c_para,nil);
  1791. end;
  1792. pocall_far16 :
  1793. begin
  1794. { Temporary stub, must be rewritten to support OS/2 far16 }
  1795. Message1(parser_w_proc_directive_ignored,'FAR16');
  1796. end;
  1797. pocall_inline :
  1798. begin
  1799. if not(cs_support_inline in aktmoduleswitches) then
  1800. begin
  1801. Message(parser_e_proc_inline_not_supported);
  1802. pd.proccalloption:=pocall_default;
  1803. end;
  1804. end;
  1805. end;
  1806. { For varargs directive also cdecl and external must be defined }
  1807. if (po_varargs in pd.procoptions) then
  1808. begin
  1809. { check first for external in the interface, if available there
  1810. then the cdecl must also be there since there is no implementation
  1811. available to contain it }
  1812. if parse_only then
  1813. begin
  1814. { if external is available, then cdecl must also be available,
  1815. procvars don't need external }
  1816. if not((po_external in pd.procoptions) or
  1817. (pd.deftype=procvardef)) and
  1818. not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1819. Message(parser_e_varargs_need_cdecl_and_external);
  1820. end
  1821. else
  1822. begin
  1823. { both must be defined now }
  1824. if not((po_external in pd.procoptions) or
  1825. (pd.deftype=procvardef)) or
  1826. not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1827. Message(parser_e_varargs_need_cdecl_and_external);
  1828. end;
  1829. end;
  1830. { Make var parameters regable, this must be done after the calling
  1831. convention is set. }
  1832. pd.parast.foreach_static(@set_addr_param_regable,pd);
  1833. { insert hidden high parameters }
  1834. pd.parast.foreach_static(@insert_hidden_para,pd);
  1835. { insert hidden self parameter }
  1836. insert_self_and_vmt_para(pd);
  1837. { insert funcret parameter if required }
  1838. insert_funcret_para(pd);
  1839. { insert parentfp parameter if required }
  1840. insert_parentfp_para(pd);
  1841. { Calculate parameter tlist }
  1842. pd.calcparas;
  1843. end;
  1844. procedure parse_proc_directives(pd:tabstractprocdef;var pdflags:tpdflags);
  1845. {
  1846. Parse the procedure directives. It does not matter if procedure directives
  1847. are written using ;procdir; or ['procdir'] syntax.
  1848. }
  1849. var
  1850. res : boolean;
  1851. begin
  1852. if (m_mac in aktmodeswitches) and (cs_externally_visible in aktlocalswitches) then
  1853. begin
  1854. tprocdef(pd).aliasnames.insert(tprocdef(pd).procsym.realname);
  1855. include(pd.procoptions,po_public);
  1856. include(pd.procoptions,po_has_public_name);
  1857. include(pd.procoptions,po_global);
  1858. end;
  1859. while token in [_ID,_LECKKLAMMER] do
  1860. begin
  1861. if try_to_consume(_LECKKLAMMER) then
  1862. begin
  1863. repeat
  1864. parse_proc_direc(pd,pdflags);
  1865. until not try_to_consume(_COMMA);
  1866. consume(_RECKKLAMMER);
  1867. { we always expect at least '[];' }
  1868. res:=true;
  1869. end
  1870. else
  1871. begin
  1872. res:=parse_proc_direc(pd,pdflags);
  1873. end;
  1874. { A procedure directive normally followed by a semicolon, but in
  1875. a const section or reading a type we should stop when _EQUAL is found,
  1876. because a constant/default value follows }
  1877. if res then
  1878. begin
  1879. if (block_type in [bt_const,bt_type]) and
  1880. (token=_EQUAL) then
  1881. break;
  1882. { support procedure proc;stdcall export; }
  1883. if not(check_proc_directive((pd.deftype=procvardef))) then
  1884. consume(_SEMICOLON);
  1885. end
  1886. else
  1887. break;
  1888. end;
  1889. end;
  1890. procedure parse_var_proc_directives(sym:tsym);
  1891. var
  1892. pdflags : tpdflags;
  1893. pd : tabstractprocdef;
  1894. begin
  1895. pdflags:=[pd_procvar];
  1896. pd:=nil;
  1897. case sym.typ of
  1898. fieldvarsym,
  1899. globalvarsym,
  1900. localvarsym,
  1901. paravarsym :
  1902. pd:=tabstractprocdef(tabstractvarsym(sym).vartype.def);
  1903. typedconstsym :
  1904. pd:=tabstractprocdef(ttypedconstsym(sym).typedconsttype.def);
  1905. typesym :
  1906. pd:=tabstractprocdef(ttypesym(sym).restype.def);
  1907. else
  1908. internalerror(2003042617);
  1909. end;
  1910. if pd.deftype<>procvardef then
  1911. internalerror(2003042618);
  1912. { names should never be used anyway }
  1913. parse_proc_directives(pd,pdflags);
  1914. end;
  1915. procedure parse_object_proc_directives(pd:tabstractprocdef);
  1916. var
  1917. pdflags : tpdflags;
  1918. begin
  1919. pdflags:=[pd_object];
  1920. parse_proc_directives(pd,pdflags);
  1921. end;
  1922. function proc_add_definition(var pd:tprocdef):boolean;
  1923. {
  1924. Add definition aprocdef to the overloaded definitions of aprocsym. If a
  1925. forwarddef is found and reused it returns true
  1926. }
  1927. var
  1928. hd : tprocdef;
  1929. ad,fd : tsym;
  1930. s1,s2 : stringid;
  1931. i : cardinal;
  1932. forwardfound : boolean;
  1933. po_comp : tprocoptions;
  1934. aprocsym : tprocsym;
  1935. begin
  1936. forwardfound:=false;
  1937. aprocsym:=tprocsym(pd.procsym);
  1938. { check overloaded functions if the same function already exists }
  1939. for i:=1 to aprocsym.procdef_count do
  1940. begin
  1941. hd:=aprocsym.procdef[i];
  1942. { Skip overloaded definitions that are declared in other
  1943. units }
  1944. if hd.procsym<>aprocsym then
  1945. continue;
  1946. { check the parameters, for delphi/tp it is possible to
  1947. leave the parameters away in the implementation (forwarddef=false).
  1948. But for an overload declared function this is not allowed }
  1949. if { check if empty implementation arguments match is allowed }
  1950. (
  1951. not(m_repeat_forward in aktmodeswitches) and
  1952. not(pd.forwarddef) and
  1953. (pd.maxparacount=0) and
  1954. not(po_overload in hd.procoptions)
  1955. ) or
  1956. { check arguments }
  1957. (
  1958. (compare_paras(pd.paras,hd.paras,cp_none,[cpo_comparedefaultvalue])>=te_equal) and
  1959. { for operators equal_paras is not enough !! }
  1960. ((pd.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
  1961. equal_defs(hd.rettype.def,pd.rettype.def))
  1962. ) then
  1963. begin
  1964. { Check if we've found the forwarddef, if found then
  1965. we need to update the forward def with the current
  1966. implementation settings }
  1967. if hd.forwarddef then
  1968. begin
  1969. forwardfound:=true;
  1970. { Check if the procedure type and return type are correct,
  1971. also the parameters must match also with the type }
  1972. if (hd.proctypeoption<>pd.proctypeoption) or
  1973. (
  1974. (m_repeat_forward in aktmodeswitches) and
  1975. (not((pd.maxparacount=0) or
  1976. (compare_paras(pd.paras,hd.paras,cp_all,[cpo_comparedefaultvalue])>=te_equal)))
  1977. ) or
  1978. (
  1979. ((m_repeat_forward in aktmodeswitches) or
  1980. not(is_void(pd.rettype.def))) and
  1981. (not equal_defs(hd.rettype.def,pd.rettype.def))) then
  1982. begin
  1983. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,
  1984. pd.fullprocname(false));
  1985. aprocsym.write_parameter_lists(pd);
  1986. break;
  1987. end;
  1988. { Check if both are declared forward }
  1989. if hd.forwarddef and pd.forwarddef then
  1990. begin
  1991. MessagePos1(pd.fileinfo,parser_e_function_already_declared_public_forward,
  1992. pd.fullprocname(false));
  1993. end;
  1994. { internconst or internproc only need to be defined once }
  1995. if (hd.proccalloption=pocall_internproc) then
  1996. pd.proccalloption:=hd.proccalloption
  1997. else
  1998. if (pd.proccalloption=pocall_internproc) then
  1999. hd.proccalloption:=pd.proccalloption;
  2000. { Check calling convention }
  2001. if (hd.proccalloption<>pd.proccalloption) then
  2002. begin
  2003. { In delphi it is possible to specify the calling
  2004. convention in the interface or implementation if
  2005. there was no convention specified in the other
  2006. part }
  2007. if (m_delphi in aktmodeswitches) then
  2008. begin
  2009. if not(po_hascallingconvention in pd.procoptions) then
  2010. pd.proccalloption:=hd.proccalloption
  2011. else
  2012. if not(po_hascallingconvention in hd.procoptions) then
  2013. hd.proccalloption:=pd.proccalloption
  2014. else
  2015. begin
  2016. MessagePos(pd.fileinfo,parser_e_call_convention_dont_match_forward);
  2017. aprocsym.write_parameter_lists(pd);
  2018. { restore interface settings }
  2019. pd.proccalloption:=hd.proccalloption;
  2020. end;
  2021. end
  2022. else
  2023. begin
  2024. MessagePos(pd.fileinfo,parser_e_call_convention_dont_match_forward);
  2025. aprocsym.write_parameter_lists(pd);
  2026. { restore interface settings }
  2027. pd.proccalloption:=hd.proccalloption;
  2028. end;
  2029. end;
  2030. { Check procedure options, Delphi requires that class is
  2031. repeated in the implementation for class methods }
  2032. if (m_fpc in aktmodeswitches) then
  2033. po_comp:=[po_varargs,po_methodpointer,po_interrupt]
  2034. else
  2035. po_comp:=[po_classmethod,po_methodpointer];
  2036. if ((po_comp * hd.procoptions)<>(po_comp * pd.procoptions)) then
  2037. begin
  2038. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,
  2039. pd.fullprocname(false));
  2040. aprocsym.write_parameter_lists(pd);
  2041. { This error is non-fatal, we can recover }
  2042. end;
  2043. { Forward declaration is external? }
  2044. if (po_external in hd.procoptions) then
  2045. MessagePos(pd.fileinfo,parser_e_proc_already_external);
  2046. { Check parameters }
  2047. if (m_repeat_forward in aktmodeswitches) or
  2048. (pd.minparacount>0) then
  2049. begin
  2050. { If mangled names are equal then they have the same amount of arguments }
  2051. { We can check the names of the arguments }
  2052. { both symtables are in the same order from left to right }
  2053. ad:=tsym(hd.parast.symindex.first);
  2054. fd:=tsym(pd.parast.symindex.first);
  2055. repeat
  2056. { skip default parameter constsyms }
  2057. while assigned(ad) and (ad.typ<>paravarsym) do
  2058. ad:=tsym(ad.indexnext);
  2059. while assigned(fd) and (fd.typ<>paravarsym) do
  2060. fd:=tsym(fd.indexnext);
  2061. { stop when one of the two lists is at the end }
  2062. if not assigned(ad) or not assigned(fd) then
  2063. break;
  2064. { retrieve names, remove reg for register parameters }
  2065. s1:=ad.name;
  2066. s2:=fd.name;
  2067. { compare names }
  2068. if (s1<>s2) then
  2069. begin
  2070. MessagePos3(pd.fileinfo,parser_e_header_different_var_names,
  2071. aprocsym.name,s1,s2);
  2072. break;
  2073. end;
  2074. ad:=tsym(ad.indexnext);
  2075. fd:=tsym(fd.indexnext);
  2076. until false;
  2077. if assigned(ad) xor assigned(fd) then
  2078. internalerror(200204178);
  2079. end;
  2080. { Everything is checked, now we can update the forward declaration
  2081. with the new data from the implementation }
  2082. hd.forwarddef:=pd.forwarddef;
  2083. hd.hasforward:=true;
  2084. hd.procoptions:=hd.procoptions+pd.procoptions;
  2085. if hd.extnumber=65535 then
  2086. hd.extnumber:=pd.extnumber;
  2087. while not pd.aliasnames.empty do
  2088. hd.aliasnames.insert(pd.aliasnames.getfirst);
  2089. { update fileinfo so position references the implementation,
  2090. also update funcretsym if it is already generated }
  2091. hd.fileinfo:=pd.fileinfo;
  2092. if assigned(hd.funcretsym) then
  2093. hd.funcretsym.fileinfo:=pd.fileinfo;
  2094. { import names }
  2095. if assigned(pd.import_dll) then
  2096. begin
  2097. stringdispose(hd.import_dll);
  2098. hd.import_dll:=stringdup(pd.import_dll^);
  2099. end;
  2100. if assigned(pd.import_name) then
  2101. begin
  2102. stringdispose(hd.import_name);
  2103. hd.import_name:=stringdup(pd.import_name^);
  2104. end;
  2105. hd.import_nr:=pd.import_nr;
  2106. { for compilerproc defines we need to rename and update the
  2107. symbolname to lowercase }
  2108. if (pd.proccalloption=pocall_compilerproc) then
  2109. begin
  2110. { rename to lowercase so users can't access it }
  2111. aprocsym.owner.rename(aprocsym.name,lower(aprocsym.name));
  2112. { also update the realname that is stored in the ppu }
  2113. stringdispose(aprocsym._realname);
  2114. aprocsym._realname:=stringdup('$'+aprocsym.name);
  2115. { the mangeled name is already changed by the pd_compilerproc }
  2116. { handler. It must be done immediately because if we have a }
  2117. { call to a compilerproc before it's implementation is }
  2118. { encountered, it must already use the new mangled name (JM) }
  2119. end;
  2120. { the procdef will be released by the symtable, we release
  2121. at least the parast }
  2122. pd.releasemem;
  2123. pd:=hd;
  2124. end
  2125. else
  2126. begin
  2127. { abstract methods aren't forward defined, but this }
  2128. { needs another error message }
  2129. if (po_abstractmethod in hd.procoptions) then
  2130. MessagePos(pd.fileinfo,parser_e_abstract_no_definition)
  2131. else
  2132. begin
  2133. MessagePos(pd.fileinfo,parser_e_overloaded_have_same_parameters);
  2134. aprocsym.write_parameter_lists(pd);
  2135. end;
  2136. end;
  2137. { we found one proc with the same arguments, there are no others
  2138. so we can stop }
  2139. break;
  2140. end;
  2141. { check for allowing overload directive }
  2142. if not(m_fpc in aktmodeswitches) then
  2143. begin
  2144. { overload directive turns on overloading }
  2145. if ((po_overload in pd.procoptions) or
  2146. (po_overload in hd.procoptions)) then
  2147. begin
  2148. { check if all procs have overloading, but not if the proc is a method or
  2149. already declared forward, then the check is already done }
  2150. if not(hd.hasforward or
  2151. assigned(pd._class) or
  2152. (pd.forwarddef<>hd.forwarddef) or
  2153. ((po_overload in pd.procoptions) and
  2154. (po_overload in hd.procoptions))) then
  2155. begin
  2156. MessagePos1(pd.fileinfo,parser_e_no_overload_for_all_procs,aprocsym.realname);
  2157. break;
  2158. end;
  2159. end
  2160. else
  2161. begin
  2162. if not(hd.forwarddef) then
  2163. begin
  2164. MessagePos(pd.fileinfo,parser_e_procedure_overloading_is_off);
  2165. break;
  2166. end;
  2167. end;
  2168. end; { equal arguments }
  2169. end;
  2170. { if we didn't reuse a forwarddef then we add the procdef to the overloaded
  2171. list }
  2172. if not forwardfound then
  2173. aprocsym.addprocdef(pd);
  2174. proc_add_definition:=forwardfound;
  2175. end;
  2176. end.
  2177. {
  2178. $Log$
  2179. Revision 1.220 2004-12-15 19:30:32 peter
  2180. * syscall with sysv abi for morphos
  2181. Revision 1.219 2004/12/15 16:00:16 peter
  2182. * external is again allowed in implementation
  2183. Revision 1.218 2004/12/07 16:11:52 peter
  2184. * set vo_explicit_paraloc flag
  2185. Revision 1.217 2004/12/05 12:28:11 peter
  2186. * procvar handling for tp procvar mode fixed
  2187. * proc to procvar moved from addrnode to typeconvnode
  2188. * inlininginfo is now allocated only for inline routines that
  2189. can be inlined, introduced a new flag po_has_inlining_info
  2190. Revision 1.216 2004/12/05 00:32:56 olle
  2191. + bugfix for $Z+ for mode macpas
  2192. Revision 1.215 2004/11/29 21:50:08 peter
  2193. * public is allowd in interface
  2194. Revision 1.214 2004/11/29 17:48:34 peter
  2195. * when importing by index don't change mangledname
  2196. Revision 1.213 2004/11/22 12:22:25 jonas
  2197. * fixed importing of cdecl routines for OS'es which have a cprefix
  2198. Revision 1.212 2004/11/21 17:54:59 peter
  2199. * ttempcreatenode.create_reg merged into .create with parameter
  2200. whether a register is allowed
  2201. * funcret_paraloc renamed to funcretloc
  2202. Revision 1.211 2004/11/21 16:33:19 peter
  2203. * fixed message methods
  2204. * fixed typo with win32 dll import from implementation
  2205. * released external check
  2206. Revision 1.210 2004/11/19 08:17:01 michael
  2207. * Split po_public into po_public and po_global (Peter)
  2208. Revision 1.209 2004/11/17 22:41:41 peter
  2209. * make some checks EXTDEBUG only for now so linux cycles again
  2210. Revision 1.208 2004/11/17 22:21:35 peter
  2211. mangledname setting moved to place after the complete proc declaration is read
  2212. import generation moved to place where body is also parsed (still gives problems with win32)
  2213. Revision 1.207 2004/11/16 22:09:57 peter
  2214. * _mangledname for symbols moved only to symbols that really need it
  2215. * overload number removed, add function result type to the mangledname fo
  2216. procdefs
  2217. Revision 1.206 2004/11/16 20:32:40 peter
  2218. * fixes for win32 mangledname
  2219. Revision 1.205 2004/11/15 23:35:31 peter
  2220. * tparaitem removed, use tparavarsym instead
  2221. * parameter order is now calculated from paranr value in tparavarsym
  2222. Revision 1.204 2004/11/14 16:26:29 florian
  2223. * fixed morphos syscall
  2224. Revision 1.203 2004/11/11 19:31:33 peter
  2225. * fixed compile of powerpc,sparc,arm
  2226. Revision 1.202 2004/11/09 22:32:59 peter
  2227. * small m68k updates to bring it up2date
  2228. * give better error for external local variable
  2229. Revision 1.201 2004/11/09 17:26:47 peter
  2230. * fixed wrong typecasts
  2231. Revision 1.200 2004/11/08 22:09:59 peter
  2232. * tvarsym splitted
  2233. Revision 1.199 2004/11/05 21:16:55 peter
  2234. * rename duplicate symbols and insert with unique name in the
  2235. symtable
  2236. Revision 1.198 2004/10/31 18:54:24 peter
  2237. * $fpctarget expands to <cpu>-<os>
  2238. * allow * in middle of the path to support ../*/units/$fpctarget
  2239. Revision 1.197 2004/10/24 20:01:08 peter
  2240. * remove saveregister calling convention
  2241. Revision 1.196 2004/10/24 13:48:50 peter
  2242. * don't give warning for property as unknwon proc directive
  2243. Revision 1.195 2004/10/24 11:44:28 peter
  2244. * small regvar fixes
  2245. * loadref parameter removed from concatcopy,incrrefcount,etc
  2246. Revision 1.194 2004/10/15 09:14:17 mazen
  2247. - remove $IFDEF DELPHI and related code
  2248. - remove $IFDEF FPCPROCVAR and related code
  2249. Revision 1.193 2004/10/11 15:45:35 peter
  2250. * mark non-regable after calling convention is set
  2251. Revision 1.192 2004/10/10 21:08:55 peter
  2252. * parameter regvar fixes
  2253. Revision 1.191 2004/10/08 17:09:43 peter
  2254. * tvarsym.varregable added, split vo_regable from varoptions
  2255. Revision 1.190 2004/08/29 11:28:41 peter
  2256. fixed crash with error in default value
  2257. allow assembler directive in interface
  2258. Revision 1.189 2004/08/25 15:57:19 peter
  2259. * fix for tw3261
  2260. Revision 1.188 2004/08/22 20:11:38 florian
  2261. * morphos now takes any pointer var. as libbase
  2262. * alignment for sparc fixed
  2263. * int -> double conversion on sparc fixed
  2264. Revision 1.187 2004/08/22 11:24:27 peter
  2265. * don't insert result variables for constructor/destructors
  2266. Revision 1.186 2004/08/13 17:53:37 jonas
  2267. * only set the mangled name immediately for external procedures in macpas
  2268. mode if the procedure isn't cdecl (so that the c-prefix is taken into
  2269. account, necessary for Mac OS X)
  2270. Revision 1.185 2004/08/08 12:35:09 florian
  2271. * proc. var declarations in a class doesn't eat a public anymore
  2272. Revision 1.184 2004/07/17 13:51:57 florian
  2273. * function result location for syscalls on MOS hopefully correctly set now
  2274. Revision 1.183 2004/07/14 23:19:21 olle
  2275. + added external facilities for macpas
  2276. Revision 1.182 2004/06/20 08:55:30 florian
  2277. * logs truncated
  2278. Revision 1.181 2004/06/16 20:07:09 florian
  2279. * dwarf branch merged
  2280. Revision 1.180 2004/05/23 20:54:39 peter
  2281. * fixed 3114
  2282. Revision 1.179 2004/05/23 19:06:26 peter
  2283. * expect : after function when it is a forwarddef
  2284. Revision 1.178 2004/05/12 13:21:09 karoly
  2285. * few small changes to add syscall support to M68k/Amiga target
  2286. Revision 1.177 2004/05/11 22:52:48 olle
  2287. * Moved import_implicit_external to symsym
  2288. }