pdecsub.pas 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514
  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. Message1(parser_w_proc_directive_ignored,'REGISTER');
  1590. end;
  1591. pocall_far16 :
  1592. begin
  1593. { Temporary stub, must be rewritten to support OS/2 far16 }
  1594. Message1(parser_w_proc_directive_ignored,'FAR16');
  1595. end;
  1596. pocall_palmossyscall :
  1597. begin
  1598. if (pd.deftype=procdef) then
  1599. begin
  1600. { Adjust positions of args for cdecl or stdcall }
  1601. pd.parast.dataalignment:=std_param_align;
  1602. end;
  1603. end;
  1604. pocall_inline :
  1605. begin
  1606. if not(cs_support_inline in aktmoduleswitches) then
  1607. begin
  1608. Message(parser_e_proc_inline_not_supported);
  1609. pd.proccalloption:=pocall_default;
  1610. end;
  1611. end;
  1612. end;
  1613. { For varargs directive also cdecl and external must be defined }
  1614. if (po_varargs in pd.procoptions) then
  1615. begin
  1616. { check first for external in the interface, if available there
  1617. then the cdecl must also be there since there is no implementation
  1618. available to contain it }
  1619. if parse_only then
  1620. begin
  1621. { if external is available, then cdecl must also be available }
  1622. if (po_external in pd.procoptions) and
  1623. not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1624. Message(parser_e_varargs_need_cdecl_and_external);
  1625. end
  1626. else
  1627. begin
  1628. { both must be defined now }
  1629. if not(po_external in pd.procoptions) or
  1630. not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
  1631. Message(parser_e_varargs_need_cdecl_and_external);
  1632. end;
  1633. end;
  1634. { add mangledname to external list }
  1635. if (pd.deftype=procdef) and
  1636. (po_external in pd.procoptions) and
  1637. target_info.DllScanSupported then
  1638. current_module.externals.insert(tExternalsItem.create(tprocdef(pd).mangledname));
  1639. end;
  1640. procedure calc_parast(pd:tabstractprocdef);
  1641. var
  1642. currpara : tparaitem;
  1643. st : tsymtable;
  1644. begin
  1645. { insert hidden high parameters }
  1646. insert_hidden_para(pd);
  1647. { insert hidden self parameter }
  1648. insert_self_and_vmt_para(pd);
  1649. { insert funcret parameter if required }
  1650. insert_funcret_para(pd);
  1651. if (pd.deftype=procdef) then
  1652. begin
  1653. { rename value parameters that need a local copy to valXXX,
  1654. this is not required for assembler procedures }
  1655. if not(po_assembler in pd.procoptions) then
  1656. tprocdef(pd).parast.foreach_static({$ifdef FPCPROCVAR}@{$endif}rename_value_para,nil);
  1657. { Calculate symtable addresses }
  1658. st:=pd.parast;
  1659. if pd.proccalloption in pushleftright_pocalls then
  1660. begin
  1661. { pushed from left to right, so the in reverse order
  1662. on the stack }
  1663. currpara:=tparaitem(pd.para.last);
  1664. while assigned(currpara) do
  1665. begin
  1666. if not(assigned(currpara.parasym) and (currpara.parasym.typ=varsym)) then
  1667. internalerror(200304231);
  1668. st.insertvardata(currpara.parasym);
  1669. currpara:=tparaitem(currpara.previous);
  1670. end;
  1671. end
  1672. else
  1673. begin
  1674. { pushed from right to left }
  1675. currpara:=tparaitem(pd.para.first);
  1676. while assigned(currpara) do
  1677. begin
  1678. if not(assigned(currpara.parasym) and (currpara.parasym.typ=varsym)) then
  1679. internalerror(200304232);
  1680. st.insertvardata(currpara.parasym);
  1681. currpara:=tparaitem(currpara.next);
  1682. end;
  1683. end;
  1684. end;
  1685. end;
  1686. procedure parse_proc_directives(pd:tabstractprocdef;var pdflags:tpdflags);
  1687. {
  1688. Parse the procedure directives. It does not matter if procedure directives
  1689. are written using ;procdir; or ['procdir'] syntax.
  1690. }
  1691. var
  1692. res : boolean;
  1693. begin
  1694. while token in [_ID,_LECKKLAMMER] do
  1695. begin
  1696. if try_to_consume(_LECKKLAMMER) then
  1697. begin
  1698. repeat
  1699. parse_proc_direc(pd,pdflags);
  1700. until not try_to_consume(_COMMA);
  1701. consume(_RECKKLAMMER);
  1702. { we always expect at least '[];' }
  1703. res:=true;
  1704. end
  1705. else
  1706. begin
  1707. res:=parse_proc_direc(pd,pdflags);
  1708. end;
  1709. { A procedure directive normally followed by a semicolon, but in
  1710. a const section we should stop when _EQUAL is found }
  1711. if res then
  1712. begin
  1713. if (block_type=bt_const) and
  1714. (token=_EQUAL) then
  1715. break;
  1716. { support procedure proc;stdcall export; in Delphi mode only }
  1717. if not((m_delphi in aktmodeswitches) and
  1718. is_proc_directive(token)) then
  1719. consume(_SEMICOLON);
  1720. end
  1721. else
  1722. break;
  1723. end;
  1724. handle_calling_convention(pd);
  1725. end;
  1726. procedure parse_var_proc_directives(sym:tsym);
  1727. var
  1728. pdflags : tpdflags;
  1729. pd : tabstractprocdef;
  1730. begin
  1731. pdflags:=[pd_procvar];
  1732. pd:=nil;
  1733. case sym.typ of
  1734. varsym :
  1735. pd:=tabstractprocdef(tvarsym(sym).vartype.def);
  1736. typedconstsym :
  1737. pd:=tabstractprocdef(ttypedconstsym(sym).typedconsttype.def);
  1738. typesym :
  1739. pd:=tabstractprocdef(ttypesym(sym).restype.def);
  1740. else
  1741. internalerror(2003042617);
  1742. end;
  1743. if pd.deftype<>procvardef then
  1744. internalerror(2003042618);
  1745. { names should never be used anyway }
  1746. parse_proc_directives(pd,pdflags);
  1747. end;
  1748. procedure parse_object_proc_directives(pd:tabstractprocdef);
  1749. var
  1750. pdflags : tpdflags;
  1751. begin
  1752. pdflags:=[pd_object];
  1753. parse_proc_directives(pd,pdflags);
  1754. end;
  1755. function proc_add_definition(var pd:tprocdef):boolean;
  1756. {
  1757. Add definition aprocdef to the overloaded definitions of aprocsym. If a
  1758. forwarddef is found and reused it returns true
  1759. }
  1760. var
  1761. hd : tprocdef;
  1762. ad,fd : tsym;
  1763. i : cardinal;
  1764. forwardfound : boolean;
  1765. po_comp : tprocoptions;
  1766. aprocsym : tprocsym;
  1767. begin
  1768. forwardfound:=false;
  1769. aprocsym:=tprocsym(pd.procsym);
  1770. { check overloaded functions if the same function already exists }
  1771. for i:=1 to aprocsym.procdef_count do
  1772. begin
  1773. hd:=aprocsym.procdef[i];
  1774. { Skip overloaded definitions that are declared in other
  1775. units }
  1776. if hd.procsym<>aprocsym then
  1777. continue;
  1778. { check the parameters, for delphi/tp it is possible to
  1779. leave the parameters away in the implementation (forwarddef=false).
  1780. But for an overload declared function this is not allowed }
  1781. if { check if empty implementation arguments match is allowed }
  1782. (
  1783. not(m_repeat_forward in aktmodeswitches) and
  1784. not(pd.forwarddef) and
  1785. (pd.maxparacount=0) and
  1786. not(po_overload in hd.procoptions)
  1787. ) or
  1788. { check arguments }
  1789. (
  1790. (compare_paras(pd.para,hd.para,cp_none,false)>=te_equal) and
  1791. { for operators equal_paras is not enough !! }
  1792. ((pd.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
  1793. equal_defs(hd.rettype.def,pd.rettype.def))
  1794. ) then
  1795. begin
  1796. { Check if we've found the forwarddef, if found then
  1797. we need to update the forward def with the current
  1798. implementation settings }
  1799. if hd.forwarddef then
  1800. begin
  1801. forwardfound:=true;
  1802. { Check if the procedure type and return type are correct,
  1803. also the parameters must match also with the type }
  1804. if (hd.proctypeoption<>pd.proctypeoption) or
  1805. (
  1806. (m_repeat_forward in aktmodeswitches) and
  1807. (not((pd.maxparacount=0) or
  1808. (compare_paras(pd.para,hd.para,cp_all,false)>=te_equal)))
  1809. ) or
  1810. (
  1811. ((m_repeat_forward in aktmodeswitches) or
  1812. not(is_void(pd.rettype.def))) and
  1813. (not equal_defs(hd.rettype.def,pd.rettype.def))) then
  1814. begin
  1815. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,
  1816. pd.fullprocname(false));
  1817. aprocsym.write_parameter_lists(pd);
  1818. break;
  1819. end;
  1820. { Check if both are declared forward }
  1821. if hd.forwarddef and pd.forwarddef then
  1822. begin
  1823. MessagePos1(pd.fileinfo,parser_e_function_already_declared_public_forward,
  1824. pd.fullprocname(false));
  1825. end;
  1826. { internconst or internproc only need to be defined once }
  1827. if (hd.proccalloption=pocall_internproc) then
  1828. pd.proccalloption:=hd.proccalloption
  1829. else
  1830. if (pd.proccalloption=pocall_internproc) then
  1831. hd.proccalloption:=pd.proccalloption;
  1832. if (po_internconst in hd.procoptions) then
  1833. include(pd.procoptions,po_internconst)
  1834. else if (po_internconst in pd.procoptions) then
  1835. include(hd.procoptions,po_internconst);
  1836. { Check calling convention }
  1837. if (hd.proccalloption<>pd.proccalloption) then
  1838. begin
  1839. { In delphi it is possible to specify the calling
  1840. convention in the interface or implementation if
  1841. there was no convention specified in the other
  1842. part }
  1843. if (m_delphi in aktmodeswitches) then
  1844. begin
  1845. if not(po_hascallingconvention in pd.procoptions) then
  1846. pd.proccalloption:=hd.proccalloption
  1847. else
  1848. if not(po_hascallingconvention in hd.procoptions) then
  1849. hd.proccalloption:=pd.proccalloption
  1850. else
  1851. begin
  1852. MessagePos(pd.fileinfo,parser_e_call_convention_dont_match_forward);
  1853. aprocsym.write_parameter_lists(pd);
  1854. { restore interface settings }
  1855. pd.proccalloption:=hd.proccalloption;
  1856. end;
  1857. end
  1858. else
  1859. begin
  1860. MessagePos(pd.fileinfo,parser_e_call_convention_dont_match_forward);
  1861. aprocsym.write_parameter_lists(pd);
  1862. { restore interface settings }
  1863. pd.proccalloption:=hd.proccalloption;
  1864. end;
  1865. end;
  1866. { Check procedure options, Delphi requires that class is
  1867. repeated in the implementation for class methods }
  1868. if (m_fpc in aktmodeswitches) then
  1869. po_comp:=[po_varargs,po_methodpointer,po_interrupt]
  1870. else
  1871. po_comp:=[po_classmethod,po_methodpointer];
  1872. if ((po_comp * hd.procoptions)<>(po_comp * pd.procoptions)) then
  1873. begin
  1874. MessagePos1(pd.fileinfo,parser_e_header_dont_match_forward,
  1875. pd.fullprocname(false));
  1876. aprocsym.write_parameter_lists(pd);
  1877. { This error is non-fatal, we can recover }
  1878. end;
  1879. { Check manglednames }
  1880. if (m_repeat_forward in aktmodeswitches) or
  1881. (pd.minparacount>0) then
  1882. begin
  1883. { If mangled names are equal then they have the same amount of arguments }
  1884. { We can check the names of the arguments }
  1885. { both symtables are in the same order from left to right }
  1886. ad:=tsym(hd.parast.symindex.first);
  1887. fd:=tsym(pd.parast.symindex.first);
  1888. repeat
  1889. { skip default parameter constsyms }
  1890. while assigned(ad) and (ad.typ<>varsym) do
  1891. ad:=tsym(ad.indexnext);
  1892. while assigned(fd) and (fd.typ<>varsym) do
  1893. fd:=tsym(fd.indexnext);
  1894. { stop when one of the two lists is at the end }
  1895. if not assigned(ad) or not assigned(fd) then
  1896. break;
  1897. if (ad.name<>fd.name) then
  1898. begin
  1899. MessagePos3(pd.fileinfo,parser_e_header_different_var_names,
  1900. aprocsym.name,ad.name,fd.name);
  1901. break;
  1902. end;
  1903. ad:=tsym(ad.indexnext);
  1904. fd:=tsym(fd.indexnext);
  1905. until false;
  1906. if assigned(ad) xor assigned(fd) then
  1907. internalerror(200204178);
  1908. end;
  1909. { Everything is checked, now we can update the forward declaration
  1910. with the new data from the implementation }
  1911. hd.forwarddef:=pd.forwarddef;
  1912. hd.hasforward:=true;
  1913. hd.parast.address_fixup:=pd.parast.address_fixup;
  1914. hd.procoptions:=hd.procoptions+pd.procoptions;
  1915. if hd.extnumber=65535 then
  1916. hd.extnumber:=pd.extnumber;
  1917. while not pd.aliasnames.empty do
  1918. hd.aliasnames.insert(pd.aliasnames.getfirst);
  1919. { update fileinfo so position references the implementation,
  1920. also update funcretsym if it is already generated }
  1921. hd.fileinfo:=pd.fileinfo;
  1922. if assigned(hd.funcretsym) then
  1923. hd.funcretsym.fileinfo:=pd.fileinfo;
  1924. { update mangledname if the implementation has a fixed mangledname set }
  1925. if pd.has_mangledname then
  1926. begin
  1927. { rename also asmsymbol first, because the name can already be used }
  1928. objectlibrary.renameasmsymbol(hd.mangledname,pd.mangledname);
  1929. hd.setmangledname(pd.mangledname);
  1930. end;
  1931. { for compilerproc defines we need to rename and update the
  1932. symbolname to lowercase }
  1933. if (pd.proccalloption=pocall_compilerproc) then
  1934. begin
  1935. { rename to lowercase so users can't access it }
  1936. aprocsym.owner.rename(aprocsym.name,lower(aprocsym.name));
  1937. { also update the realname that is stored in the ppu }
  1938. stringdispose(aprocsym._realname);
  1939. aprocsym._realname:=stringdup('$'+aprocsym.name);
  1940. { the mangeled name is already changed by the pd_compilerproc }
  1941. { handler. It must be done immediately because if we have a }
  1942. { call to a compilerproc before it's implementation is }
  1943. { encountered, it must already use the new mangled name (JM) }
  1944. end;
  1945. { the procdef will be released by the symtable, we release
  1946. at least the parast }
  1947. pd.releasemem;
  1948. pd:=hd;
  1949. end
  1950. else
  1951. begin
  1952. { abstract methods aren't forward defined, but this }
  1953. { needs another error message }
  1954. if (po_abstractmethod in hd.procoptions) then
  1955. MessagePos(pd.fileinfo,parser_e_abstract_no_definition)
  1956. else
  1957. MessagePos(pd.fileinfo,parser_e_overloaded_have_same_parameters);
  1958. end;
  1959. { we found one proc with the same arguments, there are no others
  1960. so we can stop }
  1961. break;
  1962. end;
  1963. { check for allowing overload directive }
  1964. if not(m_fpc in aktmodeswitches) then
  1965. begin
  1966. { overload directive turns on overloading }
  1967. if ((po_overload in pd.procoptions) or
  1968. (po_overload in hd.procoptions)) then
  1969. begin
  1970. { check if all procs have overloading, but not if the proc was
  1971. already declared forward, then the check is already done }
  1972. if not(hd.hasforward or
  1973. (pd.forwarddef<>hd.forwarddef) or
  1974. ((po_overload in pd.procoptions) and
  1975. (po_overload in hd.procoptions))) then
  1976. begin
  1977. MessagePos1(pd.fileinfo,parser_e_no_overload_for_all_procs,aprocsym.realname);
  1978. break;
  1979. end;
  1980. end
  1981. else
  1982. begin
  1983. if not(hd.forwarddef) then
  1984. begin
  1985. MessagePos(pd.fileinfo,parser_e_procedure_overloading_is_off);
  1986. break;
  1987. end;
  1988. end;
  1989. end; { equal arguments }
  1990. end;
  1991. { if we didn't reuse a forwarddef then we add the procdef to the overloaded
  1992. list }
  1993. if not forwardfound then
  1994. begin
  1995. aprocsym.addprocdef(pd);
  1996. { add overloadnumber for unique naming, the overloadcount is
  1997. counted per module and 0 for the first procedure }
  1998. pd.overloadnumber:=aprocsym.overloadcount;
  1999. inc(aprocsym.overloadcount);
  2000. end;
  2001. proc_add_definition:=forwardfound;
  2002. end;
  2003. end.
  2004. {
  2005. $Log$
  2006. Revision 1.132 2003-09-09 15:54:10 peter
  2007. * calling convention fix
  2008. Revision 1.131 2003/09/07 22:09:35 peter
  2009. * preparations for different default calling conventions
  2010. * various RA fixes
  2011. Revision 1.130 2003/09/03 11:18:37 florian
  2012. * fixed arm concatcopy
  2013. + arm support in the common compiler sources added
  2014. * moved some generic cg code around
  2015. + tfputype added
  2016. * ...
  2017. Revision 1.129 2003/07/02 22:18:04 peter
  2018. * paraloc splitted in callerparaloc,calleeparaloc
  2019. * sparc calling convention updates
  2020. Revision 1.128 2003/06/13 21:19:31 peter
  2021. * current_procdef removed, use current_procinfo.procdef instead
  2022. Revision 1.127 2003/06/05 20:04:43 peter
  2023. * set po_public also when parsing the object declaration
  2024. Revision 1.126 2003/06/02 21:42:05 jonas
  2025. * function results can now also be regvars
  2026. - removed tprocinfo.return_offset, never use it again since it's invalid
  2027. if the result is a regvar
  2028. Revision 1.125 2003/05/22 21:31:35 peter
  2029. * defer codegeneration for nested procedures
  2030. Revision 1.124 2003/05/15 18:58:53 peter
  2031. * removed selfpointer_offset, vmtpointer_offset
  2032. * tvarsym.adjusted_address
  2033. * address in localsymtable is now in the real direction
  2034. * removed some obsolete globals
  2035. Revision 1.123 2003/05/13 15:18:49 peter
  2036. * fixed various crashes
  2037. Revision 1.122 2003/05/09 17:47:03 peter
  2038. * self moved to hidden parameter
  2039. * removed hdisposen,hnewn,selfn
  2040. Revision 1.121 2003/05/05 14:53:16 peter
  2041. * vs_hidden replaced by is_hidden boolean
  2042. Revision 1.120 2003/04/30 09:42:42 florian
  2043. + first changes to make self a hidden parameter
  2044. Revision 1.119 2003/04/27 11:21:33 peter
  2045. * aktprocdef renamed to current_procinfo.procdef
  2046. * procinfo renamed to current_procinfo
  2047. * procinfo will now be stored in current_module so it can be
  2048. cleaned up properly
  2049. * gen_main_procsym changed to create_main_proc and release_main_proc
  2050. to also generate a tprocinfo structure
  2051. * fixed unit implicit initfinal
  2052. Revision 1.118 2003/04/27 07:29:50 peter
  2053. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  2054. a new procdef declaration
  2055. * aktprocsym removed
  2056. * lexlevel removed, use symtable.symtablelevel instead
  2057. * implicit init/final code uses the normal genentry/genexit
  2058. * funcret state checking updated for new funcret handling
  2059. Revision 1.117 2003/04/26 00:33:07 peter
  2060. * vo_is_result flag added for the special RESULT symbol
  2061. Revision 1.116 2003/04/25 20:59:33 peter
  2062. * removed funcretn,funcretsym, function result is now in varsym
  2063. and aliases for result and function name are added using absolutesym
  2064. * vs_hidden parameter for funcret passed in parameter
  2065. * vs_hidden fixes
  2066. * writenode changed to printnode and released from extdebug
  2067. * -vp option added to generate a tree.log with the nodetree
  2068. * nicer printnode for statements, callnode
  2069. Revision 1.115 2003/04/24 13:03:01 florian
  2070. * comp is now written with its bit pattern to the ppu instead as an extended
  2071. Revision 1.114 2003/04/23 13:12:26 peter
  2072. * fix po_comp setting for fpc mode
  2073. Revision 1.113 2003/04/23 10:12:51 peter
  2074. * don't check po_varargs for delphi
  2075. Revision 1.112 2003/04/22 13:47:08 peter
  2076. * fixed C style array of const
  2077. * fixed C array passing
  2078. * fixed left to right with high parameters
  2079. Revision 1.111 2003/04/10 17:57:53 peter
  2080. * vs_hidden released
  2081. Revision 1.110 2003/03/28 19:16:56 peter
  2082. * generic constructor working for i386
  2083. * remove fixed self register
  2084. * esi added as address register for i386
  2085. Revision 1.109 2003/03/23 23:21:42 hajny
  2086. + emx target added
  2087. Revision 1.108 2003/03/19 17:34:04 peter
  2088. * only allow class [procedure|function]
  2089. Revision 1.107 2003/03/17 18:56:02 peter
  2090. * fix crash with duplicate id
  2091. Revision 1.106 2003/03/17 15:54:22 peter
  2092. * store symoptions also for procdef
  2093. * check symoptions (private,public) when calculating possible
  2094. overload candidates
  2095. Revision 1.105 2003/01/15 20:02:28 carl
  2096. * fix highname problem
  2097. Revision 1.104 2003/01/12 15:42:23 peter
  2098. * m68k pathexist update from 1.0.x
  2099. * palmos res update from 1.0.x
  2100. Revision 1.103 2003/01/07 19:16:38 peter
  2101. * removed some duplicate code when creating aktprocsym
  2102. Revision 1.102 2003/01/05 18:17:45 peter
  2103. * more conflicts for constructor/destructor types
  2104. Revision 1.100 2003/01/02 19:49:00 peter
  2105. * update self parameter only for methodpointer and methods
  2106. Revision 1.99 2003/01/01 22:51:03 peter
  2107. * high value insertion changed so it works also when 2 parameters
  2108. are passed
  2109. Revision 1.98 2003/01/01 14:35:33 peter
  2110. * don't check for export directive repeat
  2111. Revision 1.97 2002/12/29 18:16:06 peter
  2112. * delphi allows setting calling convention in interface or
  2113. implementation
  2114. Revision 1.96 2002/12/29 14:55:44 peter
  2115. * fix static method check
  2116. * don't require class for class methods in the implementation for
  2117. non delphi modes
  2118. Revision 1.95 2002/12/27 15:25:14 peter
  2119. * check procoptions when a forward is found
  2120. * exclude some call directives for constructor/destructor
  2121. Revision 1.94 2002/12/25 01:26:56 peter
  2122. * duplicate procsym-unitsym fix
  2123. Revision 1.93 2002/12/24 21:21:06 peter
  2124. * remove code that skipped the _ prefix for win32 imports
  2125. Revision 1.92 2002/12/23 21:24:22 peter
  2126. * fix wrong internalerror when var names were different
  2127. Revision 1.91 2002/12/23 20:58:52 peter
  2128. * cdecl array fix, hack to change it to vs_var is not needed
  2129. Revision 1.90 2002/12/17 22:19:33 peter
  2130. * fixed pushing of records>8 bytes with stdcall
  2131. * simplified hightree loading
  2132. Revision 1.89 2002/12/15 21:07:30 peter
  2133. * don't allow external in object declarations
  2134. Revision 1.88 2002/12/15 19:34:31 florian
  2135. + some front end stuff for vs_hidden added
  2136. Revision 1.87 2002/12/07 14:27:07 carl
  2137. * 3% memory optimization
  2138. * changed some types
  2139. + added type checking with different size for call node and for
  2140. parameters
  2141. Revision 1.86 2002/12/06 17:51:10 peter
  2142. * merged cdecl and array fixes
  2143. Revision 1.85 2002/12/01 22:06:14 carl
  2144. * cleanup of error messages
  2145. Revision 1.84 2002/11/29 22:31:19 carl
  2146. + unimplemented hint directive added
  2147. * hint directive parsing implemented
  2148. * warning on these directives
  2149. Revision 1.83 2002/11/27 02:35:28 peter
  2150. * fixed typo in method comparing
  2151. Revision 1.82 2002/11/25 17:43:21 peter
  2152. * splitted defbase in defutil,symutil,defcmp
  2153. * merged isconvertable and is_equal into compare_defs(_ext)
  2154. * made operator search faster by walking the list only once
  2155. Revision 1.81 2002/11/18 17:31:58 peter
  2156. * pass proccalloption to ret_in_xxx and push_xxx functions
  2157. Revision 1.80 2002/11/17 16:31:56 carl
  2158. * memory optimization (3-4%) : cleanup of tai fields,
  2159. cleanup of tdef and tsym fields.
  2160. * make it work for m68k
  2161. Revision 1.79 2002/11/16 14:20:50 peter
  2162. * fix infinite loop in pd_inline
  2163. Revision 1.78 2002/11/15 01:58:53 peter
  2164. * merged changes from 1.0.7 up to 04-11
  2165. - -V option for generating bug report tracing
  2166. - more tracing for option parsing
  2167. - errors for cdecl and high()
  2168. - win32 import stabs
  2169. - win32 records<=8 are returned in eax:edx (turned off by default)
  2170. - heaptrc update
  2171. - more info for temp management in .s file with EXTDEBUG
  2172. Revision 1.77 2002/10/06 15:09:12 peter
  2173. * variant:=nil supported
  2174. Revision 1.76 2002/09/27 21:13:29 carl
  2175. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  2176. Revision 1.75 2002/09/16 14:11:13 peter
  2177. * add argument to equal_paras() to support default values or not
  2178. Revision 1.74 2002/09/10 16:27:28 peter
  2179. * don't insert parast in symtablestack, because typesyms should not be
  2180. searched in the the parast
  2181. Revision 1.73 2002/09/09 19:39:07 peter
  2182. * check return type for forwarddefs also not delphi mode when
  2183. the type is not void
  2184. Revision 1.72 2002/09/09 17:34:15 peter
  2185. * tdicationary.replace added to replace and item in a dictionary. This
  2186. is only allowed for the same name
  2187. * varsyms are inserted in symtable before the types are parsed. This
  2188. fixes the long standing "var longint : longint" bug
  2189. - consume_idlist and idstringlist removed. The loops are inserted
  2190. at the callers place and uses the symtable for duplicate id checking
  2191. Revision 1.71 2002/09/07 15:25:06 peter
  2192. * old logs removed and tabs fixed
  2193. Revision 1.70 2002/09/03 16:26:27 daniel
  2194. * Make Tprocdef.defs protected
  2195. Revision 1.69 2002/09/01 12:11:33 peter
  2196. * calc param_offset after parameters are read, because the calculation
  2197. depends on po_containself
  2198. Revision 1.68 2002/08/25 19:25:20 peter
  2199. * sym.insert_in_data removed
  2200. * symtable.insertvardata/insertconstdata added
  2201. * removed insert_in_data call from symtable.insert, it needs to be
  2202. called separatly. This allows to deref the address calculation
  2203. * procedures now calculate the parast addresses after the procedure
  2204. directives are parsed. This fixes the cdecl parast problem
  2205. * push_addr_param has an extra argument that specifies if cdecl is used
  2206. or not
  2207. Revision 1.67 2002/08/25 11:33:06 peter
  2208. * also check the paratypes when a forward was found
  2209. Revision 1.66 2002/08/19 19:36:44 peter
  2210. * More fixes for cross unit inlining, all tnodes are now implemented
  2211. * Moved pocall_internconst to po_internconst because it is not a
  2212. calling type at all and it conflicted when inlining of these small
  2213. functions was requested
  2214. Revision 1.65 2002/08/18 20:06:24 peter
  2215. * inlining is now also allowed in interface
  2216. * renamed write/load to ppuwrite/ppuload
  2217. * tnode storing in ppu
  2218. * nld,ncon,nbas are already updated for storing in ppu
  2219. Revision 1.64 2002/08/17 09:23:39 florian
  2220. * first part of procinfo rewrite
  2221. Revision 1.63 2002/08/11 14:32:27 peter
  2222. * renamed current_library to objectlibrary
  2223. Revision 1.62 2002/08/11 13:24:12 peter
  2224. * saving of asmsymbols in ppu supported
  2225. * asmsymbollist global is removed and moved into a new class
  2226. tasmlibrarydata that will hold the info of a .a file which
  2227. corresponds with a single module. Added librarydata to tmodule
  2228. to keep the library info stored for the module. In the future the
  2229. objectfiles will also be stored to the tasmlibrarydata class
  2230. * all getlabel/newasmsymbol and friends are moved to the new class
  2231. Revision 1.61 2002/07/26 21:15:40 florian
  2232. * rewrote the system handling
  2233. Revision 1.60 2002/07/20 11:57:55 florian
  2234. * types.pas renamed to defbase.pas because D6 contains a types
  2235. unit so this would conflicts if D6 programms are compiled
  2236. + Willamette/SSE2 instructions to assembler added
  2237. Revision 1.59 2002/07/11 14:41:28 florian
  2238. * start of the new generic parameter handling
  2239. Revision 1.58 2002/07/01 18:46:25 peter
  2240. * internal linker
  2241. * reorganized aasm layer
  2242. Revision 1.57 2002/05/18 13:34:12 peter
  2243. * readded missing revisions
  2244. Revision 1.56 2002/05/16 19:46:42 carl
  2245. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  2246. + try to fix temp allocation (still in ifdef)
  2247. + generic constructor calls
  2248. + start of tassembler / tmodulebase class cleanup
  2249. Revision 1.54 2002/05/12 16:53:08 peter
  2250. * moved entry and exitcode to ncgutil and cgobj
  2251. * foreach gets extra argument for passing local data to the
  2252. iterator function
  2253. * -CR checks also class typecasts at runtime by changing them
  2254. into as
  2255. * fixed compiler to cycle with the -CR option
  2256. * fixed stabs with elf writer, finally the global variables can
  2257. be watched
  2258. * removed a lot of routines from cga unit and replaced them by
  2259. calls to cgobj
  2260. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  2261. u32bit then the other is typecasted also to u32bit without giving
  2262. a rangecheck warning/error.
  2263. * fixed pascal calling method with reversing also the high tree in
  2264. the parast, detected by tcalcst3 test
  2265. Revision 1.53 2002/04/21 19:02:04 peter
  2266. * removed newn and disposen nodes, the code is now directly
  2267. inlined from pexpr
  2268. * -an option that will write the secondpass nodes to the .s file, this
  2269. requires EXTDEBUG define to actually write the info
  2270. * fixed various internal errors and crashes due recent code changes
  2271. Revision 1.52 2002/04/20 21:32:24 carl
  2272. + generic FPC_CHECKPOINTER
  2273. + first parameter offset in stack now portable
  2274. * rename some constants
  2275. + move some cpu stuff to other units
  2276. - remove unused constents
  2277. * fix stacksize for some targets
  2278. * fix generic size problems which depend now on EXTEND_SIZE constant
  2279. Revision 1.51 2002/04/20 15:27:05 carl
  2280. - remove ifdef i386 define
  2281. Revision 1.50 2002/04/19 15:46:02 peter
  2282. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  2283. in most cases and not written to the ppu
  2284. * add mangeledname_prefix() routine to generate the prefix of
  2285. manglednames depending on the current procedure, object and module
  2286. * removed static procprefix since the mangledname is now build only
  2287. on demand from tprocdef.mangledname
  2288. }