pdecsub.pas 88 KB

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