pdecsub.pas 89 KB

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