pdecsub.pas 87 KB

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