pdecsub.pas 90 KB

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