pdecsub.pas 87 KB

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