pdecsub.pas 89 KB

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