pdecsub.pas 89 KB

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