pdecsub.pas 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507
  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. isclassmethod:=false;
  761. { read class method }
  762. if try_to_consume(_CLASS) then
  763. begin
  764. { class method only allowed for procedures and functions }
  765. if not(token in [_FUNCTION,_PROCEDURE]) then
  766. Message(parser_e_procedure_or_function_expected);
  767. if is_interface(aclass) then
  768. Message(parser_e_no_static_method_in_interfaces)
  769. else
  770. isclassmethod:=true;
  771. end;
  772. case token of
  773. _FUNCTION :
  774. begin
  775. consume(_FUNCTION);
  776. if parse_proc_head(aclass,potype_none,pd) then
  777. begin
  778. { pd=nil when it is a interface mapping }
  779. if assigned(pd) then
  780. begin
  781. if try_to_consume(_COLON) then
  782. begin
  783. inc(testcurobject);
  784. single_type(pd.rettype,hs,false);
  785. pd.test_if_fpu_result;
  786. dec(testcurobject);
  787. end
  788. else
  789. begin
  790. if (
  791. parse_only and
  792. not(is_interface(pd._class))
  793. ) or
  794. (m_repeat_forward in aktmodeswitches) then
  795. begin
  796. consume(_COLON);
  797. consume_all_until(_SEMICOLON);
  798. end;
  799. end;
  800. if isclassmethod then
  801. include(pd.procoptions,po_classmethod);
  802. end;
  803. end
  804. else
  805. begin
  806. { recover }
  807. consume(_COLON);
  808. consume_all_until(_SEMICOLON);
  809. end;
  810. end;
  811. _PROCEDURE :
  812. begin
  813. consume(_PROCEDURE);
  814. if parse_proc_head(aclass,potype_none,pd) then
  815. begin
  816. { pd=nil when it is a interface mapping }
  817. if assigned(pd) then
  818. begin
  819. pd.rettype:=voidtype;
  820. if isclassmethod then
  821. include(pd.procoptions,po_classmethod);
  822. end;
  823. end;
  824. end;
  825. _CONSTRUCTOR :
  826. begin
  827. consume(_CONSTRUCTOR);
  828. parse_proc_head(aclass,potype_constructor,pd);
  829. if assigned(pd) and
  830. assigned(pd._class) then
  831. begin
  832. { Set return type, class constructors return the
  833. created instance, object constructors return boolean }
  834. if is_class(pd._class) then
  835. pd.rettype.setdef(pd._class)
  836. else
  837. pd.rettype:=booltype;
  838. end;
  839. end;
  840. _DESTRUCTOR :
  841. begin
  842. consume(_DESTRUCTOR);
  843. parse_proc_head(aclass,potype_destructor,pd);
  844. if assigned(pd) then
  845. pd.rettype:=voidtype;
  846. end;
  847. _OPERATOR :
  848. begin
  849. consume(_OPERATOR);
  850. if (token in [first_overloaded..last_overloaded]) then
  851. begin
  852. optoken:=token;
  853. end
  854. else
  855. begin
  856. Message(parser_e_overload_operator_failed);
  857. { Use the dummy NOTOKEN that is also declared
  858. for the overloaded_operator[] }
  859. optoken:=NOTOKEN;
  860. end;
  861. consume(token);
  862. parse_proc_head(aclass,potype_operator,pd);
  863. if assigned(pd) then
  864. begin
  865. if pd.parast.symtablelevel>normal_function_level then
  866. Message(parser_e_no_local_operator);
  867. if token<>_ID then
  868. begin
  869. if not(m_result in aktmodeswitches) then
  870. consume(_ID);
  871. end
  872. else
  873. begin
  874. pd.resultname:=orgpattern;
  875. consume(_ID);
  876. end;
  877. if not try_to_consume(_COLON) then
  878. begin
  879. consume(_COLON);
  880. pd.rettype:=generrortype;
  881. consume_all_until(_SEMICOLON);
  882. end
  883. else
  884. begin
  885. single_type(pd.rettype,hs,false);
  886. pd.test_if_fpu_result;
  887. if (optoken in [_EQUAL,_GT,_LT,_GTE,_LTE]) and
  888. ((pd.rettype.def.deftype<>orddef) or
  889. (torddef(pd.rettype.def).typ<>bool8bit)) then
  890. Message(parser_e_comparative_operator_return_boolean);
  891. if (optoken=_ASSIGNMENT) and
  892. equal_defs(pd.rettype.def,
  893. tparavarsym(pd.parast.symindex.first).vartype.def) then
  894. message(parser_e_no_such_assignment)
  895. else if not isoperatoracceptable(pd,optoken) then
  896. Message(parser_e_overload_impossible);
  897. end;
  898. end
  899. else
  900. begin
  901. { recover }
  902. try_to_consume(_ID);
  903. consume(_COLON);
  904. consume_all_until(_SEMICOLON);
  905. end;
  906. end;
  907. end;
  908. { support procedure proc stdcall export; }
  909. if not(check_proc_directive(false)) then
  910. consume(_SEMICOLON);
  911. result:=pd;
  912. end;
  913. {****************************************************************************
  914. Procedure directive handlers
  915. ****************************************************************************}
  916. procedure pd_far(pd:tabstractprocdef);
  917. begin
  918. Message1(parser_w_proc_directive_ignored,'FAR');
  919. end;
  920. procedure pd_near(pd:tabstractprocdef);
  921. begin
  922. Message1(parser_w_proc_directive_ignored,'NEAR');
  923. end;
  924. procedure pd_export(pd:tabstractprocdef);
  925. begin
  926. if pd.deftype<>procdef then
  927. internalerror(200304264);
  928. if assigned(tprocdef(pd)._class) then
  929. Message(parser_e_methods_dont_be_export);
  930. if pd.parast.symtablelevel>normal_function_level then
  931. Message(parser_e_dont_nest_export);
  932. end;
  933. procedure pd_forward(pd:tabstractprocdef);
  934. begin
  935. if pd.deftype<>procdef then
  936. internalerror(200304265);
  937. tprocdef(pd).forwarddef:=true;
  938. end;
  939. procedure pd_alias(pd:tabstractprocdef);
  940. begin
  941. if pd.deftype<>procdef then
  942. internalerror(200304266);
  943. consume(_COLON);
  944. tprocdef(pd).aliasnames.insert(get_stringconst);
  945. include(pd.procoptions,po_has_public_name);
  946. end;
  947. procedure pd_public(pd:tabstractprocdef);
  948. begin
  949. if pd.deftype<>procdef then
  950. internalerror(200304266);
  951. if try_to_consume(_NAME) then
  952. begin
  953. tprocdef(pd).aliasnames.insert(get_stringconst);
  954. include(pd.procoptions,po_has_public_name);
  955. end;
  956. end;
  957. procedure pd_asmname(pd:tabstractprocdef);
  958. begin
  959. if pd.deftype<>procdef then
  960. internalerror(200304267);
  961. tprocdef(pd).aliasnames.insert(target_info.Cprefix+pattern);
  962. if token=_CCHAR then
  963. consume(_CCHAR)
  964. else
  965. consume(_CSTRING);
  966. { we don't need anything else }
  967. tprocdef(pd).forwarddef:=false;
  968. end;
  969. procedure pd_inline(pd:tabstractprocdef);
  970. begin
  971. { Check if there are parameters that can't be inlined }
  972. pd.parast.foreach_static(@check_inline_para,pd);
  973. end;
  974. procedure pd_internconst(pd:tabstractprocdef);
  975. begin
  976. if pd.deftype<>procdef then
  977. internalerror(200304268);
  978. consume(_COLON);
  979. tprocdef(pd).extnumber:=get_intconst;
  980. end;
  981. procedure pd_internproc(pd:tabstractprocdef);
  982. begin
  983. if pd.deftype<>procdef then
  984. internalerror(200304268);
  985. consume(_COLON);
  986. tprocdef(pd).extnumber:=get_intconst;
  987. { the proc is defined }
  988. tprocdef(pd).forwarddef:=false;
  989. end;
  990. procedure pd_interrupt(pd:tabstractprocdef);
  991. begin
  992. if pd.parast.symtablelevel>normal_function_level then
  993. Message(parser_e_dont_nest_interrupt);
  994. end;
  995. procedure pd_abstract(pd:tabstractprocdef);
  996. begin
  997. if pd.deftype<>procdef then
  998. internalerror(200304269);
  999. if (po_virtualmethod in pd.procoptions) then
  1000. include(pd.procoptions,po_abstractmethod)
  1001. else
  1002. Message(parser_e_only_virtual_methods_abstract);
  1003. { the method is defined }
  1004. tprocdef(pd).forwarddef:=false;
  1005. end;
  1006. procedure pd_virtual(pd:tabstractprocdef);
  1007. {$ifdef WITHDMT}
  1008. var
  1009. pt : tnode;
  1010. {$endif WITHDMT}
  1011. begin
  1012. if pd.deftype<>procdef then
  1013. internalerror(2003042610);
  1014. if (pd.proctypeoption=potype_constructor) and
  1015. is_object(tprocdef(pd)._class) then
  1016. Message(parser_e_constructor_cannot_be_not_virtual);
  1017. {$ifdef WITHDMT}
  1018. if is_object(tprocdef(pd)._class) and
  1019. (token<>_SEMICOLON) then
  1020. begin
  1021. { any type of parameter is allowed here! }
  1022. pt:=comp_expr(true);
  1023. if is_constintnode(pt) then
  1024. begin
  1025. include(pd.procoptions,po_msgint);
  1026. pd.messageinf.i:=pt^.value;
  1027. end
  1028. else
  1029. Message(parser_e_ill_msg_expr);
  1030. disposetree(pt);
  1031. end;
  1032. {$endif WITHDMT}
  1033. end;
  1034. procedure pd_static(pd:tabstractprocdef);
  1035. begin
  1036. if (cs_static_keyword in aktmoduleswitches) then
  1037. begin
  1038. if pd.deftype=procdef then
  1039. include(tprocdef(pd).procsym.symoptions,sp_static);
  1040. include(pd.procoptions,po_staticmethod);
  1041. end;
  1042. end;
  1043. procedure pd_override(pd:tabstractprocdef);
  1044. begin
  1045. if pd.deftype<>procdef then
  1046. internalerror(2003042611);
  1047. if not(is_class_or_interface(tprocdef(pd)._class)) then
  1048. Message(parser_e_no_object_override);
  1049. end;
  1050. procedure pd_overload(pd:tabstractprocdef);
  1051. begin
  1052. if pd.deftype<>procdef then
  1053. internalerror(2003042612);
  1054. include(tprocdef(pd).procsym.symoptions,sp_has_overloaded);
  1055. end;
  1056. procedure pd_message(pd:tabstractprocdef);
  1057. var
  1058. pt : tnode;
  1059. paracnt : longint;
  1060. begin
  1061. if pd.deftype<>procdef then
  1062. internalerror(2003042613);
  1063. if not is_class(tprocdef(pd)._class) then
  1064. Message(parser_e_msg_only_for_classes);
  1065. { check parameter type }
  1066. paracnt:=0;
  1067. pd.parast.foreach_static(@check_msg_para,@paracnt);
  1068. if paracnt<>1 then
  1069. Message(parser_e_ill_msg_param);
  1070. pt:=comp_expr(true);
  1071. if pt.nodetype=stringconstn then
  1072. begin
  1073. include(pd.procoptions,po_msgstr);
  1074. tprocdef(pd).messageinf.str:=strnew(tstringconstnode(pt).value_str);
  1075. end
  1076. else
  1077. if is_constintnode(pt) then
  1078. begin
  1079. include(pd.procoptions,po_msgint);
  1080. tprocdef(pd).messageinf.i:=tordconstnode(pt).value;
  1081. end
  1082. else
  1083. Message(parser_e_ill_msg_expr);
  1084. pt.free;
  1085. end;
  1086. procedure pd_reintroduce(pd:tabstractprocdef);
  1087. begin
  1088. if pd.deftype<>procdef then
  1089. internalerror(200401211);
  1090. if not(is_class_or_interface(tprocdef(pd)._class)) then
  1091. Message(parser_e_no_object_reintroduce);
  1092. end;
  1093. procedure pd_syscall(pd:tabstractprocdef);
  1094. {$ifdef powerpc}
  1095. var
  1096. vs : tparavarsym;
  1097. sym : tsym;
  1098. symtable : tsymtable;
  1099. {$endif powerpc}
  1100. begin
  1101. if pd.deftype<>procdef then
  1102. internalerror(2003042614);
  1103. tprocdef(pd).forwarddef:=false;
  1104. {$ifdef powerpc}
  1105. if target_info.system in [system_powerpc_morphos,system_m68k_amiga] then
  1106. begin
  1107. if consume_sym(sym,symtable) then
  1108. begin
  1109. if (sym.typ=globalvarsym) and
  1110. (
  1111. (tabstractvarsym(sym).vartype.def.deftype=pointerdef) or
  1112. is_32bitint(tabstractvarsym(sym).vartype.def)
  1113. ) then
  1114. begin
  1115. tprocdef(pd).libsym:=sym;
  1116. vs:=tparavarsym.create('$syscalllib',paranr_syscall,vs_value,tabstractvarsym(sym).vartype,[vo_is_syscall_lib,vo_is_hidden_para,vo_has_explicit_paraloc]);
  1117. paramanager.parseparaloc(vs,'A6');
  1118. pd.parast.insert(vs);
  1119. end
  1120. else
  1121. Message(parser_e_32bitint_or_pointer_variable_expected);
  1122. end;
  1123. (paramanager as tppcparamanager).create_funcretloc_info(pd,calleeside);
  1124. (paramanager as tppcparamanager).create_funcretloc_info(pd,callerside);
  1125. end;
  1126. {$endif powerpc}
  1127. tprocdef(pd).extnumber:=get_intconst;
  1128. end;
  1129. procedure pd_external(pd:tabstractprocdef);
  1130. {
  1131. If import_dll=nil the procedure is assumed to be in another
  1132. object file. In that object file it should have the name to
  1133. which import_name is pointing to. Otherwise, the procedure is
  1134. assumed to be in the DLL to which import_dll is pointing to. In
  1135. that case either import_nr<>0 or import_name<>nil is true, so
  1136. the procedure is either imported by number or by name. (DM)
  1137. }
  1138. begin
  1139. if pd.deftype<>procdef then
  1140. internalerror(2003042615);
  1141. with tprocdef(pd) do
  1142. begin
  1143. forwarddef:=false;
  1144. { forbid local external procedures }
  1145. if parast.symtablelevel>normal_function_level then
  1146. Message(parser_e_no_local_proc_external);
  1147. { If the procedure should be imported from a DLL, a constant string follows.
  1148. This isn't really correct, an contant string expression follows
  1149. so we check if an semicolon follows, else a string constant have to
  1150. follow (FK) }
  1151. if not(token=_SEMICOLON) and not(idtoken=_NAME) then
  1152. begin
  1153. import_dll:=stringdup(get_stringconst);
  1154. if (idtoken=_NAME) then
  1155. begin
  1156. consume(_NAME);
  1157. import_name:=stringdup(get_stringconst);
  1158. if import_name^='' then
  1159. message(parser_e_empty_import_name);
  1160. end;
  1161. if (idtoken=_INDEX) then
  1162. begin
  1163. {After the word index follows the index number in the DLL.}
  1164. consume(_INDEX);
  1165. import_nr:=get_intconst;
  1166. end;
  1167. { default is to used the realname of the procedure }
  1168. if (import_nr=0) and not assigned(import_name) then
  1169. import_name:=stringdup(procsym.realname);
  1170. end
  1171. else
  1172. begin
  1173. if (idtoken=_NAME) then
  1174. begin
  1175. consume(_NAME);
  1176. import_name:=stringdup(get_stringconst);
  1177. if import_name^='' then
  1178. message(parser_e_empty_import_name);
  1179. end;
  1180. end;
  1181. end;
  1182. end;
  1183. type
  1184. pd_handler=procedure(pd:tabstractprocdef);
  1185. proc_dir_rec=record
  1186. idtok : ttoken;
  1187. pd_flags : tpdflags;
  1188. handler : pd_handler;
  1189. pocall : tproccalloption;
  1190. pooption : tprocoptions;
  1191. mutexclpocall : tproccalloptions;
  1192. mutexclpotype : tproctypeoptions;
  1193. mutexclpo : tprocoptions;
  1194. end;
  1195. const
  1196. {Should contain the number of procedure directives we support.}
  1197. num_proc_directives=36;
  1198. proc_direcdata:array[1..num_proc_directives] of proc_dir_rec=
  1199. (
  1200. (
  1201. idtok:_ABSTRACT;
  1202. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1203. handler : @pd_abstract;
  1204. pocall : pocall_none;
  1205. pooption : [po_abstractmethod];
  1206. mutexclpocall : [pocall_internproc,pocall_inline];
  1207. mutexclpotype : [];
  1208. mutexclpo : [po_exports,po_interrupt,po_external]
  1209. ),(
  1210. idtok:_ALIAS;
  1211. pd_flags : [pd_implemen,pd_body,pd_notobjintf];
  1212. handler : @pd_alias;
  1213. pocall : pocall_none;
  1214. pooption : [];
  1215. mutexclpocall : [pocall_inline];
  1216. mutexclpotype : [];
  1217. mutexclpo : [po_external]
  1218. ),(
  1219. idtok:_ASMNAME;
  1220. pd_flags : [pd_interface,pd_implemen,pd_notobjintf];
  1221. handler : @pd_asmname;
  1222. pocall : pocall_cdecl;
  1223. pooption : [po_external];
  1224. mutexclpocall : [pocall_internproc,pocall_inline];
  1225. mutexclpotype : [];
  1226. mutexclpo : [po_external]
  1227. ),(
  1228. idtok:_ASSEMBLER;
  1229. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobjintf];
  1230. handler : nil;
  1231. pocall : pocall_none;
  1232. pooption : [po_assembler];
  1233. mutexclpocall : [];
  1234. mutexclpotype : [];
  1235. mutexclpo : [po_external]
  1236. ),(
  1237. idtok:_C; {same as cdecl for mode mac}
  1238. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1239. handler : nil;
  1240. pocall : pocall_cdecl;
  1241. pooption : [];
  1242. mutexclpocall : [];
  1243. mutexclpotype : [potype_constructor,potype_destructor];
  1244. mutexclpo : [po_assembler,po_external]
  1245. ),(
  1246. idtok:_CDECL;
  1247. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1248. handler : nil;
  1249. pocall : pocall_cdecl;
  1250. pooption : [];
  1251. mutexclpocall : [];
  1252. mutexclpotype : [potype_constructor,potype_destructor];
  1253. mutexclpo : [po_assembler,po_external]
  1254. ),(
  1255. idtok:_DYNAMIC;
  1256. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1257. handler : @pd_virtual;
  1258. pocall : pocall_none;
  1259. pooption : [po_virtualmethod];
  1260. mutexclpocall : [pocall_internproc,pocall_inline];
  1261. mutexclpotype : [];
  1262. mutexclpo : [po_exports,po_interrupt,po_external,po_overridingmethod]
  1263. ),(
  1264. idtok:_EXPORT;
  1265. pd_flags : [pd_body,pd_interface,pd_implemen,pd_notobjintf];
  1266. handler : @pd_export;
  1267. pocall : pocall_none;
  1268. pooption : [po_exports,po_global];
  1269. mutexclpocall : [pocall_internproc,pocall_inline];
  1270. mutexclpotype : [potype_constructor,potype_destructor];
  1271. mutexclpo : [po_external,po_interrupt]
  1272. ),(
  1273. idtok:_EXTERNAL;
  1274. pd_flags : [pd_implemen,pd_interface,pd_notobject,pd_notobjintf];
  1275. handler : @pd_external;
  1276. pocall : pocall_none;
  1277. pooption : [po_external];
  1278. mutexclpocall : [pocall_internproc,pocall_inline,pocall_syscall];
  1279. mutexclpotype : [potype_constructor,potype_destructor];
  1280. mutexclpo : [po_public,po_exports,po_interrupt,po_assembler]
  1281. ),(
  1282. idtok:_FAR;
  1283. pd_flags : [pd_implemen,pd_body,pd_interface,pd_procvar,pd_notobject,pd_notobjintf];
  1284. handler : @pd_far;
  1285. pocall : pocall_none;
  1286. pooption : [];
  1287. mutexclpocall : [pocall_internproc,pocall_inline];
  1288. mutexclpotype : [];
  1289. mutexclpo : []
  1290. ),(
  1291. idtok:_FAR16;
  1292. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar,pd_notobject];
  1293. handler : nil;
  1294. pocall : pocall_far16;
  1295. pooption : [];
  1296. mutexclpocall : [];
  1297. mutexclpotype : [];
  1298. mutexclpo : [po_external]
  1299. ),(
  1300. idtok:_FORWARD;
  1301. pd_flags : [pd_implemen,pd_notobject,pd_notobjintf];
  1302. handler : @pd_forward;
  1303. pocall : pocall_none;
  1304. pooption : [];
  1305. mutexclpocall : [pocall_internproc,pocall_inline];
  1306. mutexclpotype : [];
  1307. mutexclpo : [po_external]
  1308. ),(
  1309. idtok:_OLDFPCCALL;
  1310. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1311. handler : nil;
  1312. pocall : pocall_oldfpccall;
  1313. pooption : [];
  1314. mutexclpocall : [];
  1315. mutexclpotype : [];
  1316. mutexclpo : []
  1317. ),(
  1318. idtok:_INLINE;
  1319. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobjintf];
  1320. handler : @pd_inline;
  1321. pocall : pocall_inline;
  1322. pooption : [];
  1323. mutexclpocall : [];
  1324. mutexclpotype : [potype_constructor,potype_destructor];
  1325. mutexclpo : [po_exports,po_external,po_interrupt,po_virtualmethod]
  1326. ),(
  1327. idtok:_INTERNCONST;
  1328. pd_flags : [pd_interface,pd_body,pd_notobject,pd_notobjintf];
  1329. handler : @pd_internconst;
  1330. pocall : pocall_none;
  1331. pooption : [po_internconst];
  1332. mutexclpocall : [];
  1333. mutexclpotype : [potype_operator];
  1334. mutexclpo : []
  1335. ),(
  1336. idtok:_INTERNPROC;
  1337. pd_flags : [pd_interface,pd_notobject,pd_notobjintf];
  1338. handler : @pd_internproc;
  1339. pocall : pocall_internproc;
  1340. pooption : [];
  1341. mutexclpocall : [];
  1342. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1343. mutexclpo : [po_exports,po_external,po_interrupt,po_assembler,po_iocheck,po_virtualmethod]
  1344. ),(
  1345. idtok:_INTERRUPT;
  1346. pd_flags : [pd_implemen,pd_body,pd_notobject,pd_notobjintf];
  1347. handler : @pd_interrupt;
  1348. pocall : pocall_none;
  1349. pooption : [po_interrupt];
  1350. mutexclpocall : [pocall_internproc,pocall_cdecl,pocall_cppdecl,pocall_stdcall,
  1351. pocall_inline,pocall_pascal,pocall_far16,pocall_oldfpccall];
  1352. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1353. mutexclpo : [po_external]
  1354. ),(
  1355. idtok:_IOCHECK;
  1356. pd_flags : [pd_implemen,pd_body,pd_notobjintf];
  1357. handler : nil;
  1358. pocall : pocall_none;
  1359. pooption : [po_iocheck];
  1360. mutexclpocall : [pocall_internproc];
  1361. mutexclpotype : [];
  1362. mutexclpo : [po_external]
  1363. ),(
  1364. idtok:_MESSAGE;
  1365. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1366. handler : @pd_message;
  1367. pocall : pocall_none;
  1368. pooption : []; { can be po_msgstr or po_msgint }
  1369. mutexclpocall : [pocall_inline,pocall_internproc];
  1370. mutexclpotype : [potype_constructor,potype_destructor,potype_operator];
  1371. mutexclpo : [po_interrupt,po_external]
  1372. ),(
  1373. idtok:_NEAR;
  1374. pd_flags : [pd_implemen,pd_body,pd_procvar,pd_notobjintf];
  1375. handler : @pd_near;
  1376. pocall : pocall_none;
  1377. pooption : [];
  1378. mutexclpocall : [pocall_internproc];
  1379. mutexclpotype : [];
  1380. mutexclpo : []
  1381. ),(
  1382. idtok:_NOSTACKFRAME;
  1383. pd_flags : [pd_implemen,pd_body,pd_procvar,pd_notobjintf];
  1384. handler : nil;
  1385. pocall : pocall_none;
  1386. pooption : [po_nostackframe];
  1387. mutexclpocall : [pocall_internproc];
  1388. mutexclpotype : [];
  1389. mutexclpo : []
  1390. ),(
  1391. idtok:_OVERLOAD;
  1392. pd_flags : [pd_implemen,pd_interface,pd_body];
  1393. handler : @pd_overload;
  1394. pocall : pocall_none;
  1395. pooption : [po_overload];
  1396. mutexclpocall : [pocall_internproc];
  1397. mutexclpotype : [];
  1398. mutexclpo : []
  1399. ),(
  1400. idtok:_OVERRIDE;
  1401. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1402. handler : @pd_override;
  1403. pocall : pocall_none;
  1404. pooption : [po_overridingmethod,po_virtualmethod];
  1405. mutexclpocall : [pocall_inline,pocall_internproc];
  1406. mutexclpotype : [];
  1407. mutexclpo : [po_exports,po_external,po_interrupt,po_virtualmethod]
  1408. ),(
  1409. idtok:_PASCAL;
  1410. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1411. handler : nil;
  1412. pocall : pocall_pascal;
  1413. pooption : [];
  1414. mutexclpocall : [];
  1415. mutexclpotype : [potype_constructor,potype_destructor];
  1416. mutexclpo : [po_external]
  1417. ),(
  1418. idtok:_PUBLIC;
  1419. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobject,pd_notobjintf];
  1420. handler : @pd_public;
  1421. pocall : pocall_none;
  1422. pooption : [po_public,po_global];
  1423. mutexclpocall : [pocall_internproc,pocall_inline];
  1424. mutexclpotype : [];
  1425. mutexclpo : [po_external]
  1426. ),(
  1427. idtok:_REGISTER;
  1428. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1429. handler : nil;
  1430. pocall : pocall_register;
  1431. pooption : [];
  1432. mutexclpocall : [];
  1433. mutexclpotype : [potype_constructor,potype_destructor];
  1434. mutexclpo : [po_external]
  1435. ),(
  1436. idtok:_REINTRODUCE;
  1437. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1438. handler : @pd_reintroduce;
  1439. pocall : pocall_none;
  1440. pooption : [po_reintroduce];
  1441. mutexclpocall : [pocall_inline,pocall_internproc];
  1442. mutexclpotype : [];
  1443. mutexclpo : [po_external,po_interrupt,po_exports,po_overridingmethod]
  1444. ),(
  1445. idtok:_SAFECALL;
  1446. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1447. handler : nil;
  1448. pocall : pocall_safecall;
  1449. pooption : [];
  1450. mutexclpocall : [];
  1451. mutexclpotype : [potype_constructor,potype_destructor];
  1452. mutexclpo : [po_external]
  1453. ),(
  1454. idtok:_SOFTFLOAT;
  1455. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1456. handler : nil;
  1457. pocall : pocall_softfloat;
  1458. pooption : [];
  1459. mutexclpocall : [];
  1460. mutexclpotype : [potype_constructor,potype_destructor];
  1461. { it's available with po_external because the libgcc floating point routines on the arm
  1462. uses this calling convention }
  1463. mutexclpo : []
  1464. ),(
  1465. idtok:_STATIC;
  1466. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1467. handler : @pd_static;
  1468. pocall : pocall_none;
  1469. pooption : [po_staticmethod];
  1470. mutexclpocall : [pocall_inline,pocall_internproc];
  1471. mutexclpotype : [potype_constructor,potype_destructor];
  1472. mutexclpo : [po_external,po_interrupt,po_exports]
  1473. ),(
  1474. idtok:_STDCALL;
  1475. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1476. handler : nil;
  1477. pocall : pocall_stdcall;
  1478. pooption : [];
  1479. mutexclpocall : [];
  1480. mutexclpotype : [potype_constructor,potype_destructor];
  1481. mutexclpo : [po_external]
  1482. ),(
  1483. idtok:_SYSCALL;
  1484. pd_flags : [pd_interface,pd_implemen,pd_notobject,pd_notobjintf];
  1485. handler : @pd_syscall;
  1486. pocall : pocall_syscall;
  1487. pooption : [];
  1488. mutexclpocall : [];
  1489. mutexclpotype : [potype_constructor,potype_destructor];
  1490. mutexclpo : [po_external,po_assembler,po_interrupt,po_exports]
  1491. ),(
  1492. idtok:_VIRTUAL;
  1493. pd_flags : [pd_interface,pd_object,pd_notobjintf];
  1494. handler : @pd_virtual;
  1495. pocall : pocall_none;
  1496. pooption : [po_virtualmethod];
  1497. mutexclpocall : [pocall_inline,pocall_internproc];
  1498. mutexclpotype : [];
  1499. mutexclpo : [po_external,po_interrupt,po_exports,po_overridingmethod]
  1500. ),(
  1501. idtok:_CPPDECL;
  1502. pd_flags : [pd_interface,pd_implemen,pd_body,pd_procvar];
  1503. handler : nil;
  1504. pocall : pocall_cppdecl;
  1505. pooption : [];
  1506. mutexclpocall : [];
  1507. mutexclpotype : [potype_constructor,potype_destructor];
  1508. mutexclpo : [po_assembler,po_external,po_virtualmethod]
  1509. ),(
  1510. idtok:_VARARGS;
  1511. pd_flags : [pd_interface,pd_implemen,pd_procvar];
  1512. handler : nil;
  1513. pocall : pocall_none;
  1514. pooption : [po_varargs];
  1515. mutexclpocall : [pocall_internproc,pocall_stdcall,pocall_register,
  1516. pocall_inline,pocall_far16,pocall_oldfpccall];
  1517. mutexclpotype : [];
  1518. mutexclpo : [po_assembler,po_interrupt]
  1519. ),(
  1520. idtok:_COMPILERPROC;
  1521. pd_flags : [pd_interface,pd_implemen,pd_body,pd_notobjintf];
  1522. handler : nil;
  1523. pocall : pocall_compilerproc;
  1524. pooption : [];
  1525. mutexclpocall : [];
  1526. mutexclpotype : [potype_constructor,potype_destructor];
  1527. mutexclpo : [po_interrupt]
  1528. )
  1529. );
  1530. function check_proc_directive(isprocvar:boolean):boolean;
  1531. var
  1532. i : longint;
  1533. begin
  1534. result:=false;
  1535. for i:=1 to num_proc_directives do
  1536. if proc_direcdata[i].idtok=idtoken then
  1537. begin
  1538. if ((not isprocvar) or
  1539. (pd_procvar in proc_direcdata[i].pd_flags)) and
  1540. { don't eat a public directive in classes }
  1541. not((idtoken=_PUBLIC) and (symtablestack.symtabletype=objectsymtable)) then
  1542. result:=true;
  1543. exit;
  1544. end;
  1545. end;
  1546. function parse_proc_direc(pd:tabstractprocdef;var pdflags:tpdflags):boolean;
  1547. {
  1548. Parse the procedure directive, returns true if a correct directive is found
  1549. }
  1550. var
  1551. p : longint;
  1552. found : boolean;
  1553. name : stringid;
  1554. begin
  1555. parse_proc_direc:=false;
  1556. name:=tokeninfo^[idtoken].str;
  1557. found:=false;
  1558. { Hint directive? Then exit immediatly }
  1559. if (m_hintdirective in aktmodeswitches) then
  1560. begin
  1561. case idtoken of
  1562. _LIBRARY,
  1563. _PLATFORM,
  1564. _UNIMPLEMENTED,
  1565. _DEPRECATED :
  1566. exit;
  1567. end;
  1568. end;
  1569. { C directive is MAC only, because it breaks too much existing code
  1570. on other platforms (PFV) }
  1571. if (idtoken=_C) and
  1572. not(m_mac in aktmodeswitches) then
  1573. exit;
  1574. { retrieve data for directive if found }
  1575. for p:=1 to num_proc_directives do
  1576. if proc_direcdata[p].idtok=idtoken then
  1577. begin
  1578. found:=true;
  1579. break;
  1580. end;
  1581. { Check if the procedure directive is known }
  1582. if not found then
  1583. begin
  1584. { parsing a procvar type the name can be any
  1585. next variable !! }
  1586. if ((pdflags * [pd_procvar,pd_object])=[]) and
  1587. not(idtoken=_PROPERTY) then
  1588. Message1(parser_w_unknown_proc_directive_ignored,name);
  1589. exit;
  1590. end;
  1591. { static needs a special treatment }
  1592. if (idtoken=_STATIC) and not (cs_static_keyword in aktmoduleswitches) then
  1593. exit;
  1594. { check if method and directive not for object, like public.
  1595. This needs to be checked also for procvars }
  1596. if (pd_notobject in proc_direcdata[p].pd_flags) and
  1597. (symtablestack.symtabletype=objectsymtable) then
  1598. exit;
  1599. { Conflicts between directives ? }
  1600. if (pd.proctypeoption in proc_direcdata[p].mutexclpotype) or
  1601. (pd.proccalloption in proc_direcdata[p].mutexclpocall) or
  1602. ((pd.procoptions*proc_direcdata[p].mutexclpo)<>[]) then
  1603. begin
  1604. Message1(parser_e_proc_dir_conflict,name);
  1605. exit;
  1606. end;
  1607. { set calling convention }
  1608. if proc_direcdata[p].pocall<>pocall_none then
  1609. begin
  1610. if (po_hascallingconvention in pd.procoptions) then
  1611. begin
  1612. Message2(parser_w_proc_overriding_calling,
  1613. proccalloptionStr[pd.proccalloption],
  1614. proccalloptionStr[proc_direcdata[p].pocall]);
  1615. end;
  1616. { check if the target processor supports this calling convention }
  1617. if not(proc_direcdata[p].pocall in supported_calling_conventions) then
  1618. begin
  1619. Message1(parser_e_illegal_calling_convention,proccalloptionStr[proc_direcdata[p].pocall]);
  1620. { recover }
  1621. proc_direcdata[p].pocall:=pocall_stdcall;
  1622. end;
  1623. pd.proccalloption:=proc_direcdata[p].pocall;
  1624. include(pd.procoptions,po_hascallingconvention);
  1625. end;
  1626. if pd.deftype=procdef then
  1627. begin
  1628. { Check if the directive is only for objects }
  1629. if (pd_object in proc_direcdata[p].pd_flags) and
  1630. not assigned(tprocdef(pd)._class) then
  1631. exit;
  1632. { check if method and directive not for interface }
  1633. if (pd_notobjintf in proc_direcdata[p].pd_flags) and
  1634. is_interface(tprocdef(pd)._class) then
  1635. exit;
  1636. end;
  1637. { consume directive, and turn flag on }
  1638. consume(token);
  1639. parse_proc_direc:=true;
  1640. { Check the pd_flags if the directive should be allowed }
  1641. if (pd_interface in pdflags) and
  1642. not(pd_interface in proc_direcdata[p].pd_flags) then
  1643. begin
  1644. Message1(parser_e_proc_dir_not_allowed_in_interface,name);
  1645. exit;
  1646. end;
  1647. if (pd_implemen in pdflags) and
  1648. not(pd_implemen in proc_direcdata[p].pd_flags) then
  1649. begin
  1650. Message1(parser_e_proc_dir_not_allowed_in_implementation,name);
  1651. exit;
  1652. end;
  1653. if (pd_procvar in pdflags) and
  1654. not(pd_procvar in proc_direcdata[p].pd_flags) then
  1655. begin
  1656. Message1(parser_e_proc_dir_not_allowed_in_procvar,name);
  1657. exit;
  1658. end;
  1659. { Return the new pd_flags }
  1660. if not(pd_body in proc_direcdata[p].pd_flags) then
  1661. exclude(pdflags,pd_body);
  1662. { Add the correct flag }
  1663. pd.procoptions:=pd.procoptions+proc_direcdata[p].pooption;
  1664. { Call the handler }
  1665. if pointer(proc_direcdata[p].handler)<>nil then
  1666. proc_direcdata[p].handler(pd);
  1667. end;
  1668. function proc_get_importname(pd:tprocdef):string;
  1669. begin
  1670. result:='';
  1671. if not(po_external in pd.procoptions) then
  1672. internalerror(200412151);
  1673. { import by number? }
  1674. if pd.import_nr<>0 then
  1675. begin
  1676. { Nothing to do }
  1677. end
  1678. else
  1679. { external name specified }
  1680. if assigned(pd.import_name) then
  1681. begin
  1682. { Win32 imports need to use the normal name since to functions
  1683. can refer to the same DLL function. This is also needed for compatability
  1684. with Delphi and TP7 }
  1685. if not(
  1686. assigned(pd.import_dll) and
  1687. (target_info.system in [system_i386_win32,system_i386_wdosx,
  1688. system_i386_emx,system_i386_os2])
  1689. ) then
  1690. begin
  1691. if not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1692. result:=pd.import_name^
  1693. else
  1694. result:=target_info.Cprefix+pd.import_name^;
  1695. end;
  1696. end
  1697. else
  1698. begin
  1699. { Default names when importing variables }
  1700. case pd.proccalloption of
  1701. pocall_cdecl :
  1702. begin
  1703. if assigned(pd._class) then
  1704. result:=target_info.Cprefix+pd._class.objrealname^+'_'+pd.procsym.realname
  1705. else
  1706. result:=target_info.Cprefix+pd.procsym.realname;
  1707. end;
  1708. pocall_cppdecl :
  1709. begin
  1710. result:=target_info.Cprefix+pd.cplusplusmangledname;
  1711. end;
  1712. else
  1713. begin
  1714. {In MacPas a single "external" has the same effect as "external name 'xxx'" }
  1715. if (m_mac in aktmodeswitches) then
  1716. result:=tprocdef(pd).procsym.realname;
  1717. end;
  1718. end;
  1719. end;
  1720. end;
  1721. procedure proc_set_mangledname(pd:tprocdef);
  1722. var
  1723. s : string;
  1724. begin
  1725. { When the mangledname is already set we aren't allowed to change
  1726. it because it can already be used somewhere (PFV) }
  1727. if not(po_has_mangledname in pd.procoptions) then
  1728. begin
  1729. if (po_external in pd.procoptions) then
  1730. begin
  1731. { External Procedures are only allowed to change the mangledname
  1732. in their first declaration }
  1733. if (pd.forwarddef or (not pd.hasforward)) then
  1734. begin
  1735. s:=proc_get_importname(pd);
  1736. if s<>'' then
  1737. pd.setmangledname(s);
  1738. end;
  1739. end
  1740. else
  1741. { Normal procedures }
  1742. begin
  1743. case pd.proccalloption of
  1744. pocall_compilerproc :
  1745. begin
  1746. pd.setmangledname(lower(pd.procsym.name));
  1747. end;
  1748. end;
  1749. end;
  1750. end;
  1751. { Public/exported alias names }
  1752. if (po_public in pd.procoptions) and
  1753. not(po_has_public_name in pd.procoptions) then
  1754. begin
  1755. case pd.proccalloption of
  1756. pocall_cdecl :
  1757. begin
  1758. if assigned(pd._class) then
  1759. pd.aliasnames.insert(target_info.Cprefix+pd._class.objrealname^+'_'+pd.procsym.realname)
  1760. else
  1761. pd.aliasnames.insert(target_info.Cprefix+pd.procsym.realname);
  1762. end;
  1763. pocall_cppdecl :
  1764. begin
  1765. pd.aliasnames.insert(target_info.Cprefix+pd.cplusplusmangledname);
  1766. end;
  1767. end;
  1768. { prevent adding the alias a second time }
  1769. include(pd.procoptions,po_has_public_name);
  1770. end;
  1771. end;
  1772. procedure handle_calling_convention(pd:tabstractprocdef);
  1773. begin
  1774. { set the default calling convention if none provided }
  1775. if not(po_hascallingconvention in pd.procoptions) then
  1776. pd.proccalloption:=aktdefproccall
  1777. else
  1778. begin
  1779. if pd.proccalloption=pocall_none then
  1780. internalerror(200309081);
  1781. end;
  1782. { handle proccall specific settings }
  1783. case pd.proccalloption of
  1784. pocall_cdecl,
  1785. pocall_cppdecl :
  1786. begin
  1787. { check C cdecl para types }
  1788. pd.parast.foreach_static(@check_c_para,nil);
  1789. end;
  1790. pocall_far16 :
  1791. begin
  1792. { Temporary stub, must be rewritten to support OS/2 far16 }
  1793. Message1(parser_w_proc_directive_ignored,'FAR16');
  1794. end;
  1795. pocall_inline :
  1796. begin
  1797. if not(cs_support_inline in aktmoduleswitches) then
  1798. begin
  1799. Message(parser_e_proc_inline_not_supported);
  1800. pd.proccalloption:=pocall_default;
  1801. end;
  1802. end;
  1803. end;
  1804. { For varargs directive also cdecl and external must be defined }
  1805. if (po_varargs in pd.procoptions) then
  1806. begin
  1807. { check first for external in the interface, if available there
  1808. then the cdecl must also be there since there is no implementation
  1809. available to contain it }
  1810. if parse_only then
  1811. begin
  1812. { if external is available, then cdecl must also be available,
  1813. procvars don't need external }
  1814. if not((po_external in pd.procoptions) or
  1815. (pd.deftype=procvardef)) and
  1816. not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1817. Message(parser_e_varargs_need_cdecl_and_external);
  1818. end
  1819. else
  1820. begin
  1821. { both must be defined now }
  1822. if not((po_external in pd.procoptions) or
  1823. (pd.deftype=procvardef)) or
  1824. not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1825. Message(parser_e_varargs_need_cdecl_and_external);
  1826. end;
  1827. end;
  1828. { Make var parameters regable, this must be done after the calling
  1829. convention is set. }
  1830. pd.parast.foreach_static(@set_addr_param_regable,pd);
  1831. { insert hidden high parameters }
  1832. pd.parast.foreach_static(@insert_hidden_para,pd);
  1833. { insert hidden self parameter }
  1834. insert_self_and_vmt_para(pd);
  1835. { insert funcret parameter if required }
  1836. insert_funcret_para(pd);
  1837. { insert parentfp parameter if required }
  1838. insert_parentfp_para(pd);
  1839. { Calculate parameter tlist }
  1840. pd.calcparas;
  1841. end;
  1842. procedure parse_proc_directives(pd:tabstractprocdef;var pdflags:tpdflags);
  1843. {
  1844. Parse the procedure directives. It does not matter if procedure directives
  1845. are written using ;procdir; or ['procdir'] syntax.
  1846. }
  1847. var
  1848. res : boolean;
  1849. begin
  1850. if (m_mac in aktmodeswitches) and (cs_externally_visible in aktlocalswitches) then
  1851. begin
  1852. tprocdef(pd).aliasnames.insert(tprocdef(pd).procsym.realname);
  1853. include(pd.procoptions,po_public);
  1854. include(pd.procoptions,po_has_public_name);
  1855. include(pd.procoptions,po_global);
  1856. end;
  1857. while token in [_ID,_LECKKLAMMER] do
  1858. begin
  1859. if try_to_consume(_LECKKLAMMER) then
  1860. begin
  1861. repeat
  1862. parse_proc_direc(pd,pdflags);
  1863. until not try_to_consume(_COMMA);
  1864. consume(_RECKKLAMMER);
  1865. { we always expect at least '[];' }
  1866. res:=true;
  1867. end
  1868. else
  1869. begin
  1870. res:=parse_proc_direc(pd,pdflags);
  1871. end;
  1872. { A procedure directive normally followed by a semicolon, but in
  1873. a const section or reading a type we should stop when _EQUAL is found,
  1874. because a constant/default value follows }
  1875. if res then
  1876. begin
  1877. if (block_type in [bt_const,bt_type]) and
  1878. (token=_EQUAL) then
  1879. break;
  1880. { support procedure proc;stdcall export; }
  1881. if not(check_proc_directive((pd.deftype=procvardef))) then
  1882. consume(_SEMICOLON);
  1883. end
  1884. else
  1885. break;
  1886. end;
  1887. end;
  1888. procedure parse_var_proc_directives(sym:tsym);
  1889. var
  1890. pdflags : tpdflags;
  1891. pd : tabstractprocdef;
  1892. begin
  1893. pdflags:=[pd_procvar];
  1894. pd:=nil;
  1895. case sym.typ of
  1896. fieldvarsym,
  1897. globalvarsym,
  1898. localvarsym,
  1899. paravarsym :
  1900. pd:=tabstractprocdef(tabstractvarsym(sym).vartype.def);
  1901. typedconstsym :
  1902. pd:=tabstractprocdef(ttypedconstsym(sym).typedconsttype.def);
  1903. typesym :
  1904. pd:=tabstractprocdef(ttypesym(sym).restype.def);
  1905. else
  1906. internalerror(2003042617);
  1907. end;
  1908. if pd.deftype<>procvardef then
  1909. internalerror(2003042618);
  1910. { names should never be used anyway }
  1911. parse_proc_directives(pd,pdflags);
  1912. end;
  1913. procedure parse_object_proc_directives(pd:tabstractprocdef);
  1914. var
  1915. pdflags : tpdflags;
  1916. begin
  1917. pdflags:=[pd_object];
  1918. parse_proc_directives(pd,pdflags);
  1919. end;
  1920. function proc_add_definition(var pd:tprocdef):boolean;
  1921. {
  1922. Add definition aprocdef to the overloaded definitions of aprocsym. If a
  1923. forwarddef is found and reused it returns true
  1924. }
  1925. var
  1926. hd : tprocdef;
  1927. ad,fd : tsym;
  1928. s1,s2 : stringid;
  1929. i : cardinal;
  1930. forwardfound : boolean;
  1931. po_comp : tprocoptions;
  1932. aprocsym : tprocsym;
  1933. begin
  1934. forwardfound:=false;
  1935. aprocsym:=tprocsym(pd.procsym);
  1936. { check overloaded functions if the same function already exists }
  1937. for i:=1 to aprocsym.procdef_count do
  1938. begin
  1939. hd:=aprocsym.procdef[i];
  1940. { Skip overloaded definitions that are declared in other
  1941. units }
  1942. if hd.procsym<>aprocsym then
  1943. continue;
  1944. { check the parameters, for delphi/tp it is possible to
  1945. leave the parameters away in the implementation (forwarddef=false).
  1946. But for an overload declared function this is not allowed }
  1947. if { check if empty implementation arguments match is allowed }
  1948. (
  1949. not(m_repeat_forward in aktmodeswitches) and
  1950. not(pd.forwarddef) and
  1951. (pd.maxparacount=0) and
  1952. not(po_overload in hd.procoptions)
  1953. ) or
  1954. { check arguments }
  1955. (
  1956. (compare_paras(pd.paras,hd.paras,cp_none,[cpo_comparedefaultvalue])>=te_equal) and
  1957. { for operators equal_paras is not enough !! }
  1958. ((pd.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
  1959. equal_defs(hd.rettype.def,pd.rettype.def))
  1960. ) then
  1961. begin
  1962. { Check if we've found the forwarddef, if found then
  1963. we need to update the forward def with the current
  1964. implementation settings }
  1965. if hd.forwarddef then
  1966. begin
  1967. forwardfound:=true;
  1968. { Check if the procedure type and return type are correct,
  1969. also the parameters must match also with the type }
  1970. if (hd.proctypeoption<>pd.proctypeoption) or
  1971. (
  1972. (m_repeat_forward in aktmodeswitches) and
  1973. (not((pd.maxparacount=0) or
  1974. (compare_paras(pd.paras,hd.paras,cp_all,[cpo_comparedefaultvalue])>=te_equal)))
  1975. ) or
  1976. (
  1977. ((m_repeat_forward in aktmodeswitches) or
  1978. not(is_void(pd.rettype.def))) and
  1979. (not equal_defs(hd.rettype.def,pd.rettype.def))) then
  1980. begin
  1981. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,
  1982. pd.fullprocname(false));
  1983. aprocsym.write_parameter_lists(pd);
  1984. break;
  1985. end;
  1986. { Check if both are declared forward }
  1987. if hd.forwarddef and pd.forwarddef then
  1988. begin
  1989. MessagePos1(pd.fileinfo,parser_e_function_already_declared_public_forward,
  1990. pd.fullprocname(false));
  1991. end;
  1992. { internconst or internproc only need to be defined once }
  1993. if (hd.proccalloption=pocall_internproc) then
  1994. pd.proccalloption:=hd.proccalloption
  1995. else
  1996. if (pd.proccalloption=pocall_internproc) then
  1997. hd.proccalloption:=pd.proccalloption;
  1998. { Check calling convention }
  1999. if (hd.proccalloption<>pd.proccalloption) then
  2000. begin
  2001. { In delphi it is possible to specify the calling
  2002. convention in the interface or implementation if
  2003. there was no convention specified in the other
  2004. part }
  2005. if (m_delphi in aktmodeswitches) then
  2006. begin
  2007. if not(po_hascallingconvention in pd.procoptions) then
  2008. pd.proccalloption:=hd.proccalloption
  2009. else
  2010. if not(po_hascallingconvention in hd.procoptions) then
  2011. hd.proccalloption:=pd.proccalloption
  2012. else
  2013. begin
  2014. MessagePos(pd.fileinfo,parser_e_call_convention_dont_match_forward);
  2015. aprocsym.write_parameter_lists(pd);
  2016. { restore interface settings }
  2017. pd.proccalloption:=hd.proccalloption;
  2018. end;
  2019. end
  2020. else
  2021. begin
  2022. MessagePos(pd.fileinfo,parser_e_call_convention_dont_match_forward);
  2023. aprocsym.write_parameter_lists(pd);
  2024. { restore interface settings }
  2025. pd.proccalloption:=hd.proccalloption;
  2026. end;
  2027. end;
  2028. { Check procedure options, Delphi requires that class is
  2029. repeated in the implementation for class methods }
  2030. if (m_fpc in aktmodeswitches) then
  2031. po_comp:=[po_varargs,po_methodpointer,po_interrupt]
  2032. else
  2033. po_comp:=[po_classmethod,po_methodpointer];
  2034. if ((po_comp * hd.procoptions)<>(po_comp * pd.procoptions)) then
  2035. begin
  2036. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,
  2037. pd.fullprocname(false));
  2038. aprocsym.write_parameter_lists(pd);
  2039. { This error is non-fatal, we can recover }
  2040. end;
  2041. { Forward declaration is external? }
  2042. if (po_external in hd.procoptions) then
  2043. MessagePos(pd.fileinfo,parser_e_proc_already_external);
  2044. { Check parameters }
  2045. if (m_repeat_forward in aktmodeswitches) or
  2046. (pd.minparacount>0) then
  2047. begin
  2048. { If mangled names are equal then they have the same amount of arguments }
  2049. { We can check the names of the arguments }
  2050. { both symtables are in the same order from left to right }
  2051. ad:=tsym(hd.parast.symindex.first);
  2052. fd:=tsym(pd.parast.symindex.first);
  2053. repeat
  2054. { skip default parameter constsyms }
  2055. while assigned(ad) and (ad.typ<>paravarsym) do
  2056. ad:=tsym(ad.indexnext);
  2057. while assigned(fd) and (fd.typ<>paravarsym) do
  2058. fd:=tsym(fd.indexnext);
  2059. { stop when one of the two lists is at the end }
  2060. if not assigned(ad) or not assigned(fd) then
  2061. break;
  2062. { retrieve names, remove reg for register parameters }
  2063. s1:=ad.name;
  2064. s2:=fd.name;
  2065. { compare names }
  2066. if (s1<>s2) then
  2067. begin
  2068. MessagePos3(pd.fileinfo,parser_e_header_different_var_names,
  2069. aprocsym.name,s1,s2);
  2070. break;
  2071. end;
  2072. ad:=tsym(ad.indexnext);
  2073. fd:=tsym(fd.indexnext);
  2074. until false;
  2075. if assigned(ad) xor assigned(fd) then
  2076. internalerror(200204178);
  2077. end;
  2078. { Everything is checked, now we can update the forward declaration
  2079. with the new data from the implementation }
  2080. hd.forwarddef:=pd.forwarddef;
  2081. hd.hasforward:=true;
  2082. hd.procoptions:=hd.procoptions+pd.procoptions;
  2083. if hd.extnumber=65535 then
  2084. hd.extnumber:=pd.extnumber;
  2085. while not pd.aliasnames.empty do
  2086. hd.aliasnames.insert(pd.aliasnames.getfirst);
  2087. { update fileinfo so position references the implementation,
  2088. also update funcretsym if it is already generated }
  2089. hd.fileinfo:=pd.fileinfo;
  2090. if assigned(hd.funcretsym) then
  2091. hd.funcretsym.fileinfo:=pd.fileinfo;
  2092. { import names }
  2093. if assigned(pd.import_dll) then
  2094. begin
  2095. stringdispose(hd.import_dll);
  2096. hd.import_dll:=stringdup(pd.import_dll^);
  2097. end;
  2098. if assigned(pd.import_name) then
  2099. begin
  2100. stringdispose(hd.import_name);
  2101. hd.import_name:=stringdup(pd.import_name^);
  2102. end;
  2103. hd.import_nr:=pd.import_nr;
  2104. { for compilerproc defines we need to rename and update the
  2105. symbolname to lowercase }
  2106. if (pd.proccalloption=pocall_compilerproc) then
  2107. begin
  2108. { rename to lowercase so users can't access it }
  2109. aprocsym.owner.rename(aprocsym.name,lower(aprocsym.name));
  2110. { also update the realname that is stored in the ppu }
  2111. stringdispose(aprocsym._realname);
  2112. aprocsym._realname:=stringdup('$'+aprocsym.name);
  2113. { the mangeled name is already changed by the pd_compilerproc }
  2114. { handler. It must be done immediately because if we have a }
  2115. { call to a compilerproc before it's implementation is }
  2116. { encountered, it must already use the new mangled name (JM) }
  2117. end;
  2118. { the procdef will be released by the symtable, we release
  2119. at least the parast }
  2120. pd.releasemem;
  2121. pd:=hd;
  2122. end
  2123. else
  2124. begin
  2125. { abstract methods aren't forward defined, but this }
  2126. { needs another error message }
  2127. if (po_abstractmethod in hd.procoptions) then
  2128. MessagePos(pd.fileinfo,parser_e_abstract_no_definition)
  2129. else
  2130. begin
  2131. MessagePos(pd.fileinfo,parser_e_overloaded_have_same_parameters);
  2132. aprocsym.write_parameter_lists(pd);
  2133. end;
  2134. end;
  2135. { we found one proc with the same arguments, there are no others
  2136. so we can stop }
  2137. break;
  2138. end;
  2139. { check for allowing overload directive }
  2140. if not(m_fpc in aktmodeswitches) then
  2141. begin
  2142. { overload directive turns on overloading }
  2143. if ((po_overload in pd.procoptions) or
  2144. (po_overload in hd.procoptions)) then
  2145. begin
  2146. { check if all procs have overloading, but not if the proc is a method or
  2147. already declared forward, then the check is already done }
  2148. if not(hd.hasforward or
  2149. assigned(pd._class) or
  2150. (pd.forwarddef<>hd.forwarddef) or
  2151. ((po_overload in pd.procoptions) and
  2152. (po_overload in hd.procoptions))) then
  2153. begin
  2154. MessagePos1(pd.fileinfo,parser_e_no_overload_for_all_procs,aprocsym.realname);
  2155. break;
  2156. end;
  2157. end
  2158. else
  2159. begin
  2160. if not(hd.forwarddef) then
  2161. begin
  2162. MessagePos(pd.fileinfo,parser_e_procedure_overloading_is_off);
  2163. break;
  2164. end;
  2165. end;
  2166. end; { equal arguments }
  2167. end;
  2168. { if we didn't reuse a forwarddef then we add the procdef to the overloaded
  2169. list }
  2170. if not forwardfound then
  2171. aprocsym.addprocdef(pd);
  2172. proc_add_definition:=forwardfound;
  2173. end;
  2174. end.
  2175. {
  2176. $Log$
  2177. Revision 1.222 2004-12-27 17:32:06 peter
  2178. * don't parse public,private,protected as procdirectives, leave
  2179. procdirective parsing before any other check is done
  2180. Revision 1.221 2004/12/26 20:12:23 peter
  2181. * don't allow class methods in interfaces
  2182. Revision 1.220 2004/12/15 19:30:32 peter
  2183. * syscall with sysv abi for morphos
  2184. Revision 1.219 2004/12/15 16:00:16 peter
  2185. * external is again allowed in implementation
  2186. Revision 1.218 2004/12/07 16:11:52 peter
  2187. * set vo_explicit_paraloc flag
  2188. Revision 1.217 2004/12/05 12:28:11 peter
  2189. * procvar handling for tp procvar mode fixed
  2190. * proc to procvar moved from addrnode to typeconvnode
  2191. * inlininginfo is now allocated only for inline routines that
  2192. can be inlined, introduced a new flag po_has_inlining_info
  2193. Revision 1.216 2004/12/05 00:32:56 olle
  2194. + bugfix for $Z+ for mode macpas
  2195. Revision 1.215 2004/11/29 21:50:08 peter
  2196. * public is allowd in interface
  2197. Revision 1.214 2004/11/29 17:48:34 peter
  2198. * when importing by index don't change mangledname
  2199. Revision 1.213 2004/11/22 12:22:25 jonas
  2200. * fixed importing of cdecl routines for OS'es which have a cprefix
  2201. Revision 1.212 2004/11/21 17:54:59 peter
  2202. * ttempcreatenode.create_reg merged into .create with parameter
  2203. whether a register is allowed
  2204. * funcret_paraloc renamed to funcretloc
  2205. Revision 1.211 2004/11/21 16:33:19 peter
  2206. * fixed message methods
  2207. * fixed typo with win32 dll import from implementation
  2208. * released external check
  2209. Revision 1.210 2004/11/19 08:17:01 michael
  2210. * Split po_public into po_public and po_global (Peter)
  2211. Revision 1.209 2004/11/17 22:41:41 peter
  2212. * make some checks EXTDEBUG only for now so linux cycles again
  2213. Revision 1.208 2004/11/17 22:21:35 peter
  2214. mangledname setting moved to place after the complete proc declaration is read
  2215. import generation moved to place where body is also parsed (still gives problems with win32)
  2216. Revision 1.207 2004/11/16 22:09:57 peter
  2217. * _mangledname for symbols moved only to symbols that really need it
  2218. * overload number removed, add function result type to the mangledname fo
  2219. procdefs
  2220. Revision 1.206 2004/11/16 20:32:40 peter
  2221. * fixes for win32 mangledname
  2222. Revision 1.205 2004/11/15 23:35:31 peter
  2223. * tparaitem removed, use tparavarsym instead
  2224. * parameter order is now calculated from paranr value in tparavarsym
  2225. Revision 1.204 2004/11/14 16:26:29 florian
  2226. * fixed morphos syscall
  2227. Revision 1.203 2004/11/11 19:31:33 peter
  2228. * fixed compile of powerpc,sparc,arm
  2229. Revision 1.202 2004/11/09 22:32:59 peter
  2230. * small m68k updates to bring it up2date
  2231. * give better error for external local variable
  2232. Revision 1.201 2004/11/09 17:26:47 peter
  2233. * fixed wrong typecasts
  2234. Revision 1.200 2004/11/08 22:09:59 peter
  2235. * tvarsym splitted
  2236. Revision 1.199 2004/11/05 21:16:55 peter
  2237. * rename duplicate symbols and insert with unique name in the
  2238. symtable
  2239. Revision 1.198 2004/10/31 18:54:24 peter
  2240. * $fpctarget expands to <cpu>-<os>
  2241. * allow * in middle of the path to support ../*/units/$fpctarget
  2242. Revision 1.197 2004/10/24 20:01:08 peter
  2243. * remove saveregister calling convention
  2244. Revision 1.196 2004/10/24 13:48:50 peter
  2245. * don't give warning for property as unknwon proc directive
  2246. Revision 1.195 2004/10/24 11:44:28 peter
  2247. * small regvar fixes
  2248. * loadref parameter removed from concatcopy,incrrefcount,etc
  2249. Revision 1.194 2004/10/15 09:14:17 mazen
  2250. - remove $IFDEF DELPHI and related code
  2251. - remove $IFDEF FPCPROCVAR and related code
  2252. Revision 1.193 2004/10/11 15:45:35 peter
  2253. * mark non-regable after calling convention is set
  2254. Revision 1.192 2004/10/10 21:08:55 peter
  2255. * parameter regvar fixes
  2256. Revision 1.191 2004/10/08 17:09:43 peter
  2257. * tvarsym.varregable added, split vo_regable from varoptions
  2258. Revision 1.190 2004/08/29 11:28:41 peter
  2259. fixed crash with error in default value
  2260. allow assembler directive in interface
  2261. Revision 1.189 2004/08/25 15:57:19 peter
  2262. * fix for tw3261
  2263. Revision 1.188 2004/08/22 20:11:38 florian
  2264. * morphos now takes any pointer var. as libbase
  2265. * alignment for sparc fixed
  2266. * int -> double conversion on sparc fixed
  2267. Revision 1.187 2004/08/22 11:24:27 peter
  2268. * don't insert result variables for constructor/destructors
  2269. Revision 1.186 2004/08/13 17:53:37 jonas
  2270. * only set the mangled name immediately for external procedures in macpas
  2271. mode if the procedure isn't cdecl (so that the c-prefix is taken into
  2272. account, necessary for Mac OS X)
  2273. Revision 1.185 2004/08/08 12:35:09 florian
  2274. * proc. var declarations in a class doesn't eat a public anymore
  2275. Revision 1.184 2004/07/17 13:51:57 florian
  2276. * function result location for syscalls on MOS hopefully correctly set now
  2277. Revision 1.183 2004/07/14 23:19:21 olle
  2278. + added external facilities for macpas
  2279. Revision 1.182 2004/06/20 08:55:30 florian
  2280. * logs truncated
  2281. Revision 1.181 2004/06/16 20:07:09 florian
  2282. * dwarf branch merged
  2283. Revision 1.180 2004/05/23 20:54:39 peter
  2284. * fixed 3114
  2285. Revision 1.179 2004/05/23 19:06:26 peter
  2286. * expect : after function when it is a forwarddef
  2287. Revision 1.178 2004/05/12 13:21:09 karoly
  2288. * few small changes to add syscall support to M68k/Amiga target
  2289. Revision 1.177 2004/05/11 22:52:48 olle
  2290. * Moved import_implicit_external to symsym
  2291. }