pdecsub.pas 88 KB

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