pdecsub.pas 88 KB

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