pdecsub.pas 91 KB

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